Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java424
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractLockingTest.java156
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java368
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMAudit.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranches.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesSSL.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesTCP.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesUUIDs.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java66
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMLegacy.java66
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMNonAudit.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java110
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java1648
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditSameSessionTest.java92
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java1070
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java164
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingSameSessionTest.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java2072
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingWithCacheClearTest.java54
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java212
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java1882
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java1956
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CompareTest.java510
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ComplexTest.java2426
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java7650
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverMergingTest.java282
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverTest.java248
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java1172
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java976
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java806
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicEcoreTest.java158
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicUmlTest.java206
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicPackageTest.java174
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicXSDTest.java166
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFComplianceTest.java110
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java266
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMapTest.java244
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EnumTest.java380
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java1026
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FeatureMapTest.java496
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/GeneratedEcoreTest.java122
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java1082
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java1670
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java1644
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LegacyTest.java112
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LobTest.java312
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartRepositoryTest.java68
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartSessionTest.java60
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartTransactionTest.java806
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java2388
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java904
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MEMStoreQueryTest.java438
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java106
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapDynamicTest.java1220
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MemoryLeakTest.java290
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java1392
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MetaTest.java210
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java382
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NonCDOResourceTest.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java176
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java1616
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PartialCommitTest.java2826
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionTest.java1308
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionWithoutReconstructSavepointsTest.java58
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RemoteSessionManagerTest.java594
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java784
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java472
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaCascadingBranchesTest.java604
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaInBranchTest.java402
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java1508
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java84
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RollbackTest.java322
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java1516
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java1050
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StickyViewsTest.java760
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionHandlerTest.java930
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java1254
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/UnsetTest.java1122
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java300
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java622
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java702
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XRefTest.java1204
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/_FetchRuleAnalyzerTest_DISABLED_.java254
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java152
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_243310_Test.java96
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java310
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246622_Test.java288
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_247141_Test.java286
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248052_Test.java108
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248124_Test.java246
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248915_Test.java260
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java232
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250757_Test.java254
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250910_Test.java134
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java198
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251263_Test.java374
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java160
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251752_Test.java172
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java184
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252909_Test.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java156
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_255662_Test.java86
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_256141_Test.java78
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258278_Test.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258850_Test.java160
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258933_Test.java470
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259695_Test.java118
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259949_Test.java134
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260756_Test.java164
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java158
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_261218_Test.java152
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_265114_Test.java316
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java124
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java172
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267050_Test.java152
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java174
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_270429_Test.java198
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_272861_Test.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273233_Test.java266
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java566
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273758_Test.java178
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_276696_Test.java84
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_278900_Test.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279565_Test.java306
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279982_Test.java428
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java636
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_1_Test.java1130
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_2_Test.java316
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_3_Test.java340
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_285008_Test.java298
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_289932_Test.java90
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_293283_Test.java298
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_294859_Test.java240
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java286
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_298561_Test.java446
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_299190_Test.java302
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302233_Test.java224
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302414_Test.java198
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303466_Test.java300
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303807_Test.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_305527_Test.java142
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306710_Test.java374
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306998_Test.java230
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_308895_Test.java490
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_310574_Test.java2732
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313326_Test.java144
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313913_Test.java154
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_314186_Test.java116
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_315043_Test.java268
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316145_Test.java160
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316273_Test.java166
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316434_Test.java154
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316444_Test.java1274
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316887_Test.java272
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318518_Test.java192
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318844_Test.java158
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318876_Test.java166
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318919_Test.java332
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318998_Test.java200
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java814
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320690_Test.java352
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320837_Test.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321699_Test.java116
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java152
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322754_Test.java176
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322804_Test.java86
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323930_Test.java530
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323958_Test.java178
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324084_Test.java238
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324585_Test.java136
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324635_Test.java182
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324756_Test.java276
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325603_Test.java98
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325866_Test.java198
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326518_Test.java286
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326743_Test.java198
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java600
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_328790_Test.java176
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329254_Test.java798
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329752_Test.java120
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329753_Test.java122
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329869_Test.java114
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java160
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_331619_Test.java280
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333157_Test.java104
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333299_Test.java132
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java240
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java228
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java210
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335004_Test.java148
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335675_Test.java358
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java368
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336314_Test.java214
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336382_Test.java120
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336590_Test.java298
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337054_Test.java204
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337523_Test.java96
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337587_Test.java170
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338779_Test.java250
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java494
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338921_Test.java350
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339313_Test.java122
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339461_Test.java166
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java192
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java644
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341875_Test.java142
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341995_Test.java228
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_342130_Test.java122
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java182
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343471_Test.java176
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349793_Test.java208
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349804_Test.java312
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_350027_Test.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351067_Test.java154
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351096_Test.java218
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351393_Test.java140
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351921_Test.java278
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_352303_Test.java142
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_354395_Test.java280
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_355915_Test.java374
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_357441_Test.java176
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359669_Test.java134
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359992_Test.java482
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_361819_Test.java150
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_362270_Test.java368
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java134
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_365832_Test.java410
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_368223_Test.java480
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bundle/OM.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConfig.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java112
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IContainerConfig.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IModelConfig.java146
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IScenario.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java78
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ITestLifecycle.java54
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java224
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java1362
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestException.java76
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java624
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ContainerConfig.java338
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ModelConfig.java518
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java704
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/AllTestsCDODefs.java102
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOAuditDefImplTest.java164
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOPackageRegistryDefImplTest.java104
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOResourceDefImplTest.java170
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java142
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOTransactionDefImplTest.java176
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOViewDefImplTest.java198
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/EGlobalPackageDefImplTest.java68
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java182
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java266
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java218
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_328352_Test.java316
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java594
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java1264
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java684
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayed2Test.java138
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java322
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java384
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java514
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java1142
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java78
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTestsMemStore.java104
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeletePerformanceTest.java234
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java764
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceRecordAnalyzer.java42
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceRecord.java182
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTest.java178
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTestSuite.java154
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamPerformanceRecordAnalyzer.java154
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/ProbeCollector.java146
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java848
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractDBRevisionCacheTest.java166
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AllTestsCDORevisionCache.java68
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DefaultRevisionCacheTest.java66
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DerbyDBRevisionCacheTest.java118
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/H2DBRevisionCacheTest.java102
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/Session.java304
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java142
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestEMFUtil.java458
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener2.java246
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java232
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java252
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java214
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionManager.java142
288 files changed, 58650 insertions, 58650 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
index 16998f155e..66d0972e78 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
@@ -1,212 +1,212 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry;
-import org.eclipse.emf.cdo.common.revision.CDOAllRevisionsProvider;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUpdatable;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper;
-
-import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.spi.cdo.FSMUtil;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public abstract class AbstractCDOTest extends ConfigTest
-{
- @Override
- protected void doSetUp() throws Exception
- {
- try
- {
- super.doSetUp();
- }
- finally
- {
- org.eclipse.emf.cdo.internal.net4j.bundle.OM.PREF_COMMIT_MONITOR_PROGRESS_SECONDS.setValue(60);
- org.eclipse.emf.cdo.internal.net4j.bundle.OM.PREF_COMMIT_MONITOR_TIMEOUT_SECONDS.setValue(60 * 60);
- CDOPackageTypeRegistry.INSTANCE.reset();
- startTransport();
- }
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- // This override adds no functionality.
- // It just ensures that the IDE shows doSetUp() and doTearDown() in the same class.
- super.doTearDown();
- }
-
- protected static void assertTransient(EObject eObject)
- {
- CDOObject object = CDOUtil.getCDOObject(eObject);
- if (object != null)
- {
- assertEquals(true, FSMUtil.isTransient(object));
- assertNull(object.cdoID());
- assertNull(object.cdoRevision());
- assertNull(object.cdoView());
- }
- }
-
- protected static void assertInvalid(EObject eObject)
- {
- CDOObject object = CDOUtil.getCDOObject(eObject);
- if (object != null)
- {
- assertEquals(true, FSMUtil.isInvalid(object));
- }
- }
-
- protected static void assertNotTransient(EObject eObject, CDOView view)
- {
- CDOObject object = FSMUtil.adapt(eObject, view);
- assertEquals(false, FSMUtil.isTransient(object));
- assertNotNull(object.cdoID());
- assertNotNull(object.cdoRevision());
- assertNotNull(object.cdoView());
- assertNotNull(object.eResource());
- assertEquals(view, object.cdoView());
- assertEquals(object, view.getObject(object.cdoID(), false));
- }
-
- protected static void assertNew(EObject eObject, CDOView view)
- {
- CDOObject object = FSMUtil.adapt(eObject, view);
- assertNotTransient(object, view);
- assertEquals(CDOState.NEW, object.cdoState());
- }
-
- protected static void assertDirty(EObject eObject, CDOView view)
- {
- CDOObject object = FSMUtil.adapt(eObject, view);
- assertNotTransient(object, view);
- assertEquals(CDOState.DIRTY, object.cdoState());
- }
-
- protected static void assertClean(EObject eObject, CDOView view)
- {
- CDOObject object = FSMUtil.adapt(eObject, view);
- assertNotTransient(object, view);
- assertEquals(CDOState.CLEAN, object.cdoState());
- }
-
- protected static void assertProxy(EObject eObject)
- {
- CDOObject object = CDOUtil.getCDOObject(eObject);
- if (object != null)
- {
- assertEquals(false, FSMUtil.isTransient(object));
- assertNotNull(object.cdoID());
- assertNotNull(object.cdoView());
- assertEquals(CDOState.PROXY, object.cdoState());
- }
- }
-
- protected static void assertContent(EObject eContainer, EObject eContained)
- {
- CDOObject container = CDOUtil.getCDOObject(eContainer);
- CDOObject contained = CDOUtil.getCDOObject(eContained);
- if (container != null && contained != null)
- {
- assertEquals(true, container.eContents().contains(contained));
- if (container instanceof CDOResource)
- {
- assertEquals(container, contained.eResource());
- assertEquals(null, contained.eContainer());
- assertEquals(true, ((CDOResource)container).getContents().contains(contained));
- }
- else
- {
- assertEquals(container.eResource(), contained.eResource());
- assertEquals(container, contained.eContainer());
- }
- }
- }
-
- protected static void assertNotProxy(Object object)
- {
- assertEquals(false, CDOLegacyWrapper.isLegacyProxy(object));
- }
-
- protected static void assertCreatedTime(EObject eObject, long timeStamp)
- {
- CDOObject object = CDOUtil.getCDOObject(eObject);
- if (object != null)
- {
- assertEquals(timeStamp, object.cdoRevision().getTimeStamp());
- }
- }
-
- protected static void dumpAllRevisions(Object allRevisionsProvider)
- {
- try
- {
- String label = allRevisionsProvider.toString();
- IOUtil.OUT().println(label);
- for (int i = 0; i < label.length(); i++)
- {
- IOUtil.OUT().print("=");
- }
-
- IOUtil.OUT().println();
- if (allRevisionsProvider instanceof CDOAllRevisionsProvider)
- {
- CDOAllRevisionsProvider provider = (CDOAllRevisionsProvider)allRevisionsProvider;
- Map<CDOBranch, List<CDORevision>> map = provider.getAllRevisions();
- IOUtil.OUT().println(CDORevisionUtil.dumpAllRevisions(map));
- }
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- }
- }
-
- protected static CDOCommitInfo commitAndSync(CDOTransaction transaction, CDOUpdatable... updatables)
- throws CommitException
- {
- CDOCommitInfo info = transaction.commit();
- if (info != null)
- {
- for (CDOUpdatable updatable : updatables)
- {
- if (!updatable.waitForUpdate(info.getTimeStamp(), DEFAULT_TIMEOUT))
- {
- throw new TimeoutRuntimeException(updatable.toString() + " did not receive an update of " + info);
- }
- }
- }
-
- return info;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry;
+import org.eclipse.emf.cdo.common.revision.CDOAllRevisionsProvider;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUpdatable;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper;
+
+import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.spi.cdo.FSMUtil;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractCDOTest extends ConfigTest
+{
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ try
+ {
+ super.doSetUp();
+ }
+ finally
+ {
+ org.eclipse.emf.cdo.internal.net4j.bundle.OM.PREF_COMMIT_MONITOR_PROGRESS_SECONDS.setValue(60);
+ org.eclipse.emf.cdo.internal.net4j.bundle.OM.PREF_COMMIT_MONITOR_TIMEOUT_SECONDS.setValue(60 * 60);
+ CDOPackageTypeRegistry.INSTANCE.reset();
+ startTransport();
+ }
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ // This override adds no functionality.
+ // It just ensures that the IDE shows doSetUp() and doTearDown() in the same class.
+ super.doTearDown();
+ }
+
+ protected static void assertTransient(EObject eObject)
+ {
+ CDOObject object = CDOUtil.getCDOObject(eObject);
+ if (object != null)
+ {
+ assertEquals(true, FSMUtil.isTransient(object));
+ assertNull(object.cdoID());
+ assertNull(object.cdoRevision());
+ assertNull(object.cdoView());
+ }
+ }
+
+ protected static void assertInvalid(EObject eObject)
+ {
+ CDOObject object = CDOUtil.getCDOObject(eObject);
+ if (object != null)
+ {
+ assertEquals(true, FSMUtil.isInvalid(object));
+ }
+ }
+
+ protected static void assertNotTransient(EObject eObject, CDOView view)
+ {
+ CDOObject object = FSMUtil.adapt(eObject, view);
+ assertEquals(false, FSMUtil.isTransient(object));
+ assertNotNull(object.cdoID());
+ assertNotNull(object.cdoRevision());
+ assertNotNull(object.cdoView());
+ assertNotNull(object.eResource());
+ assertEquals(view, object.cdoView());
+ assertEquals(object, view.getObject(object.cdoID(), false));
+ }
+
+ protected static void assertNew(EObject eObject, CDOView view)
+ {
+ CDOObject object = FSMUtil.adapt(eObject, view);
+ assertNotTransient(object, view);
+ assertEquals(CDOState.NEW, object.cdoState());
+ }
+
+ protected static void assertDirty(EObject eObject, CDOView view)
+ {
+ CDOObject object = FSMUtil.adapt(eObject, view);
+ assertNotTransient(object, view);
+ assertEquals(CDOState.DIRTY, object.cdoState());
+ }
+
+ protected static void assertClean(EObject eObject, CDOView view)
+ {
+ CDOObject object = FSMUtil.adapt(eObject, view);
+ assertNotTransient(object, view);
+ assertEquals(CDOState.CLEAN, object.cdoState());
+ }
+
+ protected static void assertProxy(EObject eObject)
+ {
+ CDOObject object = CDOUtil.getCDOObject(eObject);
+ if (object != null)
+ {
+ assertEquals(false, FSMUtil.isTransient(object));
+ assertNotNull(object.cdoID());
+ assertNotNull(object.cdoView());
+ assertEquals(CDOState.PROXY, object.cdoState());
+ }
+ }
+
+ protected static void assertContent(EObject eContainer, EObject eContained)
+ {
+ CDOObject container = CDOUtil.getCDOObject(eContainer);
+ CDOObject contained = CDOUtil.getCDOObject(eContained);
+ if (container != null && contained != null)
+ {
+ assertEquals(true, container.eContents().contains(contained));
+ if (container instanceof CDOResource)
+ {
+ assertEquals(container, contained.eResource());
+ assertEquals(null, contained.eContainer());
+ assertEquals(true, ((CDOResource)container).getContents().contains(contained));
+ }
+ else
+ {
+ assertEquals(container.eResource(), contained.eResource());
+ assertEquals(container, contained.eContainer());
+ }
+ }
+ }
+
+ protected static void assertNotProxy(Object object)
+ {
+ assertEquals(false, CDOLegacyWrapper.isLegacyProxy(object));
+ }
+
+ protected static void assertCreatedTime(EObject eObject, long timeStamp)
+ {
+ CDOObject object = CDOUtil.getCDOObject(eObject);
+ if (object != null)
+ {
+ assertEquals(timeStamp, object.cdoRevision().getTimeStamp());
+ }
+ }
+
+ protected static void dumpAllRevisions(Object allRevisionsProvider)
+ {
+ try
+ {
+ String label = allRevisionsProvider.toString();
+ IOUtil.OUT().println(label);
+ for (int i = 0; i < label.length(); i++)
+ {
+ IOUtil.OUT().print("=");
+ }
+
+ IOUtil.OUT().println();
+ if (allRevisionsProvider instanceof CDOAllRevisionsProvider)
+ {
+ CDOAllRevisionsProvider provider = (CDOAllRevisionsProvider)allRevisionsProvider;
+ Map<CDOBranch, List<CDORevision>> map = provider.getAllRevisions();
+ IOUtil.OUT().println(CDORevisionUtil.dumpAllRevisions(map));
+ }
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+
+ protected static CDOCommitInfo commitAndSync(CDOTransaction transaction, CDOUpdatable... updatables)
+ throws CommitException
+ {
+ CDOCommitInfo info = transaction.commit();
+ if (info != null)
+ {
+ for (CDOUpdatable updatable : updatables)
+ {
+ if (!updatable.waitForUpdate(info.getTimeStamp(), DEFAULT_TIMEOUT))
+ {
+ throw new TimeoutRuntimeException(updatable.toString() + " did not receive an update of " + info);
+ }
+ }
+ }
+
+ return info;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractLockingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractLockingTest.java
index b8897df0a9..0d46615b6a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractLockingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractLockingTest.java
@@ -1,78 +1,78 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Eike Stepper
- */
-public class AbstractLockingTest extends AbstractCDOTest
-{
- protected static void readLock(EObject object) throws InterruptedException
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- assertEquals(true, cdoObject.cdoReadLock().tryLock(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
- }
-
- protected static void readUnlock(EObject object) throws InterruptedException
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- cdoObject.cdoReadLock().unlock();
- }
-
- protected static void writeLock(EObject object) throws InterruptedException
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- assertEquals(true, cdoObject.cdoWriteLock().tryLock(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
- }
-
- protected static void writeUnlock(EObject object) throws InterruptedException
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- cdoObject.cdoWriteLock().unlock();
- }
-
- protected static void writeOption(EObject object) throws InterruptedException
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- assertEquals(true, cdoObject.cdoWriteOption().tryLock(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
- }
-
- protected static void writeUnoption(EObject object) throws InterruptedException
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- cdoObject.cdoWriteOption().unlock();
- }
-
- protected static void assertReadLock(boolean expected, EObject object)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- assertEquals(expected, cdoObject.cdoReadLock().isLocked());
- }
-
- protected static void assertWriteLock(boolean expected, EObject object)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- assertEquals(expected, cdoObject.cdoWriteLock().isLocked());
- }
-
- protected static void assertWriteOption(boolean expected, EObject object)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- assertEquals(expected, cdoObject.cdoWriteOption().isLocked());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Eike Stepper
+ */
+public class AbstractLockingTest extends AbstractCDOTest
+{
+ protected static void readLock(EObject object) throws InterruptedException
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ assertEquals(true, cdoObject.cdoReadLock().tryLock(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
+ }
+
+ protected static void readUnlock(EObject object) throws InterruptedException
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ cdoObject.cdoReadLock().unlock();
+ }
+
+ protected static void writeLock(EObject object) throws InterruptedException
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ assertEquals(true, cdoObject.cdoWriteLock().tryLock(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
+ }
+
+ protected static void writeUnlock(EObject object) throws InterruptedException
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ cdoObject.cdoWriteLock().unlock();
+ }
+
+ protected static void writeOption(EObject object) throws InterruptedException
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ assertEquals(true, cdoObject.cdoWriteOption().tryLock(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
+ }
+
+ protected static void writeUnoption(EObject object) throws InterruptedException
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ cdoObject.cdoWriteOption().unlock();
+ }
+
+ protected static void assertReadLock(boolean expected, EObject object)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ assertEquals(expected, cdoObject.cdoReadLock().isLocked());
+ }
+
+ protected static void assertWriteLock(boolean expected, EObject object)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ assertEquals(expected, cdoObject.cdoWriteLock().isLocked());
+ }
+
+ protected static void assertWriteOption(boolean expected, EObject object)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ assertEquals(expected, cdoObject.cdoWriteOption().isLocked());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java
index f39fa9575e..4ef1d57fea 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java
@@ -1,184 +1,184 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.net4j.util.ref.ReferenceType;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import java.lang.ref.WeakReference;
-
-/**
- * @author Simon McDuff
- */
-public class AdapterManagerTest extends AbstractCDOTest
-{
- public void testStrongReferencePolicy_NONE() throws Exception
- {
- msg("Opening session");
- final CDOSession session = openSession();
-
- session.options().setPassiveUpdateEnabled(false);
-
- // ************************************************************* //
-
- msg("Creating company");
- Company companyA = getModel1Factory().createCompany();
- TestAdapter testAdapter = new TestAdapter();
- msg("Opening transaction");
- final CDOTransaction transaction = session.openTransaction();
- transaction.options().setCacheReferenceType(ReferenceType.WEAK);
- transaction.options().setStrongReferencePolicy(CDOAdapterPolicy.NONE);
-
- transaction.createResource(getResourcePath("/resA")).getContents().add(companyA);
-
- msg("Committing");
- transaction.commit();
-
- final CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
- companyA.eAdapters().add(testAdapter);
-
- companyA = null;
- companyA = (Company)CDOUtil.getEObject(transaction.getObject(id));
- assertEquals(0, testAdapter.getNotifications().length);
-
- companyA.setCity("Ottawa");
- Notification[] notifications = testAdapter.getNotifications();
- assertEquals(1, notifications.length); // One EMF notification
- }
-
- public void testStrongReferencePolicy_ALL() throws Exception
- {
- msg("Opening session");
- final CDOSession session = openSession();
-
- session.options().setPassiveUpdateEnabled(false);
-
- // ************************************************************* //
-
- msg("Creating company");
- Company companyA = getModel1Factory().createCompany();
- TestAdapter testAdapter = new TestAdapter();
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
- transaction.options().setCacheReferenceType(ReferenceType.WEAK);
- transaction.options().setStrongReferencePolicy(CDOAdapterPolicy.ALL);
-
- transaction.createResource(getResourcePath("/resA")).getContents().add(companyA);
-
- msg("Committing");
- transaction.commit();
- CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
- companyA.eAdapters().add(testAdapter);
- companyA = null;
-
- testAdapter.clearNotifications();
-
- System.gc();
- assertEquals(true, transaction.isObjectRegistered(id));
-
- companyA = (Company)CDOUtil.getEObject(transaction.getObject(id));
-
- assertEquals(0, testAdapter.getNotifications().length);
- companyA.setCity("Ottawa");
- assertEquals(1, testAdapter.getNotifications().length);
- }
-
- public void testStrongReferencePolicy_ALL_AttachObject() throws Exception
- {
- msg("Opening session");
- final CDOSession session = openSession();
-
- session.options().setPassiveUpdateEnabled(false);
-
- // ************************************************************* //
-
- msg("Creating company");
- Company companyA = getModel1Factory().createCompany();
- TestAdapter testAdapter = new TestAdapter();
-
- companyA.eAdapters().add(testAdapter);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
- transaction.options().setCacheReferenceType(ReferenceType.WEAK);
- transaction.options().setStrongReferencePolicy(CDOAdapterPolicy.ALL);
-
- transaction.createResource(getResourcePath("/resA")).getContents().add(companyA);
-
- msg("Committing");
- transaction.commit();
- CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
-
- companyA = null;
-
- testAdapter.clearNotifications();
-
- System.gc();
- assertEquals(true, transaction.isObjectRegistered(id));
-
- companyA = (Company)CDOUtil.getEObject(transaction.getObject(id));
-
- assertEquals(0, testAdapter.getNotifications().length);
- companyA.setCity("Ottawa");
- assertEquals(1, testAdapter.getNotifications().length);
- }
-
- public void testStrongReferencePolicy_ALL_DetachObject() throws Exception
- {
- msg("Opening session");
- final CDOSession session = openSession();
-
- session.options().setPassiveUpdateEnabled(false);
-
- // ************************************************************* //
-
- msg("Creating company");
- Company companyA = getModel1Factory().createCompany();
- WeakReference<Company> weakCompanyA = new WeakReference<Company>(companyA);
-
- TestAdapter testAdapter = new TestAdapter();
-
- companyA.eAdapters().add(testAdapter);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
- transaction.options().setCacheReferenceType(ReferenceType.WEAK);
- transaction.options().setStrongReferencePolicy(CDOAdapterPolicy.ALL);
-
- transaction.createResource(getResourcePath("/resA")).getContents().add(companyA);
-
- msg("Committing");
- transaction.commit();
- CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
- companyA = null;
-
- testAdapter.clearNotifications();
-
- System.gc();
- assertEquals(true, transaction.isObjectRegistered(id));
-
- Company companyB = (Company)CDOUtil.getEObject(transaction.getObject(id));
- assertEquals(companyB, weakCompanyA.get());
- companyB.setCity("Ottawa");
- transaction.getResource(getResourcePath("/resA")).getContents().remove(0);
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.net4j.util.ref.ReferenceType;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import java.lang.ref.WeakReference;
+
+/**
+ * @author Simon McDuff
+ */
+public class AdapterManagerTest extends AbstractCDOTest
+{
+ public void testStrongReferencePolicy_NONE() throws Exception
+ {
+ msg("Opening session");
+ final CDOSession session = openSession();
+
+ session.options().setPassiveUpdateEnabled(false);
+
+ // ************************************************************* //
+
+ msg("Creating company");
+ Company companyA = getModel1Factory().createCompany();
+ TestAdapter testAdapter = new TestAdapter();
+ msg("Opening transaction");
+ final CDOTransaction transaction = session.openTransaction();
+ transaction.options().setCacheReferenceType(ReferenceType.WEAK);
+ transaction.options().setStrongReferencePolicy(CDOAdapterPolicy.NONE);
+
+ transaction.createResource(getResourcePath("/resA")).getContents().add(companyA);
+
+ msg("Committing");
+ transaction.commit();
+
+ final CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
+ companyA.eAdapters().add(testAdapter);
+
+ companyA = null;
+ companyA = (Company)CDOUtil.getEObject(transaction.getObject(id));
+ assertEquals(0, testAdapter.getNotifications().length);
+
+ companyA.setCity("Ottawa");
+ Notification[] notifications = testAdapter.getNotifications();
+ assertEquals(1, notifications.length); // One EMF notification
+ }
+
+ public void testStrongReferencePolicy_ALL() throws Exception
+ {
+ msg("Opening session");
+ final CDOSession session = openSession();
+
+ session.options().setPassiveUpdateEnabled(false);
+
+ // ************************************************************* //
+
+ msg("Creating company");
+ Company companyA = getModel1Factory().createCompany();
+ TestAdapter testAdapter = new TestAdapter();
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+ transaction.options().setCacheReferenceType(ReferenceType.WEAK);
+ transaction.options().setStrongReferencePolicy(CDOAdapterPolicy.ALL);
+
+ transaction.createResource(getResourcePath("/resA")).getContents().add(companyA);
+
+ msg("Committing");
+ transaction.commit();
+ CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
+ companyA.eAdapters().add(testAdapter);
+ companyA = null;
+
+ testAdapter.clearNotifications();
+
+ System.gc();
+ assertEquals(true, transaction.isObjectRegistered(id));
+
+ companyA = (Company)CDOUtil.getEObject(transaction.getObject(id));
+
+ assertEquals(0, testAdapter.getNotifications().length);
+ companyA.setCity("Ottawa");
+ assertEquals(1, testAdapter.getNotifications().length);
+ }
+
+ public void testStrongReferencePolicy_ALL_AttachObject() throws Exception
+ {
+ msg("Opening session");
+ final CDOSession session = openSession();
+
+ session.options().setPassiveUpdateEnabled(false);
+
+ // ************************************************************* //
+
+ msg("Creating company");
+ Company companyA = getModel1Factory().createCompany();
+ TestAdapter testAdapter = new TestAdapter();
+
+ companyA.eAdapters().add(testAdapter);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+ transaction.options().setCacheReferenceType(ReferenceType.WEAK);
+ transaction.options().setStrongReferencePolicy(CDOAdapterPolicy.ALL);
+
+ transaction.createResource(getResourcePath("/resA")).getContents().add(companyA);
+
+ msg("Committing");
+ transaction.commit();
+ CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
+
+ companyA = null;
+
+ testAdapter.clearNotifications();
+
+ System.gc();
+ assertEquals(true, transaction.isObjectRegistered(id));
+
+ companyA = (Company)CDOUtil.getEObject(transaction.getObject(id));
+
+ assertEquals(0, testAdapter.getNotifications().length);
+ companyA.setCity("Ottawa");
+ assertEquals(1, testAdapter.getNotifications().length);
+ }
+
+ public void testStrongReferencePolicy_ALL_DetachObject() throws Exception
+ {
+ msg("Opening session");
+ final CDOSession session = openSession();
+
+ session.options().setPassiveUpdateEnabled(false);
+
+ // ************************************************************* //
+
+ msg("Creating company");
+ Company companyA = getModel1Factory().createCompany();
+ WeakReference<Company> weakCompanyA = new WeakReference<Company>(companyA);
+
+ TestAdapter testAdapter = new TestAdapter();
+
+ companyA.eAdapters().add(testAdapter);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+ transaction.options().setCacheReferenceType(ReferenceType.WEAK);
+ transaction.options().setStrongReferencePolicy(CDOAdapterPolicy.ALL);
+
+ transaction.createResource(getResourcePath("/resA")).getContents().add(companyA);
+
+ msg("Committing");
+ transaction.commit();
+ CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
+ companyA = null;
+
+ testAdapter.clearNotifications();
+
+ System.gc();
+ assertEquals(true, transaction.isObjectRegistered(id));
+
+ Company companyB = (Company)CDOUtil.getEObject(transaction.getObject(id));
+ assertEquals(companyB, weakCompanyA.get());
+ companyB.setCity("Ottawa");
+ transaction.getResource(getResourcePath("/resA")).getContents().remove(0);
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
index 5a79e158ce..2572676a61 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTests extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTests().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM, JVM, NATIVE);
- addScenario(parent, COMBINED, MEM_AUDITS, JVM, NATIVE);
- addScenario(parent, COMBINED, MEM_BRANCHES, JVM, NATIVE);
- addScenario(parent, COMBINED, MEM_BRANCHES_UUIDS, JVM, NATIVE);
-
- addScenario(parent, COMBINED, MEM, JVM, LEGACY);
- addScenario(parent, COMBINED, MEM_AUDITS, JVM, LEGACY);
- addScenario(parent, COMBINED, MEM_BRANCHES, JVM, LEGACY);
-
- addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTests extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTests().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM, JVM, NATIVE);
+ addScenario(parent, COMBINED, MEM_AUDITS, JVM, NATIVE);
+ addScenario(parent, COMBINED, MEM_BRANCHES, JVM, NATIVE);
+ addScenario(parent, COMBINED, MEM_BRANCHES_UUIDS, JVM, NATIVE);
+
+ addScenario(parent, COMBINED, MEM, JVM, LEGACY);
+ addScenario(parent, COMBINED, MEM_AUDITS, JVM, LEGACY);
+ addScenario(parent, COMBINED, MEM_BRANCHES, JVM, LEGACY);
+
+ addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMAudit.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMAudit.java
index b1dbf8c63a..d2607e50ef 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMAudit.java
@@ -1,31 +1,31 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsMEMAudit extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTestsMEMAudit().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM_AUDITS, JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsMEMAudit extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsMEMAudit().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM_AUDITS, JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranches.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranches.java
index 2109da9c6d..9e1e1a700e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranches.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranches.java
@@ -1,31 +1,31 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsMEMBranches extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTestsMEMBranches().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM_BRANCHES, JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsMEMBranches extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsMEMBranches().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM_BRANCHES, JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesSSL.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesSSL.java
index 67d5aebb63..8922571fa3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesSSL.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesSSL.java
@@ -1,31 +1,31 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsMEMBranchesSSL extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTestsMEMBranchesSSL().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, SEPARATED, MEM_BRANCHES, SSL, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsMEMBranchesSSL extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsMEMBranchesSSL().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, SEPARATED, MEM_BRANCHES, SSL, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesTCP.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesTCP.java
index 73e82b397f..fc3121e411 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesTCP.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesTCP.java
@@ -1,31 +1,31 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Caspar De Groot
- */
-public class AllTestsMEMBranchesTCP extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTestsMEMBranchesTCP().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Caspar De Groot
+ */
+public class AllTestsMEMBranchesTCP extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsMEMBranchesTCP().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesUUIDs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesUUIDs.java
index 0c8dc430b5..bd995035b5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesUUIDs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMBranchesUUIDs.java
@@ -1,31 +1,31 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsMEMBranchesUUIDs extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTestsMEMBranchesUUIDs().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM_BRANCHES_UUIDS, JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsMEMBranchesUUIDs extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsMEMBranchesUUIDs().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM_BRANCHES_UUIDS, JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java
index ef3d0c5e9d..28f924b725 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java
@@ -1,33 +1,33 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- * @deprecated Not yet supported.
- */
-@Deprecated
-public class AllTestsMEMEmbedded extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTestsMEMEmbedded().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM, EMBEDDED, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ * @deprecated Not yet supported.
+ */
+@Deprecated
+public class AllTestsMEMEmbedded extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsMEMEmbedded().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM, EMBEDDED, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMLegacy.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMLegacy.java
index 463186987b..f9e760ad31 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMLegacy.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMLegacy.java
@@ -1,33 +1,33 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Martin Fluegge
- */
-public class AllTestsMEMLegacy extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTestsMEMLegacy().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM, JVM, LEGACY);
- addScenario(parent, COMBINED, MEM_AUDITS, JVM, LEGACY);
- addScenario(parent, COMBINED, MEM_BRANCHES, JVM, LEGACY);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AllTestsMEMLegacy extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsMEMLegacy().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM, JVM, LEGACY);
+ addScenario(parent, COMBINED, MEM_AUDITS, JVM, LEGACY);
+ addScenario(parent, COMBINED, MEM_BRANCHES, JVM, LEGACY);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMNonAudit.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMNonAudit.java
index fdd29d3f67..299f078c32 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMNonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMNonAudit.java
@@ -1,31 +1,31 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsMEMNonAudit extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTestsMEMNonAudit().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM, JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsMEMNonAudit extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsMEMNonAudit().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM, JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java
index 9578d7dc95..57628e407c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java
@@ -1,55 +1,55 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-import org.eclipse.emf.cdo.tests.offline.FailoverTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineDelayed2Test;
-import org.eclipse.emf.cdo.tests.offline.OfflineLockReplicationTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineLockingTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineTest;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsMEMOffline extends AllConfigs
-{
- public static Test suite()
- {
- return new AllTestsMEMOffline().getTestSuite(AllConfigs.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM_OFFLINE, JVM, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- testClasses.add(OfflineLockingTest.class);
- testClasses.add(OfflineLockReplicationTest.class);
- testClasses.add(OfflineTest.class);
- testClasses.add(OfflineDelayed2Test.class);
- testClasses.add(FailoverTest.class);
-
- // MEM does not support raw replication
- // testClasses.add(OfflineRawTest.class);
- // testClasses.add(OfflineLockRawReplicationTest.class);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+import org.eclipse.emf.cdo.tests.offline.FailoverTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineDelayed2Test;
+import org.eclipse.emf.cdo.tests.offline.OfflineLockReplicationTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineLockingTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsMEMOffline extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsMEMOffline().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM_OFFLINE, JVM, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.add(OfflineLockingTest.class);
+ testClasses.add(OfflineLockReplicationTest.class);
+ testClasses.add(OfflineTest.class);
+ testClasses.add(OfflineDelayed2Test.class);
+ testClasses.add(FailoverTest.class);
+
+ // MEM does not support raw replication
+ // testClasses.add(OfflineRawTest.class);
+ // testClasses.add(OfflineLockRawReplicationTest.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java
index 802dfc7c7f..6ccd2dfc0a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java
@@ -1,824 +1,824 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.tests.model3.Point;
-import org.eclipse.emf.cdo.tests.model3.Polygon;
-import org.eclipse.emf.cdo.tests.model3.PolygonWithDuplicates;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Arrays;
-
-/**
- * @author Eike Stepper
- */
-public class AttributeTest extends AbstractCDOTest
-{
- public void testPrimitiveDefaults() throws Exception
- {
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Preferred Supplier");
- assertEquals(true, supplier.isPreferred());
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(supplier);
- assertEquals(true, supplier.isPreferred());
- transaction.commit();
- assertEquals(true, supplier.isPreferred());
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/my/resource"));
- Supplier supplier = (Supplier)resource.getContents().get(0);
- assertEquals(true, supplier.isPreferred());
- view.close();
- session.close();
- }
- }
-
- public void testEnumDefaults() throws Exception
- {
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Test Product");
- assertEquals(VAT.VAT15, product.getVat());
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(product);
- assertEquals(VAT.VAT15, product.getVat());
- transaction.commit();
- assertEquals(VAT.VAT15, product.getVat());
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/my/resource"));
- Product1 product = (Product1)resource.getContents().get(0);
- assertEquals(VAT.VAT15, product.getVat());
- view.close();
- session.close();
- }
- }
-
- // XXX disabled because of Bug 289445
- // @Skips("Postgresql")
- @CleanRepositoriesBefore
- public void testByteArray() throws Exception
- {
- byte saveByteArray[] = new byte[] { 0, 1, 2, 3, 0, 1, 0, 100 };
-
- {
- EPackage packageWithBytes = createDynamicEPackageWithByte();
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(packageWithBytes);
-
- CDOTransaction transaction = session.openTransaction();
-
- EClass eClass = (EClass)packageWithBytes.getEClassifier("GenOfByteArray");
- EObject genOfByteArray = packageWithBytes.getEFactoryInstance().create(eClass);
- genOfByteArray.eSet(genOfByteArray.eClass().getEStructuralFeature("bytes"), saveByteArray);
-
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(genOfByteArray);
-
- transaction.commit();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/my/resource"));
- EObject genOfByteArray = resource.getContents().get(0);
- byte storeByteArray[] = (byte[])genOfByteArray.eGet(genOfByteArray.eClass().getEStructuralFeature("bytes"));
- assertEquals(storeByteArray.length, saveByteArray.length);
- for (int i = 0; i < storeByteArray.length; i++)
- {
- assertEquals(storeByteArray[i], saveByteArray[i]);
- }
-
- view.close();
- session.close();
- }
- }
-
- // XXX disabled because of Bug 289445
- // @Skips("Postgresql")
- @CleanRepositoriesBefore
- public void testByteArrayEmpty() throws Exception
- {
- byte saveByteArray[] = new byte[0];
-
- {
- EPackage packageWithBytes = createDynamicEPackageWithByte();
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(packageWithBytes);
- CDOTransaction transaction = session.openTransaction();
-
- EClass eClass = (EClass)packageWithBytes.getEClassifier("GenOfByteArray");
- EObject genOfByteArray = packageWithBytes.getEFactoryInstance().create(eClass);
- genOfByteArray.eSet(genOfByteArray.eClass().getEStructuralFeature("bytes"), saveByteArray);
-
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(genOfByteArray);
-
- transaction.commit();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/my/resource"));
- EObject genOfByteArray = resource.getContents().get(0);
- byte storeByteArray[] = (byte[])genOfByteArray.eGet(genOfByteArray.eClass().getEStructuralFeature("bytes"));
- assertEquals(0, storeByteArray.length);
- view.close();
- session.close();
- }
- }
-
- // XXX disabled because of Bug 289445
- // @Skips("Postgresql")
- @CleanRepositoriesBefore
- public void testByteArrayNull() throws Exception
- {
- byte saveByteArray[] = null;
-
- {
- EPackage packageWithBytes = createDynamicEPackageWithByte();
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(packageWithBytes);
- CDOTransaction transaction = session.openTransaction();
-
- EClass eClass = (EClass)packageWithBytes.getEClassifier("GenOfByteArray");
- EObject genOfByteArray = packageWithBytes.getEFactoryInstance().create(eClass);
- genOfByteArray.eSet(genOfByteArray.eClass().getEStructuralFeature("bytes"), saveByteArray);
-
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(genOfByteArray);
-
- transaction.commit();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/my/resource"));
- EObject genOfByteArray = resource.getContents().get(0);
- byte storeByteArray[] = (byte[])genOfByteArray.eGet(genOfByteArray.eClass().getEStructuralFeature("bytes"));
- assertEquals(true, storeByteArray == null || storeByteArray.length == 0);
- view.close();
- session.close();
- }
- }
-
- @CleanRepositoriesBefore
- public void testBigDecimalAndBigInteger() throws Exception
- {
- BigDecimal bigDecimal = new BigDecimal(10);
- BigInteger bigInteger = BigInteger.valueOf(10);
-
- {
- EPackage ePackage = createDynamicEPackageBigIntegerAndBigDecimal();
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(ePackage);
- CDOTransaction transaction = session.openTransaction();
-
- EClass eClass = (EClass)ePackage.getEClassifier("Gen");
- EStructuralFeature bigDecimalFeature = eClass.getEStructuralFeature("bigDecimal");
- EStructuralFeature bigIntegerFeature = eClass.getEStructuralFeature("bigInteger");
-
- EObject gen = ePackage.getEFactoryInstance().create(eClass);
- gen.eSet(bigDecimalFeature, bigDecimal);
- gen.eSet(bigIntegerFeature, bigInteger);
-
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(gen);
-
- CDORevisionData data = CDOUtil.getCDOObject(gen).cdoRevision().data();
- assertEquals(BigDecimal.class, data.get(bigDecimalFeature, -1).getClass());
- assertEquals(BigInteger.class, data.get(bigIntegerFeature, -1).getClass());
-
- transaction.commit();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/my/resource"));
- EObject gen = resource.getContents().get(0);
- BigDecimal bigDecimalStore = (BigDecimal)gen.eGet(gen.eClass().getEStructuralFeature("bigDecimal"));
- BigInteger bigIntegerStore = (BigInteger)gen.eGet(gen.eClass().getEStructuralFeature("bigInteger"));
- assertEquals(bigDecimal, bigDecimalStore);
- assertEquals(bigInteger, bigIntegerStore);
-
- view.close();
- session.close();
- }
- }
-
- @CleanRepositoriesBefore
- public void testBigDecimalAndBigIntegerNull() throws Exception
- {
- BigDecimal bigDecimal = null;
- BigInteger bigInteger = null;
-
- {
- EPackage ePackage = createDynamicEPackageBigIntegerAndBigDecimal();
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(ePackage);
- CDOTransaction transaction = session.openTransaction();
-
- EClass eClass = (EClass)ePackage.getEClassifier("Gen");
- EStructuralFeature bigDecimalFeature = eClass.getEStructuralFeature("bigDecimal");
- EStructuralFeature bigIntegerFeature = eClass.getEStructuralFeature("bigInteger");
-
- EObject gen = ePackage.getEFactoryInstance().create(eClass);
- gen.eSet(bigDecimalFeature, bigDecimal);
- gen.eSet(bigIntegerFeature, bigInteger);
-
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(gen);
-
- transaction.commit();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/my/resource"));
- EObject gen = resource.getContents().get(0);
- BigDecimal bigDecimalStore = (BigDecimal)gen.eGet(gen.eClass().getEStructuralFeature("bigDecimal"));
- BigInteger bigIntegerStore = (BigInteger)gen.eGet(gen.eClass().getEStructuralFeature("bigInteger"));
- assertNull(bigDecimalStore);
- assertNull(bigIntegerStore);
-
- view.close();
- session.close();
- }
- }
-
- private EPackage createDynamicEPackageWithByte()
- {
- final EcoreFactory efactory = EcoreFactory.eINSTANCE;
- final EcorePackage epackage = EcorePackage.eINSTANCE;
-
- EClass schoolBookEClass = efactory.createEClass();
- schoolBookEClass.setName("GenOfByteArray");
-
- // create a new attribute for this EClass
- EAttribute level = efactory.createEAttribute();
- level.setName("bytes");
- level.setEType(epackage.getEByteArray());
- schoolBookEClass.getEStructuralFeatures().add(level);
-
- // Create a new EPackage and add the new EClasses
- EPackage schoolPackage = efactory.createEPackage();
- schoolPackage.setName("EPackageTest");
- schoolPackage.setNsPrefix("EPackageTest");
- schoolPackage.setNsURI("http:///www.cdo.org/testcase");
- schoolPackage.getEClassifiers().add(schoolBookEClass);
- return schoolPackage;
- }
-
- private EPackage createDynamicEPackageBigIntegerAndBigDecimal()
- {
- final EcoreFactory efactory = EcoreFactory.eINSTANCE;
- final EcorePackage epackage = EcorePackage.eINSTANCE;
-
- EClass schoolBookEClass = efactory.createEClass();
- schoolBookEClass.setName("Gen");
-
- // create a new attribute for this EClass
- EAttribute attrBigDecimal = efactory.createEAttribute();
- attrBigDecimal.setName("bigDecimal");
- attrBigDecimal.setEType(epackage.getEBigDecimal());
- schoolBookEClass.getEStructuralFeatures().add(attrBigDecimal);
-
- EAttribute attrBigInteger = efactory.createEAttribute();
- attrBigInteger.setName("bigInteger");
- attrBigInteger.setEType(epackage.getEBigInteger());
- schoolBookEClass.getEStructuralFeatures().add(attrBigInteger);
-
- // Create a new EPackage and add the new EClasses
- EPackage schoolPackage = efactory.createEPackage();
- schoolPackage.setName("EPackageTest");
- schoolPackage.setNsPrefix("EPackageTest");
- schoolPackage.setNsURI("http:///www.cdo.org/testcase");
- schoolPackage.getEClassifiers().add(schoolBookEClass);
- return schoolPackage;
- }
-
- public void testManyValuedCustomDataType_Get() throws Exception
- {
- Polygon polygon = getModel3Factory().createPolygon();
- EList<Point> points = polygon.getPoints();
- points.add(new Point(1, 2));
- points.add(new Point(3, 4));
- points.add(new Point(5, 6));
-
- points = polygon.getPoints();
- assertEquals(3, points.size());
- assertInstanceOf(Point.class, points.get(0));
- assertInstanceOf(Point.class, points.get(1));
- assertInstanceOf(Point.class, points.get(2));
-
- Object[] array1 = points.toArray();
- assertEquals(points.size(), array1.length);
- assertInstanceOf(Point.class, array1[0]);
- assertInstanceOf(Point.class, array1[1]);
- assertInstanceOf(Point.class, array1[2]);
-
- Point[] array2 = points.toArray(new Point[3]);
- assertEquals(points.size(), array2.length);
- assertInstanceOf(Point.class, array2[0]);
- assertInstanceOf(Point.class, array2[1]);
- assertInstanceOf(Point.class, array2[2]);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(polygon);
-
- points = polygon.getPoints();
- assertEquals(3, points.size());
- assertInstanceOf(Point.class, points.get(0));
- assertInstanceOf(Point.class, points.get(1));
- assertInstanceOf(Point.class, points.get(2));
-
- array1 = points.toArray();
- assertEquals(points.size(), array1.length);
- assertInstanceOf(Point.class, array1[0]);
- assertInstanceOf(Point.class, array1[1]);
- assertInstanceOf(Point.class, array1[2]);
-
- array2 = points.toArray(new Point[3]);
- assertEquals(points.size(), array2.length);
- assertInstanceOf(Point.class, array2[0]);
- assertInstanceOf(Point.class, array2[1]);
- assertInstanceOf(Point.class, array2[2]);
-
- transaction.commit();
-
- points = polygon.getPoints();
- assertEquals(3, points.size());
- assertInstanceOf(Point.class, points.get(0));
- assertInstanceOf(Point.class, points.get(1));
- assertInstanceOf(Point.class, points.get(2));
-
- array1 = points.toArray();
- assertEquals(points.size(), array1.length);
- assertInstanceOf(Point.class, array1[0]);
- assertInstanceOf(Point.class, array1[1]);
- assertInstanceOf(Point.class, array1[2]);
-
- array2 = points.toArray(new Point[3]);
- assertEquals(points.size(), array2.length);
- assertInstanceOf(Point.class, array2[0]);
- assertInstanceOf(Point.class, array2[1]);
- assertInstanceOf(Point.class, array2[2]);
-
- session.close();
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/my/resource"));
- polygon = (Polygon)resource.getContents().get(0);
-
- points = polygon.getPoints();
- assertEquals(3, points.size());
- assertInstanceOf(Point.class, points.get(0));
- assertInstanceOf(Point.class, points.get(1));
- assertInstanceOf(Point.class, points.get(2));
-
- array1 = points.toArray();
- assertEquals(points.size(), array1.length);
- assertInstanceOf(Point.class, array1[0]);
- assertInstanceOf(Point.class, array1[1]);
- assertInstanceOf(Point.class, array1[2]);
-
- array2 = points.toArray(new Point[3]);
- assertEquals(points.size(), array2.length);
- assertInstanceOf(Point.class, array2[0]);
- assertInstanceOf(Point.class, array2[1]);
- assertInstanceOf(Point.class, array2[2]);
- }
-
- public void testManyValuedCustomDataType_Contains() throws Exception
- {
- Polygon polygon = getModel3Factory().createPolygon();
- EList<Point> points = polygon.getPoints();
- points.add(new Point(1, 2));
- points.add(new Point(3, 4));
- points.add(new Point(5, 6));
- points.add(new Point(7, 8));
- points.add(new Point(9, 0));
-
- assertEquals(true, points.contains(new Point(1, 2)));
- assertEquals(true, points.contains(new Point(3, 4)));
- assertEquals(true, points.contains(new Point(5, 6)));
- assertEquals(true, points.contains(new Point(7, 8)));
- assertEquals(true, points.contains(new Point(9, 0)));
-
- assertEquals(false, points.contains(new Point(0, 2)));
- assertEquals(false, points.contains(new Point(0, 4)));
- assertEquals(false, points.contains(new Point(0, 6)));
- assertEquals(false, points.contains(new Point(0, 8)));
- assertEquals(false, points.contains(new Point(0, 0)));
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(polygon);
-
- points = polygon.getPoints();
- assertEquals(true, points.contains(new Point(1, 2)));
- assertEquals(true, points.contains(new Point(3, 4)));
- assertEquals(true, points.contains(new Point(5, 6)));
- assertEquals(true, points.contains(new Point(7, 8)));
- assertEquals(true, points.contains(new Point(9, 0)));
-
- assertEquals(false, points.contains(new Point(0, 2)));
- assertEquals(false, points.contains(new Point(0, 4)));
- assertEquals(false, points.contains(new Point(0, 6)));
- assertEquals(false, points.contains(new Point(0, 8)));
- assertEquals(false, points.contains(new Point(0, 0)));
-
- transaction.commit();
-
- points = polygon.getPoints();
- assertEquals(true, points.contains(new Point(1, 2)));
- assertEquals(true, points.contains(new Point(3, 4)));
- assertEquals(true, points.contains(new Point(5, 6)));
- assertEquals(true, points.contains(new Point(7, 8)));
- assertEquals(true, points.contains(new Point(9, 0)));
-
- assertEquals(false, points.contains(new Point(0, 2)));
- assertEquals(false, points.contains(new Point(0, 4)));
- assertEquals(false, points.contains(new Point(0, 6)));
- assertEquals(false, points.contains(new Point(0, 8)));
- assertEquals(false, points.contains(new Point(0, 0)));
-
- session.close();
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/my/resource"));
- polygon = (Polygon)resource.getContents().get(0);
-
- points = polygon.getPoints();
- assertEquals(true, points.contains(new Point(1, 2)));
- assertEquals(true, points.contains(new Point(3, 4)));
- assertEquals(true, points.contains(new Point(5, 6)));
- assertEquals(true, points.contains(new Point(7, 8)));
- assertEquals(true, points.contains(new Point(9, 0)));
-
- assertEquals(false, points.contains(new Point(0, 2)));
- assertEquals(false, points.contains(new Point(0, 4)));
- assertEquals(false, points.contains(new Point(0, 6)));
- assertEquals(false, points.contains(new Point(0, 8)));
- assertEquals(false, points.contains(new Point(0, 0)));
- }
-
- public void testManyValuedCustomDataType_ContainsAll() throws Exception
- {
- Polygon polygon = getModel3Factory().createPolygon();
- EList<Point> points = polygon.getPoints();
- points.add(new Point(1, 2));
- points.add(new Point(3, 4));
- points.add(new Point(5, 6));
- points.add(new Point(7, 8));
- points.add(new Point(9, 0));
-
- assertEquals(true, points.containsAll(points));
-
- assertEquals(
- true,
- points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
- new Point(9, 0) })));
- assertEquals(true,
- points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(9, 0) })));
- assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(9, 0) })));
- assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(9, 0) })));
-
- assertEquals(
- false,
- points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
- new Point(0, 0) })));
- assertEquals(false,
- points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(0, 0) })));
- assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(0, 0) })));
- assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(0, 0) })));
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(polygon);
-
- points = polygon.getPoints();
- assertEquals(true, points.containsAll(points));
-
- assertEquals(
- true,
- points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
- new Point(9, 0) })));
- assertEquals(true,
- points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(9, 0) })));
- assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(9, 0) })));
- assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(9, 0) })));
-
- assertEquals(
- false,
- points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
- new Point(0, 0) })));
- assertEquals(false,
- points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(0, 0) })));
- assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(0, 0) })));
- assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(0, 0) })));
-
- transaction.commit();
-
- points = polygon.getPoints();
- assertEquals(true, points.containsAll(points));
-
- assertEquals(
- true,
- points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
- new Point(9, 0) })));
- assertEquals(true,
- points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(9, 0) })));
- assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(9, 0) })));
- assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(9, 0) })));
-
- assertEquals(
- false,
- points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
- new Point(0, 0) })));
- assertEquals(false,
- points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(0, 0) })));
- assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(0, 0) })));
- assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(0, 0) })));
-
- session.close();
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/my/resource"));
- polygon = (Polygon)resource.getContents().get(0);
-
- points = polygon.getPoints();
- assertEquals(true, points.containsAll(points));
-
- assertEquals(
- true,
- points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
- new Point(9, 0) })));
- assertEquals(true,
- points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(9, 0) })));
- assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(9, 0) })));
- assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(9, 0) })));
-
- assertEquals(
- false,
- points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
- new Point(0, 0) })));
- assertEquals(false,
- points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(0, 0) })));
- assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(0, 0) })));
- assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(0, 0) })));
- }
-
- public void testManyValuedCustomDataType_IndexOf() throws Exception
- {
- PolygonWithDuplicates polygon = getModel3Factory().createPolygonWithDuplicates();
- EList<Point> points = polygon.getPoints();
- points.add(new Point(1, 2));
- points.add(new Point(3, 4));
- points.add(new Point(5, 6));
- points.add(new Point(7, 8));
- points.add(new Point(9, 0));
- points.add(new Point(1, 2));
- points.add(new Point(3, 4));
- points.add(new Point(5, 6));
- points.add(new Point(7, 8));
- points.add(new Point(9, 0));
-
- assertEquals(0, points.indexOf(new Point(1, 2)));
- assertEquals(1, points.indexOf(new Point(3, 4)));
- assertEquals(2, points.indexOf(new Point(5, 6)));
- assertEquals(3, points.indexOf(new Point(7, 8)));
- assertEquals(4, points.indexOf(new Point(9, 0)));
-
- assertEquals(-1, points.indexOf(new Point(0, 2)));
- assertEquals(-1, points.indexOf(new Point(0, 4)));
- assertEquals(-1, points.indexOf(new Point(0, 6)));
- assertEquals(-1, points.indexOf(new Point(0, 8)));
- assertEquals(-1, points.indexOf(new Point(0, 0)));
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(polygon);
-
- points = polygon.getPoints();
- assertEquals(0, points.indexOf(new Point(1, 2)));
- assertEquals(1, points.indexOf(new Point(3, 4)));
- assertEquals(2, points.indexOf(new Point(5, 6)));
- assertEquals(3, points.indexOf(new Point(7, 8)));
- assertEquals(4, points.indexOf(new Point(9, 0)));
-
- assertEquals(-1, points.indexOf(new Point(0, 2)));
- assertEquals(-1, points.indexOf(new Point(0, 4)));
- assertEquals(-1, points.indexOf(new Point(0, 6)));
- assertEquals(-1, points.indexOf(new Point(0, 8)));
- assertEquals(-1, points.indexOf(new Point(0, 0)));
-
- transaction.commit();
-
- points = polygon.getPoints();
- assertEquals(0, points.indexOf(new Point(1, 2)));
- assertEquals(1, points.indexOf(new Point(3, 4)));
- assertEquals(2, points.indexOf(new Point(5, 6)));
- assertEquals(3, points.indexOf(new Point(7, 8)));
- assertEquals(4, points.indexOf(new Point(9, 0)));
-
- assertEquals(-1, points.indexOf(new Point(0, 2)));
- assertEquals(-1, points.indexOf(new Point(0, 4)));
- assertEquals(-1, points.indexOf(new Point(0, 6)));
- assertEquals(-1, points.indexOf(new Point(0, 8)));
- assertEquals(-1, points.indexOf(new Point(0, 0)));
-
- session.close();
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/my/resource"));
- polygon = (PolygonWithDuplicates)resource.getContents().get(0);
-
- points = polygon.getPoints();
- assertEquals(0, points.indexOf(new Point(1, 2)));
- assertEquals(1, points.indexOf(new Point(3, 4)));
- assertEquals(2, points.indexOf(new Point(5, 6)));
- assertEquals(3, points.indexOf(new Point(7, 8)));
- assertEquals(4, points.indexOf(new Point(9, 0)));
-
- assertEquals(-1, points.indexOf(new Point(0, 2)));
- assertEquals(-1, points.indexOf(new Point(0, 4)));
- assertEquals(-1, points.indexOf(new Point(0, 6)));
- assertEquals(-1, points.indexOf(new Point(0, 8)));
- assertEquals(-1, points.indexOf(new Point(0, 0)));
- }
-
- public void testManyValuedCustomDataType_LastIndexOf() throws Exception
- {
- PolygonWithDuplicates polygon = getModel3Factory().createPolygonWithDuplicates();
- EList<Point> points = polygon.getPoints();
- points.add(new Point(1, 2));
- points.add(new Point(3, 4));
- points.add(new Point(5, 6));
- points.add(new Point(7, 8));
- points.add(new Point(9, 0));
- points.add(new Point(1, 2));
- points.add(new Point(3, 4));
- points.add(new Point(5, 6));
- points.add(new Point(7, 8));
- points.add(new Point(9, 0));
-
- assertEquals(5, points.lastIndexOf(new Point(1, 2)));
- assertEquals(6, points.lastIndexOf(new Point(3, 4)));
- assertEquals(7, points.lastIndexOf(new Point(5, 6)));
- assertEquals(8, points.lastIndexOf(new Point(7, 8)));
- assertEquals(9, points.lastIndexOf(new Point(9, 0)));
-
- assertEquals(-1, points.lastIndexOf(new Point(0, 2)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 4)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 6)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 8)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 0)));
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(polygon);
-
- points = polygon.getPoints();
- assertEquals(5, points.lastIndexOf(new Point(1, 2)));
- assertEquals(6, points.lastIndexOf(new Point(3, 4)));
- assertEquals(7, points.lastIndexOf(new Point(5, 6)));
- assertEquals(8, points.lastIndexOf(new Point(7, 8)));
- assertEquals(9, points.lastIndexOf(new Point(9, 0)));
-
- assertEquals(-1, points.lastIndexOf(new Point(0, 2)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 4)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 6)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 8)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 0)));
-
- transaction.commit();
-
- points = polygon.getPoints();
- assertEquals(5, points.lastIndexOf(new Point(1, 2)));
- assertEquals(6, points.lastIndexOf(new Point(3, 4)));
- assertEquals(7, points.lastIndexOf(new Point(5, 6)));
- assertEquals(8, points.lastIndexOf(new Point(7, 8)));
- assertEquals(9, points.lastIndexOf(new Point(9, 0)));
-
- assertEquals(-1, points.lastIndexOf(new Point(0, 2)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 4)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 6)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 8)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 0)));
-
- session.close();
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/my/resource"));
- polygon = (PolygonWithDuplicates)resource.getContents().get(0);
-
- points = polygon.getPoints();
- assertEquals(5, points.lastIndexOf(new Point(1, 2)));
- assertEquals(6, points.lastIndexOf(new Point(3, 4)));
- assertEquals(7, points.lastIndexOf(new Point(5, 6)));
- assertEquals(8, points.lastIndexOf(new Point(7, 8)));
- assertEquals(9, points.lastIndexOf(new Point(9, 0)));
-
- assertEquals(-1, points.lastIndexOf(new Point(0, 2)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 4)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 6)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 8)));
- assertEquals(-1, points.lastIndexOf(new Point(0, 0)));
- }
-
- public void testManyValuedCustomDataType_Bugzilla_319950() throws Exception
- {
- Polygon polygon = getModel3Factory().createPolygon();
- EList<Point> points = polygon.getPoints();
- points.add(new Point(1, 2));
- points.add(new Point(3, 4));
- points.add(new Point(5, 6));
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(polygon);
- transaction.commit();
- session.close();
-
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/my/resource"));
- EList<EObject> contents = resource.getContents();
-
- // java.lang.ClassCastException: org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl
- EcoreUtil.copyAll(contents);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.tests.model3.Point;
+import org.eclipse.emf.cdo.tests.model3.Polygon;
+import org.eclipse.emf.cdo.tests.model3.PolygonWithDuplicates;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Arrays;
+
+/**
+ * @author Eike Stepper
+ */
+public class AttributeTest extends AbstractCDOTest
+{
+ public void testPrimitiveDefaults() throws Exception
+ {
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Preferred Supplier");
+ assertEquals(true, supplier.isPreferred());
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(supplier);
+ assertEquals(true, supplier.isPreferred());
+ transaction.commit();
+ assertEquals(true, supplier.isPreferred());
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/my/resource"));
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ assertEquals(true, supplier.isPreferred());
+ view.close();
+ session.close();
+ }
+ }
+
+ public void testEnumDefaults() throws Exception
+ {
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Test Product");
+ assertEquals(VAT.VAT15, product.getVat());
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(product);
+ assertEquals(VAT.VAT15, product.getVat());
+ transaction.commit();
+ assertEquals(VAT.VAT15, product.getVat());
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/my/resource"));
+ Product1 product = (Product1)resource.getContents().get(0);
+ assertEquals(VAT.VAT15, product.getVat());
+ view.close();
+ session.close();
+ }
+ }
+
+ // XXX disabled because of Bug 289445
+ // @Skips("Postgresql")
+ @CleanRepositoriesBefore
+ public void testByteArray() throws Exception
+ {
+ byte saveByteArray[] = new byte[] { 0, 1, 2, 3, 0, 1, 0, 100 };
+
+ {
+ EPackage packageWithBytes = createDynamicEPackageWithByte();
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(packageWithBytes);
+
+ CDOTransaction transaction = session.openTransaction();
+
+ EClass eClass = (EClass)packageWithBytes.getEClassifier("GenOfByteArray");
+ EObject genOfByteArray = packageWithBytes.getEFactoryInstance().create(eClass);
+ genOfByteArray.eSet(genOfByteArray.eClass().getEStructuralFeature("bytes"), saveByteArray);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(genOfByteArray);
+
+ transaction.commit();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/my/resource"));
+ EObject genOfByteArray = resource.getContents().get(0);
+ byte storeByteArray[] = (byte[])genOfByteArray.eGet(genOfByteArray.eClass().getEStructuralFeature("bytes"));
+ assertEquals(storeByteArray.length, saveByteArray.length);
+ for (int i = 0; i < storeByteArray.length; i++)
+ {
+ assertEquals(storeByteArray[i], saveByteArray[i]);
+ }
+
+ view.close();
+ session.close();
+ }
+ }
+
+ // XXX disabled because of Bug 289445
+ // @Skips("Postgresql")
+ @CleanRepositoriesBefore
+ public void testByteArrayEmpty() throws Exception
+ {
+ byte saveByteArray[] = new byte[0];
+
+ {
+ EPackage packageWithBytes = createDynamicEPackageWithByte();
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(packageWithBytes);
+ CDOTransaction transaction = session.openTransaction();
+
+ EClass eClass = (EClass)packageWithBytes.getEClassifier("GenOfByteArray");
+ EObject genOfByteArray = packageWithBytes.getEFactoryInstance().create(eClass);
+ genOfByteArray.eSet(genOfByteArray.eClass().getEStructuralFeature("bytes"), saveByteArray);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(genOfByteArray);
+
+ transaction.commit();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/my/resource"));
+ EObject genOfByteArray = resource.getContents().get(0);
+ byte storeByteArray[] = (byte[])genOfByteArray.eGet(genOfByteArray.eClass().getEStructuralFeature("bytes"));
+ assertEquals(0, storeByteArray.length);
+ view.close();
+ session.close();
+ }
+ }
+
+ // XXX disabled because of Bug 289445
+ // @Skips("Postgresql")
+ @CleanRepositoriesBefore
+ public void testByteArrayNull() throws Exception
+ {
+ byte saveByteArray[] = null;
+
+ {
+ EPackage packageWithBytes = createDynamicEPackageWithByte();
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(packageWithBytes);
+ CDOTransaction transaction = session.openTransaction();
+
+ EClass eClass = (EClass)packageWithBytes.getEClassifier("GenOfByteArray");
+ EObject genOfByteArray = packageWithBytes.getEFactoryInstance().create(eClass);
+ genOfByteArray.eSet(genOfByteArray.eClass().getEStructuralFeature("bytes"), saveByteArray);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(genOfByteArray);
+
+ transaction.commit();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/my/resource"));
+ EObject genOfByteArray = resource.getContents().get(0);
+ byte storeByteArray[] = (byte[])genOfByteArray.eGet(genOfByteArray.eClass().getEStructuralFeature("bytes"));
+ assertEquals(true, storeByteArray == null || storeByteArray.length == 0);
+ view.close();
+ session.close();
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testBigDecimalAndBigInteger() throws Exception
+ {
+ BigDecimal bigDecimal = new BigDecimal(10);
+ BigInteger bigInteger = BigInteger.valueOf(10);
+
+ {
+ EPackage ePackage = createDynamicEPackageBigIntegerAndBigDecimal();
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(ePackage);
+ CDOTransaction transaction = session.openTransaction();
+
+ EClass eClass = (EClass)ePackage.getEClassifier("Gen");
+ EStructuralFeature bigDecimalFeature = eClass.getEStructuralFeature("bigDecimal");
+ EStructuralFeature bigIntegerFeature = eClass.getEStructuralFeature("bigInteger");
+
+ EObject gen = ePackage.getEFactoryInstance().create(eClass);
+ gen.eSet(bigDecimalFeature, bigDecimal);
+ gen.eSet(bigIntegerFeature, bigInteger);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(gen);
+
+ CDORevisionData data = CDOUtil.getCDOObject(gen).cdoRevision().data();
+ assertEquals(BigDecimal.class, data.get(bigDecimalFeature, -1).getClass());
+ assertEquals(BigInteger.class, data.get(bigIntegerFeature, -1).getClass());
+
+ transaction.commit();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/my/resource"));
+ EObject gen = resource.getContents().get(0);
+ BigDecimal bigDecimalStore = (BigDecimal)gen.eGet(gen.eClass().getEStructuralFeature("bigDecimal"));
+ BigInteger bigIntegerStore = (BigInteger)gen.eGet(gen.eClass().getEStructuralFeature("bigInteger"));
+ assertEquals(bigDecimal, bigDecimalStore);
+ assertEquals(bigInteger, bigIntegerStore);
+
+ view.close();
+ session.close();
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testBigDecimalAndBigIntegerNull() throws Exception
+ {
+ BigDecimal bigDecimal = null;
+ BigInteger bigInteger = null;
+
+ {
+ EPackage ePackage = createDynamicEPackageBigIntegerAndBigDecimal();
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(ePackage);
+ CDOTransaction transaction = session.openTransaction();
+
+ EClass eClass = (EClass)ePackage.getEClassifier("Gen");
+ EStructuralFeature bigDecimalFeature = eClass.getEStructuralFeature("bigDecimal");
+ EStructuralFeature bigIntegerFeature = eClass.getEStructuralFeature("bigInteger");
+
+ EObject gen = ePackage.getEFactoryInstance().create(eClass);
+ gen.eSet(bigDecimalFeature, bigDecimal);
+ gen.eSet(bigIntegerFeature, bigInteger);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(gen);
+
+ transaction.commit();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/my/resource"));
+ EObject gen = resource.getContents().get(0);
+ BigDecimal bigDecimalStore = (BigDecimal)gen.eGet(gen.eClass().getEStructuralFeature("bigDecimal"));
+ BigInteger bigIntegerStore = (BigInteger)gen.eGet(gen.eClass().getEStructuralFeature("bigInteger"));
+ assertNull(bigDecimalStore);
+ assertNull(bigIntegerStore);
+
+ view.close();
+ session.close();
+ }
+ }
+
+ private EPackage createDynamicEPackageWithByte()
+ {
+ final EcoreFactory efactory = EcoreFactory.eINSTANCE;
+ final EcorePackage epackage = EcorePackage.eINSTANCE;
+
+ EClass schoolBookEClass = efactory.createEClass();
+ schoolBookEClass.setName("GenOfByteArray");
+
+ // create a new attribute for this EClass
+ EAttribute level = efactory.createEAttribute();
+ level.setName("bytes");
+ level.setEType(epackage.getEByteArray());
+ schoolBookEClass.getEStructuralFeatures().add(level);
+
+ // Create a new EPackage and add the new EClasses
+ EPackage schoolPackage = efactory.createEPackage();
+ schoolPackage.setName("EPackageTest");
+ schoolPackage.setNsPrefix("EPackageTest");
+ schoolPackage.setNsURI("http:///www.cdo.org/testcase");
+ schoolPackage.getEClassifiers().add(schoolBookEClass);
+ return schoolPackage;
+ }
+
+ private EPackage createDynamicEPackageBigIntegerAndBigDecimal()
+ {
+ final EcoreFactory efactory = EcoreFactory.eINSTANCE;
+ final EcorePackage epackage = EcorePackage.eINSTANCE;
+
+ EClass schoolBookEClass = efactory.createEClass();
+ schoolBookEClass.setName("Gen");
+
+ // create a new attribute for this EClass
+ EAttribute attrBigDecimal = efactory.createEAttribute();
+ attrBigDecimal.setName("bigDecimal");
+ attrBigDecimal.setEType(epackage.getEBigDecimal());
+ schoolBookEClass.getEStructuralFeatures().add(attrBigDecimal);
+
+ EAttribute attrBigInteger = efactory.createEAttribute();
+ attrBigInteger.setName("bigInteger");
+ attrBigInteger.setEType(epackage.getEBigInteger());
+ schoolBookEClass.getEStructuralFeatures().add(attrBigInteger);
+
+ // Create a new EPackage and add the new EClasses
+ EPackage schoolPackage = efactory.createEPackage();
+ schoolPackage.setName("EPackageTest");
+ schoolPackage.setNsPrefix("EPackageTest");
+ schoolPackage.setNsURI("http:///www.cdo.org/testcase");
+ schoolPackage.getEClassifiers().add(schoolBookEClass);
+ return schoolPackage;
+ }
+
+ public void testManyValuedCustomDataType_Get() throws Exception
+ {
+ Polygon polygon = getModel3Factory().createPolygon();
+ EList<Point> points = polygon.getPoints();
+ points.add(new Point(1, 2));
+ points.add(new Point(3, 4));
+ points.add(new Point(5, 6));
+
+ points = polygon.getPoints();
+ assertEquals(3, points.size());
+ assertInstanceOf(Point.class, points.get(0));
+ assertInstanceOf(Point.class, points.get(1));
+ assertInstanceOf(Point.class, points.get(2));
+
+ Object[] array1 = points.toArray();
+ assertEquals(points.size(), array1.length);
+ assertInstanceOf(Point.class, array1[0]);
+ assertInstanceOf(Point.class, array1[1]);
+ assertInstanceOf(Point.class, array1[2]);
+
+ Point[] array2 = points.toArray(new Point[3]);
+ assertEquals(points.size(), array2.length);
+ assertInstanceOf(Point.class, array2[0]);
+ assertInstanceOf(Point.class, array2[1]);
+ assertInstanceOf(Point.class, array2[2]);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(polygon);
+
+ points = polygon.getPoints();
+ assertEquals(3, points.size());
+ assertInstanceOf(Point.class, points.get(0));
+ assertInstanceOf(Point.class, points.get(1));
+ assertInstanceOf(Point.class, points.get(2));
+
+ array1 = points.toArray();
+ assertEquals(points.size(), array1.length);
+ assertInstanceOf(Point.class, array1[0]);
+ assertInstanceOf(Point.class, array1[1]);
+ assertInstanceOf(Point.class, array1[2]);
+
+ array2 = points.toArray(new Point[3]);
+ assertEquals(points.size(), array2.length);
+ assertInstanceOf(Point.class, array2[0]);
+ assertInstanceOf(Point.class, array2[1]);
+ assertInstanceOf(Point.class, array2[2]);
+
+ transaction.commit();
+
+ points = polygon.getPoints();
+ assertEquals(3, points.size());
+ assertInstanceOf(Point.class, points.get(0));
+ assertInstanceOf(Point.class, points.get(1));
+ assertInstanceOf(Point.class, points.get(2));
+
+ array1 = points.toArray();
+ assertEquals(points.size(), array1.length);
+ assertInstanceOf(Point.class, array1[0]);
+ assertInstanceOf(Point.class, array1[1]);
+ assertInstanceOf(Point.class, array1[2]);
+
+ array2 = points.toArray(new Point[3]);
+ assertEquals(points.size(), array2.length);
+ assertInstanceOf(Point.class, array2[0]);
+ assertInstanceOf(Point.class, array2[1]);
+ assertInstanceOf(Point.class, array2[2]);
+
+ session.close();
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ polygon = (Polygon)resource.getContents().get(0);
+
+ points = polygon.getPoints();
+ assertEquals(3, points.size());
+ assertInstanceOf(Point.class, points.get(0));
+ assertInstanceOf(Point.class, points.get(1));
+ assertInstanceOf(Point.class, points.get(2));
+
+ array1 = points.toArray();
+ assertEquals(points.size(), array1.length);
+ assertInstanceOf(Point.class, array1[0]);
+ assertInstanceOf(Point.class, array1[1]);
+ assertInstanceOf(Point.class, array1[2]);
+
+ array2 = points.toArray(new Point[3]);
+ assertEquals(points.size(), array2.length);
+ assertInstanceOf(Point.class, array2[0]);
+ assertInstanceOf(Point.class, array2[1]);
+ assertInstanceOf(Point.class, array2[2]);
+ }
+
+ public void testManyValuedCustomDataType_Contains() throws Exception
+ {
+ Polygon polygon = getModel3Factory().createPolygon();
+ EList<Point> points = polygon.getPoints();
+ points.add(new Point(1, 2));
+ points.add(new Point(3, 4));
+ points.add(new Point(5, 6));
+ points.add(new Point(7, 8));
+ points.add(new Point(9, 0));
+
+ assertEquals(true, points.contains(new Point(1, 2)));
+ assertEquals(true, points.contains(new Point(3, 4)));
+ assertEquals(true, points.contains(new Point(5, 6)));
+ assertEquals(true, points.contains(new Point(7, 8)));
+ assertEquals(true, points.contains(new Point(9, 0)));
+
+ assertEquals(false, points.contains(new Point(0, 2)));
+ assertEquals(false, points.contains(new Point(0, 4)));
+ assertEquals(false, points.contains(new Point(0, 6)));
+ assertEquals(false, points.contains(new Point(0, 8)));
+ assertEquals(false, points.contains(new Point(0, 0)));
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(polygon);
+
+ points = polygon.getPoints();
+ assertEquals(true, points.contains(new Point(1, 2)));
+ assertEquals(true, points.contains(new Point(3, 4)));
+ assertEquals(true, points.contains(new Point(5, 6)));
+ assertEquals(true, points.contains(new Point(7, 8)));
+ assertEquals(true, points.contains(new Point(9, 0)));
+
+ assertEquals(false, points.contains(new Point(0, 2)));
+ assertEquals(false, points.contains(new Point(0, 4)));
+ assertEquals(false, points.contains(new Point(0, 6)));
+ assertEquals(false, points.contains(new Point(0, 8)));
+ assertEquals(false, points.contains(new Point(0, 0)));
+
+ transaction.commit();
+
+ points = polygon.getPoints();
+ assertEquals(true, points.contains(new Point(1, 2)));
+ assertEquals(true, points.contains(new Point(3, 4)));
+ assertEquals(true, points.contains(new Point(5, 6)));
+ assertEquals(true, points.contains(new Point(7, 8)));
+ assertEquals(true, points.contains(new Point(9, 0)));
+
+ assertEquals(false, points.contains(new Point(0, 2)));
+ assertEquals(false, points.contains(new Point(0, 4)));
+ assertEquals(false, points.contains(new Point(0, 6)));
+ assertEquals(false, points.contains(new Point(0, 8)));
+ assertEquals(false, points.contains(new Point(0, 0)));
+
+ session.close();
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ polygon = (Polygon)resource.getContents().get(0);
+
+ points = polygon.getPoints();
+ assertEquals(true, points.contains(new Point(1, 2)));
+ assertEquals(true, points.contains(new Point(3, 4)));
+ assertEquals(true, points.contains(new Point(5, 6)));
+ assertEquals(true, points.contains(new Point(7, 8)));
+ assertEquals(true, points.contains(new Point(9, 0)));
+
+ assertEquals(false, points.contains(new Point(0, 2)));
+ assertEquals(false, points.contains(new Point(0, 4)));
+ assertEquals(false, points.contains(new Point(0, 6)));
+ assertEquals(false, points.contains(new Point(0, 8)));
+ assertEquals(false, points.contains(new Point(0, 0)));
+ }
+
+ public void testManyValuedCustomDataType_ContainsAll() throws Exception
+ {
+ Polygon polygon = getModel3Factory().createPolygon();
+ EList<Point> points = polygon.getPoints();
+ points.add(new Point(1, 2));
+ points.add(new Point(3, 4));
+ points.add(new Point(5, 6));
+ points.add(new Point(7, 8));
+ points.add(new Point(9, 0));
+
+ assertEquals(true, points.containsAll(points));
+
+ assertEquals(
+ true,
+ points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
+ new Point(9, 0) })));
+ assertEquals(true,
+ points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(9, 0) })));
+ assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(9, 0) })));
+ assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(9, 0) })));
+
+ assertEquals(
+ false,
+ points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
+ new Point(0, 0) })));
+ assertEquals(false,
+ points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(0, 0) })));
+ assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(0, 0) })));
+ assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(0, 0) })));
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(polygon);
+
+ points = polygon.getPoints();
+ assertEquals(true, points.containsAll(points));
+
+ assertEquals(
+ true,
+ points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
+ new Point(9, 0) })));
+ assertEquals(true,
+ points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(9, 0) })));
+ assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(9, 0) })));
+ assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(9, 0) })));
+
+ assertEquals(
+ false,
+ points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
+ new Point(0, 0) })));
+ assertEquals(false,
+ points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(0, 0) })));
+ assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(0, 0) })));
+ assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(0, 0) })));
+
+ transaction.commit();
+
+ points = polygon.getPoints();
+ assertEquals(true, points.containsAll(points));
+
+ assertEquals(
+ true,
+ points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
+ new Point(9, 0) })));
+ assertEquals(true,
+ points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(9, 0) })));
+ assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(9, 0) })));
+ assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(9, 0) })));
+
+ assertEquals(
+ false,
+ points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
+ new Point(0, 0) })));
+ assertEquals(false,
+ points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(0, 0) })));
+ assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(0, 0) })));
+ assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(0, 0) })));
+
+ session.close();
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ polygon = (Polygon)resource.getContents().get(0);
+
+ points = polygon.getPoints();
+ assertEquals(true, points.containsAll(points));
+
+ assertEquals(
+ true,
+ points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
+ new Point(9, 0) })));
+ assertEquals(true,
+ points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(9, 0) })));
+ assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(9, 0) })));
+ assertEquals(true, points.containsAll(Arrays.asList(new Point[] { new Point(9, 0) })));
+
+ assertEquals(
+ false,
+ points.containsAll(Arrays.asList(new Point[] { new Point(3, 4), new Point(5, 6), new Point(7, 8),
+ new Point(0, 0) })));
+ assertEquals(false,
+ points.containsAll(Arrays.asList(new Point[] { new Point(5, 6), new Point(7, 8), new Point(0, 0) })));
+ assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(7, 8), new Point(0, 0) })));
+ assertEquals(false, points.containsAll(Arrays.asList(new Point[] { new Point(0, 0) })));
+ }
+
+ public void testManyValuedCustomDataType_IndexOf() throws Exception
+ {
+ PolygonWithDuplicates polygon = getModel3Factory().createPolygonWithDuplicates();
+ EList<Point> points = polygon.getPoints();
+ points.add(new Point(1, 2));
+ points.add(new Point(3, 4));
+ points.add(new Point(5, 6));
+ points.add(new Point(7, 8));
+ points.add(new Point(9, 0));
+ points.add(new Point(1, 2));
+ points.add(new Point(3, 4));
+ points.add(new Point(5, 6));
+ points.add(new Point(7, 8));
+ points.add(new Point(9, 0));
+
+ assertEquals(0, points.indexOf(new Point(1, 2)));
+ assertEquals(1, points.indexOf(new Point(3, 4)));
+ assertEquals(2, points.indexOf(new Point(5, 6)));
+ assertEquals(3, points.indexOf(new Point(7, 8)));
+ assertEquals(4, points.indexOf(new Point(9, 0)));
+
+ assertEquals(-1, points.indexOf(new Point(0, 2)));
+ assertEquals(-1, points.indexOf(new Point(0, 4)));
+ assertEquals(-1, points.indexOf(new Point(0, 6)));
+ assertEquals(-1, points.indexOf(new Point(0, 8)));
+ assertEquals(-1, points.indexOf(new Point(0, 0)));
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(polygon);
+
+ points = polygon.getPoints();
+ assertEquals(0, points.indexOf(new Point(1, 2)));
+ assertEquals(1, points.indexOf(new Point(3, 4)));
+ assertEquals(2, points.indexOf(new Point(5, 6)));
+ assertEquals(3, points.indexOf(new Point(7, 8)));
+ assertEquals(4, points.indexOf(new Point(9, 0)));
+
+ assertEquals(-1, points.indexOf(new Point(0, 2)));
+ assertEquals(-1, points.indexOf(new Point(0, 4)));
+ assertEquals(-1, points.indexOf(new Point(0, 6)));
+ assertEquals(-1, points.indexOf(new Point(0, 8)));
+ assertEquals(-1, points.indexOf(new Point(0, 0)));
+
+ transaction.commit();
+
+ points = polygon.getPoints();
+ assertEquals(0, points.indexOf(new Point(1, 2)));
+ assertEquals(1, points.indexOf(new Point(3, 4)));
+ assertEquals(2, points.indexOf(new Point(5, 6)));
+ assertEquals(3, points.indexOf(new Point(7, 8)));
+ assertEquals(4, points.indexOf(new Point(9, 0)));
+
+ assertEquals(-1, points.indexOf(new Point(0, 2)));
+ assertEquals(-1, points.indexOf(new Point(0, 4)));
+ assertEquals(-1, points.indexOf(new Point(0, 6)));
+ assertEquals(-1, points.indexOf(new Point(0, 8)));
+ assertEquals(-1, points.indexOf(new Point(0, 0)));
+
+ session.close();
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ polygon = (PolygonWithDuplicates)resource.getContents().get(0);
+
+ points = polygon.getPoints();
+ assertEquals(0, points.indexOf(new Point(1, 2)));
+ assertEquals(1, points.indexOf(new Point(3, 4)));
+ assertEquals(2, points.indexOf(new Point(5, 6)));
+ assertEquals(3, points.indexOf(new Point(7, 8)));
+ assertEquals(4, points.indexOf(new Point(9, 0)));
+
+ assertEquals(-1, points.indexOf(new Point(0, 2)));
+ assertEquals(-1, points.indexOf(new Point(0, 4)));
+ assertEquals(-1, points.indexOf(new Point(0, 6)));
+ assertEquals(-1, points.indexOf(new Point(0, 8)));
+ assertEquals(-1, points.indexOf(new Point(0, 0)));
+ }
+
+ public void testManyValuedCustomDataType_LastIndexOf() throws Exception
+ {
+ PolygonWithDuplicates polygon = getModel3Factory().createPolygonWithDuplicates();
+ EList<Point> points = polygon.getPoints();
+ points.add(new Point(1, 2));
+ points.add(new Point(3, 4));
+ points.add(new Point(5, 6));
+ points.add(new Point(7, 8));
+ points.add(new Point(9, 0));
+ points.add(new Point(1, 2));
+ points.add(new Point(3, 4));
+ points.add(new Point(5, 6));
+ points.add(new Point(7, 8));
+ points.add(new Point(9, 0));
+
+ assertEquals(5, points.lastIndexOf(new Point(1, 2)));
+ assertEquals(6, points.lastIndexOf(new Point(3, 4)));
+ assertEquals(7, points.lastIndexOf(new Point(5, 6)));
+ assertEquals(8, points.lastIndexOf(new Point(7, 8)));
+ assertEquals(9, points.lastIndexOf(new Point(9, 0)));
+
+ assertEquals(-1, points.lastIndexOf(new Point(0, 2)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 4)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 6)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 8)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 0)));
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(polygon);
+
+ points = polygon.getPoints();
+ assertEquals(5, points.lastIndexOf(new Point(1, 2)));
+ assertEquals(6, points.lastIndexOf(new Point(3, 4)));
+ assertEquals(7, points.lastIndexOf(new Point(5, 6)));
+ assertEquals(8, points.lastIndexOf(new Point(7, 8)));
+ assertEquals(9, points.lastIndexOf(new Point(9, 0)));
+
+ assertEquals(-1, points.lastIndexOf(new Point(0, 2)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 4)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 6)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 8)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 0)));
+
+ transaction.commit();
+
+ points = polygon.getPoints();
+ assertEquals(5, points.lastIndexOf(new Point(1, 2)));
+ assertEquals(6, points.lastIndexOf(new Point(3, 4)));
+ assertEquals(7, points.lastIndexOf(new Point(5, 6)));
+ assertEquals(8, points.lastIndexOf(new Point(7, 8)));
+ assertEquals(9, points.lastIndexOf(new Point(9, 0)));
+
+ assertEquals(-1, points.lastIndexOf(new Point(0, 2)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 4)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 6)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 8)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 0)));
+
+ session.close();
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ polygon = (PolygonWithDuplicates)resource.getContents().get(0);
+
+ points = polygon.getPoints();
+ assertEquals(5, points.lastIndexOf(new Point(1, 2)));
+ assertEquals(6, points.lastIndexOf(new Point(3, 4)));
+ assertEquals(7, points.lastIndexOf(new Point(5, 6)));
+ assertEquals(8, points.lastIndexOf(new Point(7, 8)));
+ assertEquals(9, points.lastIndexOf(new Point(9, 0)));
+
+ assertEquals(-1, points.lastIndexOf(new Point(0, 2)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 4)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 6)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 8)));
+ assertEquals(-1, points.lastIndexOf(new Point(0, 0)));
+ }
+
+ public void testManyValuedCustomDataType_Bugzilla_319950() throws Exception
+ {
+ Polygon polygon = getModel3Factory().createPolygon();
+ EList<Point> points = polygon.getPoints();
+ points.add(new Point(1, 2));
+ points.add(new Point(3, 4));
+ points.add(new Point(5, 6));
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(polygon);
+ transaction.commit();
+ session.close();
+
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ EList<EObject> contents = resource.getContents();
+
+ // java.lang.ClassCastException: org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl
+ EcoreUtil.copyAll(contents);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditSameSessionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditSameSessionTest.java
index f2d4f1a5d4..454b3548be 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditSameSessionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditSameSessionTest.java
@@ -1,46 +1,46 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-
-/**
- * @author Eike Stepper
- */
-public class AuditSameSessionTest extends AuditTest
-{
- public void testRepositoryCreationTime() throws Exception
- {
- CDOSession session = openSession();
- long repositoryCreationTime = session.getRepositoryInfo().getCreationTime();
- assertEquals(getRepository().getCreationTime(), repositoryCreationTime);
- assertEquals(getRepository().getStore().getCreationTime(), repositoryCreationTime);
- }
-
- public void testRepositoryTime() throws Exception
- {
- CDOSession session = openSession();
- long repositoryTime = session.getRepositoryInfo().getTimeStamp();
- assertEquals(true, Math.abs(System.currentTimeMillis() - repositoryTime) < 500);
- }
-
- @Override
- protected void closeSession1()
- {
- // Do nothing
- }
-
- @Override
- protected CDOSession openSession2()
- {
- return session1;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+
+/**
+ * @author Eike Stepper
+ */
+public class AuditSameSessionTest extends AuditTest
+{
+ public void testRepositoryCreationTime() throws Exception
+ {
+ CDOSession session = openSession();
+ long repositoryCreationTime = session.getRepositoryInfo().getCreationTime();
+ assertEquals(getRepository().getCreationTime(), repositoryCreationTime);
+ assertEquals(getRepository().getStore().getCreationTime(), repositoryCreationTime);
+ }
+
+ public void testRepositoryTime() throws Exception
+ {
+ CDOSession session = openSession();
+ long repositoryTime = session.getRepositoryInfo().getTimeStamp();
+ assertEquals(true, Math.abs(System.currentTimeMillis() - repositoryTime) < 500);
+ }
+
+ @Override
+ protected void closeSession1()
+ {
+ // Do nothing
+ }
+
+ @Override
+ protected CDOSession openSession2()
+ {
+ return session1;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java
index a9c13398bc..64e2fc8743 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java
@@ -1,535 +1,535 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model5.GenListOfInt;
-import org.eclipse.emf.cdo.tests.model5.Model5Factory;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.signal.RemoteException;
-
-import org.eclipse.emf.common.util.URI;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-@Requires(IRepositoryConfig.CAPABILITY_AUDITING)
-public class AuditTest extends AbstractCDOTest
-{
- protected CDOSession session1;
-
- protected CDOSession openSession1()
- {
- session1 = openSession();
- return session1;
- }
-
- protected void closeSession1()
- {
- session1.close();
- }
-
- protected CDOSession openSession2()
- {
- return openSession();
- }
-
- public void testNewAudit() throws Exception
- {
- CDOSession session = openSession1();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("ESC");
- resource.getContents().add(company);
- long commitTime1 = transaction.commit().getTimeStamp();
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1);
- assertEquals("ESC", company.getName());
-
- company.setName("Sympedia");
- long commitTime2 = transaction.commit().getTimeStamp();
- assertEquals(true, commitTime1 < commitTime2);
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
- assertEquals("Sympedia", company.getName());
-
- company.setName("Eclipse");
- long commitTime3 = transaction.commit().getTimeStamp();
- assertEquals(true, commitTime2 < commitTime3);
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
- assertEquals("Eclipse", company.getName());
-
- closeSession1();
- session = openSession2();
-
- CDOView audit = session.openView(commitTime1);
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- Company auditCompany = (Company)auditResource.getContents().get(0);
- assertEquals("ESC", auditCompany.getName());
-
- CDOView audit2 = session.openView(commitTime2);
- CDOResource auditResource2 = audit2.getResource(getResourcePath("/res1"));
- Company auditCompany2 = (Company)auditResource2.getContents().get(0);
- assertEquals("Sympedia", auditCompany2.getName());
- session.close();
- }
-
- public void testChangedAudit() throws Exception
- {
- CDOSession session = openSession1();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("ESC");
- resource.getContents().add(company);
- long commitTime1 = transaction.commit().getTimeStamp();
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1);
- assertEquals("ESC", company.getName());
-
- company.setName("Sympedia");
- long commitTime2 = transaction.commit().getTimeStamp();
- assertEquals(true, commitTime1 < commitTime2);
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
- assertEquals("Sympedia", company.getName());
-
- company.setName("Eclipse");
- long commitTime3 = transaction.commit().getTimeStamp();
- assertEquals(true, commitTime2 < commitTime3);
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
- assertEquals("Eclipse", company.getName());
-
- closeSession1();
- session = openSession2();
-
- CDOView audit = session.openView(commitTime1);
- {
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- Company auditCompany = (Company)auditResource.getContents().get(0);
- assertEquals("ESC", auditCompany.getName());
- }
-
- audit.setTimeStamp(commitTime2);
- {
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- Company auditCompany = (Company)auditResource.getContents().get(0);
- assertEquals("Sympedia", auditCompany.getName());
- }
-
- audit.setTimeStamp(commitTime3);
- {
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- Company auditCompany = (Company)auditResource.getContents().get(0);
- assertEquals("Eclipse", auditCompany.getName());
- }
-
- session.close();
- }
-
- public void testKeepHandle() throws Exception
- {
- CDOSession session = openSession1();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("ESC");
- resource.getContents().add(company);
- long commitTime1 = transaction.commit().getTimeStamp();
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1);
- assertEquals("ESC", company.getName());
-
- company.setName("Sympedia");
- long commitTime2 = transaction.commit().getTimeStamp();
- assertEquals(true, commitTime1 < commitTime2);
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
- assertEquals("Sympedia", company.getName());
-
- company.setName("Eclipse");
- long commitTime3 = transaction.commit().getTimeStamp();
- assertEquals(true, commitTime2 < commitTime3);
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
- assertEquals("Eclipse", company.getName());
-
- closeSession1();
- session = openSession2();
-
- CDOView audit = session.openView(commitTime1);
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- Company auditCompany = (Company)auditResource.getContents().get(0);
- assertEquals("ESC", auditCompany.getName());
-
- audit.setTimeStamp(commitTime2);
- assertEquals("Sympedia", auditCompany.getName());
-
- audit.setTimeStamp(commitTime3);
- assertEquals("Eclipse", auditCompany.getName());
- session.close();
- }
-
- public void testAddingContents() throws Exception
- {
- CDOSession session = openSession1();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- resource.getContents().add(getModel1Factory().createCompany());
- long commitTime1 = transaction.commit().getTimeStamp();
-
- resource.getContents().add(getModel1Factory().createCompany());
- long commitTime2 = transaction.commit().getTimeStamp();
-
- resource.getContents().add(getModel1Factory().createCompany());
- long commitTime3 = transaction.commit().getTimeStamp();
- closeSession1();
-
- session = openSession2();
-
- CDOView audit = session.openView(commitTime1);
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- assertEquals(1, auditResource.getContents().size());
-
- audit.setTimeStamp(commitTime2);
- assertEquals(2, auditResource.getContents().size());
-
- audit.setTimeStamp(commitTime3);
- assertEquals(3, auditResource.getContents().size());
- session.close();
- }
-
- public void testRemovingContents() throws Exception
- {
- CDOSession session = openSession1();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- long commitTime1 = transaction.commit().getTimeStamp();
-
- resource.getContents().remove(2);
- long commitTime2 = transaction.commit().getTimeStamp();
-
- resource.getContents().remove(2);
- long commitTime3 = transaction.commit().getTimeStamp();
- closeSession1();
-
- session = openSession2();
-
- CDOView audit = session.openView(commitTime1);
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- assertEquals(5, auditResource.getContents().size());
-
- audit.setTimeStamp(commitTime2);
- assertEquals(4, auditResource.getContents().size());
-
- audit.setTimeStamp(commitTime3);
- assertEquals(3, auditResource.getContents().size());
- session.close();
- }
-
- public void testRemovingContentsKeepHandle() throws Exception
- {
- CDOSession session = openSession1();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("ESC");
-
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(company);
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- long commitTime1 = transaction.commit().getTimeStamp();
-
- resource.getContents().remove(2);
- long commitTime2 = transaction.commit().getTimeStamp();
-
- closeSession1();
- session = openSession2();
-
- CDOView audit = session.openView(commitTime1);
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- assertEquals(5, auditResource.getContents().size());
-
- Company auditCompany = (Company)auditResource.getContents().get(2);
- assertEquals("ESC", auditCompany.getName());
- assertClean(auditCompany, audit);
-
- audit.setTimeStamp(commitTime2);
- assertEquals(4, auditResource.getContents().size());
- assertInvalid(auditCompany);
-
- audit.setTimeStamp(commitTime1);
- assertInvalid(auditCompany);
- assertEquals(5, auditResource.getContents().size());
- session.close();
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
- public void testConsistentHistoryForIsMany() throws Exception
- {
- ArrayList<List<Integer>> history = new ArrayList<List<Integer>>();
- ArrayList<Long> timestamps = new ArrayList<Long>();
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- GenListOfInt persistentList = Model5Factory.eINSTANCE.createGenListOfInt();
- resource.getContents().add(persistentList);
-
- timestamps.add(transaction.commit().getTimeStamp());
- history.add(new ArrayList<Integer>(persistentList.getElements()));
-
- persistentList.getElements().add(1);
- persistentList.getElements().add(2);
- persistentList.getElements().add(3);
-
- timestamps.add(transaction.commit().getTimeStamp());
- history.add(new ArrayList<Integer>(persistentList.getElements()));
-
- persistentList.getElements().add(1, 4);
-
- timestamps.add(transaction.commit().getTimeStamp());
- history.add(new ArrayList<Integer>(persistentList.getElements()));
-
- persistentList.getElements().add(0, 5);
-
- timestamps.add(transaction.commit().getTimeStamp());
- history.add(new ArrayList<Integer>(persistentList.getElements()));
-
- persistentList.getElements().move(1, 3);
-
- timestamps.add(transaction.commit().getTimeStamp());
- history.add(new ArrayList<Integer>(persistentList.getElements()));
-
- persistentList.getElements().move(4, 2);
- persistentList.getElements().move(1, 3);
-
- timestamps.add(transaction.commit().getTimeStamp());
- history.add(new ArrayList<Integer>(persistentList.getElements()));
-
- persistentList.getElements().remove(2);
-
- timestamps.add(transaction.commit().getTimeStamp());
- history.add(new ArrayList<Integer>(persistentList.getElements()));
-
- persistentList.getElements().add(1, 2);
- persistentList.getElements().remove(2);
-
- timestamps.add(transaction.commit().getTimeStamp());
- history.add(new ArrayList<Integer>(persistentList.getElements()));
-
- persistentList.getElements().clear();
- persistentList.getElements().add(6);
- persistentList.getElements().add(7);
- persistentList.getElements().add(8);
-
- timestamps.add(transaction.commit().getTimeStamp());
- history.add(new ArrayList<Integer>(persistentList.getElements()));
-
- resource.getContents().clear();
-
- transaction.commit();
- transaction.close();
- session.close();
- clearCache(getRepository().getRevisionManager());
- }
-
- {
- CDOSession session = openSession();
-
- for (int i = 0; i < timestamps.size(); i++)
- {
- msg("Checking timestamp " + i + " of " + timestamps.size() + ": " + timestamps.get(i));
- CDOView audit = session.openView(timestamps.get(i));
- CDOResource res = audit.getResource(getResourcePath("/res1"));
- GenListOfInt persistentList = (GenListOfInt)res.getContents().get(0);
-
- assertEquals(joinList(history.get(i)), joinList(persistentList.getElements()));
- audit.close();
- }
-
- CDOView view = session.openView();
- CDOResource res = view.getResource(getResourcePath("/res1"));
- assertEquals(true, res.getContents().isEmpty());
- }
- }
-
- private String joinList(List<Integer> list)
- {
- String result = "";
- for (Integer i : list)
- {
- result += " " + i;
- }
-
- return result;
- }
-
- public void testCanCreateAuditAtRepoCreationTime() throws Exception
- {
- CDOSession session = openSession1();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
- closeSession1();
-
- session = openSession2();
- session.openView(session.getRepositoryInfo().getCreationTime());
- session.close();
- }
-
- public void testCannotCreateAuditWithTimestampPriorToRepo() throws Exception
- {
- Calendar calendar = GregorianCalendar.getInstance();
- calendar.set(Calendar.YEAR, 19);
- calendar.set(Calendar.MONTH, 11);
- calendar.set(Calendar.DAY_OF_MONTH, 11);
-
- long timeStampPriorToRepoCreation = calendar.getTime().getTime();
- CDOSession session = openSession1();
-
- try
- {
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
- closeSession1();
-
- session = openSession2();
- session.openView(timeStampPriorToRepoCreation);
- fail("RemoteException expected");
- }
- catch (RemoteException eexpected)
- {
- // Success
- }
- finally
- {
- session.close();
- }
- }
-
- public void testCannotSetAuditTimestampPriorToRepo() throws Exception
- {
- Calendar calendar = GregorianCalendar.getInstance();
- calendar.set(Calendar.YEAR, 19);
- calendar.set(Calendar.MONTH, 11);
- calendar.set(Calendar.DAY_OF_MONTH, 11);
-
- long timeStampPriorToRepoCreation = calendar.getTime().getTime();
- CDOSession session = openSession1();
-
- try
- {
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- long commitTime1 = transaction.commit().getTimeStamp();
- closeSession1();
-
- session = openSession2();
- CDOView audit = session.openView(commitTime1);
- audit.setTimeStamp(timeStampPriorToRepoCreation);
- fail("Exception expected");
- }
- catch (Exception expected)
- {
- // Success
- }
- finally
- {
- session.close();
- }
- }
-
- public void testChangePath() throws Exception
- {
- long commitTime1;
- long commitTime2;
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- commitTime1 = transaction.commit().getTimeStamp();
-
- resource.setPath(getResourcePath("/renamed"));
- commitTime2 = transaction.commit().getTimeStamp();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView audit1 = session.openView(commitTime1);
- assertEquals(true, audit1.hasResource(getResourcePath("/my/resource")));
- assertEquals(false, audit1.hasResource(getResourcePath("/renamed")));
-
- CDOView audit2 = session.openView(commitTime2);
- assertEquals(false, audit2.hasResource(getResourcePath("/my/resource")));
- assertEquals(true, audit2.hasResource(getResourcePath("/renamed")));
- session.close();
- }
-
- public void testChangeURI() throws Exception
- {
- long commitTime1;
- long commitTime2;
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- commitTime1 = transaction.commit().getTimeStamp();
-
- URI uri = URI.createURI("cdo://repo1" + getResourcePath("/renamed"));
- assertEquals(CDOURIUtil.createResourceURI(session, getResourcePath("/renamed")), uri);
- resource.setURI(uri);
-
- commitTime2 = transaction.commit().getTimeStamp();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView audit1 = session.openView(commitTime1);
- assertEquals(true, audit1.hasResource(getResourcePath("/my/resource")));
- assertEquals(false, audit1.hasResource(getResourcePath("/renamed")));
-
- CDOView audit2 = session.openView(commitTime2);
- assertEquals(false, audit2.hasResource(getResourcePath("/my/resource")));
- assertEquals(true, audit2.hasResource(getResourcePath("/renamed")));
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model5.GenListOfInt;
+import org.eclipse.emf.cdo.tests.model5.Model5Factory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.signal.RemoteException;
+
+import org.eclipse.emf.common.util.URI;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+@Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+public class AuditTest extends AbstractCDOTest
+{
+ protected CDOSession session1;
+
+ protected CDOSession openSession1()
+ {
+ session1 = openSession();
+ return session1;
+ }
+
+ protected void closeSession1()
+ {
+ session1.close();
+ }
+
+ protected CDOSession openSession2()
+ {
+ return openSession();
+ }
+
+ public void testNewAudit() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("ESC");
+ resource.getContents().add(company);
+ long commitTime1 = transaction.commit().getTimeStamp();
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1);
+ assertEquals("ESC", company.getName());
+
+ company.setName("Sympedia");
+ long commitTime2 = transaction.commit().getTimeStamp();
+ assertEquals(true, commitTime1 < commitTime2);
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
+ assertEquals("Sympedia", company.getName());
+
+ company.setName("Eclipse");
+ long commitTime3 = transaction.commit().getTimeStamp();
+ assertEquals(true, commitTime2 < commitTime3);
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
+ assertEquals("Eclipse", company.getName());
+
+ closeSession1();
+ session = openSession2();
+
+ CDOView audit = session.openView(commitTime1);
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ Company auditCompany = (Company)auditResource.getContents().get(0);
+ assertEquals("ESC", auditCompany.getName());
+
+ CDOView audit2 = session.openView(commitTime2);
+ CDOResource auditResource2 = audit2.getResource(getResourcePath("/res1"));
+ Company auditCompany2 = (Company)auditResource2.getContents().get(0);
+ assertEquals("Sympedia", auditCompany2.getName());
+ session.close();
+ }
+
+ public void testChangedAudit() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("ESC");
+ resource.getContents().add(company);
+ long commitTime1 = transaction.commit().getTimeStamp();
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1);
+ assertEquals("ESC", company.getName());
+
+ company.setName("Sympedia");
+ long commitTime2 = transaction.commit().getTimeStamp();
+ assertEquals(true, commitTime1 < commitTime2);
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
+ assertEquals("Sympedia", company.getName());
+
+ company.setName("Eclipse");
+ long commitTime3 = transaction.commit().getTimeStamp();
+ assertEquals(true, commitTime2 < commitTime3);
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
+ assertEquals("Eclipse", company.getName());
+
+ closeSession1();
+ session = openSession2();
+
+ CDOView audit = session.openView(commitTime1);
+ {
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ Company auditCompany = (Company)auditResource.getContents().get(0);
+ assertEquals("ESC", auditCompany.getName());
+ }
+
+ audit.setTimeStamp(commitTime2);
+ {
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ Company auditCompany = (Company)auditResource.getContents().get(0);
+ assertEquals("Sympedia", auditCompany.getName());
+ }
+
+ audit.setTimeStamp(commitTime3);
+ {
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ Company auditCompany = (Company)auditResource.getContents().get(0);
+ assertEquals("Eclipse", auditCompany.getName());
+ }
+
+ session.close();
+ }
+
+ public void testKeepHandle() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("ESC");
+ resource.getContents().add(company);
+ long commitTime1 = transaction.commit().getTimeStamp();
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1);
+ assertEquals("ESC", company.getName());
+
+ company.setName("Sympedia");
+ long commitTime2 = transaction.commit().getTimeStamp();
+ assertEquals(true, commitTime1 < commitTime2);
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
+ assertEquals("Sympedia", company.getName());
+
+ company.setName("Eclipse");
+ long commitTime3 = transaction.commit().getTimeStamp();
+ assertEquals(true, commitTime2 < commitTime3);
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
+ assertEquals("Eclipse", company.getName());
+
+ closeSession1();
+ session = openSession2();
+
+ CDOView audit = session.openView(commitTime1);
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ Company auditCompany = (Company)auditResource.getContents().get(0);
+ assertEquals("ESC", auditCompany.getName());
+
+ audit.setTimeStamp(commitTime2);
+ assertEquals("Sympedia", auditCompany.getName());
+
+ audit.setTimeStamp(commitTime3);
+ assertEquals("Eclipse", auditCompany.getName());
+ session.close();
+ }
+
+ public void testAddingContents() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ long commitTime1 = transaction.commit().getTimeStamp();
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ long commitTime2 = transaction.commit().getTimeStamp();
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ long commitTime3 = transaction.commit().getTimeStamp();
+ closeSession1();
+
+ session = openSession2();
+
+ CDOView audit = session.openView(commitTime1);
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ assertEquals(1, auditResource.getContents().size());
+
+ audit.setTimeStamp(commitTime2);
+ assertEquals(2, auditResource.getContents().size());
+
+ audit.setTimeStamp(commitTime3);
+ assertEquals(3, auditResource.getContents().size());
+ session.close();
+ }
+
+ public void testRemovingContents() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ long commitTime1 = transaction.commit().getTimeStamp();
+
+ resource.getContents().remove(2);
+ long commitTime2 = transaction.commit().getTimeStamp();
+
+ resource.getContents().remove(2);
+ long commitTime3 = transaction.commit().getTimeStamp();
+ closeSession1();
+
+ session = openSession2();
+
+ CDOView audit = session.openView(commitTime1);
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ assertEquals(5, auditResource.getContents().size());
+
+ audit.setTimeStamp(commitTime2);
+ assertEquals(4, auditResource.getContents().size());
+
+ audit.setTimeStamp(commitTime3);
+ assertEquals(3, auditResource.getContents().size());
+ session.close();
+ }
+
+ public void testRemovingContentsKeepHandle() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("ESC");
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(company);
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ long commitTime1 = transaction.commit().getTimeStamp();
+
+ resource.getContents().remove(2);
+ long commitTime2 = transaction.commit().getTimeStamp();
+
+ closeSession1();
+ session = openSession2();
+
+ CDOView audit = session.openView(commitTime1);
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ assertEquals(5, auditResource.getContents().size());
+
+ Company auditCompany = (Company)auditResource.getContents().get(2);
+ assertEquals("ESC", auditCompany.getName());
+ assertClean(auditCompany, audit);
+
+ audit.setTimeStamp(commitTime2);
+ assertEquals(4, auditResource.getContents().size());
+ assertInvalid(auditCompany);
+
+ audit.setTimeStamp(commitTime1);
+ assertInvalid(auditCompany);
+ assertEquals(5, auditResource.getContents().size());
+ session.close();
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
+ public void testConsistentHistoryForIsMany() throws Exception
+ {
+ ArrayList<List<Integer>> history = new ArrayList<List<Integer>>();
+ ArrayList<Long> timestamps = new ArrayList<Long>();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ GenListOfInt persistentList = Model5Factory.eINSTANCE.createGenListOfInt();
+ resource.getContents().add(persistentList);
+
+ timestamps.add(transaction.commit().getTimeStamp());
+ history.add(new ArrayList<Integer>(persistentList.getElements()));
+
+ persistentList.getElements().add(1);
+ persistentList.getElements().add(2);
+ persistentList.getElements().add(3);
+
+ timestamps.add(transaction.commit().getTimeStamp());
+ history.add(new ArrayList<Integer>(persistentList.getElements()));
+
+ persistentList.getElements().add(1, 4);
+
+ timestamps.add(transaction.commit().getTimeStamp());
+ history.add(new ArrayList<Integer>(persistentList.getElements()));
+
+ persistentList.getElements().add(0, 5);
+
+ timestamps.add(transaction.commit().getTimeStamp());
+ history.add(new ArrayList<Integer>(persistentList.getElements()));
+
+ persistentList.getElements().move(1, 3);
+
+ timestamps.add(transaction.commit().getTimeStamp());
+ history.add(new ArrayList<Integer>(persistentList.getElements()));
+
+ persistentList.getElements().move(4, 2);
+ persistentList.getElements().move(1, 3);
+
+ timestamps.add(transaction.commit().getTimeStamp());
+ history.add(new ArrayList<Integer>(persistentList.getElements()));
+
+ persistentList.getElements().remove(2);
+
+ timestamps.add(transaction.commit().getTimeStamp());
+ history.add(new ArrayList<Integer>(persistentList.getElements()));
+
+ persistentList.getElements().add(1, 2);
+ persistentList.getElements().remove(2);
+
+ timestamps.add(transaction.commit().getTimeStamp());
+ history.add(new ArrayList<Integer>(persistentList.getElements()));
+
+ persistentList.getElements().clear();
+ persistentList.getElements().add(6);
+ persistentList.getElements().add(7);
+ persistentList.getElements().add(8);
+
+ timestamps.add(transaction.commit().getTimeStamp());
+ history.add(new ArrayList<Integer>(persistentList.getElements()));
+
+ resource.getContents().clear();
+
+ transaction.commit();
+ transaction.close();
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+ }
+
+ {
+ CDOSession session = openSession();
+
+ for (int i = 0; i < timestamps.size(); i++)
+ {
+ msg("Checking timestamp " + i + " of " + timestamps.size() + ": " + timestamps.get(i));
+ CDOView audit = session.openView(timestamps.get(i));
+ CDOResource res = audit.getResource(getResourcePath("/res1"));
+ GenListOfInt persistentList = (GenListOfInt)res.getContents().get(0);
+
+ assertEquals(joinList(history.get(i)), joinList(persistentList.getElements()));
+ audit.close();
+ }
+
+ CDOView view = session.openView();
+ CDOResource res = view.getResource(getResourcePath("/res1"));
+ assertEquals(true, res.getContents().isEmpty());
+ }
+ }
+
+ private String joinList(List<Integer> list)
+ {
+ String result = "";
+ for (Integer i : list)
+ {
+ result += " " + i;
+ }
+
+ return result;
+ }
+
+ public void testCanCreateAuditAtRepoCreationTime() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+ closeSession1();
+
+ session = openSession2();
+ session.openView(session.getRepositoryInfo().getCreationTime());
+ session.close();
+ }
+
+ public void testCannotCreateAuditWithTimestampPriorToRepo() throws Exception
+ {
+ Calendar calendar = GregorianCalendar.getInstance();
+ calendar.set(Calendar.YEAR, 19);
+ calendar.set(Calendar.MONTH, 11);
+ calendar.set(Calendar.DAY_OF_MONTH, 11);
+
+ long timeStampPriorToRepoCreation = calendar.getTime().getTime();
+ CDOSession session = openSession1();
+
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+ closeSession1();
+
+ session = openSession2();
+ session.openView(timeStampPriorToRepoCreation);
+ fail("RemoteException expected");
+ }
+ catch (RemoteException eexpected)
+ {
+ // Success
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ public void testCannotSetAuditTimestampPriorToRepo() throws Exception
+ {
+ Calendar calendar = GregorianCalendar.getInstance();
+ calendar.set(Calendar.YEAR, 19);
+ calendar.set(Calendar.MONTH, 11);
+ calendar.set(Calendar.DAY_OF_MONTH, 11);
+
+ long timeStampPriorToRepoCreation = calendar.getTime().getTime();
+ CDOSession session = openSession1();
+
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ long commitTime1 = transaction.commit().getTimeStamp();
+ closeSession1();
+
+ session = openSession2();
+ CDOView audit = session.openView(commitTime1);
+ audit.setTimeStamp(timeStampPriorToRepoCreation);
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // Success
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ public void testChangePath() throws Exception
+ {
+ long commitTime1;
+ long commitTime2;
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ commitTime1 = transaction.commit().getTimeStamp();
+
+ resource.setPath(getResourcePath("/renamed"));
+ commitTime2 = transaction.commit().getTimeStamp();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView audit1 = session.openView(commitTime1);
+ assertEquals(true, audit1.hasResource(getResourcePath("/my/resource")));
+ assertEquals(false, audit1.hasResource(getResourcePath("/renamed")));
+
+ CDOView audit2 = session.openView(commitTime2);
+ assertEquals(false, audit2.hasResource(getResourcePath("/my/resource")));
+ assertEquals(true, audit2.hasResource(getResourcePath("/renamed")));
+ session.close();
+ }
+
+ public void testChangeURI() throws Exception
+ {
+ long commitTime1;
+ long commitTime2;
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ commitTime1 = transaction.commit().getTimeStamp();
+
+ URI uri = URI.createURI("cdo://repo1" + getResourcePath("/renamed"));
+ assertEquals(CDOURIUtil.createResourceURI(session, getResourcePath("/renamed")), uri);
+ resource.setURI(uri);
+
+ commitTime2 = transaction.commit().getTimeStamp();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView audit1 = session.openView(commitTime1);
+ assertEquals(true, audit1.hasResource(getResourcePath("/my/resource")));
+ assertEquals(false, audit1.hasResource(getResourcePath("/renamed")));
+
+ CDOView audit2 = session.openView(commitTime2);
+ assertEquals(false, audit2.hasResource(getResourcePath("/my/resource")));
+ assertEquals(true, audit2.hasResource(getResourcePath("/renamed")));
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java
index 22affa707d..f56dbc8099 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java
@@ -1,82 +1,82 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOAutoAttacher;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * @author Simon McDuff
- */
-public class AutoAttacherTest extends AbstractCDOTest
-{
- public AutoAttacherTest()
- {
- }
-
- public void testSimple() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- new CDOAutoAttacher(transaction);
- CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
- Product1 product = getModel1Factory().createProduct1();
- product.setName("product");
-
- {
- assertTransient(product);
- resource1.getContents().add(product);
- assertEquals(resource1, product.eResource());
- assertNew(product, transaction);
- }
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
-
- {
- assertTransient(orderDetail);
- product.getOrderDetails().add(orderDetail);
- assertNew(orderDetail, transaction);
- }
-
- transaction.close();
- session.close();
- }
-
- public void testAddingObjectAndCrawl() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- new CDOAutoAttacher(transaction);
- CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
-
- supplier.getPurchaseOrders().add(purchaseOrder);
-
- assertTransient(supplier);
-
- resource1.getContents().add(supplier);
-
- assertNew(supplier, transaction);
- assertNew(purchaseOrder, transaction);
-
- transaction.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOAutoAttacher;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * @author Simon McDuff
+ */
+public class AutoAttacherTest extends AbstractCDOTest
+{
+ public AutoAttacherTest()
+ {
+ }
+
+ public void testSimple() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ new CDOAutoAttacher(transaction);
+ CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("product");
+
+ {
+ assertTransient(product);
+ resource1.getContents().add(product);
+ assertEquals(resource1, product.eResource());
+ assertNew(product, transaction);
+ }
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+
+ {
+ assertTransient(orderDetail);
+ product.getOrderDetails().add(orderDetail);
+ assertNew(orderDetail, transaction);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ public void testAddingObjectAndCrawl() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ new CDOAutoAttacher(transaction);
+ CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+
+ supplier.getPurchaseOrders().add(purchaseOrder);
+
+ assertTransient(supplier);
+
+ resource1.getContents().add(supplier);
+
+ assertNew(supplier, transaction);
+ assertNew(purchaseOrder, transaction);
+
+ transaction.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingSameSessionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingSameSessionTest.java
index 91a40715c7..eb2144899e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingSameSessionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingSameSessionTest.java
@@ -1,31 +1,31 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-
-/**
- * @author Eike Stepper
- */
-public class BranchingSameSessionTest extends BranchingTest
-{
- @Override
- protected void closeSession1()
- {
- // Do nothing
- }
-
- @Override
- protected CDOSession openSession2()
- {
- return session1;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+
+/**
+ * @author Eike Stepper
+ */
+public class BranchingSameSessionTest extends BranchingTest
+{
+ @Override
+ protected void closeSession1()
+ {
+ // Do nothing
+ }
+
+ @Override
+ protected CDOSession openSession2()
+ {
+ return session1;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java
index 8ae031d0b0..714158cc5c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java
@@ -1,1036 +1,1036 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchCreatedEvent;
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.common.revision.AbstractCDORevisionCache;
-import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.DanglingReferenceException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.ReflectUtil;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
-@CleanRepositoriesBefore
-public class BranchingTest extends AbstractCDOTest
-{
- protected CDOSession session1;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
-
- Field disableGC = ReflectUtil.getField(AbstractCDORevisionCache.class, "disableGC");
- ReflectUtil.setValue(disableGC, null, true);
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- Field disableGC = ReflectUtil.getField(AbstractCDORevisionCache.class, "disableGC");
- ReflectUtil.setValue(disableGC, null, false);
- super.doTearDown();
- }
-
- protected CDOSession openSession1()
- {
- session1 = openSession();
- return session1;
- }
-
- protected void closeSession1()
- {
- session1.close();
- session1 = null;
- }
-
- protected CDOSession openSession2()
- {
- return openSession();
- }
-
- @CleanRepositoriesBefore
- public void testMainBranch() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- assertEquals(CDOBranch.MAIN_BRANCH_ID, mainBranch.getID());
- assertEquals(CDOBranch.MAIN_BRANCH_NAME, mainBranch.getName());
- assertEquals(null, mainBranch.getBase().getBranch());
- assertEquals(0, mainBranch.getBranches().length);
- closeSession1();
-
- session = openSession2();
- mainBranch = session.getBranchManager().getBranch(CDOBranch.MAIN_BRANCH_ID);
- assertEquals(CDOBranch.MAIN_BRANCH_ID, mainBranch.getID());
- assertEquals(CDOBranch.MAIN_BRANCH_NAME, mainBranch.getName());
- assertEquals(null, mainBranch.getBase().getBranch());
- assertEquals(0, mainBranch.getBranches().length);
- session.close();
- }
-
- @CleanRepositoriesBefore
- public void testCreateBranch() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOBranch branch = mainBranch.createBranch("testing");
- assertEquals(CDOBranch.MAIN_BRANCH_ID + 1, branch.getID());
- assertEquals("testing", branch.getName());
- assertEquals(CDOBranch.MAIN_BRANCH_ID, branch.getBase().getBranch().getID());
- assertEquals(0, branch.getBranches().length);
- session.close();
- }
-
- public void testGetBranch() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOBranch branch = mainBranch.createBranch("testing");
- closeSession1();
-
- session = openSession2();
- branch = session.getBranchManager().getBranch(CDOBranch.MAIN_BRANCH_ID + 1);
- assertEquals(CDOBranch.MAIN_BRANCH_ID + 1, branch.getID());
- assertEquals("testing", branch.getName());
- assertEquals(CDOBranch.MAIN_BRANCH_ID, branch.getBase().getBranch().getID());
- assertEquals(0, branch.getBranches().length);
- session.close();
- }
-
- public void testGetSubBranches() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- mainBranch.createBranch("testing1");
- mainBranch.createBranch("testing2");
- closeSession1();
-
- session = openSession2();
- mainBranch = session.getBranchManager().getMainBranch();
- CDOBranch[] branches = mainBranch.getBranches();
- assertEquals(2, branches.length);
- assertEquals("testing1", branches[0].getName());
- assertEquals(CDOBranch.MAIN_BRANCH_ID, branches[0].getBase().getBranch().getID());
- assertEquals("testing2", branches[1].getName());
- assertEquals(CDOBranch.MAIN_BRANCH_ID, branches[1].getBase().getBranch().getID());
- session.close();
- }
-
- public void testEvent() throws Exception
- {
- CDOSession session1 = openSession1();
- CDOSession session2 = openSession2();
-
- final AsyncResult<CDOBranch> result = new AsyncResult<CDOBranch>();
- session2.getBranchManager().addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOBranchCreatedEvent)
- {
- CDOBranchCreatedEvent e = (CDOBranchCreatedEvent)event;
- result.setValue(e.getBranch());
- }
- }
- });
-
- CDOBranch mainBranch = session1.getBranchManager().getMainBranch();
- CDOBranch branch = mainBranch.createBranch("testing");
- CDOBranch resultBranch = result.getValue();
- assertEquals(branch, resultBranch);
-
- closeSession1();
- session2.close();
- }
-
- public void testGetPath() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOBranch testing1 = mainBranch.createBranch("testing1");
- CDOBranch testing2 = mainBranch.createBranch("testing2");
- CDOBranch subsub = testing1.createBranch("subsub");
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- assertEquals(mainBranch, branchManager.getBranch("MAIN"));
- assertEquals(testing1, branchManager.getBranch("MAIN/testing1"));
- assertEquals(testing2, branchManager.getBranch("MAIN/testing2"));
- assertEquals(subsub, branchManager.getBranch("MAIN/testing1/subsub"));
- assertEquals(testing1, mainBranch.getBranch("testing1"));
- assertEquals(testing2, mainBranch.getBranch("testing2"));
- assertEquals(subsub, mainBranch.getBranch("testing1/subsub"));
- assertEquals(subsub, testing1.getBranch("subsub"));
- session.close();
- }
-
- public void testGetPathName() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOBranch testing1 = mainBranch.createBranch("testing1");
- mainBranch.createBranch("testing2");
- testing1.createBranch("subsub");
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- assertEquals("MAIN", branchManager.getBranch("MAIN").getPathName());
- assertEquals("MAIN/testing1", branchManager.getBranch("MAIN/testing1").getPathName());
- assertEquals("MAIN/testing2", branchManager.getBranch("MAIN/testing2").getPathName());
- assertEquals("MAIN/testing1/subsub", branchManager.getBranch("MAIN/testing1/subsub").getPathName());
- assertEquals("MAIN/testing1", mainBranch.getBranch("testing1").getPathName());
- assertEquals("MAIN/testing2", mainBranch.getBranch("testing2").getPathName());
- assertEquals("MAIN/testing1/subsub", mainBranch.getBranch("testing1/subsub").getPathName());
- assertEquals("MAIN/testing1/subsub", testing1.getBranch("subsub").getPathName());
- session.close();
- }
-
- public void testBasePath() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOBranch testing1 = mainBranch.createBranch("testing1");
- CDOBranch testing2 = mainBranch.createBranch("testing2");
- CDOBranch subsub = testing1.createBranch("subsub");
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- assertEquals(mainBranch.getBasePath(), new CDOBranchPoint[] { mainBranch.getBase() });
- assertEquals(testing1.getBasePath(), new CDOBranchPoint[] { mainBranch.getBase(), testing1.getBase() });
- assertEquals(testing2.getBasePath(), new CDOBranchPoint[] { mainBranch.getBase(), testing2.getBase() });
- assertEquals(subsub.getBasePath(),
- new CDOBranchPoint[] { mainBranch.getBase(), testing1.getBase(), subsub.getBase() });
- session.close();
- }
-
- public void testAncestor() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
- CDOBranch mainBranch = branchManager.getMainBranch();
-
- CDOBranch testing1 = mainBranch.createBranch("testing1");
- CDOBranch subsub1 = testing1.createBranch("subsub1");
-
- CDOBranch testing2 = mainBranch.createBranch("testing2");
- CDOBranch subsub2 = testing2.createBranch("subsub2");
-
- closeSession1();
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
-
- assertAncestor(mainBranch.getBase(), mainBranch.getBase(), mainBranch.getHead());
- assertAncestor(mainBranch.getBase(), mainBranch.getBase(), testing1.getHead());
- assertAncestor(mainBranch.getBase(), mainBranch.getBase(), subsub1.getHead());
- assertAncestor(mainBranch.getBase(), mainBranch.getBase(), testing2.getHead());
- assertAncestor(mainBranch.getBase(), mainBranch.getBase(), subsub2.getHead());
-
- assertAncestor(testing1.getBase(), testing1.getBase(), testing1.getHead());
- assertAncestor(subsub1.getBase(), subsub1.getBase(), subsub1.getHead());
- assertAncestor(testing2.getBase(), testing2.getBase(), testing2.getHead());
- assertAncestor(subsub2.getBase(), subsub2.getBase(), subsub2.getHead());
-
- assertAncestor(testing1.getBase(), subsub1.getHead(), subsub2.getHead());
- assertAncestor(subsub2.getBase(), testing2.getHead(), subsub2.getHead());
- assertAncestor(subsub1.getBase(), testing1.getHead(), subsub1.getHead());
-
- session.close();
- }
-
- private void assertAncestor(CDOBranchPoint expected, CDOBranchPoint point1, CDOBranchPoint point2)
- {
- assertEquals(expected, CDOBranchUtil.getAncestor(point1, point2));
- assertEquals(expected, CDOBranchUtil.getAncestor(point2, point1));
- }
-
- public void testContainment() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
- CDOBranch mainBranch = branchManager.getMainBranch();
-
- CDOBranch testing1 = mainBranch.createBranch("testing1");
- CDOBranch subsub1 = testing1.createBranch("subsub1");
-
- CDOBranch testing2 = mainBranch.createBranch("testing2");
- CDOBranch subsub2 = testing2.createBranch("subsub2");
-
- closeSession1();
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
-
- assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), mainBranch.getHead()));
- assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), testing1.getHead()));
- assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), subsub1.getHead()));
- assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), testing2.getHead()));
- assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), subsub2.getHead()));
-
- assertEquals(true, CDOBranchUtil.isContainedBy(testing1.getBase(), testing1.getHead()));
- assertEquals(true, CDOBranchUtil.isContainedBy(subsub1.getBase(), subsub1.getHead()));
- assertEquals(true, CDOBranchUtil.isContainedBy(testing2.getBase(), testing2.getHead()));
- assertEquals(true, CDOBranchUtil.isContainedBy(subsub2.getBase(), subsub2.getHead()));
-
- session.close();
- }
-
- public void testCommit() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
-
- // Commit to main branch
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
- assertEquals(mainBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("CDO");
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setProduct(product);
- orderDetail.setPrice(5);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(product);
- resource.getContents().add(orderDetail);
-
- CDOCommitInfo commitInfo = transaction.commit();
- dumpAll(session);
- assertEquals(mainBranch, commitInfo.getBranch());
- long commitTime1 = commitInfo.getTimeStamp();
- transaction.close();
-
- // Commit to sub branch
- CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
- transaction = session.openTransaction(subBranch);
- assertEquals(subBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- resource = transaction.getResource(getResourcePath("/res"));
- orderDetail = (OrderDetail)resource.getContents().get(1);
- assertEquals(5.0f, orderDetail.getPrice());
- product = orderDetail.getProduct();
- assertEquals("CDO", product.getName());
-
- // Modify
- orderDetail.setPrice(10);
- commitInfo = transaction.commit();
- dumpAll(session);
- assertEquals(subBranch, commitInfo.getBranch());
- long commitTime2 = commitInfo.getTimeStamp();
-
- transaction.close();
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- subBranch = mainBranch.getBranch("subBranch");
-
- check(session, mainBranch, commitTime1, 5, "CDO");
- check(session, mainBranch, commitTime2, 5, "CDO");
- check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, "CDO");
-
- check(session, subBranch, commitTime1, 5, "CDO");
- check(session, subBranch, commitTime2, 10, "CDO");
- check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 10, "CDO");
-
- session.close();
- }
-
- public void testCommitAddOrderDetail() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
-
- // Commit to main branch
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
- assertEquals(mainBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("CDO");
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setProduct(product);
- orderDetail.setPrice(5);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(product);
- resource.getContents().add(orderDetail);
-
- CDOCommitInfo commitInfo = transaction.commit();
- dumpAll(session);
- assertEquals(mainBranch, commitInfo.getBranch());
- long commitTime1 = commitInfo.getTimeStamp();
- transaction.close();
-
- // Commit to sub branch
- CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
- transaction = session.openTransaction(subBranch);
- assertEquals(subBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- resource = transaction.getResource(getResourcePath("/res"));
- orderDetail = (OrderDetail)resource.getContents().get(1);
- assertEquals(5.0f, orderDetail.getPrice());
- product = orderDetail.getProduct();
- assertEquals("CDO", product.getName());
-
- // Modify
- OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
- orderDetail2.setProduct(product);
- orderDetail2.setPrice(10);
- resource.getContents().add(0, orderDetail2);
-
- commitInfo = transaction.commit();
- dumpAll(session);
- assertEquals(subBranch, commitInfo.getBranch());
- long commitTime2 = commitInfo.getTimeStamp();
-
- transaction.close();
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- subBranch = mainBranch.getBranch("subBranch");
-
- check(session, mainBranch, commitTime1, 5, "CDO");
- check(session, mainBranch, commitTime2, 5, "CDO");
- check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, "CDO");
-
- check(session, subBranch, commitTime1, 5, "CDO");
- check(session, subBranch, commitTime2, 5, 10, "CDO");
- check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, 10, "CDO");
-
- session.close();
- }
-
- public void testCommitRemoveOrderDetail() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
-
- // Commit to main branch
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
- assertEquals(mainBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("CDO");
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setProduct(product);
- orderDetail.setPrice(5);
-
- OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
- orderDetail2.setProduct(product);
- orderDetail2.setPrice(10);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(orderDetail2);
- resource.getContents().add(product);
- resource.getContents().add(orderDetail);
-
- CDOCommitInfo commitInfo = transaction.commit();
- dumpAll(session);
- assertEquals(mainBranch, commitInfo.getBranch());
- long commitTime1 = commitInfo.getTimeStamp();
- transaction.close();
-
- // Commit to sub branch
- CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
- transaction = session.openTransaction(subBranch);
- assertEquals(subBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- resource = transaction.getResource(getResourcePath("/res"));
- orderDetail = (OrderDetail)resource.getContents().get(2);
- assertEquals(5.0f, orderDetail.getPrice());
- product = orderDetail.getProduct();
- assertEquals("CDO", product.getName());
-
- // Modify
- resource.getContents().remove(product.getOrderDetails().remove(1));
-
- commitInfo = transaction.commit();
- dumpAll(session);
- assertEquals(subBranch, commitInfo.getBranch());
- long commitTime2 = commitInfo.getTimeStamp();
-
- transaction.close();
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- subBranch = mainBranch.getBranch("subBranch");
-
- check(session, mainBranch, commitTime1, 5, 10, "CDO");
- check(session, mainBranch, commitTime2, 5, 10, "CDO");
- check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, 10, "CDO");
-
- check(session, subBranch, commitTime1, 5, 10, "CDO");
- check(session, subBranch, commitTime2, 5, "CDO");
- check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, "CDO");
-
- session.close();
- }
-
- public void testDetachExisting() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
-
- // Commit to main branch
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
- assertEquals(mainBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("CDO");
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setProduct(product);
- orderDetail.setPrice(5);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(product);
- resource.getContents().add(orderDetail);
-
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(mainBranch, commitInfo.getBranch());
- long commitTime1 = commitInfo.getTimeStamp();
- transaction.close();
-
- // Commit to sub branch
- CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
- transaction = session.openTransaction(subBranch);
- assertEquals(subBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- resource = transaction.getResource(getResourcePath("/res"));
- orderDetail = (OrderDetail)resource.getContents().get(1);
- assertEquals(5.0f, orderDetail.getPrice());
- product = orderDetail.getProduct();
- assertEquals("CDO", product.getName());
-
- // Modify
- orderDetail.setPrice(10);
- commitInfo = transaction.commit();
- assertEquals(subBranch, commitInfo.getBranch());
- long commitTime2 = commitInfo.getTimeStamp();
-
- // Detach an object that already has revision in subBranch
- resource.getContents().remove(1);
-
- try
- {
- // product.getOrderDetails() contains pointer to detached orderDetail
- commitInfo = transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- assertInstanceOf(DanglingReferenceException.class, expected.getCause());
- }
-
- orderDetail.setProduct(null);
-
- commitInfo = transaction.commit();
- assertEquals(subBranch, commitInfo.getBranch());
- long commitTime3 = commitInfo.getTimeStamp();
-
- orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setPrice(777);
-
- try
- {
- product.getOrderDetails().set(0, orderDetail);
- fail("IndexOutOfBoundsException expected");
- }
- catch (IndexOutOfBoundsException expected)
- {
- // Success
- }
-
- product.getOrderDetails().add(orderDetail);
-
- try
- {
- // New orderDetail is not attached
- commitInfo = transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- assertInstanceOf(DanglingReferenceException.class, expected.getCause());
- }
-
- resource.getContents().add(orderDetail);
-
- commitInfo = transaction.commit();
- assertEquals(subBranch, commitInfo.getBranch());
- long commitTime4 = commitInfo.getTimeStamp();
-
- transaction.close();
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- subBranch = mainBranch.getBranch("subBranch");
-
- check(session, mainBranch, commitTime1, 5, "CDO");
- check(session, mainBranch, commitTime2, 5, "CDO");
- check(session, mainBranch, commitTime3, 5, "CDO");
- check(session, mainBranch, commitTime4, 5, "CDO");
- check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, "CDO");
-
- check(session, subBranch, commitTime1, 5, "CDO");
- check(session, subBranch, commitTime2, 10, "CDO");
-
- try
- {
- check(session, subBranch, commitTime3, 0, "CDO", 1);
- fail("IndexOutOfBoundsException expected");
- }
- catch (IndexOutOfBoundsException expected)
- {
- // Success
- }
-
- check(session, subBranch, commitTime4, 777, "CDO");
- check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 777, "CDO");
-
- session.close();
- }
-
- private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, String name,
- int expectedContentsSize)
- {
- CDOView view = session.openView(branch, timeStamp);
- CDOResource resource = view.getResource(getResourcePath("/res"));
- assertEquals(expectedContentsSize, resource.getContents().size());
-
- dumpAll(session);
- OrderDetail orderDetail = (OrderDetail)resource.getContents().get(1);
-
- dumpAll(session);
- assertEquals(price, orderDetail.getPrice());
-
- Product1 product = orderDetail.getProduct();
- dumpAll(session);
- assertEquals(name, product.getName());
-
- view.close();
- }
-
- private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, String name)
- {
- check(session, branch, timeStamp, price, name, 2);
- }
-
- private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, float price2, String name)
- {
- CDOView view = session.openView(branch, timeStamp);
- CDOResource resource = view.getResource(getResourcePath("/res"));
- assertEquals(3, resource.getContents().size());
-
- dumpAll(session);
- OrderDetail orderDetail2 = (OrderDetail)resource.getContents().get(0);
- OrderDetail orderDetail = (OrderDetail)resource.getContents().get(2);
-
- dumpAll(session);
- assertEquals(price, orderDetail.getPrice());
- assertEquals(price2, orderDetail2.getPrice());
-
- Product1 product = orderDetail.getProduct();
- Product1 product2 = orderDetail2.getProduct();
- dumpAll(session);
- assertEquals(name, product.getName());
- assertEquals(name, product2.getName());
-
- view.close();
- }
-
- public void testDetachWithoutRevision() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
-
- // Commit to main branch
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
- assertEquals(mainBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("CDO");
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(product);
-
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(mainBranch, commitInfo.getBranch());
- long commitTime1 = commitInfo.getTimeStamp();
- transaction.close();
-
- // Commit to sub branch
- CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
- transaction = session.openTransaction(subBranch);
- assertEquals(subBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- resource = transaction.getResource(getResourcePath("/res"));
- product = (Product1)resource.getContents().get(0);
- assertEquals("CDO", product.getName());
-
- // Detach an object that has no revision in subBranch
- resource.getContents().remove(0);
-
- commitInfo = transaction.commit();
- assertEquals(subBranch, commitInfo.getBranch());
- long commitTime2 = commitInfo.getTimeStamp();
-
- transaction.close();
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- subBranch = mainBranch.getBranch("subBranch");
-
- check(session, subBranch, commitTime1, "CDO");
-
- try
- {
- check(session, subBranch, commitTime2, "CDO");
- fail("IndexOutOfBoundsException expected");
- }
- catch (IndexOutOfBoundsException expected)
- {
- // Success
- }
-
- try
- {
- check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, "CDO");
- fail("IndexOutOfBoundsException expected");
- }
- catch (IndexOutOfBoundsException expected)
- {
- // Success
- }
-
- session.close();
- }
-
- public void testDetachWithoutRevision_CheckMainBranch() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
-
- // Commit to main branch
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
- assertEquals(mainBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("CDO");
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(product);
-
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(mainBranch, commitInfo.getBranch());
- long commitTime1 = commitInfo.getTimeStamp();
- transaction.close();
-
- // Commit to sub branch
- CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
- transaction = session.openTransaction(subBranch);
- assertEquals(subBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- resource = transaction.getResource(getResourcePath("/res"));
- product = (Product1)resource.getContents().get(0);
- assertEquals("CDO", product.getName());
-
- // Detach an object that has no revision in subBranch
- resource.getContents().remove(0);
-
- commitInfo = transaction.commit();
- assertEquals(subBranch, commitInfo.getBranch());
- long commitTime2 = commitInfo.getTimeStamp();
-
- transaction.close();
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- subBranch = mainBranch.getBranch("subBranch");
-
- check(session, mainBranch, commitTime1, "CDO");
- check(session, mainBranch, commitTime2, "CDO");
- check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, "CDO");
-
- check(session, subBranch, commitTime1, "CDO");
-
- try
- {
- check(session, subBranch, commitTime2, "CDO");
- fail("IndexOutOfBoundsException expected");
- }
- catch (IndexOutOfBoundsException expected)
- {
- // Success
- }
-
- try
- {
- check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, "CDO");
- fail("IndexOutOfBoundsException expected");
- }
- catch (IndexOutOfBoundsException expected)
- {
- // Success
- }
-
- session.close();
- }
-
- @CleanRepositoriesBefore
- public void testhandleRevisionsAfterDetachInSubBranch() throws Exception
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
-
- // Commit to main branch
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
- assertEquals(mainBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("CDO");
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(product);
-
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(mainBranch, commitInfo.getBranch());
- long commitTime1 = commitInfo.getTimeStamp();
- transaction.close();
-
- // Commit to sub branch
- CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
- transaction = session.openTransaction(subBranch);
- assertEquals(subBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- resource = transaction.getResource(getResourcePath("/res"));
- product = (Product1)resource.getContents().get(0);
- assertEquals("CDO", product.getName());
-
- product.setName("handleRevisions");
- commitInfo = transaction.commit();
- assertEquals(subBranch, commitInfo.getBranch());
-
- resource.getContents().remove(0);
- commitInfo = transaction.commit();
- assertEquals(subBranch, commitInfo.getBranch());
-
- transaction.close();
- closeSession1();
-
- session = openSession2();
- branchManager = session.getBranchManager();
- mainBranch = branchManager.getMainBranch();
- subBranch = mainBranch.getBranch("subBranch");
-
- final List<CDORevision> revisions = new ArrayList<CDORevision>();
-
- ((InternalCDOSession)session).getSessionProtocol().handleRevisions(null, subBranch, false,
- CDOBranchPoint.UNSPECIFIED_DATE, false, new CDORevisionHandler()
- {
- public boolean handleRevision(CDORevision revision)
- {
- assertNotSame("Product1", revision.getEClass().getName());
- revisions.add(revision);
- return true;
- }
- });
-
- assertEquals(3, revisions.size());
- }
-
- public void testSwitchViewTarget() throws CommitException
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
-
- // Commit to main branch
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
- assertEquals(mainBranch, transaction.getBranch());
- assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("CDO");
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(product);
-
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(mainBranch, commitInfo.getBranch());
- long commitTime1 = commitInfo.getTimeStamp();
- transaction.close();
-
- CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
-
- CDOID id = CDOUtil.getCDOObject(product).cdoID();
- CDOView view = session.openView();
- product = (Product1)CDOUtil.getEObject(view.getObject(id));
-
- view.setBranch(subBranch);
-
- assertEquals(false, CDOUtil.getCDOObject(product).cdoState().equals(CDOState.INVALID));
- assertNotNull(product.getName());
- }
-
- public void testSwitchTransactionTarget() throws CommitException
- {
- CDOSession session = openSession1();
- CDOBranchManager branchManager = session.getBranchManager();
-
- CDOBranch mainBranch = branchManager.getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("CDO");
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(product);
-
- // Commit to main branch
- long commitTime1 = transaction.commit().getTimeStamp();
-
- // Create sub branch
- CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
-
- // Switch to sub branch
- transaction.setBranch(subBranch);
- assertEquals("CDO", product.getName());
-
- // Commit to sub branch
- product.setName("EMF");
- transaction.commit();
-
- // Switch to main branch
- transaction.setBranch(mainBranch);
- assertEquals("CDO", product.getName());
-
- // Commit to main branch
- product.setName("EMF");
- transaction.commit();
- }
-
- private void check(CDOSession session, CDOBranch branch, long timeStamp, String name)
- {
- CDOView view = session.openView(branch, timeStamp);
- CDOResource resource = view.getResource(getResourcePath("/res"));
-
- dumpAll(session);
- Product1 product = (Product1)resource.getContents().get(0);
- assertEquals(name, product.getName());
-
- view.close();
- }
-
- private void dumpAll(CDOSession session)
- {
- IStore store = getRepository().getStore();
- if (store instanceof MEMStore)
- {
- MEMStore memStore = (MEMStore)store;
- dump("MEMStore", memStore.getAllRevisions());
- }
-
- dump("ServerCache", getRepository().getRevisionManager().getCache().getAllRevisions());
- dump("ClientCache", ((InternalCDOSession)session).getRevisionManager().getCache().getAllRevisions());
- }
-
- public static void dump(String label, Map<CDOBranch, List<CDORevision>> revisions)
- {
- System.out.println();
- System.out.println();
- System.out.println(label);
- System.out
- .println("===============================================================================================");
- CDORevisionUtil.dumpAllRevisions(revisions, System.out);
- System.out.println();
- System.out.println();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchCreatedEvent;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.common.revision.AbstractCDORevisionCache;
+import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.DanglingReferenceException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+@CleanRepositoriesBefore
+public class BranchingTest extends AbstractCDOTest
+{
+ protected CDOSession session1;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+
+ Field disableGC = ReflectUtil.getField(AbstractCDORevisionCache.class, "disableGC");
+ ReflectUtil.setValue(disableGC, null, true);
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ Field disableGC = ReflectUtil.getField(AbstractCDORevisionCache.class, "disableGC");
+ ReflectUtil.setValue(disableGC, null, false);
+ super.doTearDown();
+ }
+
+ protected CDOSession openSession1()
+ {
+ session1 = openSession();
+ return session1;
+ }
+
+ protected void closeSession1()
+ {
+ session1.close();
+ session1 = null;
+ }
+
+ protected CDOSession openSession2()
+ {
+ return openSession();
+ }
+
+ @CleanRepositoriesBefore
+ public void testMainBranch() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ assertEquals(CDOBranch.MAIN_BRANCH_ID, mainBranch.getID());
+ assertEquals(CDOBranch.MAIN_BRANCH_NAME, mainBranch.getName());
+ assertEquals(null, mainBranch.getBase().getBranch());
+ assertEquals(0, mainBranch.getBranches().length);
+ closeSession1();
+
+ session = openSession2();
+ mainBranch = session.getBranchManager().getBranch(CDOBranch.MAIN_BRANCH_ID);
+ assertEquals(CDOBranch.MAIN_BRANCH_ID, mainBranch.getID());
+ assertEquals(CDOBranch.MAIN_BRANCH_NAME, mainBranch.getName());
+ assertEquals(null, mainBranch.getBase().getBranch());
+ assertEquals(0, mainBranch.getBranches().length);
+ session.close();
+ }
+
+ @CleanRepositoriesBefore
+ public void testCreateBranch() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOBranch branch = mainBranch.createBranch("testing");
+ assertEquals(CDOBranch.MAIN_BRANCH_ID + 1, branch.getID());
+ assertEquals("testing", branch.getName());
+ assertEquals(CDOBranch.MAIN_BRANCH_ID, branch.getBase().getBranch().getID());
+ assertEquals(0, branch.getBranches().length);
+ session.close();
+ }
+
+ public void testGetBranch() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOBranch branch = mainBranch.createBranch("testing");
+ closeSession1();
+
+ session = openSession2();
+ branch = session.getBranchManager().getBranch(CDOBranch.MAIN_BRANCH_ID + 1);
+ assertEquals(CDOBranch.MAIN_BRANCH_ID + 1, branch.getID());
+ assertEquals("testing", branch.getName());
+ assertEquals(CDOBranch.MAIN_BRANCH_ID, branch.getBase().getBranch().getID());
+ assertEquals(0, branch.getBranches().length);
+ session.close();
+ }
+
+ public void testGetSubBranches() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ mainBranch.createBranch("testing1");
+ mainBranch.createBranch("testing2");
+ closeSession1();
+
+ session = openSession2();
+ mainBranch = session.getBranchManager().getMainBranch();
+ CDOBranch[] branches = mainBranch.getBranches();
+ assertEquals(2, branches.length);
+ assertEquals("testing1", branches[0].getName());
+ assertEquals(CDOBranch.MAIN_BRANCH_ID, branches[0].getBase().getBranch().getID());
+ assertEquals("testing2", branches[1].getName());
+ assertEquals(CDOBranch.MAIN_BRANCH_ID, branches[1].getBase().getBranch().getID());
+ session.close();
+ }
+
+ public void testEvent() throws Exception
+ {
+ CDOSession session1 = openSession1();
+ CDOSession session2 = openSession2();
+
+ final AsyncResult<CDOBranch> result = new AsyncResult<CDOBranch>();
+ session2.getBranchManager().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOBranchCreatedEvent)
+ {
+ CDOBranchCreatedEvent e = (CDOBranchCreatedEvent)event;
+ result.setValue(e.getBranch());
+ }
+ }
+ });
+
+ CDOBranch mainBranch = session1.getBranchManager().getMainBranch();
+ CDOBranch branch = mainBranch.createBranch("testing");
+ CDOBranch resultBranch = result.getValue();
+ assertEquals(branch, resultBranch);
+
+ closeSession1();
+ session2.close();
+ }
+
+ public void testGetPath() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOBranch testing1 = mainBranch.createBranch("testing1");
+ CDOBranch testing2 = mainBranch.createBranch("testing2");
+ CDOBranch subsub = testing1.createBranch("subsub");
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ assertEquals(mainBranch, branchManager.getBranch("MAIN"));
+ assertEquals(testing1, branchManager.getBranch("MAIN/testing1"));
+ assertEquals(testing2, branchManager.getBranch("MAIN/testing2"));
+ assertEquals(subsub, branchManager.getBranch("MAIN/testing1/subsub"));
+ assertEquals(testing1, mainBranch.getBranch("testing1"));
+ assertEquals(testing2, mainBranch.getBranch("testing2"));
+ assertEquals(subsub, mainBranch.getBranch("testing1/subsub"));
+ assertEquals(subsub, testing1.getBranch("subsub"));
+ session.close();
+ }
+
+ public void testGetPathName() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOBranch testing1 = mainBranch.createBranch("testing1");
+ mainBranch.createBranch("testing2");
+ testing1.createBranch("subsub");
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ assertEquals("MAIN", branchManager.getBranch("MAIN").getPathName());
+ assertEquals("MAIN/testing1", branchManager.getBranch("MAIN/testing1").getPathName());
+ assertEquals("MAIN/testing2", branchManager.getBranch("MAIN/testing2").getPathName());
+ assertEquals("MAIN/testing1/subsub", branchManager.getBranch("MAIN/testing1/subsub").getPathName());
+ assertEquals("MAIN/testing1", mainBranch.getBranch("testing1").getPathName());
+ assertEquals("MAIN/testing2", mainBranch.getBranch("testing2").getPathName());
+ assertEquals("MAIN/testing1/subsub", mainBranch.getBranch("testing1/subsub").getPathName());
+ assertEquals("MAIN/testing1/subsub", testing1.getBranch("subsub").getPathName());
+ session.close();
+ }
+
+ public void testBasePath() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOBranch testing1 = mainBranch.createBranch("testing1");
+ CDOBranch testing2 = mainBranch.createBranch("testing2");
+ CDOBranch subsub = testing1.createBranch("subsub");
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ assertEquals(mainBranch.getBasePath(), new CDOBranchPoint[] { mainBranch.getBase() });
+ assertEquals(testing1.getBasePath(), new CDOBranchPoint[] { mainBranch.getBase(), testing1.getBase() });
+ assertEquals(testing2.getBasePath(), new CDOBranchPoint[] { mainBranch.getBase(), testing2.getBase() });
+ assertEquals(subsub.getBasePath(),
+ new CDOBranchPoint[] { mainBranch.getBase(), testing1.getBase(), subsub.getBase() });
+ session.close();
+ }
+
+ public void testAncestor() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+ CDOBranch mainBranch = branchManager.getMainBranch();
+
+ CDOBranch testing1 = mainBranch.createBranch("testing1");
+ CDOBranch subsub1 = testing1.createBranch("subsub1");
+
+ CDOBranch testing2 = mainBranch.createBranch("testing2");
+ CDOBranch subsub2 = testing2.createBranch("subsub2");
+
+ closeSession1();
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+
+ assertAncestor(mainBranch.getBase(), mainBranch.getBase(), mainBranch.getHead());
+ assertAncestor(mainBranch.getBase(), mainBranch.getBase(), testing1.getHead());
+ assertAncestor(mainBranch.getBase(), mainBranch.getBase(), subsub1.getHead());
+ assertAncestor(mainBranch.getBase(), mainBranch.getBase(), testing2.getHead());
+ assertAncestor(mainBranch.getBase(), mainBranch.getBase(), subsub2.getHead());
+
+ assertAncestor(testing1.getBase(), testing1.getBase(), testing1.getHead());
+ assertAncestor(subsub1.getBase(), subsub1.getBase(), subsub1.getHead());
+ assertAncestor(testing2.getBase(), testing2.getBase(), testing2.getHead());
+ assertAncestor(subsub2.getBase(), subsub2.getBase(), subsub2.getHead());
+
+ assertAncestor(testing1.getBase(), subsub1.getHead(), subsub2.getHead());
+ assertAncestor(subsub2.getBase(), testing2.getHead(), subsub2.getHead());
+ assertAncestor(subsub1.getBase(), testing1.getHead(), subsub1.getHead());
+
+ session.close();
+ }
+
+ private void assertAncestor(CDOBranchPoint expected, CDOBranchPoint point1, CDOBranchPoint point2)
+ {
+ assertEquals(expected, CDOBranchUtil.getAncestor(point1, point2));
+ assertEquals(expected, CDOBranchUtil.getAncestor(point2, point1));
+ }
+
+ public void testContainment() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+ CDOBranch mainBranch = branchManager.getMainBranch();
+
+ CDOBranch testing1 = mainBranch.createBranch("testing1");
+ CDOBranch subsub1 = testing1.createBranch("subsub1");
+
+ CDOBranch testing2 = mainBranch.createBranch("testing2");
+ CDOBranch subsub2 = testing2.createBranch("subsub2");
+
+ closeSession1();
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+
+ assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), mainBranch.getHead()));
+ assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), testing1.getHead()));
+ assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), subsub1.getHead()));
+ assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), testing2.getHead()));
+ assertEquals(true, CDOBranchUtil.isContainedBy(mainBranch.getBase(), subsub2.getHead()));
+
+ assertEquals(true, CDOBranchUtil.isContainedBy(testing1.getBase(), testing1.getHead()));
+ assertEquals(true, CDOBranchUtil.isContainedBy(subsub1.getBase(), subsub1.getHead()));
+ assertEquals(true, CDOBranchUtil.isContainedBy(testing2.getBase(), testing2.getHead()));
+ assertEquals(true, CDOBranchUtil.isContainedBy(subsub2.getBase(), subsub2.getHead()));
+
+ session.close();
+ }
+
+ public void testCommit() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ // Commit to main branch
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ assertEquals(mainBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("CDO");
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setProduct(product);
+ orderDetail.setPrice(5);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(product);
+ resource.getContents().add(orderDetail);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ dumpAll(session);
+ assertEquals(mainBranch, commitInfo.getBranch());
+ long commitTime1 = commitInfo.getTimeStamp();
+ transaction.close();
+
+ // Commit to sub branch
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
+ transaction = session.openTransaction(subBranch);
+ assertEquals(subBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ resource = transaction.getResource(getResourcePath("/res"));
+ orderDetail = (OrderDetail)resource.getContents().get(1);
+ assertEquals(5.0f, orderDetail.getPrice());
+ product = orderDetail.getProduct();
+ assertEquals("CDO", product.getName());
+
+ // Modify
+ orderDetail.setPrice(10);
+ commitInfo = transaction.commit();
+ dumpAll(session);
+ assertEquals(subBranch, commitInfo.getBranch());
+ long commitTime2 = commitInfo.getTimeStamp();
+
+ transaction.close();
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ subBranch = mainBranch.getBranch("subBranch");
+
+ check(session, mainBranch, commitTime1, 5, "CDO");
+ check(session, mainBranch, commitTime2, 5, "CDO");
+ check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, "CDO");
+
+ check(session, subBranch, commitTime1, 5, "CDO");
+ check(session, subBranch, commitTime2, 10, "CDO");
+ check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 10, "CDO");
+
+ session.close();
+ }
+
+ public void testCommitAddOrderDetail() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ // Commit to main branch
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ assertEquals(mainBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("CDO");
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setProduct(product);
+ orderDetail.setPrice(5);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(product);
+ resource.getContents().add(orderDetail);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ dumpAll(session);
+ assertEquals(mainBranch, commitInfo.getBranch());
+ long commitTime1 = commitInfo.getTimeStamp();
+ transaction.close();
+
+ // Commit to sub branch
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
+ transaction = session.openTransaction(subBranch);
+ assertEquals(subBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ resource = transaction.getResource(getResourcePath("/res"));
+ orderDetail = (OrderDetail)resource.getContents().get(1);
+ assertEquals(5.0f, orderDetail.getPrice());
+ product = orderDetail.getProduct();
+ assertEquals("CDO", product.getName());
+
+ // Modify
+ OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
+ orderDetail2.setProduct(product);
+ orderDetail2.setPrice(10);
+ resource.getContents().add(0, orderDetail2);
+
+ commitInfo = transaction.commit();
+ dumpAll(session);
+ assertEquals(subBranch, commitInfo.getBranch());
+ long commitTime2 = commitInfo.getTimeStamp();
+
+ transaction.close();
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ subBranch = mainBranch.getBranch("subBranch");
+
+ check(session, mainBranch, commitTime1, 5, "CDO");
+ check(session, mainBranch, commitTime2, 5, "CDO");
+ check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, "CDO");
+
+ check(session, subBranch, commitTime1, 5, "CDO");
+ check(session, subBranch, commitTime2, 5, 10, "CDO");
+ check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, 10, "CDO");
+
+ session.close();
+ }
+
+ public void testCommitRemoveOrderDetail() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ // Commit to main branch
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ assertEquals(mainBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("CDO");
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setProduct(product);
+ orderDetail.setPrice(5);
+
+ OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
+ orderDetail2.setProduct(product);
+ orderDetail2.setPrice(10);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(orderDetail2);
+ resource.getContents().add(product);
+ resource.getContents().add(orderDetail);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ dumpAll(session);
+ assertEquals(mainBranch, commitInfo.getBranch());
+ long commitTime1 = commitInfo.getTimeStamp();
+ transaction.close();
+
+ // Commit to sub branch
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
+ transaction = session.openTransaction(subBranch);
+ assertEquals(subBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ resource = transaction.getResource(getResourcePath("/res"));
+ orderDetail = (OrderDetail)resource.getContents().get(2);
+ assertEquals(5.0f, orderDetail.getPrice());
+ product = orderDetail.getProduct();
+ assertEquals("CDO", product.getName());
+
+ // Modify
+ resource.getContents().remove(product.getOrderDetails().remove(1));
+
+ commitInfo = transaction.commit();
+ dumpAll(session);
+ assertEquals(subBranch, commitInfo.getBranch());
+ long commitTime2 = commitInfo.getTimeStamp();
+
+ transaction.close();
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ subBranch = mainBranch.getBranch("subBranch");
+
+ check(session, mainBranch, commitTime1, 5, 10, "CDO");
+ check(session, mainBranch, commitTime2, 5, 10, "CDO");
+ check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, 10, "CDO");
+
+ check(session, subBranch, commitTime1, 5, 10, "CDO");
+ check(session, subBranch, commitTime2, 5, "CDO");
+ check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, "CDO");
+
+ session.close();
+ }
+
+ public void testDetachExisting() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ // Commit to main branch
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ assertEquals(mainBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("CDO");
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setProduct(product);
+ orderDetail.setPrice(5);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(product);
+ resource.getContents().add(orderDetail);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(mainBranch, commitInfo.getBranch());
+ long commitTime1 = commitInfo.getTimeStamp();
+ transaction.close();
+
+ // Commit to sub branch
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
+ transaction = session.openTransaction(subBranch);
+ assertEquals(subBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ resource = transaction.getResource(getResourcePath("/res"));
+ orderDetail = (OrderDetail)resource.getContents().get(1);
+ assertEquals(5.0f, orderDetail.getPrice());
+ product = orderDetail.getProduct();
+ assertEquals("CDO", product.getName());
+
+ // Modify
+ orderDetail.setPrice(10);
+ commitInfo = transaction.commit();
+ assertEquals(subBranch, commitInfo.getBranch());
+ long commitTime2 = commitInfo.getTimeStamp();
+
+ // Detach an object that already has revision in subBranch
+ resource.getContents().remove(1);
+
+ try
+ {
+ // product.getOrderDetails() contains pointer to detached orderDetail
+ commitInfo = transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ assertInstanceOf(DanglingReferenceException.class, expected.getCause());
+ }
+
+ orderDetail.setProduct(null);
+
+ commitInfo = transaction.commit();
+ assertEquals(subBranch, commitInfo.getBranch());
+ long commitTime3 = commitInfo.getTimeStamp();
+
+ orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setPrice(777);
+
+ try
+ {
+ product.getOrderDetails().set(0, orderDetail);
+ fail("IndexOutOfBoundsException expected");
+ }
+ catch (IndexOutOfBoundsException expected)
+ {
+ // Success
+ }
+
+ product.getOrderDetails().add(orderDetail);
+
+ try
+ {
+ // New orderDetail is not attached
+ commitInfo = transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ assertInstanceOf(DanglingReferenceException.class, expected.getCause());
+ }
+
+ resource.getContents().add(orderDetail);
+
+ commitInfo = transaction.commit();
+ assertEquals(subBranch, commitInfo.getBranch());
+ long commitTime4 = commitInfo.getTimeStamp();
+
+ transaction.close();
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ subBranch = mainBranch.getBranch("subBranch");
+
+ check(session, mainBranch, commitTime1, 5, "CDO");
+ check(session, mainBranch, commitTime2, 5, "CDO");
+ check(session, mainBranch, commitTime3, 5, "CDO");
+ check(session, mainBranch, commitTime4, 5, "CDO");
+ check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 5, "CDO");
+
+ check(session, subBranch, commitTime1, 5, "CDO");
+ check(session, subBranch, commitTime2, 10, "CDO");
+
+ try
+ {
+ check(session, subBranch, commitTime3, 0, "CDO", 1);
+ fail("IndexOutOfBoundsException expected");
+ }
+ catch (IndexOutOfBoundsException expected)
+ {
+ // Success
+ }
+
+ check(session, subBranch, commitTime4, 777, "CDO");
+ check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 777, "CDO");
+
+ session.close();
+ }
+
+ private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, String name,
+ int expectedContentsSize)
+ {
+ CDOView view = session.openView(branch, timeStamp);
+ CDOResource resource = view.getResource(getResourcePath("/res"));
+ assertEquals(expectedContentsSize, resource.getContents().size());
+
+ dumpAll(session);
+ OrderDetail orderDetail = (OrderDetail)resource.getContents().get(1);
+
+ dumpAll(session);
+ assertEquals(price, orderDetail.getPrice());
+
+ Product1 product = orderDetail.getProduct();
+ dumpAll(session);
+ assertEquals(name, product.getName());
+
+ view.close();
+ }
+
+ private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, String name)
+ {
+ check(session, branch, timeStamp, price, name, 2);
+ }
+
+ private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, float price2, String name)
+ {
+ CDOView view = session.openView(branch, timeStamp);
+ CDOResource resource = view.getResource(getResourcePath("/res"));
+ assertEquals(3, resource.getContents().size());
+
+ dumpAll(session);
+ OrderDetail orderDetail2 = (OrderDetail)resource.getContents().get(0);
+ OrderDetail orderDetail = (OrderDetail)resource.getContents().get(2);
+
+ dumpAll(session);
+ assertEquals(price, orderDetail.getPrice());
+ assertEquals(price2, orderDetail2.getPrice());
+
+ Product1 product = orderDetail.getProduct();
+ Product1 product2 = orderDetail2.getProduct();
+ dumpAll(session);
+ assertEquals(name, product.getName());
+ assertEquals(name, product2.getName());
+
+ view.close();
+ }
+
+ public void testDetachWithoutRevision() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ // Commit to main branch
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ assertEquals(mainBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("CDO");
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(product);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(mainBranch, commitInfo.getBranch());
+ long commitTime1 = commitInfo.getTimeStamp();
+ transaction.close();
+
+ // Commit to sub branch
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
+ transaction = session.openTransaction(subBranch);
+ assertEquals(subBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ resource = transaction.getResource(getResourcePath("/res"));
+ product = (Product1)resource.getContents().get(0);
+ assertEquals("CDO", product.getName());
+
+ // Detach an object that has no revision in subBranch
+ resource.getContents().remove(0);
+
+ commitInfo = transaction.commit();
+ assertEquals(subBranch, commitInfo.getBranch());
+ long commitTime2 = commitInfo.getTimeStamp();
+
+ transaction.close();
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ subBranch = mainBranch.getBranch("subBranch");
+
+ check(session, subBranch, commitTime1, "CDO");
+
+ try
+ {
+ check(session, subBranch, commitTime2, "CDO");
+ fail("IndexOutOfBoundsException expected");
+ }
+ catch (IndexOutOfBoundsException expected)
+ {
+ // Success
+ }
+
+ try
+ {
+ check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, "CDO");
+ fail("IndexOutOfBoundsException expected");
+ }
+ catch (IndexOutOfBoundsException expected)
+ {
+ // Success
+ }
+
+ session.close();
+ }
+
+ public void testDetachWithoutRevision_CheckMainBranch() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ // Commit to main branch
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ assertEquals(mainBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("CDO");
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(product);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(mainBranch, commitInfo.getBranch());
+ long commitTime1 = commitInfo.getTimeStamp();
+ transaction.close();
+
+ // Commit to sub branch
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
+ transaction = session.openTransaction(subBranch);
+ assertEquals(subBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ resource = transaction.getResource(getResourcePath("/res"));
+ product = (Product1)resource.getContents().get(0);
+ assertEquals("CDO", product.getName());
+
+ // Detach an object that has no revision in subBranch
+ resource.getContents().remove(0);
+
+ commitInfo = transaction.commit();
+ assertEquals(subBranch, commitInfo.getBranch());
+ long commitTime2 = commitInfo.getTimeStamp();
+
+ transaction.close();
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ subBranch = mainBranch.getBranch("subBranch");
+
+ check(session, mainBranch, commitTime1, "CDO");
+ check(session, mainBranch, commitTime2, "CDO");
+ check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, "CDO");
+
+ check(session, subBranch, commitTime1, "CDO");
+
+ try
+ {
+ check(session, subBranch, commitTime2, "CDO");
+ fail("IndexOutOfBoundsException expected");
+ }
+ catch (IndexOutOfBoundsException expected)
+ {
+ // Success
+ }
+
+ try
+ {
+ check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, "CDO");
+ fail("IndexOutOfBoundsException expected");
+ }
+ catch (IndexOutOfBoundsException expected)
+ {
+ // Success
+ }
+
+ session.close();
+ }
+
+ @CleanRepositoriesBefore
+ public void testhandleRevisionsAfterDetachInSubBranch() throws Exception
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ // Commit to main branch
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ assertEquals(mainBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("CDO");
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(product);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(mainBranch, commitInfo.getBranch());
+ long commitTime1 = commitInfo.getTimeStamp();
+ transaction.close();
+
+ // Commit to sub branch
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
+ transaction = session.openTransaction(subBranch);
+ assertEquals(subBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ resource = transaction.getResource(getResourcePath("/res"));
+ product = (Product1)resource.getContents().get(0);
+ assertEquals("CDO", product.getName());
+
+ product.setName("handleRevisions");
+ commitInfo = transaction.commit();
+ assertEquals(subBranch, commitInfo.getBranch());
+
+ resource.getContents().remove(0);
+ commitInfo = transaction.commit();
+ assertEquals(subBranch, commitInfo.getBranch());
+
+ transaction.close();
+ closeSession1();
+
+ session = openSession2();
+ branchManager = session.getBranchManager();
+ mainBranch = branchManager.getMainBranch();
+ subBranch = mainBranch.getBranch("subBranch");
+
+ final List<CDORevision> revisions = new ArrayList<CDORevision>();
+
+ ((InternalCDOSession)session).getSessionProtocol().handleRevisions(null, subBranch, false,
+ CDOBranchPoint.UNSPECIFIED_DATE, false, new CDORevisionHandler()
+ {
+ public boolean handleRevision(CDORevision revision)
+ {
+ assertNotSame("Product1", revision.getEClass().getName());
+ revisions.add(revision);
+ return true;
+ }
+ });
+
+ assertEquals(3, revisions.size());
+ }
+
+ public void testSwitchViewTarget() throws CommitException
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ // Commit to main branch
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ assertEquals(mainBranch, transaction.getBranch());
+ assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("CDO");
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(product);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(mainBranch, commitInfo.getBranch());
+ long commitTime1 = commitInfo.getTimeStamp();
+ transaction.close();
+
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
+
+ CDOID id = CDOUtil.getCDOObject(product).cdoID();
+ CDOView view = session.openView();
+ product = (Product1)CDOUtil.getEObject(view.getObject(id));
+
+ view.setBranch(subBranch);
+
+ assertEquals(false, CDOUtil.getCDOObject(product).cdoState().equals(CDOState.INVALID));
+ assertNotNull(product.getName());
+ }
+
+ public void testSwitchTransactionTarget() throws CommitException
+ {
+ CDOSession session = openSession1();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ CDOBranch mainBranch = branchManager.getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("CDO");
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(product);
+
+ // Commit to main branch
+ long commitTime1 = transaction.commit().getTimeStamp();
+
+ // Create sub branch
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", commitTime1);
+
+ // Switch to sub branch
+ transaction.setBranch(subBranch);
+ assertEquals("CDO", product.getName());
+
+ // Commit to sub branch
+ product.setName("EMF");
+ transaction.commit();
+
+ // Switch to main branch
+ transaction.setBranch(mainBranch);
+ assertEquals("CDO", product.getName());
+
+ // Commit to main branch
+ product.setName("EMF");
+ transaction.commit();
+ }
+
+ private void check(CDOSession session, CDOBranch branch, long timeStamp, String name)
+ {
+ CDOView view = session.openView(branch, timeStamp);
+ CDOResource resource = view.getResource(getResourcePath("/res"));
+
+ dumpAll(session);
+ Product1 product = (Product1)resource.getContents().get(0);
+ assertEquals(name, product.getName());
+
+ view.close();
+ }
+
+ private void dumpAll(CDOSession session)
+ {
+ IStore store = getRepository().getStore();
+ if (store instanceof MEMStore)
+ {
+ MEMStore memStore = (MEMStore)store;
+ dump("MEMStore", memStore.getAllRevisions());
+ }
+
+ dump("ServerCache", getRepository().getRevisionManager().getCache().getAllRevisions());
+ dump("ClientCache", ((InternalCDOSession)session).getRevisionManager().getCache().getAllRevisions());
+ }
+
+ public static void dump(String label, Map<CDOBranch, List<CDORevision>> revisions)
+ {
+ System.out.println();
+ System.out.println();
+ System.out.println(label);
+ System.out
+ .println("===============================================================================================");
+ CDORevisionUtil.dumpAllRevisions(revisions, System.out);
+ System.out.println();
+ System.out.println();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingWithCacheClearTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingWithCacheClearTest.java
index bd7eb27a89..e3e97d551d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingWithCacheClearTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingWithCacheClearTest.java
@@ -1,27 +1,27 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-
-/**
- * @author Eike Stepper
- */
-@CleanRepositoriesBefore
-public class BranchingWithCacheClearTest extends BranchingTest
-{
- @Override
- protected void closeSession1()
- {
- super.closeSession1();
- clearCache(getRepository().getRevisionManager());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+
+/**
+ * @author Eike Stepper
+ */
+@CleanRepositoriesBefore
+public class BranchingWithCacheClearTest extends BranchingTest
+{
+ @Override
+ protected void closeSession1()
+ {
+ super.closeSession1();
+ clearCache(getRepository().getRevisionManager());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java
index 64d8858fca..1ab61c5041 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java
@@ -1,106 +1,106 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDExternal;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDNullImpl;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectLongImpl;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectImpl;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * @author Stefan Winkler
- */
-public class CDOIDTest extends AbstractCDOTest
-{
- public void testGetLong_Null()
- {
- assertEquals(AbstractCDOIDLong.NULL_VALUE, CDOIDUtil.getLong(null));
- }
-
- public void testGetLong_NullId()
- {
- CDOIDNullImpl id = CDOIDNullImpl.INSTANCE;
- assertEquals(AbstractCDOIDLong.NULL_VALUE, CDOIDUtil.getLong(id));
- }
-
- public void testGetLong_LongId()
- {
- CDOIDObjectLongImpl id = new CDOIDObjectLongImpl(123L);
- assertEquals(123L, CDOIDUtil.getLong(id));
- }
-
- public void testGetLong_TempId()
- {
- CDOIDTempObjectImpl id = new CDOIDTempObjectImpl(456);
- assertIllegalArgument(id);
- }
-
- public void testGetLong_ExtTempId()
- {
- CDOIDTempObjectExternalImpl id = new CDOIDTempObjectExternalImpl("cdo://repo123/resource456");
- assertIllegalArgument(id);
- }
-
- public void testGetLong_ExtId()
- {
- CDOIDExternal id = CDOIDUtil.createExternal("cdo://repo123/resource456");
- assertIllegalArgument(id);
- }
-
- private void assertIllegalArgument(CDOID id)
- {
- boolean thrown = false;
- try
- {
- CDOIDUtil.getLong(id);
- }
- catch (IllegalArgumentException e)
- {
- thrown = true;
- }
-
- if (!thrown)
- {
- fail("Expected IllegalArgumentException!");
- }
- }
-
- public void testURIFragment() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
-
- resource.getContents().add(supplier);
- transaction.commit();
-
- StringBuilder builder = new StringBuilder();
- CDOIDUtil.write(builder, CDOUtil.getCDOObject(supplier).cdoID());
-
- String uriFragment = builder.toString();
- System.out.println(uriFragment);
-
- CDOID id = CDOIDUtil.read(uriFragment);
- System.out.println(id);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDExternal;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDNullImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectLongImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectImpl;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * @author Stefan Winkler
+ */
+public class CDOIDTest extends AbstractCDOTest
+{
+ public void testGetLong_Null()
+ {
+ assertEquals(AbstractCDOIDLong.NULL_VALUE, CDOIDUtil.getLong(null));
+ }
+
+ public void testGetLong_NullId()
+ {
+ CDOIDNullImpl id = CDOIDNullImpl.INSTANCE;
+ assertEquals(AbstractCDOIDLong.NULL_VALUE, CDOIDUtil.getLong(id));
+ }
+
+ public void testGetLong_LongId()
+ {
+ CDOIDObjectLongImpl id = new CDOIDObjectLongImpl(123L);
+ assertEquals(123L, CDOIDUtil.getLong(id));
+ }
+
+ public void testGetLong_TempId()
+ {
+ CDOIDTempObjectImpl id = new CDOIDTempObjectImpl(456);
+ assertIllegalArgument(id);
+ }
+
+ public void testGetLong_ExtTempId()
+ {
+ CDOIDTempObjectExternalImpl id = new CDOIDTempObjectExternalImpl("cdo://repo123/resource456");
+ assertIllegalArgument(id);
+ }
+
+ public void testGetLong_ExtId()
+ {
+ CDOIDExternal id = CDOIDUtil.createExternal("cdo://repo123/resource456");
+ assertIllegalArgument(id);
+ }
+
+ private void assertIllegalArgument(CDOID id)
+ {
+ boolean thrown = false;
+ try
+ {
+ CDOIDUtil.getLong(id);
+ }
+ catch (IllegalArgumentException e)
+ {
+ thrown = true;
+ }
+
+ if (!thrown)
+ {
+ fail("Expected IllegalArgumentException!");
+ }
+ }
+
+ public void testURIFragment() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+
+ resource.getContents().add(supplier);
+ transaction.commit();
+
+ StringBuilder builder = new StringBuilder();
+ CDOIDUtil.write(builder, CDOUtil.getCDOObject(supplier).cdoID());
+
+ String uriFragment = builder.toString();
+ System.out.println(uriFragment);
+
+ CDOID id = CDOIDUtil.read(uriFragment);
+ System.out.println(id);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java
index 3de301c9a9..1e3b5201a0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java
@@ -1,941 +1,941 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDODeltaNotification;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Simon McDuff
- */
-public class ChangeSubscriptionTest extends AbstractCDOTest
-{
- public void testSameSession() throws Exception
- {
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- final Company companyA = getModel1Factory().createCompany();
- companyA.getCategories().add(category1A);
-
- final CDOSession session = openSession();
-
- // ************************************************************* //
-
- final CDOTransaction transaction = session.openTransaction();
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(companyA);
-
- transaction.commit();
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
-
- // ************************************************************* //
-
- final CDOTransaction transaction2 = session.openTransaction();
-
- final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A)
- .cdoID(), true));
- category1B.setName("CHANGED NAME");
- assertEquals(0, adapter.getNotifications().length);
-
- transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // Commit notifications from the same session always have full deltas
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1;
- }
- }.assertNoTimeOut();
-
- // Removing policy
- transaction.options().removeChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- adapter.clearNotifications();
-
- category1B.setName("CHANGED NAME_VERSION 2");
- assertEquals(0, adapter.getNotifications().length);
-
- transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // Commit notifications from the same session always have full deltas
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1;
- }
- }.assertNoTimeOut();
- }
-
- public void testSameSession_WithoutPolicy() throws Exception
- {
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- final Company companyA = getModel1Factory().createCompany();
- companyA.getCategories().add(category1A);
-
- final CDOSession session = openSession();
-
- // ************************************************************* //
-
- final CDOTransaction transaction = session.openTransaction();
-
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(companyA);
-
- transaction.commit();
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
-
- // ************************************************************* //
-
- final CDOTransaction transaction2 = session.openTransaction();
-
- final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A)
- .cdoID(), true));
- category1B.setName("CHANGED NAME");
- assertEquals(0, adapter.getNotifications().length);
-
- transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // Commit notifications from the same session always have full deltas
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1;
- }
- }.assertNoTimeOut();
-
- // Adding policy
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- adapter.clearNotifications();
-
- category1B.setName("CHANGED NAME_VERSION 2");
- assertEquals(0, adapter.getNotifications().length);
-
- transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // Commit notifications from the same session always have full deltas
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1;
- }
- }.assertNoTimeOut();
- }
-
- public void testSeparateSession() throws Exception
- {
- Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- Company companyA = getModel1Factory().createCompany();
- companyA.getCategories().add(category1A);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(companyA);
- transaction.commit();
-
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
-
- // ************************************************************* //
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
-
- Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A).cdoID(),
- true));
- category1B.setName("CHANGED NAME");
- assertEquals(0, adapter.getNotifications().length);
-
- transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // Change subscription leads to delta nnotification
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1;
- }
- }.assertNoTimeOut();
-
- // Removing policy
- transaction.options().removeChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- adapter.clearNotifications();
-
- category1B.setName("CHANGED NAME_VERSION 2");
- assertEquals(0, adapter.getNotifications().length);
-
- transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // No change subscription, other session ==> no delta notification
- Notification[] notifications = adapter.getNotifications();
- return notifications.length != 0;
- }
- }.assertTimeOut();
- }
-
- public void testSeparateSession_WithoutPolicy() throws Exception
- {
- Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- Company companyA = getModel1Factory().createCompany();
- companyA.getCategories().add(category1A);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(companyA);
- transaction.commit();
-
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
-
- // ************************************************************* //
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
-
- Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A).cdoID(),
- true));
- category1B.setName("CHANGED NAME");
- assertEquals(0, adapter.getNotifications().length);
-
- transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // No change subscription, other session ==> no delta notification
- Notification[] notifications = adapter.getNotifications();
- return notifications.length != 0;
- }
- }.assertTimeOut();
-
- // Adding policy
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- adapter.clearNotifications();
-
- category1B.setName("CHANGED NAME_VERSION 2");
- assertEquals(0, adapter.getNotifications().length);
-
- transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // Change subscription leads to delta nnotification
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1;
- }
- }.assertNoTimeOut();
- }
-
- public void testTemporaryObject() throws Exception
- {
- msg("Opening session");
- final CDOSession session = openSession();
-
- // ************************************************************* //
-
- msg("Creating category1");
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- msg("Creating company");
- final Company companyA = getModel1Factory().createCompany();
-
- msg("Adding categories");
- companyA.getCategories().add(category1A);
-
- msg("Opening transaction");
- final CDOTransaction transaction = session.openTransaction();
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- msg("Creating resource");
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resourceA.getContents().add(companyA);
-
- msg("Committing");
-
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
-
- transaction.commit();
-
- // ************************************************************* //
-
- msg("Opening view");
- final CDOSession session2 = openSession();
- final CDOTransaction transaction2 = session2.openTransaction();
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A)
- .cdoID(), true));
-
- msg("Changing name");
- category1B.setName("CHANGED NAME");
-
- assertEquals(0, adapter.getNotifications().length);
-
- msg("Committing");
- transaction2.commit();
-
- msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
- }
-
- public void testSeparateSession_CUSTOM() throws Exception
- {
- CDOIDFilterChangeSubscriptionPolicy customPolicy = new CDOIDFilterChangeSubscriptionPolicy();
-
- msg("Opening session");
- final CDOSession session = openSession();
-
- // ************************************************************* //
-
- msg("Creating category1");
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- msg("Creating company");
- final Company companyA = getModel1Factory().createCompany();
-
- msg("Adding categories");
- companyA.getCategories().add(category1A);
-
- msg("Opening transaction");
- final CDOTransaction transaction = session.openTransaction();
-
- transaction.options().addChangeSubscriptionPolicy(customPolicy);
-
- msg("Creating resource");
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resourceA.getContents().add(companyA);
-
- msg("Committing");
- transaction.commit();
-
- final TestAdapter adapter = new TestAdapter();
-
- customPolicy.getCdoIDs().add(CDOUtil.getCDOObject(category1A).cdoID());
-
- category1A.eAdapters().add(adapter);
- companyA.eAdapters().add(adapter);
-
- // ************************************************************* //
-
- msg("Opening view");
- final CDOSession session2 = openSession();
- final CDOTransaction transaction2 = session2.openTransaction();
-
- final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A)
- .cdoID(), true));
- final Company company1B = (Company)CDOUtil.getEObject(transaction2.getObject(
- CDOUtil.getCDOObject(companyA).cdoID(), true));
-
- msg("Changing name");
- category1B.setName("CHANGED NAME");
- company1B.setName("TEST1");
-
- assertEquals(0, adapter.getNotifications().length);
-
- msg("Committing");
- transaction2.commit();
-
- msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
-
- // Switching policy to the other
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- adapter.clearNotifications();
-
- msg("Changing name");
- category1B.setName("CHANGED NAME_VERSION 2");
- company1B.setName("TEST2");
-
- assertEquals(0, adapter.getNotifications().length);
-
- msg("Committing");
- transaction2.commit();
-
- msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == 2;
- }
- }.assertNoTimeOut();
- }
-
- public void testNotificationChain() throws Exception
- {
- msg("Opening session");
- final CDOSession session = openSession();
-
- // ************************************************************* //
-
- msg("Creating category1");
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- msg("Creating company");
- final Company companyA = getModel1Factory().createCompany();
-
- msg("Adding categories");
- companyA.getCategories().add(category1A);
-
- msg("Opening transaction");
- final CDOTransaction transaction = session.openTransaction();
-
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- msg("Creating resource");
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resourceA.getContents().add(companyA);
-
- msg("Committing");
- transaction.commit();
-
- final TestAdapter adapter = new TestAdapter();
-
- companyA.eAdapters().add(adapter);
-
- // ************************************************************* //
-
- msg("Opening view");
- final CDOSession session2 = openSession();
- final CDOTransaction transaction2 = session2.openTransaction();
-
- final Company company1B = (Company)CDOUtil.getEObject(transaction2.getObject(
- CDOUtil.getCDOObject(companyA).cdoID(), true));
-
- msg("Changing name");
- company1B.setName("TEST1");
- company1B.setCity("CITY1");
-
- final Category category2B = getModel1Factory().createCategory();
- company1B.getCategories().add(category2B);
-
- assertEquals(0, adapter.getNotifications().length);
-
- msg("Committing");
- transaction2.commit();
-
- msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == 3;
- }
- }.assertNoTimeOut();
-
- int count = 0;
- for (Notification notification : adapter.getNotifications())
- {
- CDODeltaNotification cdoNotification = (CDODeltaNotification)notification;
- if (adapter.getNotifications().length - 1 == count)
- {
- assertEquals(false, cdoNotification.hasNext());
- }
- else
- {
- assertEquals(true, cdoNotification.hasNext());
- }
-
- if (notification.getFeature() == getModel1Package().getCategory_Name())
- {
- assertEquals(Notification.SET, notification.getEventType());
- assertEquals("TEST1", notification.getNewStringValue());
- }
- else if (notification.getFeature() == getModel1Package().getAddress_City())
- {
- assertEquals(Notification.SET, notification.getEventType());
- assertEquals("CITY1", notification.getNewStringValue());
- }
- else if (notification.getFeature() == getModel1Package().getCompany_Categories())
- {
- assertEquals(Notification.ADD, notification.getEventType());
- assertEquals(1, notification.getPosition());
- assertEquals(transaction.getObject(CDOUtil.getCDOObject(category2B).cdoID(), true), notification.getNewValue());
- }
- else
- {
- assertEquals(false, false);
- }
-
- count++;
- }
- }
-
- public void testRemoveContained() throws Exception
- {
- List<Category> categories = new ArrayList<Category>();
- categories.add(getModel1Factory().createCategory());
-
- Company company = getModel1Factory().createCompany();
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().addAll(categories);
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(company);
- transaction.commit();
-
- CDOSession session2 = openSession();
- CDOView view = session2.openView();
- view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- CDOResource resource2 = view.getResource(getResourcePath("/test1"));
- Company company2 = (Company)resource2.getContents().get(0);
-
- Object[] strongRefs = company2.getCategories().toArray(); // Keep those in memory
- msg(strongRefs);
-
- final TestAdapter adapter = new TestAdapter();
- company2.eAdapters().add(adapter);
-
- company.getCategories().removeAll(categories);
- transaction.commit();
-
- final Object[] oldValue = { null };
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- for (Notification notification : adapter.getNotifications())
- {
- if (notification.getEventType() == Notification.REMOVE
- && notification.getFeature() == getModel1Package().getCompany_Categories())
- {
- oldValue[0] = notification.getOldValue();
- return true;
- }
- }
-
- return false;
- }
- }.assertNoTimeOut();
-
- assertInstanceOf(Category.class, CDOUtil.getEObject((EObject)oldValue[0]));
- }
-
- public void testRemoveManyContained() throws Exception
- {
- final List<Category> categories = new ArrayList<Category>();
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
-
- Company company = getModel1Factory().createCompany();
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().addAll(categories);
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(company);
- transaction.commit();
-
- CDOSession session2 = openSession();
- CDOView view = session2.openView();
- view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- CDOResource resource2 = view.getResource(getResourcePath("/test1"));
- Company company2 = (Company)resource2.getContents().get(0);
-
- Object[] strongRefs = company2.getCategories().toArray(); // Keep those in memory
- msg(strongRefs);
-
- final TestAdapter adapter = new TestAdapter();
- company2.eAdapters().add(adapter);
-
- company.getCategories().removeAll(categories);
- transaction.commit();
-
- // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
- // final Object[] oldValue = { null };
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == categories.size();
-
- // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
- // for (Notification notification : adapter.getNotifications())
- // {
- // if (notification.getEventType() == Notification.REMOVE_MANY
- // && notification.getFeature() == getModel1Package().getCompany_Categories())
- // {
- // oldValue[0] = notification.getOldValue();
- // return true;
- // }
- // }
- //
- // return false;
- }
- }.assertNoTimeOut();
-
- // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
- // assertInstanceOf(Collection.class, oldValue[0]);
- // assertEquals(categories.size(), ((Collection<?>)oldValue[0]).size());
- }
-
- public void testRemoveXRef() throws Exception
- {
- List<OrderDetail> details = new ArrayList<OrderDetail>();
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("test1");
- product.getOrderDetails().addAll(details);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(product);
- resource.getContents().addAll(details);
- transaction.commit();
-
- CDOSession session2 = openSession();
- CDOView view = session2.openView();
- view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- CDOResource resource2 = view.getResource(getResourcePath("/test1"));
- Product1 product2 = (Product1)resource2.getContents().get(0);
-
- Object[] strongRefs = product2.getOrderDetails().toArray(); // Keep those in memory
- msg(strongRefs);
-
- final TestAdapter adapter = new TestAdapter();
- product2.eAdapters().add(adapter);
-
- details.remove(0);
- details.remove(0);
- details.remove(0);
- details.remove(1);
- details.remove(1);
- details.remove(1);
- product.getOrderDetails().removeAll(details);
- transaction.commit();
-
- final Object[] oldValue = { null };
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- for (Notification notification : adapter.getNotifications())
- {
- if (notification.getEventType() == Notification.REMOVE
- && notification.getFeature() == getModel1Package().getProduct1_OrderDetails())
- {
- oldValue[0] = notification.getOldValue();
- return true;
- }
- }
-
- return false;
- }
- }.assertNoTimeOut();
-
- assertInstanceOf(OrderDetail.class, CDOUtil.getEObject((EObject)oldValue[0]));
- }
-
- public void testRemoveManyXRef() throws Exception
- {
- final List<OrderDetail> details = new ArrayList<OrderDetail>();
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
- details.add(getModel1Factory().createOrderDetail());
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("test1");
- product.getOrderDetails().addAll(details);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(product);
- resource.getContents().addAll(details);
- transaction.commit();
-
- CDOSession session2 = openSession();
- CDOView view = session2.openView();
- view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- CDOResource resource2 = view.getResource(getResourcePath("/test1"));
- Product1 product2 = (Product1)resource2.getContents().get(0);
-
- Object[] strongRefs = product2.getOrderDetails().toArray(); // Keep those in memory
- msg(strongRefs);
-
- final TestAdapter adapter = new TestAdapter();
- product2.eAdapters().add(adapter);
-
- details.remove(0);
- details.remove(0);
- details.remove(0);
- details.remove(4);
- details.remove(4);
- details.remove(4);
- product.getOrderDetails().removeAll(details);
- transaction.commit();
-
- // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
- // final Object[] oldValue = { null };
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == details.size();
-
- // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
- // for (Notification notification : adapter.getNotifications())
- // {
- // if (notification.getEventType() == Notification.REMOVE_MANY
- // && notification.getFeature() == getModel1Package().getProduct1_OrderDetails())
- // {
- // oldValue[0] = notification.getOldValue();
- // return true;
- // }
- // }
- //
- // return false;
- }
- }.assertNoTimeOut();
-
- // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
- // assertInstanceOf(Collection.class, oldValue[0]);
- // assertEquals(details.size(), ((Collection<?>)oldValue[0]).size());
- }
-
- /**
- * See bug 315409.
- */
- public void testInvalidationWithDeltas_SameBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOView view = session.openView();
-
- Company company = getModel1Factory().createCompany();
- company.setName("main-v1");
-
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(company);
-
- commitAndSync(transaction, view);
-
- company.setName("main-v2");
- commitAndSync(transaction, view);
-
- view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- Company company2 = view.getObject(company);
- company2.eAdapters().add(new AdapterImpl());
-
- company.setName("main-v3");
- commitAndSync(transaction, view);
-
- CDORevision revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
- assertEquals(3, revision2.getVersion());
- assertEquals(transaction.getBranch(), revision2.getBranch());
- assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
-
- company.setName("main-v4");
- commitAndSync(transaction, view);
-
- revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
- assertEquals(4, revision2.getVersion());
- assertEquals(transaction.getBranch(), revision2.getBranch());
- assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
- }
-
- /**
- * See bug 315409.
- */
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void _testInvalidationWithDeltas_SubBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- Company company = getModel1Factory().createCompany();
- company.setName("main-v1");
-
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(company);
-
- transaction.commit();
-
- company.setName("main-v2");
- transaction.commit();
-
- CDOBranch subBranch = transaction.getBranch().createBranch("SUB_BRANCH");
- transaction.setBranch(subBranch);
-
- CDOView view = session.openView(subBranch);
- view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- Company company2 = view.getObject(company);
- company2.eAdapters().add(new AdapterImpl());
-
- company.setName("sub-v1");
- commitAndSync(transaction, view);
-
- CDORevision revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
- assertEquals(1, revision2.getVersion());
- assertEquals(transaction.getBranch(), revision2.getBranch());
- assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
-
- company.setName("sub-v2");
- commitAndSync(transaction, view);
-
- revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
- assertEquals(2, revision2.getVersion());
- assertEquals(transaction.getBranch(), revision2.getBranch());
- assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
- }
-
- /**
- * @author Simon McDuff
- */
- private class CDOIDFilterChangeSubscriptionPolicy implements CDOAdapterPolicy
- {
- private Set<CDOID> ids = new HashSet<CDOID>();
-
- public CDOIDFilterChangeSubscriptionPolicy()
- {
- }
-
- public boolean isValid(EObject eObject, Adapter object)
- {
- return ids.contains(((InternalCDOObject)eObject).cdoID());
- }
-
- public Set<CDOID> getCdoIDs()
- {
- return ids;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDODeltaNotification;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Simon McDuff
+ */
+public class ChangeSubscriptionTest extends AbstractCDOTest
+{
+ public void testSameSession() throws Exception
+ {
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ final Company companyA = getModel1Factory().createCompany();
+ companyA.getCategories().add(category1A);
+
+ final CDOSession session = openSession();
+
+ // ************************************************************* //
+
+ final CDOTransaction transaction = session.openTransaction();
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(companyA);
+
+ transaction.commit();
+ final TestAdapter adapter = new TestAdapter();
+ category1A.eAdapters().add(adapter);
+
+ // ************************************************************* //
+
+ final CDOTransaction transaction2 = session.openTransaction();
+
+ final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A)
+ .cdoID(), true));
+ category1B.setName("CHANGED NAME");
+ assertEquals(0, adapter.getNotifications().length);
+
+ transaction2.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // Commit notifications from the same session always have full deltas
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length == 1;
+ }
+ }.assertNoTimeOut();
+
+ // Removing policy
+ transaction.options().removeChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ adapter.clearNotifications();
+
+ category1B.setName("CHANGED NAME_VERSION 2");
+ assertEquals(0, adapter.getNotifications().length);
+
+ transaction2.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // Commit notifications from the same session always have full deltas
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length == 1;
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testSameSession_WithoutPolicy() throws Exception
+ {
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ final Company companyA = getModel1Factory().createCompany();
+ companyA.getCategories().add(category1A);
+
+ final CDOSession session = openSession();
+
+ // ************************************************************* //
+
+ final CDOTransaction transaction = session.openTransaction();
+
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(companyA);
+
+ transaction.commit();
+ final TestAdapter adapter = new TestAdapter();
+ category1A.eAdapters().add(adapter);
+
+ // ************************************************************* //
+
+ final CDOTransaction transaction2 = session.openTransaction();
+
+ final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A)
+ .cdoID(), true));
+ category1B.setName("CHANGED NAME");
+ assertEquals(0, adapter.getNotifications().length);
+
+ transaction2.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // Commit notifications from the same session always have full deltas
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length == 1;
+ }
+ }.assertNoTimeOut();
+
+ // Adding policy
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ adapter.clearNotifications();
+
+ category1B.setName("CHANGED NAME_VERSION 2");
+ assertEquals(0, adapter.getNotifications().length);
+
+ transaction2.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // Commit notifications from the same session always have full deltas
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length == 1;
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testSeparateSession() throws Exception
+ {
+ Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ Company companyA = getModel1Factory().createCompany();
+ companyA.getCategories().add(category1A);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(companyA);
+ transaction.commit();
+
+ final TestAdapter adapter = new TestAdapter();
+ category1A.eAdapters().add(adapter);
+
+ // ************************************************************* //
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+
+ Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A).cdoID(),
+ true));
+ category1B.setName("CHANGED NAME");
+ assertEquals(0, adapter.getNotifications().length);
+
+ transaction2.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // Change subscription leads to delta nnotification
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length == 1;
+ }
+ }.assertNoTimeOut();
+
+ // Removing policy
+ transaction.options().removeChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ adapter.clearNotifications();
+
+ category1B.setName("CHANGED NAME_VERSION 2");
+ assertEquals(0, adapter.getNotifications().length);
+
+ transaction2.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // No change subscription, other session ==> no delta notification
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length != 0;
+ }
+ }.assertTimeOut();
+ }
+
+ public void testSeparateSession_WithoutPolicy() throws Exception
+ {
+ Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ Company companyA = getModel1Factory().createCompany();
+ companyA.getCategories().add(category1A);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(companyA);
+ transaction.commit();
+
+ final TestAdapter adapter = new TestAdapter();
+ category1A.eAdapters().add(adapter);
+
+ // ************************************************************* //
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+
+ Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A).cdoID(),
+ true));
+ category1B.setName("CHANGED NAME");
+ assertEquals(0, adapter.getNotifications().length);
+
+ transaction2.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // No change subscription, other session ==> no delta notification
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length != 0;
+ }
+ }.assertTimeOut();
+
+ // Adding policy
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ adapter.clearNotifications();
+
+ category1B.setName("CHANGED NAME_VERSION 2");
+ assertEquals(0, adapter.getNotifications().length);
+
+ transaction2.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // Change subscription leads to delta nnotification
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length == 1;
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testTemporaryObject() throws Exception
+ {
+ msg("Opening session");
+ final CDOSession session = openSession();
+
+ // ************************************************************* //
+
+ msg("Creating category1");
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ msg("Creating company");
+ final Company companyA = getModel1Factory().createCompany();
+
+ msg("Adding categories");
+ companyA.getCategories().add(category1A);
+
+ msg("Opening transaction");
+ final CDOTransaction transaction = session.openTransaction();
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ msg("Creating resource");
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resourceA.getContents().add(companyA);
+
+ msg("Committing");
+
+ final TestAdapter adapter = new TestAdapter();
+ category1A.eAdapters().add(adapter);
+
+ transaction.commit();
+
+ // ************************************************************* //
+
+ msg("Opening view");
+ final CDOSession session2 = openSession();
+ final CDOTransaction transaction2 = session2.openTransaction();
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A)
+ .cdoID(), true));
+
+ msg("Changing name");
+ category1B.setName("CHANGED NAME");
+
+ assertEquals(0, adapter.getNotifications().length);
+
+ msg("Committing");
+ transaction2.commit();
+
+ msg("Checking after commit");
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return adapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testSeparateSession_CUSTOM() throws Exception
+ {
+ CDOIDFilterChangeSubscriptionPolicy customPolicy = new CDOIDFilterChangeSubscriptionPolicy();
+
+ msg("Opening session");
+ final CDOSession session = openSession();
+
+ // ************************************************************* //
+
+ msg("Creating category1");
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ msg("Creating company");
+ final Company companyA = getModel1Factory().createCompany();
+
+ msg("Adding categories");
+ companyA.getCategories().add(category1A);
+
+ msg("Opening transaction");
+ final CDOTransaction transaction = session.openTransaction();
+
+ transaction.options().addChangeSubscriptionPolicy(customPolicy);
+
+ msg("Creating resource");
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resourceA.getContents().add(companyA);
+
+ msg("Committing");
+ transaction.commit();
+
+ final TestAdapter adapter = new TestAdapter();
+
+ customPolicy.getCdoIDs().add(CDOUtil.getCDOObject(category1A).cdoID());
+
+ category1A.eAdapters().add(adapter);
+ companyA.eAdapters().add(adapter);
+
+ // ************************************************************* //
+
+ msg("Opening view");
+ final CDOSession session2 = openSession();
+ final CDOTransaction transaction2 = session2.openTransaction();
+
+ final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A)
+ .cdoID(), true));
+ final Company company1B = (Company)CDOUtil.getEObject(transaction2.getObject(
+ CDOUtil.getCDOObject(companyA).cdoID(), true));
+
+ msg("Changing name");
+ category1B.setName("CHANGED NAME");
+ company1B.setName("TEST1");
+
+ assertEquals(0, adapter.getNotifications().length);
+
+ msg("Committing");
+ transaction2.commit();
+
+ msg("Checking after commit");
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return adapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut();
+
+ // Switching policy to the other
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ adapter.clearNotifications();
+
+ msg("Changing name");
+ category1B.setName("CHANGED NAME_VERSION 2");
+ company1B.setName("TEST2");
+
+ assertEquals(0, adapter.getNotifications().length);
+
+ msg("Committing");
+ transaction2.commit();
+
+ msg("Checking after commit");
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return adapter.getNotifications().length == 2;
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testNotificationChain() throws Exception
+ {
+ msg("Opening session");
+ final CDOSession session = openSession();
+
+ // ************************************************************* //
+
+ msg("Creating category1");
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ msg("Creating company");
+ final Company companyA = getModel1Factory().createCompany();
+
+ msg("Adding categories");
+ companyA.getCategories().add(category1A);
+
+ msg("Opening transaction");
+ final CDOTransaction transaction = session.openTransaction();
+
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ msg("Creating resource");
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resourceA.getContents().add(companyA);
+
+ msg("Committing");
+ transaction.commit();
+
+ final TestAdapter adapter = new TestAdapter();
+
+ companyA.eAdapters().add(adapter);
+
+ // ************************************************************* //
+
+ msg("Opening view");
+ final CDOSession session2 = openSession();
+ final CDOTransaction transaction2 = session2.openTransaction();
+
+ final Company company1B = (Company)CDOUtil.getEObject(transaction2.getObject(
+ CDOUtil.getCDOObject(companyA).cdoID(), true));
+
+ msg("Changing name");
+ company1B.setName("TEST1");
+ company1B.setCity("CITY1");
+
+ final Category category2B = getModel1Factory().createCategory();
+ company1B.getCategories().add(category2B);
+
+ assertEquals(0, adapter.getNotifications().length);
+
+ msg("Committing");
+ transaction2.commit();
+
+ msg("Checking after commit");
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return adapter.getNotifications().length == 3;
+ }
+ }.assertNoTimeOut();
+
+ int count = 0;
+ for (Notification notification : adapter.getNotifications())
+ {
+ CDODeltaNotification cdoNotification = (CDODeltaNotification)notification;
+ if (adapter.getNotifications().length - 1 == count)
+ {
+ assertEquals(false, cdoNotification.hasNext());
+ }
+ else
+ {
+ assertEquals(true, cdoNotification.hasNext());
+ }
+
+ if (notification.getFeature() == getModel1Package().getCategory_Name())
+ {
+ assertEquals(Notification.SET, notification.getEventType());
+ assertEquals("TEST1", notification.getNewStringValue());
+ }
+ else if (notification.getFeature() == getModel1Package().getAddress_City())
+ {
+ assertEquals(Notification.SET, notification.getEventType());
+ assertEquals("CITY1", notification.getNewStringValue());
+ }
+ else if (notification.getFeature() == getModel1Package().getCompany_Categories())
+ {
+ assertEquals(Notification.ADD, notification.getEventType());
+ assertEquals(1, notification.getPosition());
+ assertEquals(transaction.getObject(CDOUtil.getCDOObject(category2B).cdoID(), true), notification.getNewValue());
+ }
+ else
+ {
+ assertEquals(false, false);
+ }
+
+ count++;
+ }
+ }
+
+ public void testRemoveContained() throws Exception
+ {
+ List<Category> categories = new ArrayList<Category>();
+ categories.add(getModel1Factory().createCategory());
+
+ Company company = getModel1Factory().createCompany();
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().addAll(categories);
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ CDOSession session2 = openSession();
+ CDOView view = session2.openView();
+ view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resource2 = view.getResource(getResourcePath("/test1"));
+ Company company2 = (Company)resource2.getContents().get(0);
+
+ Object[] strongRefs = company2.getCategories().toArray(); // Keep those in memory
+ msg(strongRefs);
+
+ final TestAdapter adapter = new TestAdapter();
+ company2.eAdapters().add(adapter);
+
+ company.getCategories().removeAll(categories);
+ transaction.commit();
+
+ final Object[] oldValue = { null };
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ for (Notification notification : adapter.getNotifications())
+ {
+ if (notification.getEventType() == Notification.REMOVE
+ && notification.getFeature() == getModel1Package().getCompany_Categories())
+ {
+ oldValue[0] = notification.getOldValue();
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }.assertNoTimeOut();
+
+ assertInstanceOf(Category.class, CDOUtil.getEObject((EObject)oldValue[0]));
+ }
+
+ public void testRemoveManyContained() throws Exception
+ {
+ final List<Category> categories = new ArrayList<Category>();
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+
+ Company company = getModel1Factory().createCompany();
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().addAll(categories);
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ CDOSession session2 = openSession();
+ CDOView view = session2.openView();
+ view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resource2 = view.getResource(getResourcePath("/test1"));
+ Company company2 = (Company)resource2.getContents().get(0);
+
+ Object[] strongRefs = company2.getCategories().toArray(); // Keep those in memory
+ msg(strongRefs);
+
+ final TestAdapter adapter = new TestAdapter();
+ company2.eAdapters().add(adapter);
+
+ company.getCategories().removeAll(categories);
+ transaction.commit();
+
+ // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
+ // final Object[] oldValue = { null };
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return adapter.getNotifications().length == categories.size();
+
+ // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
+ // for (Notification notification : adapter.getNotifications())
+ // {
+ // if (notification.getEventType() == Notification.REMOVE_MANY
+ // && notification.getFeature() == getModel1Package().getCompany_Categories())
+ // {
+ // oldValue[0] = notification.getOldValue();
+ // return true;
+ // }
+ // }
+ //
+ // return false;
+ }
+ }.assertNoTimeOut();
+
+ // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
+ // assertInstanceOf(Collection.class, oldValue[0]);
+ // assertEquals(categories.size(), ((Collection<?>)oldValue[0]).size());
+ }
+
+ public void testRemoveXRef() throws Exception
+ {
+ List<OrderDetail> details = new ArrayList<OrderDetail>();
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("test1");
+ product.getOrderDetails().addAll(details);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(product);
+ resource.getContents().addAll(details);
+ transaction.commit();
+
+ CDOSession session2 = openSession();
+ CDOView view = session2.openView();
+ view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resource2 = view.getResource(getResourcePath("/test1"));
+ Product1 product2 = (Product1)resource2.getContents().get(0);
+
+ Object[] strongRefs = product2.getOrderDetails().toArray(); // Keep those in memory
+ msg(strongRefs);
+
+ final TestAdapter adapter = new TestAdapter();
+ product2.eAdapters().add(adapter);
+
+ details.remove(0);
+ details.remove(0);
+ details.remove(0);
+ details.remove(1);
+ details.remove(1);
+ details.remove(1);
+ product.getOrderDetails().removeAll(details);
+ transaction.commit();
+
+ final Object[] oldValue = { null };
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ for (Notification notification : adapter.getNotifications())
+ {
+ if (notification.getEventType() == Notification.REMOVE
+ && notification.getFeature() == getModel1Package().getProduct1_OrderDetails())
+ {
+ oldValue[0] = notification.getOldValue();
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }.assertNoTimeOut();
+
+ assertInstanceOf(OrderDetail.class, CDOUtil.getEObject((EObject)oldValue[0]));
+ }
+
+ public void testRemoveManyXRef() throws Exception
+ {
+ final List<OrderDetail> details = new ArrayList<OrderDetail>();
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+ details.add(getModel1Factory().createOrderDetail());
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("test1");
+ product.getOrderDetails().addAll(details);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(product);
+ resource.getContents().addAll(details);
+ transaction.commit();
+
+ CDOSession session2 = openSession();
+ CDOView view = session2.openView();
+ view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resource2 = view.getResource(getResourcePath("/test1"));
+ Product1 product2 = (Product1)resource2.getContents().get(0);
+
+ Object[] strongRefs = product2.getOrderDetails().toArray(); // Keep those in memory
+ msg(strongRefs);
+
+ final TestAdapter adapter = new TestAdapter();
+ product2.eAdapters().add(adapter);
+
+ details.remove(0);
+ details.remove(0);
+ details.remove(0);
+ details.remove(4);
+ details.remove(4);
+ details.remove(4);
+ product.getOrderDetails().removeAll(details);
+ transaction.commit();
+
+ // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
+ // final Object[] oldValue = { null };
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return adapter.getNotifications().length == details.size();
+
+ // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
+ // for (Notification notification : adapter.getNotifications())
+ // {
+ // if (notification.getEventType() == Notification.REMOVE_MANY
+ // && notification.getFeature() == getModel1Package().getProduct1_OrderDetails())
+ // {
+ // oldValue[0] = notification.getOldValue();
+ // return true;
+ // }
+ // }
+ //
+ // return false;
+ }
+ }.assertNoTimeOut();
+
+ // TODO Consider to uncomment the following if bug 317144 is addressed in EMF
+ // assertInstanceOf(Collection.class, oldValue[0]);
+ // assertEquals(details.size(), ((Collection<?>)oldValue[0]).size());
+ }
+
+ /**
+ * See bug 315409.
+ */
+ public void testInvalidationWithDeltas_SameBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOView view = session.openView();
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("main-v1");
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+
+ commitAndSync(transaction, view);
+
+ company.setName("main-v2");
+ commitAndSync(transaction, view);
+
+ view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ Company company2 = view.getObject(company);
+ company2.eAdapters().add(new AdapterImpl());
+
+ company.setName("main-v3");
+ commitAndSync(transaction, view);
+
+ CDORevision revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
+ assertEquals(3, revision2.getVersion());
+ assertEquals(transaction.getBranch(), revision2.getBranch());
+ assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
+
+ company.setName("main-v4");
+ commitAndSync(transaction, view);
+
+ revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
+ assertEquals(4, revision2.getVersion());
+ assertEquals(transaction.getBranch(), revision2.getBranch());
+ assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
+ }
+
+ /**
+ * See bug 315409.
+ */
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void _testInvalidationWithDeltas_SubBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("main-v1");
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+
+ transaction.commit();
+
+ company.setName("main-v2");
+ transaction.commit();
+
+ CDOBranch subBranch = transaction.getBranch().createBranch("SUB_BRANCH");
+ transaction.setBranch(subBranch);
+
+ CDOView view = session.openView(subBranch);
+ view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ Company company2 = view.getObject(company);
+ company2.eAdapters().add(new AdapterImpl());
+
+ company.setName("sub-v1");
+ commitAndSync(transaction, view);
+
+ CDORevision revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
+ assertEquals(1, revision2.getVersion());
+ assertEquals(transaction.getBranch(), revision2.getBranch());
+ assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
+
+ company.setName("sub-v2");
+ commitAndSync(transaction, view);
+
+ revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
+ assertEquals(2, revision2.getVersion());
+ assertEquals(transaction.getBranch(), revision2.getBranch());
+ assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
+ }
+
+ /**
+ * @author Simon McDuff
+ */
+ private class CDOIDFilterChangeSubscriptionPolicy implements CDOAdapterPolicy
+ {
+ private Set<CDOID> ids = new HashSet<CDOID>();
+
+ public CDOIDFilterChangeSubscriptionPolicy()
+ {
+ }
+
+ public boolean isValid(EObject eObject, Adapter object)
+ {
+ return ids.contains(((InternalCDOObject)eObject).cdoID());
+ }
+
+ public Set<CDOID> getCdoIDs()
+ {
+ return ids;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java
index 67651310ff..de53368210 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java
@@ -1,978 +1,978 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.common.commit.handler.AsyncCommitInfoHandler;
-import org.eclipse.emf.cdo.common.commit.handler.TextCommitInfoLog;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
-import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.emf.cdo.server.StoreThreadLocal;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.security.PasswordCredentials;
-import org.eclipse.net4j.util.security.PasswordCredentialsProvider;
-import org.eclipse.net4j.util.security.UserManager;
-
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Andre Dietisheim
- */
-public class CommitInfoTest extends AbstractCDOTest
-{
- private static final String REPO_NAME = "commitinforepo";
-
- private static final String USER_ID = "stepper";
-
- private static final char[] PASSWORD = "eike2010".toCharArray();
-
- private static final String RESOURCE_PATH = "/res";
-
- public void testLocalTimestamp() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
- long timeStamp = commitInfo.getTimeStamp();
- assertEquals(true, timeStamp > CDOBranchPoint.UNSPECIFIED_DATE);
- }
-
- public void testLocalBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(transaction.getBranch(), commitInfo.getBranch());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testLocalSubBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(transaction.getBranch(), commitInfo.getBranch());
- }
-
- public void testLocalUser() throws Exception
- {
- UserManager userManager = new UserManager();
- userManager.activate();
- userManager.addUser(USER_ID, PASSWORD);
-
- getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
- getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
- new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
-
- getRepository(REPO_NAME);
-
- CDOSession session = openSession(REPO_NAME);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(USER_ID, commitInfo.getUserID());
- }
-
- public void testLocalComment() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- String comment = "Andre";
- transaction.setCommitComment(comment);
-
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(comment, commitInfo.getComment());
- }
-
- @Skips("MongoDB")
- @CleanRepositoriesBefore
- public void testServerTimestamp() throws Exception
- {
- CDOSession session = openSession();
- InternalSession serverSession = getRepository().getSessionManager().getSession(session.getSessionID());
- StoreThreadLocal.setSession(serverSession);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getTimeStamp(), infos.get(1).getTimeStamp());
- }
-
- @Skips("MongoDB")
- @CleanRepositoriesBefore
- public void testServerBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
-
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- @CleanRepositoriesBefore
- public void testServerSubBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
- }
-
- @Skips("MongoDB")
- @CleanRepositoriesBefore
- public void testServerUser() throws Exception
- {
- UserManager userManager = new UserManager();
- userManager.activate();
- userManager.addUser(USER_ID, PASSWORD);
-
- getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
- getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
- new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
-
- getRepository(REPO_NAME);
-
- CDOSession session = openSession(REPO_NAME);
- StoreThreadLocal.setSession(getRepository(REPO_NAME).getSessionManager().getSession(session.getSessionID()));
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getUserID(), infos.get(1).getUserID());
- }
-
- @Skips("MongoDB")
- @CleanRepositoriesBefore
- public void testServerComment() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- String comment = "Andre";
- transaction.setCommitComment(comment);
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getComment(), infos.get(1).getComment());
- }
-
- @Skips("MongoDB")
- @CleanRepositoriesBefore
- public void testServerTimestampWithBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(
- getRepository().getBranchManager().getBranch(transaction.getBranch().getID()), CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getTimeStamp(), infos.get(1).getTimeStamp());
- }
-
- @Skips("MongoDB")
- @CleanRepositoriesBefore
- public void testServerBranchWithBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(
- getRepository().getBranchManager().getBranch(transaction.getBranch().getID()), CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testServerSubBranchWithBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(
- getRepository().getBranchManager().getBranch(transaction.getBranch().getID()), CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(1, infos.size());
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
- }
-
- @Skips("MongoDB")
- @CleanRepositoriesBefore
- public void testServerUserWithBranch() throws Exception
- {
- UserManager userManager = new UserManager();
- userManager.activate();
- userManager.addUser(USER_ID, PASSWORD);
-
- getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
- getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
- new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
-
- getRepository(REPO_NAME);
-
- CDOSession session = openSession(REPO_NAME);
- StoreThreadLocal.setSession(getRepository(REPO_NAME).getSessionManager().getSession(session.getSessionID()));
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(
- getRepository(REPO_NAME).getBranchManager().getBranch(transaction.getBranch().getID()),
- CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getUserID(), infos.get(1).getUserID());
- }
-
- @Skips("MongoDB")
- @CleanRepositoriesBefore
- public void testServerCommentWithBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- String comment = "Andre";
- transaction.setCommitComment(comment);
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(
- getRepository().getBranchManager().getBranch(transaction.getBranch().getID()), CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getComment(), infos.get(1).getComment());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testServerTimestampWithWrongBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testServerBranchWithWrongBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testServerSubBranchWithWrongBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testServerUserWithWrongBranch() throws Exception
- {
- UserManager userManager = new UserManager();
- userManager.activate();
- userManager.addUser(USER_ID, PASSWORD);
-
- getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
- getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
- new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
-
- getRepository(REPO_NAME);
-
- CDOSession session = openSession(REPO_NAME);
- StoreThreadLocal.setSession(getRepository(REPO_NAME).getSessionManager().getSession(session.getSessionID()));
-
- CDOBranch wrong = getRepository(REPO_NAME).getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- transaction.commit();
-
- Handler handler = new Handler();
- getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testServerCommentWithWrongBranch() throws Exception
- {
- CDOSession session = openSession();
- StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
-
- CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- String comment = "Andre";
- transaction.setCommitComment(comment);
-
- transaction.commit();
-
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @CleanRepositoriesBefore
- public void testClientTimestamp() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getTimeStamp(), infos.get(1).getTimeStamp());
- }
-
- @CleanRepositoriesBefore
- public void testClientBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- @CleanRepositoriesBefore
- public void testClientSubBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
- }
-
- @CleanRepositoriesBefore
- public void testClientUser() throws Exception
- {
- UserManager userManager = new UserManager();
- userManager.activate();
- userManager.addUser(USER_ID, PASSWORD);
-
- getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
- getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
- new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
-
- getRepository(REPO_NAME);
-
- CDOSession session = openSession(REPO_NAME);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getUserID(), infos.get(1).getUserID());
- }
-
- @CleanRepositoriesBefore
- public void testClientComment() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- String comment = "Andre";
- transaction.setCommitComment(comment);
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getComment(), infos.get(1).getComment());
- }
-
- @CleanRepositoriesBefore
- public void testClientTimestampWithBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getTimeStamp(), infos.get(1).getTimeStamp());
- }
-
- @CleanRepositoriesBefore
- public void testClientBranchWithBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testClientSubBranchWithBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(1, infos.size());
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
- }
-
- @CleanRepositoriesBefore
- public void testClientUserWithBranch() throws Exception
- {
- UserManager userManager = new UserManager();
- userManager.activate();
- userManager.addUser(USER_ID, PASSWORD);
-
- getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
- getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
- new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
-
- getRepository(REPO_NAME);
-
- CDOSession session = openSession(REPO_NAME);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getUserID(), infos.get(1).getUserID());
- }
-
- @CleanRepositoriesBefore
- public void testClientCommentWithBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- String comment = "Andre";
- transaction.setCommitComment(comment);
-
- CDOCommitInfo commitInfo = transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getComment(), infos.get(1).getComment());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testClientTimestampWithWrongBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testClientBranchWithWrongBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testClientSubBranchWithWrongBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testClientUserWithWrongBranch() throws Exception
- {
- UserManager userManager = new UserManager();
- userManager.activate();
- userManager.addUser(USER_ID, PASSWORD);
-
- getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
- getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
- new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
-
- getRepository(REPO_NAME);
-
- CDOSession session = openSession(REPO_NAME);
- CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testClientCommentWithWrongBranch() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
-
- String comment = "Andre";
- transaction.setCommitComment(comment);
-
- transaction.commit();
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(0, infos.size());
- }
-
- @CleanRepositoriesBefore
- public void testMultipleEntries() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
-
- List<CDOCommitInfo> expected = new ArrayList<CDOCommitInfo>();
- final int COMMITS = 20;
- for (int i = 0; i < COMMITS; i++)
- {
- resource.getContents().add(getModel1Factory().createProduct1());
- transaction.setCommitComment("Commit " + i);
- expected.add(transaction.commit());
- }
-
- Handler handler = new Handler();
- session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, handler);
-
- List<CDOCommitInfo> infos = handler.getInfos();
-
- assertEquals(1 + COMMITS, infos.size()); // Initial root resource commit + COMMITS
- for (int i = 0; i < COMMITS; i++)
- {
- assertEquals(expected.get(i), infos.get(1 + i));
- }
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
- public void testLogThroughClient() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
-
- final int COMMITS = 20;
- for (int i = 0; i < COMMITS; i++)
- {
- resource.getContents().add(getModel1Factory().createProduct1());
- transaction.setCommitComment("Commit " + i);
- transaction.commit();
- }
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- TextCommitInfoLog log = new TextCommitInfoLog(baos);
-
- session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
- CDOBranchPoint.UNSPECIFIED_DATE, log);
-
- System.out.println(baos.toString());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
- public void testLogThroughWriteAccessHandler() throws Exception
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final TextCommitInfoLog log = new TextCommitInfoLog(baos);
-
- getRepository().addHandler(new IRepository.WriteAccessHandler()
- {
- public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor) throws RuntimeException
- {
- }
-
- public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor)
- {
- log.handleCommitInfo(commitContext.createCommitInfo());
- }
- });
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
-
- final int COMMITS = 20;
- for (int i = 0; i < COMMITS; i++)
- {
- resource.getContents().add(getModel1Factory().createProduct1());
- transaction.setCommitComment("Commit " + i);
- transaction.commit();
- }
-
- System.out.println(baos.toString());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
- public void testLogThroughCommitInfoHandler() throws Exception
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- getRepository().addCommitInfoHandler(new TextCommitInfoLog(baos));
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
-
- final int COMMITS = 20;
- for (int i = 0; i < COMMITS; i++)
- {
- resource.getContents().add(getModel1Factory().createProduct1());
- transaction.setCommitComment("Commit " + i);
- transaction.commit();
- }
-
- System.out.println(baos.toString());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
- public void testLogAsync() throws Exception
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- AsyncCommitInfoHandler log = new AsyncCommitInfoHandler(new TextCommitInfoLog(baos));
- log.activate();
- getRepository().addCommitInfoHandler(log);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
-
- final int COMMITS = 20;
- for (int i = 0; i < COMMITS; i++)
- {
- resource.getContents().add(getModel1Factory().createProduct1());
- transaction.setCommitComment("Commit " + i);
- transaction.commit();
- }
-
- log.deactivate();
- LifecycleUtil.waitForInactive(log, Long.MAX_VALUE);
-
- System.out.println(baos.toString());
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class Handler implements CDOCommitInfoHandler
- {
- private List<CDOCommitInfo> infos = new ArrayList<CDOCommitInfo>();
-
- public List<CDOCommitInfo> getInfos()
- {
- return infos;
- }
-
- public void handleCommitInfo(CDOCommitInfo commitInfo)
- {
- infos.add(commitInfo);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
+import org.eclipse.emf.cdo.common.commit.handler.AsyncCommitInfoHandler;
+import org.eclipse.emf.cdo.common.commit.handler.TextCommitInfoLog;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.server.StoreThreadLocal;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalSession;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.security.PasswordCredentials;
+import org.eclipse.net4j.util.security.PasswordCredentialsProvider;
+import org.eclipse.net4j.util.security.UserManager;
+
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CommitInfoTest extends AbstractCDOTest
+{
+ private static final String REPO_NAME = "commitinforepo";
+
+ private static final String USER_ID = "stepper";
+
+ private static final char[] PASSWORD = "eike2010".toCharArray();
+
+ private static final String RESOURCE_PATH = "/res";
+
+ public void testLocalTimestamp() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ long timeStamp = commitInfo.getTimeStamp();
+ assertEquals(true, timeStamp > CDOBranchPoint.UNSPECIFIED_DATE);
+ }
+
+ public void testLocalBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(transaction.getBranch(), commitInfo.getBranch());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testLocalSubBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(transaction.getBranch(), commitInfo.getBranch());
+ }
+
+ public void testLocalUser() throws Exception
+ {
+ UserManager userManager = new UserManager();
+ userManager.activate();
+ userManager.addUser(USER_ID, PASSWORD);
+
+ getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
+ getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
+ new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
+
+ getRepository(REPO_NAME);
+
+ CDOSession session = openSession(REPO_NAME);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(USER_ID, commitInfo.getUserID());
+ }
+
+ public void testLocalComment() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(comment, commitInfo.getComment());
+ }
+
+ @Skips("MongoDB")
+ @CleanRepositoriesBefore
+ public void testServerTimestamp() throws Exception
+ {
+ CDOSession session = openSession();
+ InternalSession serverSession = getRepository().getSessionManager().getSession(session.getSessionID());
+ StoreThreadLocal.setSession(serverSession);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getTimeStamp(), infos.get(1).getTimeStamp());
+ }
+
+ @Skips("MongoDB")
+ @CleanRepositoriesBefore
+ public void testServerBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ @CleanRepositoriesBefore
+ public void testServerSubBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
+ }
+
+ @Skips("MongoDB")
+ @CleanRepositoriesBefore
+ public void testServerUser() throws Exception
+ {
+ UserManager userManager = new UserManager();
+ userManager.activate();
+ userManager.addUser(USER_ID, PASSWORD);
+
+ getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
+ getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
+ new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
+
+ getRepository(REPO_NAME);
+
+ CDOSession session = openSession(REPO_NAME);
+ StoreThreadLocal.setSession(getRepository(REPO_NAME).getSessionManager().getSession(session.getSessionID()));
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getUserID(), infos.get(1).getUserID());
+ }
+
+ @Skips("MongoDB")
+ @CleanRepositoriesBefore
+ public void testServerComment() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getComment(), infos.get(1).getComment());
+ }
+
+ @Skips("MongoDB")
+ @CleanRepositoriesBefore
+ public void testServerTimestampWithBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(
+ getRepository().getBranchManager().getBranch(transaction.getBranch().getID()), CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getTimeStamp(), infos.get(1).getTimeStamp());
+ }
+
+ @Skips("MongoDB")
+ @CleanRepositoriesBefore
+ public void testServerBranchWithBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(
+ getRepository().getBranchManager().getBranch(transaction.getBranch().getID()), CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testServerSubBranchWithBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(
+ getRepository().getBranchManager().getBranch(transaction.getBranch().getID()), CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(1, infos.size());
+ assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ }
+
+ @Skips("MongoDB")
+ @CleanRepositoriesBefore
+ public void testServerUserWithBranch() throws Exception
+ {
+ UserManager userManager = new UserManager();
+ userManager.activate();
+ userManager.addUser(USER_ID, PASSWORD);
+
+ getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
+ getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
+ new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
+
+ getRepository(REPO_NAME);
+
+ CDOSession session = openSession(REPO_NAME);
+ StoreThreadLocal.setSession(getRepository(REPO_NAME).getSessionManager().getSession(session.getSessionID()));
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(
+ getRepository(REPO_NAME).getBranchManager().getBranch(transaction.getBranch().getID()),
+ CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getUserID(), infos.get(1).getUserID());
+ }
+
+ @Skips("MongoDB")
+ @CleanRepositoriesBefore
+ public void testServerCommentWithBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(
+ getRepository().getBranchManager().getBranch(transaction.getBranch().getID()), CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getComment(), infos.get(1).getComment());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testServerTimestampWithWrongBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testServerBranchWithWrongBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testServerSubBranchWithWrongBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testServerUserWithWrongBranch() throws Exception
+ {
+ UserManager userManager = new UserManager();
+ userManager.activate();
+ userManager.addUser(USER_ID, PASSWORD);
+
+ getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
+ getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
+ new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
+
+ getRepository(REPO_NAME);
+
+ CDOSession session = openSession(REPO_NAME);
+ StoreThreadLocal.setSession(getRepository(REPO_NAME).getSessionManager().getSession(session.getSessionID()));
+
+ CDOBranch wrong = getRepository(REPO_NAME).getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testServerCommentWithWrongBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
+
+ CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @CleanRepositoriesBefore
+ public void testClientTimestamp() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getTimeStamp(), infos.get(1).getTimeStamp());
+ }
+
+ @CleanRepositoriesBefore
+ public void testClientBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ @CleanRepositoriesBefore
+ public void testClientSubBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
+ }
+
+ @CleanRepositoriesBefore
+ public void testClientUser() throws Exception
+ {
+ UserManager userManager = new UserManager();
+ userManager.activate();
+ userManager.addUser(USER_ID, PASSWORD);
+
+ getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
+ getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
+ new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
+
+ getRepository(REPO_NAME);
+
+ CDOSession session = openSession(REPO_NAME);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getUserID(), infos.get(1).getUserID());
+ }
+
+ @CleanRepositoriesBefore
+ public void testClientComment() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getComment(), infos.get(1).getComment());
+ }
+
+ @CleanRepositoriesBefore
+ public void testClientTimestampWithBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getTimeStamp(), infos.get(1).getTimeStamp());
+ }
+
+ @CleanRepositoriesBefore
+ public void testClientBranchWithBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getBranch(), infos.get(1).getBranch());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testClientSubBranchWithBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(1, infos.size());
+ assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ }
+
+ @CleanRepositoriesBefore
+ public void testClientUserWithBranch() throws Exception
+ {
+ UserManager userManager = new UserManager();
+ userManager.activate();
+ userManager.addUser(USER_ID, PASSWORD);
+
+ getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
+ getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
+ new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
+
+ getRepository(REPO_NAME);
+
+ CDOSession session = openSession(REPO_NAME);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getUserID(), infos.get(1).getUserID());
+ }
+
+ @CleanRepositoriesBefore
+ public void testClientCommentWithBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
+
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(transaction.getBranch(), CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getComment(), infos.get(1).getComment());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testClientTimestampWithWrongBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testClientBranchWithWrongBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testClientSubBranchWithWrongBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testClientUserWithWrongBranch() throws Exception
+ {
+ UserManager userManager = new UserManager();
+ userManager.activate();
+ userManager.addUser(USER_ID, PASSWORD);
+
+ getTestProperties().put(RepositoryConfig.PROP_TEST_USER_MANAGER, userManager);
+ getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER,
+ new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, PASSWORD)));
+
+ getRepository(REPO_NAME);
+
+ CDOSession session = openSession(REPO_NAME);
+ CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testClientCommentWithWrongBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch wrong = session.getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
+
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
+
+ transaction.commit();
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(0, infos.size());
+ }
+
+ @CleanRepositoriesBefore
+ public void testMultipleEntries() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+
+ List<CDOCommitInfo> expected = new ArrayList<CDOCommitInfo>();
+ final int COMMITS = 20;
+ for (int i = 0; i < COMMITS; i++)
+ {
+ resource.getContents().add(getModel1Factory().createProduct1());
+ transaction.setCommitComment("Commit " + i);
+ expected.add(transaction.commit());
+ }
+
+ Handler handler = new Handler();
+ session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, handler);
+
+ List<CDOCommitInfo> infos = handler.getInfos();
+
+ assertEquals(1 + COMMITS, infos.size()); // Initial root resource commit + COMMITS
+ for (int i = 0; i < COMMITS; i++)
+ {
+ assertEquals(expected.get(i), infos.get(1 + i));
+ }
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+ public void testLogThroughClient() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+
+ final int COMMITS = 20;
+ for (int i = 0; i < COMMITS; i++)
+ {
+ resource.getContents().add(getModel1Factory().createProduct1());
+ transaction.setCommitComment("Commit " + i);
+ transaction.commit();
+ }
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ TextCommitInfoLog log = new TextCommitInfoLog(baos);
+
+ session.getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE,
+ CDOBranchPoint.UNSPECIFIED_DATE, log);
+
+ System.out.println(baos.toString());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+ public void testLogThroughWriteAccessHandler() throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final TextCommitInfoLog log = new TextCommitInfoLog(baos);
+
+ getRepository().addHandler(new IRepository.WriteAccessHandler()
+ {
+ public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor) throws RuntimeException
+ {
+ }
+
+ public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor)
+ {
+ log.handleCommitInfo(commitContext.createCommitInfo());
+ }
+ });
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+
+ final int COMMITS = 20;
+ for (int i = 0; i < COMMITS; i++)
+ {
+ resource.getContents().add(getModel1Factory().createProduct1());
+ transaction.setCommitComment("Commit " + i);
+ transaction.commit();
+ }
+
+ System.out.println(baos.toString());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+ public void testLogThroughCommitInfoHandler() throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ getRepository().addCommitInfoHandler(new TextCommitInfoLog(baos));
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+
+ final int COMMITS = 20;
+ for (int i = 0; i < COMMITS; i++)
+ {
+ resource.getContents().add(getModel1Factory().createProduct1());
+ transaction.setCommitComment("Commit " + i);
+ transaction.commit();
+ }
+
+ System.out.println(baos.toString());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+ public void testLogAsync() throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ AsyncCommitInfoHandler log = new AsyncCommitInfoHandler(new TextCommitInfoLog(baos));
+ log.activate();
+ getRepository().addCommitInfoHandler(log);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+
+ final int COMMITS = 20;
+ for (int i = 0; i < COMMITS; i++)
+ {
+ resource.getContents().add(getModel1Factory().createProduct1());
+ transaction.setCommitComment("Commit " + i);
+ transaction.commit();
+ }
+
+ log.deactivate();
+ LifecycleUtil.waitForInactive(log, Long.MAX_VALUE);
+
+ System.out.println(baos.toString());
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class Handler implements CDOCommitInfoHandler
+ {
+ private List<CDOCommitInfo> infos = new ArrayList<CDOCommitInfo>();
+
+ public List<CDOCommitInfo> getInfos()
+ {
+ return infos;
+ }
+
+ public void handleCommitInfo(CDOCommitInfo commitInfo)
+ {
+ infos.add(commitInfo);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CompareTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CompareTest.java
index 663ebcfbfe..6a681ddba0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CompareTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CompareTest.java
@@ -1,255 +1,255 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * @author Eike Stepper
- */
-@Requires(IRepositoryConfig.CAPABILITY_AUDITING)
-public class CompareTest extends AbstractCDOTest
-{
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testFromEmptyBranches() throws Exception
- {
- CDOSession session = openSession();
- ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol().setTimeout(1000000000);
-
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time2 = transaction.commit().getTimeStamp();
- CDOBranch source2 = mainBranch.createBranch("source2", time2);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time3 = transaction.commit().getTimeStamp();
- CDOBranch source3 = mainBranch.createBranch("source3", time3);
-
- assertCompare(session, mainBranch.getHead(), source1.getHead(), 7, 1, 0);
- assertCompare(session, mainBranch.getHead(), source2.getHead(), 3, 1, 0);
- assertCompare(session, mainBranch.getHead(), source3.getHead(), 0, 0, 0);
-
- assertCompare(session, mainBranch.getHead(), mainBranch.getPoint(time1), 7, 1, 0);
- assertCompare(session, mainBranch.getHead(), mainBranch.getPoint(time2), 3, 1, 0);
- assertCompare(session, mainBranch.getHead(), mainBranch.getPoint(time3), 0, 0, 0);
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testFromBranchWithAdditions() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- transaction.commit();
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- transaction.commit();
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- addCompany(contents1);
- addCompany(contents1);
- tx1.commit();
- tx1.close();
-
- assertCompare(session, mainBranch.getHead(), source1.getHead(), 7, 1, 2);
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testAdditionsInSourceAndTarget() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time2 = transaction.commit().getTimeStamp();
- CDOBranch source2 = mainBranch.createBranch("source2", time2);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- transaction.commit();
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- addCompany(contents1);
- addCompany(contents1);
- tx1.commit();
- tx1.close();
-
- sleep(10);
- CDOTransaction tx2 = session.openTransaction(source2);
- CDOResource res2 = tx2.getResource(getResourcePath("/res"));
- EList<EObject> contents2 = res2.getContents();
- addCompany(contents2);
- tx2.commit();
- tx2.close();
-
- assertCompare(session, mainBranch.getHead(), source1.getHead(), 7, 1, 2);
- assertCompare(session, mainBranch.getHead(), source2.getHead(), 3, 1, 1);
- assertCompare(session, source1.getHead(), source2.getHead(), 2, 1, 5);
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testFromBranchWithChangesInSource() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource("/res" + 0);
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time = transaction.commit().getTimeStamp();
- CDOBranch source = mainBranch.createBranch("source" + 0, time);
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source);
- CDOResource res1 = tx1.getResource(getResourcePath("/res" + 0));
- EList<EObject> contents1 = res1.getContents();
- ((Company)contents1.get(0)).setName("Company0");
- ((Company)contents1.get(1)).setName("Company1");
- ((Company)contents1.get(2)).setName("Company2");
- tx1.commit();
- tx1.close();
-
- assertCompare(session, mainBranch.getHead(), source.getHead(), 0, 3, 0);
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testFromBranchWithRemovalsInSource() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time = transaction.commit().getTimeStamp();
- CDOBranch source = mainBranch.createBranch("source", time);
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- ((Company)contents1.get(0)).setName("Company0");
- contents1.remove(1);
- tx1.commit();
- tx1.close();
-
- assertCompare(session, mainBranch.getHead(), source.getHead(), 1, 2, 0);
- }
-
- private Company addCompany(EList<EObject> contents)
- {
- Company company = getModel1Factory().createCompany();
- contents.add(company);
- return company;
- }
-
- private void assertCompare(CDOSession session, CDOBranchPoint target, CDOBranchPoint source, int n, int c, int d)
- {
- CDOView view = session.openView(target.getBranch(), target.getTimeStamp());
- CDOChangeSetData result = view.compareRevisions(source);
- assertEquals(n == 0 && c == 0 && d == 0, result.isEmpty());
- assertEquals("NewObjects", n, result.getNewObjects().size());
- assertEquals("ChangedObjects", c, result.getChangedObjects().size());
- assertEquals("DetachedObjects", d, result.getDetachedObjects().size());
- view.close();
-
- view = session.openView(source.getBranch(), source.getTimeStamp());
- result = view.compareRevisions(target);
- assertEquals(n == 0 && c == 0 && d == 0, result.isEmpty());
- assertEquals("NewObjects", d, result.getNewObjects().size());
- assertEquals("ChangedObjects", c, result.getChangedObjects().size());
- assertEquals("DetachedObjects", n, result.getDetachedObjects().size());
- view.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * @author Eike Stepper
+ */
+@Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+public class CompareTest extends AbstractCDOTest
+{
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testFromEmptyBranches() throws Exception
+ {
+ CDOSession session = openSession();
+ ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol().setTimeout(1000000000);
+
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time2 = transaction.commit().getTimeStamp();
+ CDOBranch source2 = mainBranch.createBranch("source2", time2);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time3 = transaction.commit().getTimeStamp();
+ CDOBranch source3 = mainBranch.createBranch("source3", time3);
+
+ assertCompare(session, mainBranch.getHead(), source1.getHead(), 7, 1, 0);
+ assertCompare(session, mainBranch.getHead(), source2.getHead(), 3, 1, 0);
+ assertCompare(session, mainBranch.getHead(), source3.getHead(), 0, 0, 0);
+
+ assertCompare(session, mainBranch.getHead(), mainBranch.getPoint(time1), 7, 1, 0);
+ assertCompare(session, mainBranch.getHead(), mainBranch.getPoint(time2), 3, 1, 0);
+ assertCompare(session, mainBranch.getHead(), mainBranch.getPoint(time3), 0, 0, 0);
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testFromBranchWithAdditions() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ addCompany(contents1);
+ addCompany(contents1);
+ tx1.commit();
+ tx1.close();
+
+ assertCompare(session, mainBranch.getHead(), source1.getHead(), 7, 1, 2);
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testAdditionsInSourceAndTarget() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time2 = transaction.commit().getTimeStamp();
+ CDOBranch source2 = mainBranch.createBranch("source2", time2);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ addCompany(contents1);
+ addCompany(contents1);
+ tx1.commit();
+ tx1.close();
+
+ sleep(10);
+ CDOTransaction tx2 = session.openTransaction(source2);
+ CDOResource res2 = tx2.getResource(getResourcePath("/res"));
+ EList<EObject> contents2 = res2.getContents();
+ addCompany(contents2);
+ tx2.commit();
+ tx2.close();
+
+ assertCompare(session, mainBranch.getHead(), source1.getHead(), 7, 1, 2);
+ assertCompare(session, mainBranch.getHead(), source2.getHead(), 3, 1, 1);
+ assertCompare(session, source1.getHead(), source2.getHead(), 2, 1, 5);
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testFromBranchWithChangesInSource() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource("/res" + 0);
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time = transaction.commit().getTimeStamp();
+ CDOBranch source = mainBranch.createBranch("source" + 0, time);
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res" + 0));
+ EList<EObject> contents1 = res1.getContents();
+ ((Company)contents1.get(0)).setName("Company0");
+ ((Company)contents1.get(1)).setName("Company1");
+ ((Company)contents1.get(2)).setName("Company2");
+ tx1.commit();
+ tx1.close();
+
+ assertCompare(session, mainBranch.getHead(), source.getHead(), 0, 3, 0);
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testFromBranchWithRemovalsInSource() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time = transaction.commit().getTimeStamp();
+ CDOBranch source = mainBranch.createBranch("source", time);
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ ((Company)contents1.get(0)).setName("Company0");
+ contents1.remove(1);
+ tx1.commit();
+ tx1.close();
+
+ assertCompare(session, mainBranch.getHead(), source.getHead(), 1, 2, 0);
+ }
+
+ private Company addCompany(EList<EObject> contents)
+ {
+ Company company = getModel1Factory().createCompany();
+ contents.add(company);
+ return company;
+ }
+
+ private void assertCompare(CDOSession session, CDOBranchPoint target, CDOBranchPoint source, int n, int c, int d)
+ {
+ CDOView view = session.openView(target.getBranch(), target.getTimeStamp());
+ CDOChangeSetData result = view.compareRevisions(source);
+ assertEquals(n == 0 && c == 0 && d == 0, result.isEmpty());
+ assertEquals("NewObjects", n, result.getNewObjects().size());
+ assertEquals("ChangedObjects", c, result.getChangedObjects().size());
+ assertEquals("DetachedObjects", d, result.getDetachedObjects().size());
+ view.close();
+
+ view = session.openView(source.getBranch(), source.getTimeStamp());
+ result = view.compareRevisions(target);
+ assertEquals(n == 0 && c == 0 && d == 0, result.isEmpty());
+ assertEquals("NewObjects", d, result.getNewObjects().size());
+ assertEquals("ChangedObjects", c, result.getChangedObjects().size());
+ assertEquals("DetachedObjects", n, result.getDetachedObjects().size());
+ view.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ComplexTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ComplexTest.java
index afb96019ce..d8ba283a5e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ComplexTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ComplexTest.java
@@ -1,1213 +1,1213 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.GenRefMultiContained;
-import org.eclipse.emf.cdo.tests.model4.GenRefMultiNonContained;
-import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
-import org.eclipse.emf.cdo.tests.model4.GenRefSingleNonContained;
-import org.eclipse.emf.cdo.tests.model4.ImplContainedElementNPL;
-import org.eclipse.emf.cdo.tests.model4.ImplMultiRefContainedElement;
-import org.eclipse.emf.cdo.tests.model4.ImplMultiRefContainer;
-import org.eclipse.emf.cdo.tests.model4.ImplMultiRefContainerNPL;
-import org.eclipse.emf.cdo.tests.model4.ImplMultiRefNonContainedElement;
-import org.eclipse.emf.cdo.tests.model4.ImplMultiRefNonContainer;
-import org.eclipse.emf.cdo.tests.model4.ImplMultiRefNonContainerNPL;
-import org.eclipse.emf.cdo.tests.model4.ImplSingleRefContainedElement;
-import org.eclipse.emf.cdo.tests.model4.ImplSingleRefContainer;
-import org.eclipse.emf.cdo.tests.model4.ImplSingleRefContainerNPL;
-import org.eclipse.emf.cdo.tests.model4.ImplSingleRefNonContainedElement;
-import org.eclipse.emf.cdo.tests.model4.ImplSingleRefNonContainer;
-import org.eclipse.emf.cdo.tests.model4.ImplSingleRefNonContainerNPL;
-import org.eclipse.emf.cdo.tests.model4.MultiContainedElement;
-import org.eclipse.emf.cdo.tests.model4.MultiNonContainedElement;
-import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
-import org.eclipse.emf.cdo.tests.model4.RefMultiContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefMultiNonContained;
-import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContained;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefSingleNonContained;
-import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.SingleContainedElement;
-import org.eclipse.emf.cdo.tests.model4.SingleNonContainedElement;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.tests.model4interfaces.IContainedElementNoParentLink;
-import org.eclipse.emf.cdo.tests.model4interfaces.IMultiRefContainedElement;
-import org.eclipse.emf.cdo.tests.model4interfaces.IMultiRefNonContainedElement;
-import org.eclipse.emf.cdo.tests.model4interfaces.INamedElement;
-import org.eclipse.emf.cdo.tests.model4interfaces.ISingleRefContainedElement;
-import org.eclipse.emf.cdo.tests.model4interfaces.ISingleRefNonContainedElement;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class ComplexTest extends AbstractCDOTest
-{
- private static long uniqueCounter = System.currentTimeMillis();
-
- private model4Factory factory;
-
- private CDOResource resource1;
-
- private CDOResource resource2;
-
- private CDOTransaction transaction;
-
- private CDOSession session;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- String path1 = getResourcePath("/resources/folder1/" + uniqueCounter);
- String path2 = getResourcePath("/resources/folder2/" + uniqueCounter);
- ++uniqueCounter;
-
- init(path1, path2);
- commit();
- }
-
- private void purgeCaches()
- {
- // according to Eike's comment at Bug 249681, client caches are
- // ignored, if a new session is opened.
- // server caches are wiped by the clearCache call.
- String path1 = resource1.getPath();
- String path2 = resource2.getPath();
-
- transaction.close();
- session.close();
-
- clearCache(getRepository().getRevisionManager());
- init(path1, path2);
- }
-
- private void init(String path1, String path2)
- {
- factory = getModel4Factory();
-
- session = openSession();
- session.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- session.getPackageRegistry().putEPackage(getModel4Package());
-
- transaction = session.openTransaction();
-
- resource1 = transaction.getOrCreateResource(path1);
- resource2 = transaction.getOrCreateResource(path2);
- }
-
- private void commit()
- {
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- public void testPlainSingleNonContainedBidirectional()
- {
- RefSingleNonContained container = factory.createRefSingleNonContained();
- SingleNonContainedElement element0 = factory.createSingleNonContainedElement();
- element0.setName("PlainSingleNonContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(2, resource1.getContents().size());
-
- container = (RefSingleNonContained)resource1.getContents().get(0);
- element0 = (SingleNonContainedElement)resource1.getContents().get(1);
-
- assertEquals(element0, container.getElement());
- assertEquals(container, element0.getParent());
- assertEquals("PlainSingleNonContainedBidirectional-Element-0", element0.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0);
- }
-
- public void testPlainSingleContainedBidirectional()
- {
- RefSingleContained container = factory.createRefSingleContained();
- SingleContainedElement element0 = factory.createSingleContainedElement();
- element0.setName("PlainSingleContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
-
- container = (RefSingleContained)CDOUtil.getEObject(resource1.getContents().get(0));
- element0 = container.getElement();
-
- assertEquals(container, element0.getParent());
- assertEquals("PlainSingleContainedBidirectional-Element-0", element0.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
-
- assertContent(resource1, container);
- assertContent(container, element0);
- }
-
- public void testPlainMultiNonContainedBidirectional()
- {
- RefMultiNonContained container = factory.createRefMultiNonContained();
- MultiNonContainedElement element0 = factory.createMultiNonContainedElement();
- element0.setName("PlainMultiNonContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- MultiNonContainedElement element1 = factory.createMultiNonContainedElement();
- element1.setName("PlainMultiNonContainedBidirectional-Element-1");
- resource1.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(3, resource1.getContents().size());
-
- container = (RefMultiNonContained)CDOUtil.getEObject(resource1.getContents().get(0));
- element0 = (MultiNonContainedElement)resource1.getContents().get(1);
- element1 = (MultiNonContainedElement)resource1.getContents().get(2);
-
- assertEquals(element0, container.getElements().get(0));
- assertEquals(element1, container.getElements().get(1));
- assertEquals(container, element0.getParent());
- assertEquals(container, element1.getParent());
- assertEquals("PlainMultiNonContainedBidirectional-Element-0", element0.getName());
- assertEquals("PlainMultiNonContainedBidirectional-Element-1", element1.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
- assertEquals(resource1, element1.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0);
- assertContent(resource1, element1);
- }
-
- public void testPlainMultiContainedBidirectional()
- {
- RefMultiContained container = factory.createRefMultiContained();
- MultiContainedElement element0 = factory.createMultiContainedElement();
- element0.setName("PlainMultiContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- MultiContainedElement element1 = factory.createMultiContainedElement();
- element1.setName("PlainMultiContainedBidirectional-Element-1");
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
-
- container = (RefMultiContained)resource1.getContents().get(0);
- assertEquals(2, container.getElements().size());
-
- element0 = container.getElements().get(0);
- element1 = container.getElements().get(1);
-
- assertEquals(container, element0.getParent());
- assertEquals(container, element1.getParent());
- assertEquals("PlainMultiContainedBidirectional-Element-0", element0.getName());
- assertEquals("PlainMultiContainedBidirectional-Element-1", element1.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
- assertEquals(resource1, element1.eResource());
-
- assertContent(resource1, container);
- assertContent(container, element0);
- assertContent(container, element1);
- }
-
- public void testPlainSingleNonContainedUnidirectional()
- {
- RefSingleNonContainedNPL container = factory.createRefSingleNonContainedNPL();
- ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
- element0.setName("PlainSingleNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(2, resource1.getContents().size());
-
- container = (RefSingleNonContainedNPL)resource1.getContents().get(0);
- element0 = (ContainedElementNoOpposite)resource1.getContents().get(1);
-
- assertEquals(element0, container.getElement());
- assertEquals("PlainSingleNonContainedUnidirectional-Element-0", element0.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0);
- }
-
- public void testPlainSingleContainedUnidirectional()
- {
- RefSingleContainedNPL container = factory.createRefSingleContainedNPL();
- ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
- element0.setName("PlainSingleContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
-
- container = (RefSingleContainedNPL)resource1.getContents().get(0);
- element0 = container.getElement();
-
- assertEquals("PlainSingleContainedUnidirectional-Element-0", element0.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
-
- assertContent(resource1, container);
- assertContent(container, element0);
- }
-
- public void testPlainMultiNonContainedUnidirectional()
- {
- RefMultiNonContainedNPL container = factory.createRefMultiNonContainedNPL();
- ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
- element0.setName("PlainMultiNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- ContainedElementNoOpposite element1 = factory.createContainedElementNoOpposite();
- element1.setName("PlainMultiNonContainedUnidirectional-Element-1");
- resource1.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(3, resource1.getContents().size());
-
- container = (RefMultiNonContainedNPL)resource1.getContents().get(0);
- element0 = (ContainedElementNoOpposite)resource1.getContents().get(1);
- element1 = (ContainedElementNoOpposite)resource1.getContents().get(2);
-
- assertEquals(element0, container.getElements().get(0));
- assertEquals(element1, container.getElements().get(1));
- assertEquals("PlainMultiNonContainedUnidirectional-Element-0", element0.getName());
- assertEquals("PlainMultiNonContainedUnidirectional-Element-1", element1.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
- assertEquals(resource1, element1.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0);
- assertContent(resource1, element1);
- }
-
- public void testPlainMultiContainedUnidirectional()
- {
- RefMultiContainedNPL container = factory.createRefMultiContainedNPL();
- ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
- element0.setName("PlainMultiContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- ContainedElementNoOpposite element1 = factory.createContainedElementNoOpposite();
- element1.setName("PlainMultiContainedUnidirectional-Element-1");
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
-
- container = (RefMultiContainedNPL)resource1.getContents().get(0);
- assertEquals(2, container.getElements().size());
-
- element0 = container.getElements().get(0);
- element1 = container.getElements().get(1);
-
- assertEquals("PlainMultiContainedUnidirectional-Element-0", element0.getName());
- assertEquals("PlainMultiContainedUnidirectional-Element-1", element1.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
- assertEquals(resource1, element1.eResource());
-
- assertContent(resource1, container);
- assertContent(container, element0);
- assertContent(container, element1);
- }
-
- public void testGenRefSingleNonContainedUnidirectional()
- {
- GenRefSingleNonContained container = factory.createGenRefSingleNonContained();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("GenRefSingleNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(2, resource1.getContents().size());
-
- container = (GenRefSingleNonContained)resource1.getContents().get(0);
- element0 = (ImplContainedElementNPL)resource1.getContents().get(1);
-
- assertEquals(element0, container.getElement());
- assertEquals("GenRefSingleNonContainedUnidirectional-Element-0", element0.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0);
- }
-
- public void testGenRefSingleContainedUnidirectional()
- {
- GenRefSingleContained container = factory.createGenRefSingleContained();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("GenRefSingleContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- container.setElement(element0);
-
- resource1.getContents().add(element0);
-
- commit();
-
- purgeCaches();
- assertEquals(2, resource1.getContents().size());
-
- container = (GenRefSingleContained)resource1.getContents().get(0);
- element0 = (ImplContainedElementNPL)container.getElement();
-
- // assertEquals("GenRefSingleContainedUnidirectional-Element-0", element0.getName());
- assertEquals(resource1, container.eResource());
- // assertEquals(resource1, element0.eResource());
-
- assertContent(resource1, container);
- // assertContent(container, element0);
- }
-
- public void testGenRefMultiNonContainedUnidirectional()
- {
- GenRefMultiNonContained container = factory.createGenRefMultiNonContained();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("GenRefMultiNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
- element1.setName("GenRefMultiNonContainedUnidirectional-Element-1");
- resource1.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(3, resource1.getContents().size());
-
- container = (GenRefMultiNonContained)resource1.getContents().get(0);
- element0 = (ImplContainedElementNPL)resource1.getContents().get(1);
- element1 = (ImplContainedElementNPL)resource1.getContents().get(2);
-
- assertEquals(element0, container.getElements().get(0));
- assertEquals(element1, container.getElements().get(1));
- assertEquals("GenRefMultiNonContainedUnidirectional-Element-0", element0.getName());
- assertEquals("GenRefMultiNonContainedUnidirectional-Element-1", element1.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
- assertEquals(resource1, element1.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0);
- assertContent(resource1, element1);
- }
-
- public void testGenRefMultiContainedUnidirectional()
- {
- GenRefMultiContained container = factory.createGenRefMultiContained();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("GenRefMultiContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
- element1.setName("GenRefMultiContainedUnidirectional-Element-1");
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
-
- container = (GenRefMultiContained)resource1.getContents().get(0);
- assertEquals(2, container.getElements().size());
-
- element0 = (ImplContainedElementNPL)container.getElements().get(0);
- element1 = (ImplContainedElementNPL)container.getElements().get(1);
-
- assertEquals("GenRefMultiContainedUnidirectional-Element-0", element0.getName());
- assertEquals("GenRefMultiContainedUnidirectional-Element-1", element1.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0.eResource());
- assertEquals(resource1, element1.eResource());
-
- assertContent(resource1, container);
- assertContent(container, element0);
- assertContent(container, element1);
- }
-
- public void testIfcimplSingleNonContainedBidirectional()
- {
- ImplSingleRefNonContainer container = factory.createImplSingleRefNonContainer();
- ImplSingleRefNonContainedElement element0 = factory.createImplSingleRefNonContainedElement();
- element0.setName("IfcimplSingleNonContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(2, resource1.getContents().size());
-
- container = (ImplSingleRefNonContainer)CDOUtil.getEObject(resource1.getContents().get(0));
- ISingleRefNonContainedElement element0_ = (ISingleRefNonContainedElement)resource1.getContents().get(1);
-
- assertEquals(element0_, container.getElement());
- assertEquals(container, element0_.getParent());
- assertEquals("IfcimplSingleNonContainedBidirectional-Element-0",
- ((ImplSingleRefNonContainedElement)element0_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0_.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0_);
- }
-
- public void testIfcimplSingleContainedBidirectional()
- {
- ImplSingleRefContainer container = factory.createImplSingleRefContainer();
- ImplSingleRefContainedElement element0 = factory.createImplSingleRefContainedElement();
- element0.setName("IfcimplSingleContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
-
- container = (ImplSingleRefContainer)CDOUtil.getEObject(resource1.getContents().get(0));
- ISingleRefContainedElement element0_ = container.getElement();
-
- assertEquals(container, element0_.getParent());
- assertEquals("IfcimplSingleContainedBidirectional-Element-0", ((ImplSingleRefContainedElement)element0_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0_.eResource());
-
- assertContent(resource1, container);
- assertContent(container, element0_);
- }
-
- public void testIfcimplMultiNonContainedBidirectional()
- {
- ImplMultiRefNonContainer container = factory.createImplMultiRefNonContainer();
- ImplMultiRefNonContainedElement element0 = factory.createImplMultiRefNonContainedElement();
- element0.setName("IfcimplMultiNonContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- ImplMultiRefNonContainedElement element1 = factory.createImplMultiRefNonContainedElement();
- element1.setName("IfcimplMultiNonContainedBidirectional-Element-1");
- resource1.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(3, resource1.getContents().size());
-
- container = (ImplMultiRefNonContainer)resource1.getContents().get(0);
- IMultiRefNonContainedElement element0_ = (IMultiRefNonContainedElement)resource1.getContents().get(1);
- IMultiRefNonContainedElement element1_ = (IMultiRefNonContainedElement)resource1.getContents().get(2);
-
- assertEquals(element0_, container.getElements().get(0));
- assertEquals(element1_, container.getElements().get(1));
- assertEquals(container, element0_.getParent());
- assertEquals(container, element1_.getParent());
- assertEquals("IfcimplMultiNonContainedBidirectional-Element-0",
- ((ImplMultiRefNonContainedElement)element0_).getName());
- assertEquals("IfcimplMultiNonContainedBidirectional-Element-1",
- ((ImplMultiRefNonContainedElement)element1_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0_.eResource());
- assertEquals(resource1, element1_.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0_);
- assertContent(resource1, element1_);
- }
-
- public void testIfcimplMultiContainedBidirectional()
- {
- ImplMultiRefContainer container = factory.createImplMultiRefContainer();
- ImplMultiRefContainedElement element0 = factory.createImplMultiRefContainedElement();
- element0.setName("IfcimplMultiContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- ImplMultiRefContainedElement element1 = factory.createImplMultiRefContainedElement();
- element1.setName("IfcimplMultiContainedBidirectional-Element-1");
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
-
- container = (ImplMultiRefContainer)resource1.getContents().get(0);
- assertEquals(2, container.getElements().size());
-
- IMultiRefContainedElement element0_ = container.getElements().get(0);
- IMultiRefContainedElement element1_ = container.getElements().get(1);
-
- assertEquals(container, element0_.getParent());
- assertEquals(container, element1_.getParent());
- assertEquals("IfcimplMultiContainedBidirectional-Element-0", ((ImplMultiRefContainedElement)element0_).getName());
- assertEquals("IfcimplMultiContainedBidirectional-Element-1", ((ImplMultiRefContainedElement)element1_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0_.eResource());
- assertEquals(resource1, element1_.eResource());
-
- assertContent(resource1, container);
- assertContent(container, element0_);
- assertContent(container, element1_);
- }
-
- public void testIfcimplSingleNonContainedUnidirectional()
- {
- ImplSingleRefNonContainerNPL container = factory.createImplSingleRefNonContainerNPL();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("IfcimplSingleNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(2, resource1.getContents().size());
-
- container = (ImplSingleRefNonContainerNPL)resource1.getContents().get(0);
- IContainedElementNoParentLink element0_ = (IContainedElementNoParentLink)resource1.getContents().get(1);
-
- assertEquals(element0_, container.getElement());
- assertEquals("IfcimplSingleNonContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0_.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0_);
- }
-
- public void testIfcimplSingleContainedUnidirectional()
- {
- ImplSingleRefContainerNPL container = factory.createImplSingleRefContainerNPL();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("IfcimplSingleContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
-
- container = (ImplSingleRefContainerNPL)resource1.getContents().get(0);
- IContainedElementNoParentLink element0_ = container.getElement();
-
- assertEquals("IfcimplSingleContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0_.eResource());
-
- assertContent(resource1, container);
- assertContent(container, element0_);
- }
-
- public void testIfcimplMultiNonContainedUnidirectional()
- {
- ImplMultiRefNonContainerNPL container = factory.createImplMultiRefNonContainerNPL();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("IfcimplMultiNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource1.getContents().add(element0);
- ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
- element1.setName("IfcimplMultiNonContainedUnidirectional-Element-1");
- resource1.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(3, resource1.getContents().size());
-
- container = (ImplMultiRefNonContainerNPL)resource1.getContents().get(0);
- IContainedElementNoParentLink element0_ = (IContainedElementNoParentLink)resource1.getContents().get(1);
- IContainedElementNoParentLink element1_ = (IContainedElementNoParentLink)resource1.getContents().get(2);
-
- assertEquals(element0_, container.getElements().get(0));
- assertEquals(element1_, container.getElements().get(1));
- assertEquals("IfcimplMultiNonContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
- assertEquals("IfcimplMultiNonContainedUnidirectional-Element-1", ((INamedElement)element1_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0_.eResource());
- assertEquals(resource1, element1_.eResource());
-
- assertContent(resource1, container);
- assertContent(resource1, element0_);
- assertContent(resource1, element1_);
- }
-
- public void testIfcimplMultiContainedUnidirectional()
- {
- ImplMultiRefContainerNPL container = factory.createImplMultiRefContainerNPL();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("IfcimplMultiContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
- element1.setName("IfcimplMultiContainedUnidirectional-Element-1");
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
-
- container = (ImplMultiRefContainerNPL)resource1.getContents().get(0);
- assertEquals(2, container.getElements().size());
-
- IContainedElementNoParentLink element0_ = container.getElements().get(0);
- IContainedElementNoParentLink element1_ = container.getElements().get(1);
-
- assertEquals("IfcimplMultiContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
- assertEquals("IfcimplMultiContainedUnidirectional-Element-1", ((INamedElement)element1_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource1, element0_.eResource());
- assertEquals(resource1, element1_.eResource());
-
- assertContent(resource1, container);
- assertContent(container, element0_);
- assertContent(container, element1_);
- }
-
- public void testCrossResourcePlainSingleNonContainedBidirectional()
- {
- RefSingleNonContained container = factory.createRefSingleNonContained();
- SingleNonContainedElement element0 = factory.createSingleNonContainedElement();
- element0.setName("CrossResourcePlainSingleNonContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(1, resource2.getContents().size());
-
- container = (RefSingleNonContained)CDOUtil.getEObject(resource1.getContents().get(0));
- element0 = (SingleNonContainedElement)resource2.getContents().get(0);
-
- assertEquals(element0, container.getElement());
- assertEquals(container, element0.getParent());
- assertEquals("CrossResourcePlainSingleNonContainedBidirectional-Element-0", element0.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0);
- }
-
- public void testCrossResourcePlainMultiNonContainedBidirectional()
- {
- RefMultiNonContained container = factory.createRefMultiNonContained();
- MultiNonContainedElement element0 = factory.createMultiNonContainedElement();
- element0.setName("CrossResourcePlainMultiNonContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- MultiNonContainedElement element1 = factory.createMultiNonContainedElement();
- element1.setName("CrossResourcePlainMultiNonContainedBidirectional-Element-1");
- resource2.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(2, resource2.getContents().size());
-
- container = (RefMultiNonContained)resource1.getContents().get(0);
- element0 = (MultiNonContainedElement)resource2.getContents().get(0);
- element1 = (MultiNonContainedElement)resource2.getContents().get(1);
-
- assertEquals(element0, container.getElements().get(0));
- assertEquals(element1, container.getElements().get(1));
- assertEquals(container, element0.getParent());
- assertEquals(container, element1.getParent());
- assertEquals("CrossResourcePlainMultiNonContainedBidirectional-Element-0", element0.getName());
- assertEquals("CrossResourcePlainMultiNonContainedBidirectional-Element-1", element1.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0.eResource());
- assertEquals(resource2, element1.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0);
- assertContent(resource2, element1);
- }
-
- public void testCrossResourcePlainSingleNonContainedUnidirectional()
- {
- RefSingleNonContainedNPL container = factory.createRefSingleNonContainedNPL();
- ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
- element0.setName("CrossResourcePlainSingleNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(1, resource2.getContents().size());
-
- container = (RefSingleNonContainedNPL)resource1.getContents().get(0);
- element0 = (ContainedElementNoOpposite)resource2.getContents().get(0);
-
- assertEquals(element0, container.getElement());
- assertEquals("CrossResourcePlainSingleNonContainedUnidirectional-Element-0", element0.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0);
- }
-
- public void testCrossResourcePlainMultiNonContainedUnidirectional()
- {
- RefMultiNonContainedNPL container = factory.createRefMultiNonContainedNPL();
- ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
- element0.setName("CrossResourcePlainMultiNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- ContainedElementNoOpposite element1 = factory.createContainedElementNoOpposite();
- element1.setName("CrossResourcePlainMultiNonContainedUnidirectional-Element-1");
- resource2.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(2, resource2.getContents().size());
-
- container = (RefMultiNonContainedNPL)resource1.getContents().get(0);
- element0 = (ContainedElementNoOpposite)resource2.getContents().get(0);
- element1 = (ContainedElementNoOpposite)resource2.getContents().get(1);
-
- assertEquals(element0, container.getElements().get(0));
- assertEquals(element1, container.getElements().get(1));
- assertEquals("CrossResourcePlainMultiNonContainedUnidirectional-Element-0", element0.getName());
- assertEquals("CrossResourcePlainMultiNonContainedUnidirectional-Element-1", element1.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0.eResource());
- assertEquals(resource2, element1.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0);
- assertContent(resource2, element1);
- }
-
- public void testCrossResourceGenRefSingleNonContainedUnidirectional()
- {
- GenRefSingleNonContained container = factory.createGenRefSingleNonContained();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("CrossResourceGenRefSingleNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(1, resource2.getContents().size());
-
- container = (GenRefSingleNonContained)resource1.getContents().get(0);
- element0 = (ImplContainedElementNPL)resource2.getContents().get(0);
-
- assertEquals(element0, container.getElement());
- assertEquals("CrossResourceGenRefSingleNonContainedUnidirectional-Element-0", element0.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0);
- }
-
- public void testCrossResourceGenRefMultiNonContainedUnidirectional()
- {
- GenRefMultiNonContained container = factory.createGenRefMultiNonContained();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("CrossResourceGenRefMultiNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
- element1.setName("CrossResourceGenRefMultiNonContainedUnidirectional-Element-1");
- resource2.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(2, resource2.getContents().size());
-
- container = (GenRefMultiNonContained)resource1.getContents().get(0);
- element0 = (ImplContainedElementNPL)resource2.getContents().get(0);
- element1 = (ImplContainedElementNPL)resource2.getContents().get(1);
-
- assertEquals(element0, container.getElements().get(0));
- assertEquals(element1, container.getElements().get(1));
- assertEquals("CrossResourceGenRefMultiNonContainedUnidirectional-Element-0", element0.getName());
- assertEquals("CrossResourceGenRefMultiNonContainedUnidirectional-Element-1", element1.getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0.eResource());
- assertEquals(resource2, element1.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0);
- assertContent(resource2, element1);
- }
-
- public void testCrossResourceIfcimplSingleNonContainedBidirectional()
- {
- ImplSingleRefNonContainer container = factory.createImplSingleRefNonContainer();
- ImplSingleRefNonContainedElement element0 = factory.createImplSingleRefNonContainedElement();
- element0.setName("CrossResourceIfcimplSingleNonContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(1, resource2.getContents().size());
-
- container = (ImplSingleRefNonContainer)CDOUtil.getEObject(resource1.getContents().get(0));
- ISingleRefNonContainedElement element0_ = (ISingleRefNonContainedElement)resource2.getContents().get(0);
-
- assertEquals(element0_, container.getElement());
- assertEquals(container, element0_.getParent());
- assertEquals("CrossResourceIfcimplSingleNonContainedBidirectional-Element-0",
- ((ImplSingleRefNonContainedElement)element0_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0_.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0_);
- }
-
- public void testCrossResourceIfcimplMultiNonContainedBidirectional()
- {
- ImplMultiRefNonContainer container = factory.createImplMultiRefNonContainer();
- ImplMultiRefNonContainedElement element0 = factory.createImplMultiRefNonContainedElement();
- element0.setName("CrossResourceIfcimplMultiNonContainedBidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- ImplMultiRefNonContainedElement element1 = factory.createImplMultiRefNonContainedElement();
- element1.setName("CrossResourceIfcimplMultiNonContainedBidirectional-Element-1");
- resource2.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(2, resource2.getContents().size());
-
- container = (ImplMultiRefNonContainer)resource1.getContents().get(0);
- IMultiRefNonContainedElement element0_ = (IMultiRefNonContainedElement)resource2.getContents().get(0);
- IMultiRefNonContainedElement element1_ = (IMultiRefNonContainedElement)resource2.getContents().get(1);
-
- assertEquals(element0_, container.getElements().get(0));
- assertEquals(element1_, container.getElements().get(1));
- assertEquals(container, element0_.getParent());
- assertEquals(container, element1_.getParent());
- assertEquals("CrossResourceIfcimplMultiNonContainedBidirectional-Element-0",
- ((ImplMultiRefNonContainedElement)element0_).getName());
- assertEquals("CrossResourceIfcimplMultiNonContainedBidirectional-Element-1",
- ((ImplMultiRefNonContainedElement)element1_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0_.eResource());
- assertEquals(resource2, element1_.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0_);
- assertContent(resource2, element1_);
- }
-
- public void testCrossResourceIfcimplSingleNonContainedUnidirectional()
- {
- ImplSingleRefNonContainerNPL container = factory.createImplSingleRefNonContainerNPL();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("CrossResourceIfcimplSingleNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- container.setElement(element0);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(1, resource1.getContents().size());
-
- container = (ImplSingleRefNonContainerNPL)resource1.getContents().get(0);
- IContainedElementNoParentLink element0_ = (IContainedElementNoParentLink)resource2.getContents().get(0);
-
- assertEquals(element0_, container.getElement());
- assertEquals("CrossResourceIfcimplSingleNonContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0_.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0_);
- }
-
- public void testCrossResourceIfcimplMultiNonContainedUnidirectional()
- {
- ImplMultiRefNonContainerNPL container = factory.createImplMultiRefNonContainerNPL();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("CrossResourceIfcimplMultiNonContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- resource2.getContents().add(element0);
- ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
- element1.setName("CrossResourceIfcimplMultiNonContainedUnidirectional-Element-1");
- resource2.getContents().add(element1);
- container.getElements().add(element0);
- container.getElements().add(element1);
- commit();
-
- purgeCaches();
- assertEquals(1, resource1.getContents().size());
- assertEquals(2, resource2.getContents().size());
-
- container = (ImplMultiRefNonContainerNPL)resource1.getContents().get(0);
- IContainedElementNoParentLink element0_ = (IContainedElementNoParentLink)resource2.getContents().get(0);
- IContainedElementNoParentLink element1_ = (IContainedElementNoParentLink)resource2.getContents().get(1);
-
- assertEquals(element0_, container.getElements().get(0));
- assertEquals(element1_, container.getElements().get(1));
- assertEquals("CrossResourceIfcimplMultiNonContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
- assertEquals("CrossResourceIfcimplMultiNonContainedUnidirectional-Element-1", ((INamedElement)element1_).getName());
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, element0_.eResource());
- assertEquals(resource2, element1_.eResource());
-
- assertContent(resource1, container);
- assertContent(resource2, element0_);
- assertContent(resource2, element1_);
- }
-
- public void testMultipleTransactions3() throws CommitException
- {
- CDOTransaction transaction1 = session.openTransaction();
- String resource1path = getResourcePath("/resources/3/" + uniqueCounter);
- CDOResource resource1 = transaction1.createResource(resource1path);
- transaction1.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- String resource2path = getResourcePath("/resources/4/" + uniqueCounter++);
- CDOResource resource2 = transaction2.createResource(resource2path);
- transaction2.commit();
-
- MultiContainedElement element0 = factory.createMultiContainedElement();
- element0.setName("MultipleTransactions-Element-0");
-
- MultiContainedElement element1 = factory.createMultiContainedElement();
- element1.setName("MultipleTransactions-Element-0");
-
- MultiContainedElement element2 = factory.createMultiContainedElement();
- element2.setName("MultipleTransactions-Element-0");
-
- MultiContainedElement element3 = factory.createMultiContainedElement();
- element3.setName("MultipleTransactions-Element-0");
-
- resource1.getContents().add(element0);
- resource1.getContents().add(element1);
- resource1.getContents().add(element2);
- resource1.getContents().add(element3);
-
- transaction1.commit();
-
- RefMultiContained container = factory.createRefMultiContained();
- resource2.getContents().add(container);
-
- transaction2.commit();
-
- CDOTransaction transaction3 = session.openTransaction();
- EList<EObject> elements = transaction3.getResource(resource1path).getContents();
- EList<EObject> containers = transaction3.getResource(resource2path).getContents();
- List<EObject> elementToRemove = new ArrayList<EObject>();
- for (EObject o : elements)
- {
- elementToRemove.add(o);
- }
-
- RefMultiContained container_work = (RefMultiContained)containers.get(0);
- for (EObject o : elementToRemove)
- {
- MultiContainedElement element_work = (MultiContainedElement)o;
- container_work.getElements().add(element_work);
- transaction3.commit();
- }
- }
-
- public void testMultipleTransactions2() throws CommitException
- {
- CDOTransaction transaction1 = session.openTransaction();
- String resource1path = getResourcePath("/resources/3/" + uniqueCounter);
- CDOResource resource1 = transaction1.createResource(resource1path);
- transaction1.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- String resource2path = getResourcePath("/resources/4/" + uniqueCounter++);
- CDOResource resource2 = transaction2.createResource(resource2path);
- transaction2.commit();
-
- MultiContainedElement element0 = factory.createMultiContainedElement();
- element0.setName("MultipleTransactions-Element-0");
-
- MultiContainedElement element1 = factory.createMultiContainedElement();
- element1.setName("MultipleTransactions-Element-0");
-
- MultiContainedElement element2 = factory.createMultiContainedElement();
- element2.setName("MultipleTransactions-Element-0");
-
- MultiContainedElement element3 = factory.createMultiContainedElement();
- element3.setName("MultipleTransactions-Element-0");
-
- resource1.getContents().add(element0);
- resource1.getContents().add(element1);
- resource1.getContents().add(element2);
- resource1.getContents().add(element3);
-
- transaction1.commit();
-
- RefMultiContained container = factory.createRefMultiContained();
- resource2.getContents().add(container);
-
- transaction2.commit();
- CDOResource resource1FromTx2 = transaction2.getResource(resource1path);
- EList<EObject> elements = resource1FromTx2.getContents();
- List<EObject> elementToRemove = new ArrayList<EObject>();
- for (EObject o : elements)
- {
- elementToRemove.add(o);
- }
-
- for (EObject o : elementToRemove)
- {
- MultiContainedElement element_work = (MultiContainedElement)o;
- assertEquals(resource1FromTx2, CDOUtil.getCDOObject(element_work).cdoDirectResource());
- assertEquals(resource1FromTx2, element_work.eResource());
-
- container.getElements().add(element_work);
-
- assertEquals(null, CDOUtil.getCDOObject(element_work).cdoDirectResource());
- assertEquals(resource2, element_work.eResource());
- transaction2.commit();
- }
- }
-
- public void testMigrateContainmentSingle()
- {
- SingleContainedElement element = factory.createSingleContainedElement();
- element.setName("MigrateContainmentSingle-Element-0");
-
- RefSingleContained container1 = factory.createRefSingleContained();
- container1.setElement(element);
- resource1.getContents().add(container1);
-
- RefSingleContained container2 = factory.createRefSingleContained();
- resource2.getContents().add(container2);
- commit();
-
- container2.setElement(element);
- commit();
-
- assertEquals(true, element.getParent() == container2);
- assertEquals(true, element.eContainer() == container2);
- assertEquals(true, CDOUtil.getCDOObject(element).cdoDirectResource() == null);
-
- assertEquals(true, container1.getElement() == null);
- assertEquals(true, CDOUtil.getCDOObject(container1).cdoDirectResource() == resource1);
-
- assertEquals(true, container2.getElement() == element);
- assertEquals(true, CDOUtil.getCDOObject(container2).cdoDirectResource() == resource2);
- }
-
- public void testMigrateContainmentMulti()
- {
- MultiContainedElement elementA = factory.createMultiContainedElement();
- elementA.setName("MigrateContainmentMulti-Element-A");
-
- MultiContainedElement elementB = factory.createMultiContainedElement();
- elementB.setName("MigrateContainmentMulti-Element-B");
-
- RefMultiContained container1 = factory.createRefMultiContained();
- container1.getElements().add(elementA);
- container1.getElements().add(elementB);
-
- resource1.getContents().add(container1);
-
- RefMultiContained container2 = factory.createRefMultiContained();
- resource2.getContents().add(container2);
- commit();
-
- container2.getElements().add(container1.getElements().get(0));
- commit();
-
- assertEquals(true, elementA.getParent() == container2);
- assertEquals(true, elementA.eContainer() == container2);
- assertEquals(true, CDOUtil.getCDOObject(elementA).cdoDirectResource() == null);
- assertEquals(true, elementA.eResource() == resource2);
-
- assertEquals(true, elementB.getParent() == container1);
- assertEquals(true, elementB.eContainer() == container1);
- assertEquals(true, CDOUtil.getCDOObject(elementB).cdoDirectResource() == null);
- assertEquals(true, elementB.eResource() == resource1);
-
- assertEquals(true, CDOUtil.getCDOObject(container1).cdoDirectResource() == resource1);
- assertEquals(1, container1.getElements().size());
- assertEquals(elementB, container1.getElements().get(0));
-
- assertEquals(true, CDOUtil.getCDOObject(container2).cdoDirectResource() == resource2);
- assertEquals(1, container2.getElements().size());
- assertEquals(elementA, container2.getElements().get(0));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.GenRefMultiContained;
+import org.eclipse.emf.cdo.tests.model4.GenRefMultiNonContained;
+import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
+import org.eclipse.emf.cdo.tests.model4.GenRefSingleNonContained;
+import org.eclipse.emf.cdo.tests.model4.ImplContainedElementNPL;
+import org.eclipse.emf.cdo.tests.model4.ImplMultiRefContainedElement;
+import org.eclipse.emf.cdo.tests.model4.ImplMultiRefContainer;
+import org.eclipse.emf.cdo.tests.model4.ImplMultiRefContainerNPL;
+import org.eclipse.emf.cdo.tests.model4.ImplMultiRefNonContainedElement;
+import org.eclipse.emf.cdo.tests.model4.ImplMultiRefNonContainer;
+import org.eclipse.emf.cdo.tests.model4.ImplMultiRefNonContainerNPL;
+import org.eclipse.emf.cdo.tests.model4.ImplSingleRefContainedElement;
+import org.eclipse.emf.cdo.tests.model4.ImplSingleRefContainer;
+import org.eclipse.emf.cdo.tests.model4.ImplSingleRefContainerNPL;
+import org.eclipse.emf.cdo.tests.model4.ImplSingleRefNonContainedElement;
+import org.eclipse.emf.cdo.tests.model4.ImplSingleRefNonContainer;
+import org.eclipse.emf.cdo.tests.model4.ImplSingleRefNonContainerNPL;
+import org.eclipse.emf.cdo.tests.model4.MultiContainedElement;
+import org.eclipse.emf.cdo.tests.model4.MultiNonContainedElement;
+import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
+import org.eclipse.emf.cdo.tests.model4.RefMultiContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefMultiNonContained;
+import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContained;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefSingleNonContained;
+import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.SingleContainedElement;
+import org.eclipse.emf.cdo.tests.model4.SingleNonContainedElement;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.tests.model4interfaces.IContainedElementNoParentLink;
+import org.eclipse.emf.cdo.tests.model4interfaces.IMultiRefContainedElement;
+import org.eclipse.emf.cdo.tests.model4interfaces.IMultiRefNonContainedElement;
+import org.eclipse.emf.cdo.tests.model4interfaces.INamedElement;
+import org.eclipse.emf.cdo.tests.model4interfaces.ISingleRefContainedElement;
+import org.eclipse.emf.cdo.tests.model4interfaces.ISingleRefNonContainedElement;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class ComplexTest extends AbstractCDOTest
+{
+ private static long uniqueCounter = System.currentTimeMillis();
+
+ private model4Factory factory;
+
+ private CDOResource resource1;
+
+ private CDOResource resource2;
+
+ private CDOTransaction transaction;
+
+ private CDOSession session;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ String path1 = getResourcePath("/resources/folder1/" + uniqueCounter);
+ String path2 = getResourcePath("/resources/folder2/" + uniqueCounter);
+ ++uniqueCounter;
+
+ init(path1, path2);
+ commit();
+ }
+
+ private void purgeCaches()
+ {
+ // according to Eike's comment at Bug 249681, client caches are
+ // ignored, if a new session is opened.
+ // server caches are wiped by the clearCache call.
+ String path1 = resource1.getPath();
+ String path2 = resource2.getPath();
+
+ transaction.close();
+ session.close();
+
+ clearCache(getRepository().getRevisionManager());
+ init(path1, path2);
+ }
+
+ private void init(String path1, String path2)
+ {
+ factory = getModel4Factory();
+
+ session = openSession();
+ session.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ session.getPackageRegistry().putEPackage(getModel4Package());
+
+ transaction = session.openTransaction();
+
+ resource1 = transaction.getOrCreateResource(path1);
+ resource2 = transaction.getOrCreateResource(path2);
+ }
+
+ private void commit()
+ {
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ public void testPlainSingleNonContainedBidirectional()
+ {
+ RefSingleNonContained container = factory.createRefSingleNonContained();
+ SingleNonContainedElement element0 = factory.createSingleNonContainedElement();
+ element0.setName("PlainSingleNonContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(2, resource1.getContents().size());
+
+ container = (RefSingleNonContained)resource1.getContents().get(0);
+ element0 = (SingleNonContainedElement)resource1.getContents().get(1);
+
+ assertEquals(element0, container.getElement());
+ assertEquals(container, element0.getParent());
+ assertEquals("PlainSingleNonContainedBidirectional-Element-0", element0.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0);
+ }
+
+ public void testPlainSingleContainedBidirectional()
+ {
+ RefSingleContained container = factory.createRefSingleContained();
+ SingleContainedElement element0 = factory.createSingleContainedElement();
+ element0.setName("PlainSingleContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+
+ container = (RefSingleContained)CDOUtil.getEObject(resource1.getContents().get(0));
+ element0 = container.getElement();
+
+ assertEquals(container, element0.getParent());
+ assertEquals("PlainSingleContainedBidirectional-Element-0", element0.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+
+ assertContent(resource1, container);
+ assertContent(container, element0);
+ }
+
+ public void testPlainMultiNonContainedBidirectional()
+ {
+ RefMultiNonContained container = factory.createRefMultiNonContained();
+ MultiNonContainedElement element0 = factory.createMultiNonContainedElement();
+ element0.setName("PlainMultiNonContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ MultiNonContainedElement element1 = factory.createMultiNonContainedElement();
+ element1.setName("PlainMultiNonContainedBidirectional-Element-1");
+ resource1.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(3, resource1.getContents().size());
+
+ container = (RefMultiNonContained)CDOUtil.getEObject(resource1.getContents().get(0));
+ element0 = (MultiNonContainedElement)resource1.getContents().get(1);
+ element1 = (MultiNonContainedElement)resource1.getContents().get(2);
+
+ assertEquals(element0, container.getElements().get(0));
+ assertEquals(element1, container.getElements().get(1));
+ assertEquals(container, element0.getParent());
+ assertEquals(container, element1.getParent());
+ assertEquals("PlainMultiNonContainedBidirectional-Element-0", element0.getName());
+ assertEquals("PlainMultiNonContainedBidirectional-Element-1", element1.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+ assertEquals(resource1, element1.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0);
+ assertContent(resource1, element1);
+ }
+
+ public void testPlainMultiContainedBidirectional()
+ {
+ RefMultiContained container = factory.createRefMultiContained();
+ MultiContainedElement element0 = factory.createMultiContainedElement();
+ element0.setName("PlainMultiContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ MultiContainedElement element1 = factory.createMultiContainedElement();
+ element1.setName("PlainMultiContainedBidirectional-Element-1");
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+
+ container = (RefMultiContained)resource1.getContents().get(0);
+ assertEquals(2, container.getElements().size());
+
+ element0 = container.getElements().get(0);
+ element1 = container.getElements().get(1);
+
+ assertEquals(container, element0.getParent());
+ assertEquals(container, element1.getParent());
+ assertEquals("PlainMultiContainedBidirectional-Element-0", element0.getName());
+ assertEquals("PlainMultiContainedBidirectional-Element-1", element1.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+ assertEquals(resource1, element1.eResource());
+
+ assertContent(resource1, container);
+ assertContent(container, element0);
+ assertContent(container, element1);
+ }
+
+ public void testPlainSingleNonContainedUnidirectional()
+ {
+ RefSingleNonContainedNPL container = factory.createRefSingleNonContainedNPL();
+ ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
+ element0.setName("PlainSingleNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(2, resource1.getContents().size());
+
+ container = (RefSingleNonContainedNPL)resource1.getContents().get(0);
+ element0 = (ContainedElementNoOpposite)resource1.getContents().get(1);
+
+ assertEquals(element0, container.getElement());
+ assertEquals("PlainSingleNonContainedUnidirectional-Element-0", element0.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0);
+ }
+
+ public void testPlainSingleContainedUnidirectional()
+ {
+ RefSingleContainedNPL container = factory.createRefSingleContainedNPL();
+ ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
+ element0.setName("PlainSingleContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+
+ container = (RefSingleContainedNPL)resource1.getContents().get(0);
+ element0 = container.getElement();
+
+ assertEquals("PlainSingleContainedUnidirectional-Element-0", element0.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+
+ assertContent(resource1, container);
+ assertContent(container, element0);
+ }
+
+ public void testPlainMultiNonContainedUnidirectional()
+ {
+ RefMultiNonContainedNPL container = factory.createRefMultiNonContainedNPL();
+ ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
+ element0.setName("PlainMultiNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ ContainedElementNoOpposite element1 = factory.createContainedElementNoOpposite();
+ element1.setName("PlainMultiNonContainedUnidirectional-Element-1");
+ resource1.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(3, resource1.getContents().size());
+
+ container = (RefMultiNonContainedNPL)resource1.getContents().get(0);
+ element0 = (ContainedElementNoOpposite)resource1.getContents().get(1);
+ element1 = (ContainedElementNoOpposite)resource1.getContents().get(2);
+
+ assertEquals(element0, container.getElements().get(0));
+ assertEquals(element1, container.getElements().get(1));
+ assertEquals("PlainMultiNonContainedUnidirectional-Element-0", element0.getName());
+ assertEquals("PlainMultiNonContainedUnidirectional-Element-1", element1.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+ assertEquals(resource1, element1.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0);
+ assertContent(resource1, element1);
+ }
+
+ public void testPlainMultiContainedUnidirectional()
+ {
+ RefMultiContainedNPL container = factory.createRefMultiContainedNPL();
+ ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
+ element0.setName("PlainMultiContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ ContainedElementNoOpposite element1 = factory.createContainedElementNoOpposite();
+ element1.setName("PlainMultiContainedUnidirectional-Element-1");
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+
+ container = (RefMultiContainedNPL)resource1.getContents().get(0);
+ assertEquals(2, container.getElements().size());
+
+ element0 = container.getElements().get(0);
+ element1 = container.getElements().get(1);
+
+ assertEquals("PlainMultiContainedUnidirectional-Element-0", element0.getName());
+ assertEquals("PlainMultiContainedUnidirectional-Element-1", element1.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+ assertEquals(resource1, element1.eResource());
+
+ assertContent(resource1, container);
+ assertContent(container, element0);
+ assertContent(container, element1);
+ }
+
+ public void testGenRefSingleNonContainedUnidirectional()
+ {
+ GenRefSingleNonContained container = factory.createGenRefSingleNonContained();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("GenRefSingleNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(2, resource1.getContents().size());
+
+ container = (GenRefSingleNonContained)resource1.getContents().get(0);
+ element0 = (ImplContainedElementNPL)resource1.getContents().get(1);
+
+ assertEquals(element0, container.getElement());
+ assertEquals("GenRefSingleNonContainedUnidirectional-Element-0", element0.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0);
+ }
+
+ public void testGenRefSingleContainedUnidirectional()
+ {
+ GenRefSingleContained container = factory.createGenRefSingleContained();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("GenRefSingleContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ container.setElement(element0);
+
+ resource1.getContents().add(element0);
+
+ commit();
+
+ purgeCaches();
+ assertEquals(2, resource1.getContents().size());
+
+ container = (GenRefSingleContained)resource1.getContents().get(0);
+ element0 = (ImplContainedElementNPL)container.getElement();
+
+ // assertEquals("GenRefSingleContainedUnidirectional-Element-0", element0.getName());
+ assertEquals(resource1, container.eResource());
+ // assertEquals(resource1, element0.eResource());
+
+ assertContent(resource1, container);
+ // assertContent(container, element0);
+ }
+
+ public void testGenRefMultiNonContainedUnidirectional()
+ {
+ GenRefMultiNonContained container = factory.createGenRefMultiNonContained();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("GenRefMultiNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
+ element1.setName("GenRefMultiNonContainedUnidirectional-Element-1");
+ resource1.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(3, resource1.getContents().size());
+
+ container = (GenRefMultiNonContained)resource1.getContents().get(0);
+ element0 = (ImplContainedElementNPL)resource1.getContents().get(1);
+ element1 = (ImplContainedElementNPL)resource1.getContents().get(2);
+
+ assertEquals(element0, container.getElements().get(0));
+ assertEquals(element1, container.getElements().get(1));
+ assertEquals("GenRefMultiNonContainedUnidirectional-Element-0", element0.getName());
+ assertEquals("GenRefMultiNonContainedUnidirectional-Element-1", element1.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+ assertEquals(resource1, element1.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0);
+ assertContent(resource1, element1);
+ }
+
+ public void testGenRefMultiContainedUnidirectional()
+ {
+ GenRefMultiContained container = factory.createGenRefMultiContained();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("GenRefMultiContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
+ element1.setName("GenRefMultiContainedUnidirectional-Element-1");
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+
+ container = (GenRefMultiContained)resource1.getContents().get(0);
+ assertEquals(2, container.getElements().size());
+
+ element0 = (ImplContainedElementNPL)container.getElements().get(0);
+ element1 = (ImplContainedElementNPL)container.getElements().get(1);
+
+ assertEquals("GenRefMultiContainedUnidirectional-Element-0", element0.getName());
+ assertEquals("GenRefMultiContainedUnidirectional-Element-1", element1.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0.eResource());
+ assertEquals(resource1, element1.eResource());
+
+ assertContent(resource1, container);
+ assertContent(container, element0);
+ assertContent(container, element1);
+ }
+
+ public void testIfcimplSingleNonContainedBidirectional()
+ {
+ ImplSingleRefNonContainer container = factory.createImplSingleRefNonContainer();
+ ImplSingleRefNonContainedElement element0 = factory.createImplSingleRefNonContainedElement();
+ element0.setName("IfcimplSingleNonContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(2, resource1.getContents().size());
+
+ container = (ImplSingleRefNonContainer)CDOUtil.getEObject(resource1.getContents().get(0));
+ ISingleRefNonContainedElement element0_ = (ISingleRefNonContainedElement)resource1.getContents().get(1);
+
+ assertEquals(element0_, container.getElement());
+ assertEquals(container, element0_.getParent());
+ assertEquals("IfcimplSingleNonContainedBidirectional-Element-0",
+ ((ImplSingleRefNonContainedElement)element0_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0_);
+ }
+
+ public void testIfcimplSingleContainedBidirectional()
+ {
+ ImplSingleRefContainer container = factory.createImplSingleRefContainer();
+ ImplSingleRefContainedElement element0 = factory.createImplSingleRefContainedElement();
+ element0.setName("IfcimplSingleContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+
+ container = (ImplSingleRefContainer)CDOUtil.getEObject(resource1.getContents().get(0));
+ ISingleRefContainedElement element0_ = container.getElement();
+
+ assertEquals(container, element0_.getParent());
+ assertEquals("IfcimplSingleContainedBidirectional-Element-0", ((ImplSingleRefContainedElement)element0_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(container, element0_);
+ }
+
+ public void testIfcimplMultiNonContainedBidirectional()
+ {
+ ImplMultiRefNonContainer container = factory.createImplMultiRefNonContainer();
+ ImplMultiRefNonContainedElement element0 = factory.createImplMultiRefNonContainedElement();
+ element0.setName("IfcimplMultiNonContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ ImplMultiRefNonContainedElement element1 = factory.createImplMultiRefNonContainedElement();
+ element1.setName("IfcimplMultiNonContainedBidirectional-Element-1");
+ resource1.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(3, resource1.getContents().size());
+
+ container = (ImplMultiRefNonContainer)resource1.getContents().get(0);
+ IMultiRefNonContainedElement element0_ = (IMultiRefNonContainedElement)resource1.getContents().get(1);
+ IMultiRefNonContainedElement element1_ = (IMultiRefNonContainedElement)resource1.getContents().get(2);
+
+ assertEquals(element0_, container.getElements().get(0));
+ assertEquals(element1_, container.getElements().get(1));
+ assertEquals(container, element0_.getParent());
+ assertEquals(container, element1_.getParent());
+ assertEquals("IfcimplMultiNonContainedBidirectional-Element-0",
+ ((ImplMultiRefNonContainedElement)element0_).getName());
+ assertEquals("IfcimplMultiNonContainedBidirectional-Element-1",
+ ((ImplMultiRefNonContainedElement)element1_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0_.eResource());
+ assertEquals(resource1, element1_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0_);
+ assertContent(resource1, element1_);
+ }
+
+ public void testIfcimplMultiContainedBidirectional()
+ {
+ ImplMultiRefContainer container = factory.createImplMultiRefContainer();
+ ImplMultiRefContainedElement element0 = factory.createImplMultiRefContainedElement();
+ element0.setName("IfcimplMultiContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ ImplMultiRefContainedElement element1 = factory.createImplMultiRefContainedElement();
+ element1.setName("IfcimplMultiContainedBidirectional-Element-1");
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+
+ container = (ImplMultiRefContainer)resource1.getContents().get(0);
+ assertEquals(2, container.getElements().size());
+
+ IMultiRefContainedElement element0_ = container.getElements().get(0);
+ IMultiRefContainedElement element1_ = container.getElements().get(1);
+
+ assertEquals(container, element0_.getParent());
+ assertEquals(container, element1_.getParent());
+ assertEquals("IfcimplMultiContainedBidirectional-Element-0", ((ImplMultiRefContainedElement)element0_).getName());
+ assertEquals("IfcimplMultiContainedBidirectional-Element-1", ((ImplMultiRefContainedElement)element1_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0_.eResource());
+ assertEquals(resource1, element1_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(container, element0_);
+ assertContent(container, element1_);
+ }
+
+ public void testIfcimplSingleNonContainedUnidirectional()
+ {
+ ImplSingleRefNonContainerNPL container = factory.createImplSingleRefNonContainerNPL();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("IfcimplSingleNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(2, resource1.getContents().size());
+
+ container = (ImplSingleRefNonContainerNPL)resource1.getContents().get(0);
+ IContainedElementNoParentLink element0_ = (IContainedElementNoParentLink)resource1.getContents().get(1);
+
+ assertEquals(element0_, container.getElement());
+ assertEquals("IfcimplSingleNonContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0_);
+ }
+
+ public void testIfcimplSingleContainedUnidirectional()
+ {
+ ImplSingleRefContainerNPL container = factory.createImplSingleRefContainerNPL();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("IfcimplSingleContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+
+ container = (ImplSingleRefContainerNPL)resource1.getContents().get(0);
+ IContainedElementNoParentLink element0_ = container.getElement();
+
+ assertEquals("IfcimplSingleContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(container, element0_);
+ }
+
+ public void testIfcimplMultiNonContainedUnidirectional()
+ {
+ ImplMultiRefNonContainerNPL container = factory.createImplMultiRefNonContainerNPL();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("IfcimplMultiNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource1.getContents().add(element0);
+ ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
+ element1.setName("IfcimplMultiNonContainedUnidirectional-Element-1");
+ resource1.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(3, resource1.getContents().size());
+
+ container = (ImplMultiRefNonContainerNPL)resource1.getContents().get(0);
+ IContainedElementNoParentLink element0_ = (IContainedElementNoParentLink)resource1.getContents().get(1);
+ IContainedElementNoParentLink element1_ = (IContainedElementNoParentLink)resource1.getContents().get(2);
+
+ assertEquals(element0_, container.getElements().get(0));
+ assertEquals(element1_, container.getElements().get(1));
+ assertEquals("IfcimplMultiNonContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
+ assertEquals("IfcimplMultiNonContainedUnidirectional-Element-1", ((INamedElement)element1_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0_.eResource());
+ assertEquals(resource1, element1_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource1, element0_);
+ assertContent(resource1, element1_);
+ }
+
+ public void testIfcimplMultiContainedUnidirectional()
+ {
+ ImplMultiRefContainerNPL container = factory.createImplMultiRefContainerNPL();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("IfcimplMultiContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
+ element1.setName("IfcimplMultiContainedUnidirectional-Element-1");
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+
+ container = (ImplMultiRefContainerNPL)resource1.getContents().get(0);
+ assertEquals(2, container.getElements().size());
+
+ IContainedElementNoParentLink element0_ = container.getElements().get(0);
+ IContainedElementNoParentLink element1_ = container.getElements().get(1);
+
+ assertEquals("IfcimplMultiContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
+ assertEquals("IfcimplMultiContainedUnidirectional-Element-1", ((INamedElement)element1_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource1, element0_.eResource());
+ assertEquals(resource1, element1_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(container, element0_);
+ assertContent(container, element1_);
+ }
+
+ public void testCrossResourcePlainSingleNonContainedBidirectional()
+ {
+ RefSingleNonContained container = factory.createRefSingleNonContained();
+ SingleNonContainedElement element0 = factory.createSingleNonContainedElement();
+ element0.setName("CrossResourcePlainSingleNonContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(1, resource2.getContents().size());
+
+ container = (RefSingleNonContained)CDOUtil.getEObject(resource1.getContents().get(0));
+ element0 = (SingleNonContainedElement)resource2.getContents().get(0);
+
+ assertEquals(element0, container.getElement());
+ assertEquals(container, element0.getParent());
+ assertEquals("CrossResourcePlainSingleNonContainedBidirectional-Element-0", element0.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0);
+ }
+
+ public void testCrossResourcePlainMultiNonContainedBidirectional()
+ {
+ RefMultiNonContained container = factory.createRefMultiNonContained();
+ MultiNonContainedElement element0 = factory.createMultiNonContainedElement();
+ element0.setName("CrossResourcePlainMultiNonContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ MultiNonContainedElement element1 = factory.createMultiNonContainedElement();
+ element1.setName("CrossResourcePlainMultiNonContainedBidirectional-Element-1");
+ resource2.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(2, resource2.getContents().size());
+
+ container = (RefMultiNonContained)resource1.getContents().get(0);
+ element0 = (MultiNonContainedElement)resource2.getContents().get(0);
+ element1 = (MultiNonContainedElement)resource2.getContents().get(1);
+
+ assertEquals(element0, container.getElements().get(0));
+ assertEquals(element1, container.getElements().get(1));
+ assertEquals(container, element0.getParent());
+ assertEquals(container, element1.getParent());
+ assertEquals("CrossResourcePlainMultiNonContainedBidirectional-Element-0", element0.getName());
+ assertEquals("CrossResourcePlainMultiNonContainedBidirectional-Element-1", element1.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0.eResource());
+ assertEquals(resource2, element1.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0);
+ assertContent(resource2, element1);
+ }
+
+ public void testCrossResourcePlainSingleNonContainedUnidirectional()
+ {
+ RefSingleNonContainedNPL container = factory.createRefSingleNonContainedNPL();
+ ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
+ element0.setName("CrossResourcePlainSingleNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(1, resource2.getContents().size());
+
+ container = (RefSingleNonContainedNPL)resource1.getContents().get(0);
+ element0 = (ContainedElementNoOpposite)resource2.getContents().get(0);
+
+ assertEquals(element0, container.getElement());
+ assertEquals("CrossResourcePlainSingleNonContainedUnidirectional-Element-0", element0.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0);
+ }
+
+ public void testCrossResourcePlainMultiNonContainedUnidirectional()
+ {
+ RefMultiNonContainedNPL container = factory.createRefMultiNonContainedNPL();
+ ContainedElementNoOpposite element0 = factory.createContainedElementNoOpposite();
+ element0.setName("CrossResourcePlainMultiNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ ContainedElementNoOpposite element1 = factory.createContainedElementNoOpposite();
+ element1.setName("CrossResourcePlainMultiNonContainedUnidirectional-Element-1");
+ resource2.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(2, resource2.getContents().size());
+
+ container = (RefMultiNonContainedNPL)resource1.getContents().get(0);
+ element0 = (ContainedElementNoOpposite)resource2.getContents().get(0);
+ element1 = (ContainedElementNoOpposite)resource2.getContents().get(1);
+
+ assertEquals(element0, container.getElements().get(0));
+ assertEquals(element1, container.getElements().get(1));
+ assertEquals("CrossResourcePlainMultiNonContainedUnidirectional-Element-0", element0.getName());
+ assertEquals("CrossResourcePlainMultiNonContainedUnidirectional-Element-1", element1.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0.eResource());
+ assertEquals(resource2, element1.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0);
+ assertContent(resource2, element1);
+ }
+
+ public void testCrossResourceGenRefSingleNonContainedUnidirectional()
+ {
+ GenRefSingleNonContained container = factory.createGenRefSingleNonContained();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("CrossResourceGenRefSingleNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(1, resource2.getContents().size());
+
+ container = (GenRefSingleNonContained)resource1.getContents().get(0);
+ element0 = (ImplContainedElementNPL)resource2.getContents().get(0);
+
+ assertEquals(element0, container.getElement());
+ assertEquals("CrossResourceGenRefSingleNonContainedUnidirectional-Element-0", element0.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0);
+ }
+
+ public void testCrossResourceGenRefMultiNonContainedUnidirectional()
+ {
+ GenRefMultiNonContained container = factory.createGenRefMultiNonContained();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("CrossResourceGenRefMultiNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
+ element1.setName("CrossResourceGenRefMultiNonContainedUnidirectional-Element-1");
+ resource2.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(2, resource2.getContents().size());
+
+ container = (GenRefMultiNonContained)resource1.getContents().get(0);
+ element0 = (ImplContainedElementNPL)resource2.getContents().get(0);
+ element1 = (ImplContainedElementNPL)resource2.getContents().get(1);
+
+ assertEquals(element0, container.getElements().get(0));
+ assertEquals(element1, container.getElements().get(1));
+ assertEquals("CrossResourceGenRefMultiNonContainedUnidirectional-Element-0", element0.getName());
+ assertEquals("CrossResourceGenRefMultiNonContainedUnidirectional-Element-1", element1.getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0.eResource());
+ assertEquals(resource2, element1.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0);
+ assertContent(resource2, element1);
+ }
+
+ public void testCrossResourceIfcimplSingleNonContainedBidirectional()
+ {
+ ImplSingleRefNonContainer container = factory.createImplSingleRefNonContainer();
+ ImplSingleRefNonContainedElement element0 = factory.createImplSingleRefNonContainedElement();
+ element0.setName("CrossResourceIfcimplSingleNonContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(1, resource2.getContents().size());
+
+ container = (ImplSingleRefNonContainer)CDOUtil.getEObject(resource1.getContents().get(0));
+ ISingleRefNonContainedElement element0_ = (ISingleRefNonContainedElement)resource2.getContents().get(0);
+
+ assertEquals(element0_, container.getElement());
+ assertEquals(container, element0_.getParent());
+ assertEquals("CrossResourceIfcimplSingleNonContainedBidirectional-Element-0",
+ ((ImplSingleRefNonContainedElement)element0_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0_);
+ }
+
+ public void testCrossResourceIfcimplMultiNonContainedBidirectional()
+ {
+ ImplMultiRefNonContainer container = factory.createImplMultiRefNonContainer();
+ ImplMultiRefNonContainedElement element0 = factory.createImplMultiRefNonContainedElement();
+ element0.setName("CrossResourceIfcimplMultiNonContainedBidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ ImplMultiRefNonContainedElement element1 = factory.createImplMultiRefNonContainedElement();
+ element1.setName("CrossResourceIfcimplMultiNonContainedBidirectional-Element-1");
+ resource2.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(2, resource2.getContents().size());
+
+ container = (ImplMultiRefNonContainer)resource1.getContents().get(0);
+ IMultiRefNonContainedElement element0_ = (IMultiRefNonContainedElement)resource2.getContents().get(0);
+ IMultiRefNonContainedElement element1_ = (IMultiRefNonContainedElement)resource2.getContents().get(1);
+
+ assertEquals(element0_, container.getElements().get(0));
+ assertEquals(element1_, container.getElements().get(1));
+ assertEquals(container, element0_.getParent());
+ assertEquals(container, element1_.getParent());
+ assertEquals("CrossResourceIfcimplMultiNonContainedBidirectional-Element-0",
+ ((ImplMultiRefNonContainedElement)element0_).getName());
+ assertEquals("CrossResourceIfcimplMultiNonContainedBidirectional-Element-1",
+ ((ImplMultiRefNonContainedElement)element1_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0_.eResource());
+ assertEquals(resource2, element1_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0_);
+ assertContent(resource2, element1_);
+ }
+
+ public void testCrossResourceIfcimplSingleNonContainedUnidirectional()
+ {
+ ImplSingleRefNonContainerNPL container = factory.createImplSingleRefNonContainerNPL();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("CrossResourceIfcimplSingleNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ container.setElement(element0);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(1, resource1.getContents().size());
+
+ container = (ImplSingleRefNonContainerNPL)resource1.getContents().get(0);
+ IContainedElementNoParentLink element0_ = (IContainedElementNoParentLink)resource2.getContents().get(0);
+
+ assertEquals(element0_, container.getElement());
+ assertEquals("CrossResourceIfcimplSingleNonContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0_);
+ }
+
+ public void testCrossResourceIfcimplMultiNonContainedUnidirectional()
+ {
+ ImplMultiRefNonContainerNPL container = factory.createImplMultiRefNonContainerNPL();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("CrossResourceIfcimplMultiNonContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ resource2.getContents().add(element0);
+ ImplContainedElementNPL element1 = factory.createImplContainedElementNPL();
+ element1.setName("CrossResourceIfcimplMultiNonContainedUnidirectional-Element-1");
+ resource2.getContents().add(element1);
+ container.getElements().add(element0);
+ container.getElements().add(element1);
+ commit();
+
+ purgeCaches();
+ assertEquals(1, resource1.getContents().size());
+ assertEquals(2, resource2.getContents().size());
+
+ container = (ImplMultiRefNonContainerNPL)resource1.getContents().get(0);
+ IContainedElementNoParentLink element0_ = (IContainedElementNoParentLink)resource2.getContents().get(0);
+ IContainedElementNoParentLink element1_ = (IContainedElementNoParentLink)resource2.getContents().get(1);
+
+ assertEquals(element0_, container.getElements().get(0));
+ assertEquals(element1_, container.getElements().get(1));
+ assertEquals("CrossResourceIfcimplMultiNonContainedUnidirectional-Element-0", ((INamedElement)element0_).getName());
+ assertEquals("CrossResourceIfcimplMultiNonContainedUnidirectional-Element-1", ((INamedElement)element1_).getName());
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, element0_.eResource());
+ assertEquals(resource2, element1_.eResource());
+
+ assertContent(resource1, container);
+ assertContent(resource2, element0_);
+ assertContent(resource2, element1_);
+ }
+
+ public void testMultipleTransactions3() throws CommitException
+ {
+ CDOTransaction transaction1 = session.openTransaction();
+ String resource1path = getResourcePath("/resources/3/" + uniqueCounter);
+ CDOResource resource1 = transaction1.createResource(resource1path);
+ transaction1.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ String resource2path = getResourcePath("/resources/4/" + uniqueCounter++);
+ CDOResource resource2 = transaction2.createResource(resource2path);
+ transaction2.commit();
+
+ MultiContainedElement element0 = factory.createMultiContainedElement();
+ element0.setName("MultipleTransactions-Element-0");
+
+ MultiContainedElement element1 = factory.createMultiContainedElement();
+ element1.setName("MultipleTransactions-Element-0");
+
+ MultiContainedElement element2 = factory.createMultiContainedElement();
+ element2.setName("MultipleTransactions-Element-0");
+
+ MultiContainedElement element3 = factory.createMultiContainedElement();
+ element3.setName("MultipleTransactions-Element-0");
+
+ resource1.getContents().add(element0);
+ resource1.getContents().add(element1);
+ resource1.getContents().add(element2);
+ resource1.getContents().add(element3);
+
+ transaction1.commit();
+
+ RefMultiContained container = factory.createRefMultiContained();
+ resource2.getContents().add(container);
+
+ transaction2.commit();
+
+ CDOTransaction transaction3 = session.openTransaction();
+ EList<EObject> elements = transaction3.getResource(resource1path).getContents();
+ EList<EObject> containers = transaction3.getResource(resource2path).getContents();
+ List<EObject> elementToRemove = new ArrayList<EObject>();
+ for (EObject o : elements)
+ {
+ elementToRemove.add(o);
+ }
+
+ RefMultiContained container_work = (RefMultiContained)containers.get(0);
+ for (EObject o : elementToRemove)
+ {
+ MultiContainedElement element_work = (MultiContainedElement)o;
+ container_work.getElements().add(element_work);
+ transaction3.commit();
+ }
+ }
+
+ public void testMultipleTransactions2() throws CommitException
+ {
+ CDOTransaction transaction1 = session.openTransaction();
+ String resource1path = getResourcePath("/resources/3/" + uniqueCounter);
+ CDOResource resource1 = transaction1.createResource(resource1path);
+ transaction1.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ String resource2path = getResourcePath("/resources/4/" + uniqueCounter++);
+ CDOResource resource2 = transaction2.createResource(resource2path);
+ transaction2.commit();
+
+ MultiContainedElement element0 = factory.createMultiContainedElement();
+ element0.setName("MultipleTransactions-Element-0");
+
+ MultiContainedElement element1 = factory.createMultiContainedElement();
+ element1.setName("MultipleTransactions-Element-0");
+
+ MultiContainedElement element2 = factory.createMultiContainedElement();
+ element2.setName("MultipleTransactions-Element-0");
+
+ MultiContainedElement element3 = factory.createMultiContainedElement();
+ element3.setName("MultipleTransactions-Element-0");
+
+ resource1.getContents().add(element0);
+ resource1.getContents().add(element1);
+ resource1.getContents().add(element2);
+ resource1.getContents().add(element3);
+
+ transaction1.commit();
+
+ RefMultiContained container = factory.createRefMultiContained();
+ resource2.getContents().add(container);
+
+ transaction2.commit();
+ CDOResource resource1FromTx2 = transaction2.getResource(resource1path);
+ EList<EObject> elements = resource1FromTx2.getContents();
+ List<EObject> elementToRemove = new ArrayList<EObject>();
+ for (EObject o : elements)
+ {
+ elementToRemove.add(o);
+ }
+
+ for (EObject o : elementToRemove)
+ {
+ MultiContainedElement element_work = (MultiContainedElement)o;
+ assertEquals(resource1FromTx2, CDOUtil.getCDOObject(element_work).cdoDirectResource());
+ assertEquals(resource1FromTx2, element_work.eResource());
+
+ container.getElements().add(element_work);
+
+ assertEquals(null, CDOUtil.getCDOObject(element_work).cdoDirectResource());
+ assertEquals(resource2, element_work.eResource());
+ transaction2.commit();
+ }
+ }
+
+ public void testMigrateContainmentSingle()
+ {
+ SingleContainedElement element = factory.createSingleContainedElement();
+ element.setName("MigrateContainmentSingle-Element-0");
+
+ RefSingleContained container1 = factory.createRefSingleContained();
+ container1.setElement(element);
+ resource1.getContents().add(container1);
+
+ RefSingleContained container2 = factory.createRefSingleContained();
+ resource2.getContents().add(container2);
+ commit();
+
+ container2.setElement(element);
+ commit();
+
+ assertEquals(true, element.getParent() == container2);
+ assertEquals(true, element.eContainer() == container2);
+ assertEquals(true, CDOUtil.getCDOObject(element).cdoDirectResource() == null);
+
+ assertEquals(true, container1.getElement() == null);
+ assertEquals(true, CDOUtil.getCDOObject(container1).cdoDirectResource() == resource1);
+
+ assertEquals(true, container2.getElement() == element);
+ assertEquals(true, CDOUtil.getCDOObject(container2).cdoDirectResource() == resource2);
+ }
+
+ public void testMigrateContainmentMulti()
+ {
+ MultiContainedElement elementA = factory.createMultiContainedElement();
+ elementA.setName("MigrateContainmentMulti-Element-A");
+
+ MultiContainedElement elementB = factory.createMultiContainedElement();
+ elementB.setName("MigrateContainmentMulti-Element-B");
+
+ RefMultiContained container1 = factory.createRefMultiContained();
+ container1.getElements().add(elementA);
+ container1.getElements().add(elementB);
+
+ resource1.getContents().add(container1);
+
+ RefMultiContained container2 = factory.createRefMultiContained();
+ resource2.getContents().add(container2);
+ commit();
+
+ container2.getElements().add(container1.getElements().get(0));
+ commit();
+
+ assertEquals(true, elementA.getParent() == container2);
+ assertEquals(true, elementA.eContainer() == container2);
+ assertEquals(true, CDOUtil.getCDOObject(elementA).cdoDirectResource() == null);
+ assertEquals(true, elementA.eResource() == resource2);
+
+ assertEquals(true, elementB.getParent() == container1);
+ assertEquals(true, elementB.eContainer() == container1);
+ assertEquals(true, CDOUtil.getCDOObject(elementB).cdoDirectResource() == null);
+ assertEquals(true, elementB.eResource() == resource1);
+
+ assertEquals(true, CDOUtil.getCDOObject(container1).cdoDirectResource() == resource1);
+ assertEquals(1, container1.getElements().size());
+ assertEquals(elementB, container1.getElements().get(0));
+
+ assertEquals(true, CDOUtil.getCDOObject(container2).cdoDirectResource() == resource2);
+ assertEquals(1, container2.getElements().size());
+ assertEquals(elementA, container2.getElements().get(0));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java
index 3eee1a635f..7802e43f3d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java
@@ -1,3825 +1,3825 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model6.BaseObject;
-import org.eclipse.emf.cdo.tests.model6.ContainmentObject;
-import org.eclipse.emf.cdo.tests.model6.ReferenceObject;
-import org.eclipse.emf.cdo.tests.model6.Root;
-import org.eclipse.emf.cdo.transaction.CDOConflictResolver;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.EList;
-
-import java.util.List;
-
-/**
- * @author Pascal Lehmann
- */
-public class ConflictResolverExtendedTest extends AbstractCDOTest
-{
- private static final String TEST_RESOURCE_NAME = "/test1";
-
- @SuppressWarnings("deprecation")
- private CDOConflictResolver conflictResolver = new org.eclipse.emf.spi.cdo.CDOMergingConflictResolver();
-
- // --- initialize model ----------------------------------------------------
-
- private void initTestModelSimple() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(TEST_RESOURCE_NAME));
-
- Root testRoot = getModel6Factory().createRoot();
- resource.getContents().add(testRoot);
-
- BaseObject bObject1 = createBaseObject("BaseObject 1"); //$NON-NLS-1$
- BaseObject bObject2 = createBaseObject("BaseObject 2"); //$NON-NLS-1$
- BaseObject bObject3 = createBaseObject("BaseObject 3"); //$NON-NLS-1$
-
- testRoot.getListA().add(bObject1);
- testRoot.getListA().add(bObject2);
- testRoot.getListA().add(bObject3);
-
- ContainmentObject cObject1L1 = createContainmentObject("ContainmentObject 1 - Level 1"); //$NON-NLS-1$
- ContainmentObject cObject1L2 = createContainmentObject("ContainmentObject 1 - Level 2"); //$NON-NLS-1$
- cObject1L1.getContainmentList().add(cObject1L2);
-
- testRoot.getListB().add(cObject1L1);
-
- transaction.commit();
- }
-
- private void initTestModel() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(TEST_RESOURCE_NAME));
-
- Root root = getModel6Factory().createRoot();
- resource.getContents().add(root);
-
- // setup base objects.
- BaseObject bObject0 = createBaseObject("BaseObject 0"); //$NON-NLS-1$
- BaseObject bObject1 = createBaseObject("BaseObject 1"); //$NON-NLS-1$
- BaseObject bObject2 = createBaseObject("BaseObject 2"); //$NON-NLS-1$
- BaseObject bObject3 = createBaseObject("BaseObject 3"); //$NON-NLS-1$
- BaseObject bObject4 = createBaseObject("BaseObject 4"); //$NON-NLS-1$
-
- root.getListA().add(bObject0);
- root.getListA().add(bObject1);
- root.getListA().add(bObject2);
- root.getListA().add(bObject3);
- root.getListA().add(bObject4);
-
- // containment objects.
- ContainmentObject cObject0 = createContainmentObject("ContainmentObject 0"); //$NON-NLS-1$
- ContainmentObject cObject00 = createContainmentObject("ContainmentObject 00"); //$NON-NLS-1$
- BaseObject bcObject01 = createBaseObject("BaseContainmentObject 01"); //$NON-NLS-1$
-
- cObject00.getContainmentList().add(bcObject01);
- cObject0.getContainmentList().add(cObject00);
-
- ContainmentObject cObject1 = createContainmentObject("ContainmentObject 1"); //$NON-NLS-1$
-
- root.getListB().add(cObject0);
- root.getListB().add(cObject1);
-
- // commit the model.
- transaction.commit();
- }
-
- // --- conflict test -------------------------------------------------------
-
- public void _testProvokeConflictOnServerTest() throws Exception
- {
- // should provoke an "attempt to modify historical revision" error.
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
-
- initTestModelSimple();
-
- BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
- assertNotNull(thisObject);
- BaseObject thatObject = thatTransaction.getObject(thisObject);
-
- thisObject.setAttributeOptional("this"); //$NON-NLS-1$
- thatObject.setAttributeOptional("that"); //$NON-NLS-1$
-
- thisTransaction.commit();
-
- try
- {
- commitAndSync(thatTransaction, thisTransaction);
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- }
- }
-
- public void _testProvokeConflictLocalTest() throws Exception
- {
- // should provoke an "this transaction has conflicts" error.
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
-
- initTestModelSimple();
-
- BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
- assertNotNull(thisObject);
- BaseObject thatObject = thatTransaction.getObject(thisObject);
-
- thisObject.setAttributeOptional("this"); //$NON-NLS-1$
- thatObject.setAttributeOptional("that"); //$NON-NLS-1$
-
- commitAndSync(thisTransaction, thatTransaction);
-
- try
- {
- commitAndSync(thatTransaction, thisTransaction);
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- }
- }
-
- // --- single value conflict resolver tests --------------------------
-
- public void testConflictResolverChangeChangeTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
-
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
- thisObject.setAttributeOptional("this"); //$NON-NLS-1$
-
- BaseObject thatObject = thatTransaction.getObject(thisObject);
- thatObject.setAttributeOptional("that"); //$NON-NLS-1$
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- }
-
- public void testConflictResolverRemoveChangeTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
-
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
- assertNotNull(thisObject);
-
- BaseObject thatObject = thatTransaction.getObject(thisObject);
- assertNotNull(thatObject);
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // remove object.
- getTestModelRoot(thisTransaction).getListA().remove(0);
-
- // change object.
- thatObject.setAttributeOptional("that"); //$NON-NLS-1$
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testConflictResolverChangeRemoveTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
-
- // add conflict resolver.
- addConflictResolver(thatTransaction);
-
- BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
- assertNotNull(thisObject);
- BaseObject thatObject = thatTransaction.getObject(thisObject);
- assertNotNull(thatObject);
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // change object.
- thisObject.setAttributeOptional("this"); //$NON-NLS-1$
-
- // remove object.
- Root thatRoot = thatTransaction.getObject(getTestModelRoot(thisTransaction));
- thatRoot.getListA().remove(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testConflictResolverRemoveAddTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
-
- // add conflict resolver.
- addConflictResolver(thatTransaction);
-
- ContainmentObject thisObject = (ContainmentObject)getTestModelRoot(thisTransaction).getListB().get(0);
- assertNotNull(thisObject);
- ContainmentObject thatObject = thatTransaction.getObject(thisObject);
- assertNotNull(thatObject);
- int objects = getTestModelRoot(thisTransaction).getListB().size();
-
- // remove object.
- getTestModelRoot(thisTransaction).getListB().remove(0);
-
- // add object.
- BaseObject addObject = createBaseObject("AddObject"); //$NON-NLS-1$
-
- ContainmentObject thatChild = (ContainmentObject)thatObject.getContainmentList().get(0);
- assertNotNull(thatChild);
- thatChild.getContainmentList().add(addObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListB().size());
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- }
-
- public void testConflictResolverAddRemoveTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
-
- // add conflict resolver.
- addConflictResolver(thatTransaction);
-
- ContainmentObject thisObject = (ContainmentObject)getTestModelRoot(thisTransaction).getListB().get(0);
- assertNotNull(thisObject);
- ContainmentObject thatObject = thatTransaction.getObject(thisObject);
- assertNotNull(thatObject);
- int objects = getTestModelRoot(thisTransaction).getListB().size();
-
- // add object.
- BaseObject addObject = createBaseObject("AddObject"); //$NON-NLS-1$
-
- ContainmentObject thisChild = (ContainmentObject)thisObject.getContainmentList().get(0);
- assertNotNull(thisChild);
- thisChild.getContainmentList().add(addObject);
-
- // remove object.
- Root thatRoot = thatTransaction.getObject(getTestModelRoot(thisTransaction));
- thatRoot.getListB().remove(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListB().size());
- }
-
- public void testConflictResolverRemoveRemoveTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
-
- // add conflict resolver.
- addConflictResolver(thatTransaction);
-
- ContainmentObject thisObject = (ContainmentObject)getTestModelRoot(thisTransaction).getListB().get(0);
- assertNotNull(thisObject);
- ContainmentObject thatObject = thatTransaction.getObject(thisObject);
- assertNotNull(thatObject);
- int objects = getTestModelRoot(thisTransaction).getListB().size();
-
- // remove object.
- getTestModelRoot(thisTransaction).getListB().remove(0);
-
- // remove object.
- Root thatRoot = thatTransaction.getObject(getTestModelRoot(thisTransaction));
- thatRoot.getListB().remove(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListB().size());
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- }
-
- // --- resolve many valued changes -------------------------------------
-
- public void testManyValuedAddAddTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // create new objects.
- BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
- BaseObject thatObject = createBaseObject("ThatObject"); //$NON-NLS-1$
-
- // add elements.
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().add(thisObject);
-
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(objects + 2, getTestModelRoot(thisTransaction).getListA().size());
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- }
-
- public void testManyValuedAddChangeTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // create new objects.
- BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
-
- // add elements.
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().add(thisObject);
-
- // move element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- EList<BaseObject> containmentList = thatRoot.getListA();
- containmentList.move(2, containmentList.get(0));
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects + 1, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedChangeAddTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // move element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- EList<BaseObject> containmentList = thisRoot.getListA();
- containmentList.move(2, containmentList.get(0));
-
- // create new objects.
- BaseObject thatObject = createBaseObject("ThatObject"); //$NON-NLS-1$
-
- // add elements.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects + 1, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedAddRemoveTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // create new objects.
- BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
-
- // add elements.
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().add(thisObject);
-
- // remove element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().remove(1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedRemoveAddTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // remove element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().remove(1);
-
- // create new objects.
- BaseObject thatObject = createBaseObject("ThatObject"); //$NON-NLS-1$
-
- // add elements.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedChangeRemoveTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // move element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- EList<BaseObject> containmentList = thisRoot.getListA();
- containmentList.move(2, containmentList.get(0));
-
- // remove element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().remove(1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedChangeRemoveTest2() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // move element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- EList<BaseObject> containmentList = thisRoot.getListA();
- containmentList.move(2, containmentList.get(0));
-
- // remove same element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().remove(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedRemoveChangeTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // remove element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().remove(1);
-
- // move element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- EList<BaseObject> listA = thatRoot.getListA();
- listA.move(2, 0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedRemoveChangeTest2() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // remove same element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().remove(0);
-
- // move element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- EList<BaseObject> containmentList = thatRoot.getListA();
- containmentList.move(2, containmentList.get(0));
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedChangeChangeTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // move element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- EList<BaseObject> containmentList = thisRoot.getListA();
- containmentList.move(2, containmentList.get(0));
-
- // move element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- EList<BaseObject> thatContainmentList = thatRoot.getListA();
- thatContainmentList.move(2, thatContainmentList.get(1));
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedChangeChangeTest2() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // move element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- EList<BaseObject> containmentList = thisRoot.getListA();
- containmentList.move(2, containmentList.get(0));
-
- // move element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- EList<BaseObject> thatContainmentList = thatRoot.getListA();
- thatContainmentList.move(2, thatContainmentList.get(0));
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedRemoveRemoveTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // remove element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().remove(0);
-
- // remove element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().remove(2);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects - 2, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedRemoveRemoveTest2() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // remove element.
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().remove(0);
-
- // remove same element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().remove(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedAddAddRemoveRemoveTest() throws Exception
- {
- // test to produce exception of bug #306710
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // add some elements.
- BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
- BaseObject thisObject2 = createBaseObject("ThisObject2"); //$NON-NLS-1$
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().add(0, thisObject);
- thisRoot.getListA().add(0, thisObject2);
-
- // remove element.
- thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().remove(4);
-
- // remove element.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().remove(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
- }
-
- public void testManyValuedAddAddRemoveRemove2Test() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // remove elements.
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().remove(0);
- thisRoot.getListA().remove(0);
-
- // add elements.
- BaseObject thatObject = createBaseObject("ThatObject"); //$NON-NLS-1$
- BaseObject thatObject2 = createBaseObject("ThatObject2"); //$NON-NLS-1$
-
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().add(thatObject);
- thatRoot.getListA().add(thatObject2);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
-
- }
-
- public void testManyValuedRemoveRemoveAddAddTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModelSimple();
- addConflictResolver(thatTransaction);
-
- int objects = getTestModelRoot(thisTransaction).getListA().size();
-
- // add elements.
- BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
- BaseObject thisObject2 = createBaseObject("ThisObject2"); //$NON-NLS-1$
-
- Root thisRoot = getTestModelRoot(thisTransaction);
- thisRoot.getListA().add(thisObject);
- thisRoot.getListA().add(thisObject2);
-
- // remove elements.
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
- thatRoot.getListA().remove(0);
- thatRoot.getListA().remove(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
-
- }
-
- // --- list conflict resolver tests ----------------------------------------
-
- public void testAddHeadAddHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(0, thisObject);
-
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(0, thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(0), thisObject);
- assertEquals(thisRoot.getListA().get(1), thisTransaction.getObject(thatObject));
- assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(1), thatObject);
- }
-
- public void testAddHeadAddTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(0, thisObject);
-
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(0), thisObject);
- assertEquals(thisRoot.getListA().get(size - 1), thisTransaction.getObject(thatObject));
- assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(size - 1), thatObject);
- }
-
- public void testAddTailAddTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(thisObject);
-
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(size - 2), thisObject);
- assertEquals(thisRoot.getListA().get(size - 1), thisTransaction.getObject(thatObject));
- assertEquals(thatRoot.getListA().get(size - 2), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(size - 1), thatObject);
- }
-
- public void testAddTailAddHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(thisObject);
-
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(0, thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(size - 1), thisObject);
- assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatObject));
- assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(0), thatObject);
- }
-
- // add - remove
-
- public void testAddHeadRemoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create object.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(0, thisObject);
-
- // remove object (get it before deletion).
- BaseObject thatRemoveObject = thatRoot.getListA().get(0);
- assertNotNull(thatRemoveObject);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- assertNotNull(thisRemoveObject);
-
- thatRoot.getListA().remove(0);
- BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(0), thisObject);
- assertEquals(thisRoot.getListA().get(1), thisTransaction.getObject(thatAfterRemoveObject));
- assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(1), thatAfterRemoveObject);
- assertEquals(CDOUtil.getCDOObject(thisRemoveObject).cdoState(), CDOState.INVALID);
- assertEquals(CDOUtil.getCDOObject(thatRemoveObject).cdoState(), CDOState.TRANSIENT);
- }
-
- public void testAddHeadRemoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create object.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(0, thisObject);
-
- // remove object (get it before deletion).
- int listSize = thatRoot.getListA().size();
- BaseObject thatRemoveObject = thatRoot.getListA().get(listSize - 1);
- assertNotNull(thatRemoveObject);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- assertNotNull(thisRemoveObject);
-
- thatRoot.getListA().remove(listSize - 1);
- BaseObject thatBeforeRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(0), thisObject);
- assertEquals(thisRoot.getListA().get(size - 1), thisTransaction.getObject(thatBeforeRemoveObject));
- assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(size - 1), thatBeforeRemoveObject);
- assertEquals(CDOUtil.getCDOObject(thisRemoveObject).cdoState(), CDOState.INVALID);
- assertEquals(CDOUtil.getCDOObject(thatRemoveObject).cdoState(), CDOState.TRANSIENT);
- }
-
- public void testAddTailRemoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create object.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(thisObject);
-
- // remove object (get it before deletion).
- int listSize = thatRoot.getListA().size();
- BaseObject thatRemoveObject = thatRoot.getListA().get(listSize - 1);
- assertNotNull(thatRemoveObject);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- assertNotNull(thisRemoveObject);
-
- thatRoot.getListA().remove(listSize - 1);
- BaseObject thatBeforeRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(size - 1), thisObject);
- assertEquals(thisRoot.getListA().get(size - 2), thisTransaction.getObject(thatBeforeRemoveObject));
- assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(size - 2), thatBeforeRemoveObject);
- assertEquals(CDOUtil.getCDOObject(thisRemoveObject).cdoState(), CDOState.INVALID);
- assertEquals(CDOUtil.getCDOObject(thatRemoveObject).cdoState(), CDOState.TRANSIENT);
- }
-
- public void testAddTailRemoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(thisObject);
-
- // remove object (get it before deletion).
- BaseObject thatRemoveObject = thatRoot.getListA().get(0);
- assertNotNull(thatRemoveObject);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- assertNotNull(thisRemoveObject);
-
- thatRoot.getListA().remove(0);
- BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(size - 1), thisObject);
- assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatAfterRemoveObject));
- assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(0), thatAfterRemoveObject);
- assertEquals(CDOUtil.getCDOObject(thisRemoveObject).cdoState(), CDOState.INVALID);
- assertEquals(CDOUtil.getCDOObject(thatRemoveObject).cdoState(), CDOState.TRANSIENT);
- }
-
- // add - move
-
- public void testAddHeadMoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create object.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(0, thisObject);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(0);
- thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(0), thisObject);
- assertEquals(thisRoot.getListA().get(size - 1), thisTransaction.getObject(thatMoveObject));
- assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(size - 1), thatMoveObject);
- }
-
- public void testAddHeadMoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create object.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(0, thisObject);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(0), thisObject);
- assertEquals(thisRoot.getListA().get(1), thisTransaction.getObject(thatMoveObject));
- assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(1), thatMoveObject);
- }
-
- public void testAddTailMoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create object.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(thisObject);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(size - 1), thisObject);
- assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatMoveObject));
- assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(0), thatMoveObject);
- }
-
- public void testAddTailMoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(thisObject);
-
- // remove object.
- thatRoot.getListA().remove(0);
- BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(size - 1), thisObject);
- assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatAfterRemoveObject));
- assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
- assertEquals(thatRoot.getListA().get(0), thatAfterRemoveObject);
- }
-
- public void testAddHeadClearTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(0, thisObject);
-
- // clear list.
- thatRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisObject).cdoState());
- }
-
- public void testAddTailClearTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
- thisRoot.getListA().add(thisObject);
-
- // clear list.
- thatRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisObject).cdoState());
- }
-
- public void testRemoveHeadAddHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(0);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
-
- // create object.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(0, thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatObject));
- assertEquals(thisRoot.getListA().get(1), thisAfterRemoveObject);
- assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thatObject));
- assertEquals(thatRoot.getListA().get(1), thatTransaction.getObject(thisAfterRemoveObject));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- }
-
- public void testRemoveHeadAddTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(0);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
-
- // create object.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(listSize - 1), thisTransaction.getObject(thatObject));
- assertEquals(thisRoot.getListA().get(0), thisAfterRemoveObject);
- assertEquals(thatRoot.getListA().get(listSize - 1), thatTransaction.getObject(thatObject));
- assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisAfterRemoveObject));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- }
-
- public void testRemoveTailAddHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // create object.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(0, thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatObject));
- assertEquals(thisRoot.getListA().get(listSize - 1), thisAfterRemoveObject);
- assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thatObject));
- assertEquals(thatRoot.getListA().get(listSize - 1), thatTransaction.getObject(thisAfterRemoveObject));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- }
-
- public void testRemoveTailAddTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // create object.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisRoot.getListA().get(listSize - 1), thisTransaction.getObject(thatObject));
- assertEquals(thisRoot.getListA().get(listSize - 2), thisAfterRemoveObject);
- assertEquals(thatRoot.getListA().get(listSize - 1), thatTransaction.getObject(thatObject));
- assertEquals(thatRoot.getListA().get(listSize - 2), thatTransaction.getObject(thisAfterRemoveObject));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- }
-
- public void testRemoveHeadRemoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject1 = thisRoot.getListA().get(0);
- assertNotNull(thisRemoveObject1);
- BaseObject thatRemoveObject1 = thatTransaction.getObject(thisRemoveObject1);
- assertNotNull(thatRemoveObject1);
-
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemoveObject1 = thisRoot.getListA().get(0);
-
- // // remove object (get it before deletion).
- BaseObject thatRemoveObject2 = thatRoot.getListA().get(0);
- assertNotNull(thatRemoveObject2);
- BaseObject thisRemoveObject2 = thisTransaction.getObject(thatRemoveObject2);
- assertNotNull(thisRemoveObject2);
-
- thatRoot.getListA().remove(0);
- BaseObject thatAfterRemoveObject2 = thatRoot.getListA().get(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveObject1, thisRoot.getListA().get(0));
- assertEquals(thatAfterRemoveObject2, thatRoot.getListA().get(0));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject1).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject1).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject2).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject2).cdoState());
- }
-
- public void testRemoveHeadRemoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject1 = thisRoot.getListA().get(0);
- assertNotNull(thisRemoveObject1);
- BaseObject thatRemoveObject1 = thatTransaction.getObject(thisRemoveObject1);
- assertNotNull(thatRemoveObject1);
-
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemoveObject1 = thisRoot.getListA().get(0);
-
- // // remove object (get it before deletion).
- BaseObject thatRemoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- assertNotNull(thatRemoveObject2);
- BaseObject thisRemoveObject2 = thisTransaction.getObject(thatRemoveObject2);
- assertNotNull(thisRemoveObject2);
-
- thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
- BaseObject thatAfterRemoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveObject1, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveObject1), thatRoot.getListA().get(0));
- assertEquals(thisTransaction.getObject(thatAfterRemoveObject2), thisRoot.getListA().get(listSize - 1));
- assertEquals(thatAfterRemoveObject2, thatRoot.getListA().get(listSize - 1));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject1).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject1).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject2).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject2).cdoState());
- }
-
- public void testRemoveTailRemoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- assertNotNull(thisRemoveObject1);
- BaseObject thatRemoveObject1 = thatTransaction.getObject(thisRemoveObject1);
- assertNotNull(thatRemoveObject1);
-
- thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
- BaseObject thisAfterRemoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // // remove object (get it before deletion).
- BaseObject thatRemoveObject2 = thatRoot.getListA().get(0);
- assertNotNull(thatRemoveObject2);
- BaseObject thisRemoveObject2 = thisTransaction.getObject(thatRemoveObject2);
- assertNotNull(thisRemoveObject2);
-
- thatRoot.getListA().remove(0);
- BaseObject thatAfterRemoveObject2 = thatRoot.getListA().get(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveObject1, thisRoot.getListA().get(listSize - 1));
- assertEquals(thatTransaction.getObject(thisAfterRemoveObject1), thatRoot.getListA().get(listSize - 1));
- assertEquals(thisTransaction.getObject(thatAfterRemoveObject2), thisRoot.getListA().get(0));
- assertEquals(thatAfterRemoveObject2, thatRoot.getListA().get(0));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject1).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject1).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject2).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject2).cdoState());
- }
-
- public void testRemoveTailRemoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- assertNotNull(thisRemoveObject1);
- BaseObject thatRemoveObject1 = thatTransaction.getObject(thisRemoveObject1);
- assertNotNull(thatRemoveObject1);
-
- thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
- BaseObject thisAfterRemoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // // remove object (get it before deletion).
- BaseObject thatRemoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- assertNotNull(thatRemoveObject2);
- BaseObject thisRemoveObject2 = thisTransaction.getObject(thatRemoveObject2);
- assertNotNull(thisRemoveObject2);
-
- thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
- BaseObject thatAfterRemoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveObject1, thisRoot.getListA().get(listSize - 1));
- assertEquals(thatTransaction.getObject(thisAfterRemoveObject1), thatRoot.getListA().get(listSize - 1));
- assertEquals(thisTransaction.getObject(thatAfterRemoveObject2), thisRoot.getListA().get(listSize - 1));
- assertEquals(thatAfterRemoveObject2, thatRoot.getListA().get(listSize - 1));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject1).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject1).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject2).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject2).cdoState());
- }
-
- public void testRemoveHeadMoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(0);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(0);
- thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
- BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(0));
- assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(0));
- assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
- }
-
- public void testRemoveHeadMoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(0);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
- BaseObject thatAfterMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(1));
- assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(1));
- assertEquals(thisTransaction.getObject(thatMoveObject), thisRoot.getListA().get(0));
- assertEquals(thatMoveObject, thatRoot.getListA().get(0));
- assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(listSize - 1));
- assertEquals(thatAfterMoveObject, thatRoot.getListA().get(listSize - 1));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- }
-
- public void testRemoveTailMoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(0);
- thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
- BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(listSize - 2));
- assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(listSize - 2));
- assertEquals(thisTransaction.getObject(thatMoveObject), thisRoot.getListA().get(listSize - 1));
- assertEquals(thatMoveObject, thatRoot.getListA().get(listSize - 1));
- assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(0));
- assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- }
-
- public void testRemoveTailMoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
- BaseObject thatAfterMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(listSize - 1));
- assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(listSize - 1));
- assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(listSize - 1));
- assertEquals(thatAfterMoveObject, thatRoot.getListA().get(listSize - 1));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
- }
-
- public void testRemoveHeadClearTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(0);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
-
- // clear.
- thatRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisAfterRemoveObject).cdoState());
- }
-
- public void testRemoveTailClearTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // clear.
- thatRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisAfterRemoveObject).cdoState());
- }
-
- public void testMoveHeadAddHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(0);
- thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
-
- // create object.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(0, thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(0));
- assertEquals(thatObject, thatRoot.getListA().get(0));
- assertEquals(thisAfterMoveObject, thisRoot.getListA().get(1));
- assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(1));
- assertEquals(thisMoveObject, thisRoot.getListA().get(size - 1));
- assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(size - 1));
- }
-
- public void testMoveHeadAddTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(0);
- thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
-
- // create object.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(size - 1));
- assertEquals(thatObject, thatRoot.getListA().get(size - 1));
- assertEquals(thisAfterMoveObject, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(0));
- assertEquals(thisMoveObject, thisRoot.getListA().get(size - 2));
- assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(size - 2));
- }
-
- public void testMoveTailAddHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // create object.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$);
- thatRoot.getListA().add(0, thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(1));
- assertEquals(thatObject, thatRoot.getListA().get(1));
- assertEquals(thisAfterMoveObject, thisRoot.getListA().get(size - 1));
- assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(size - 1));
- assertEquals(thisMoveObject, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(0));
- }
-
- public void testMoveTailAddTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // create object.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$);
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(size - 1));
- assertEquals(thatObject, thatRoot.getListA().get(size - 1));
- assertEquals(thisAfterMoveObject, thisRoot.getListA().get(size - 2));
- assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(size - 2));
- assertEquals(thisMoveObject, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(0));
- }
-
- public void testMoveHeadRemoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(0);
- thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
-
- // remove object.
- BaseObject thatRemoveObject = thatRoot.getListA().get(0);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- thatRoot.getListA().remove(0);
- BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterMoveObject, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(0));
- assertEquals(thisTransaction.getObject(thatAfterRemoveObject), thisRoot.getListA().get(0));
- assertEquals(thatAfterRemoveObject, thatRoot.getListA().get(0));
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisMoveObject).cdoState());
- }
-
- public void testMoveHeadRemoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(0);
- thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
-
- // remove object.
- BaseObject thatRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
- BaseObject thatAfterRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterMoveObject, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(0));
- assertEquals(thisMoveObject, thisRoot.getListA().get(size - 1));
- assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(size - 1));
- assertEquals(thisTransaction.getObject(thatAfterRemoveObject), thisRoot.getListA().get(size - 2));
- assertEquals(thatAfterRemoveObject, thatRoot.getListA().get(size - 2));
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- }
-
- public void testMoveTailRemoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // remove object.
- BaseObject thatRemoveObject = thatRoot.getListA().get(0);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- thatRoot.getListA().remove(0);
- BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterMoveObject, thisRoot.getListA().get(size - 1));
- assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(size - 1));
- assertEquals(thisMoveObject, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(0));
- assertEquals(thisTransaction.getObject(thatAfterRemoveObject), thisRoot.getListA().get(1));
- assertEquals(thatAfterRemoveObject, thatRoot.getListA().get(1));
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- }
-
- public void testMoveTailRemoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
-
- // remove object.
- BaseObject thatRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
- BaseObject thatAfterRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterMoveObject, thisRoot.getListA().get(size - 1));
- assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(size - 1));
- assertEquals(thisTransaction.getObject(thatAfterRemoveObject), thisRoot.getListA().get(size - 1));
- assertEquals(thatAfterRemoveObject, thatRoot.getListA().get(size - 1));
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisMoveObject).cdoState());
- }
-
- public void testMoveHeadMoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject1 = thisRoot.getListA().get(0);
- BaseObject thatMoveObject1 = thatTransaction.getObject(thisMoveObject1);
- thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
- BaseObject thisAfterMoveObject1 = thisRoot.getListA().get(0);
- BaseObject thatAfterMoveObject1 = thatTransaction.getObject(thisAfterMoveObject1);
-
- // Move object.
- BaseObject thatMoveObject2 = thatRoot.getListA().get(0);
- BaseObject thisMoveObject2 = thisTransaction.getObject(thatMoveObject2);
- thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
- BaseObject thatAfterMoveObject2 = thatRoot.getListA().get(0);
- BaseObject thisAfterMoveObject2 = thisTransaction.getObject(thatAfterMoveObject2);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisMoveObject1, thisRoot.getListA().get(size - 1));
- assertEquals(thatMoveObject1, thatRoot.getListA().get(size - 1));
- assertEquals(thisMoveObject2, thisRoot.getListA().get(size - 1));
- assertEquals(thatMoveObject2, thatRoot.getListA().get(size - 1));
- assertEquals(thisAfterMoveObject1, thisRoot.getListA().get(0));
- assertEquals(thatAfterMoveObject1, thatRoot.getListA().get(0));
- assertEquals(thisAfterMoveObject2, thisRoot.getListA().get(0));
- assertEquals(thatAfterMoveObject2, thatRoot.getListA().get(0));
- }
-
- public void testMoveHeadMoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject1 = thisRoot.getListA().get(0);
- BaseObject thatMoveObject1 = thatTransaction.getObject(thisMoveObject1);
- thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
- BaseObject thisAfterMoveObject1 = thisRoot.getListA().get(0);
- BaseObject thatAfterMoveObject1 = thatTransaction.getObject(thisAfterMoveObject1);
-
- // Move object.
- BaseObject thatMoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- BaseObject thisMoveObject2 = thisTransaction.getObject(thatMoveObject2);
- thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
- BaseObject thatAfterMoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject2 = thisTransaction.getObject(thatAfterMoveObject2);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisMoveObject1, thisRoot.getListA().get(size - 1));
- assertEquals(thatMoveObject1, thatRoot.getListA().get(size - 1));
- assertEquals(thisMoveObject2, thisRoot.getListA().get(0));
- assertEquals(thatMoveObject2, thatRoot.getListA().get(0));
- assertEquals(thisAfterMoveObject1, thisRoot.getListA().get(1));
- assertEquals(thatAfterMoveObject1, thatRoot.getListA().get(1));
- assertEquals(thisAfterMoveObject2, thisRoot.getListA().get(size - 2));
- assertEquals(thatAfterMoveObject2, thatRoot.getListA().get(size - 2));
- }
-
- public void testMoveTailMoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- BaseObject thatMoveObject1 = thatTransaction.getObject(thisMoveObject1);
- thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- BaseObject thatAfterMoveObject1 = thatTransaction.getObject(thisAfterMoveObject1);
-
- // Move object.
- BaseObject thatMoveObject2 = thatRoot.getListA().get(0);
- BaseObject thisMoveObject2 = thisTransaction.getObject(thatMoveObject2);
- thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
- BaseObject thatAfterMoveObject2 = thatRoot.getListA().get(0);
- BaseObject thisAfterMoveObject2 = thisTransaction.getObject(thatAfterMoveObject2);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisMoveObject1, thisRoot.getListA().get(0));
- assertEquals(thatMoveObject1, thatRoot.getListA().get(0));
- assertEquals(thisMoveObject2, thisRoot.getListA().get(size - 1));
- assertEquals(thatMoveObject2, thatRoot.getListA().get(size - 1));
- assertEquals(thisAfterMoveObject1, thisRoot.getListA().get(size - 2));
- assertEquals(thatAfterMoveObject1, thatRoot.getListA().get(size - 2));
- assertEquals(thisAfterMoveObject2, thisRoot.getListA().get(1));
- assertEquals(thatAfterMoveObject2, thatRoot.getListA().get(1));
- }
-
- public void testMoveTailMoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- BaseObject thatMoveObject1 = thatTransaction.getObject(thisMoveObject1);
- thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- BaseObject thatAfterMoveObject1 = thatTransaction.getObject(thisAfterMoveObject1);
-
- // Move object.
- BaseObject thatMoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- BaseObject thisMoveObject2 = thisTransaction.getObject(thatMoveObject2);
- thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
- BaseObject thatAfterMoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject2 = thisTransaction.getObject(thatAfterMoveObject2);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int size = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisMoveObject1, thisRoot.getListA().get(0));
- assertEquals(thatMoveObject1, thatRoot.getListA().get(0));
- assertEquals(thisMoveObject2, thisRoot.getListA().get(0));
- assertEquals(thatMoveObject2, thatRoot.getListA().get(0));
- assertEquals(thisAfterMoveObject1, thisRoot.getListA().get(size - 1));
- assertEquals(thatAfterMoveObject1, thatRoot.getListA().get(size - 1));
- assertEquals(thisAfterMoveObject2, thisRoot.getListA().get(size - 1));
- assertEquals(thatAfterMoveObject2, thatRoot.getListA().get(size - 1));
- }
-
- public void testMoveHeadClearTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(0);
- BaseObject thatMoveObject = thatTransaction.getObject(thisMoveObject);
- thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
- BaseObject thatAfterMoveObject = thatTransaction.getObject(thisAfterMoveObject);
-
- // clear.
- thatRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisMoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisAfterMoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatMoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatAfterMoveObject).cdoState());
- }
-
- public void testMoveTailClearTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- BaseObject thatMoveObject = thatTransaction.getObject(thisMoveObject);
- thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
- BaseObject thatAfterMoveObject = thatTransaction.getObject(thisAfterMoveObject);
-
- // clear.
- thatRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisMoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisAfterMoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatMoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatAfterMoveObject).cdoState());
- }
-
- public void testClearAddHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // clear.
- thisRoot.getListA().clear();
-
- // create objects.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(0, thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(1, thisRoot.getListA().size());
- assertEquals(1, thatRoot.getListA().size());
- assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(0));
- assertEquals(thatObject, thatRoot.getListA().get(0));
- }
-
- public void testClearAddTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // clear.
- thisRoot.getListA().clear();
-
- // create objects.
- BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
- thatRoot.getListA().add(thatObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(1, thisRoot.getListA().size());
- assertEquals(1, thatRoot.getListA().size());
- assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(0));
- assertEquals(thatObject, thatRoot.getListA().get(0));
- }
-
- public void testClearRemoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thatRemoveObject = thatRoot.getListA().get(0);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- thatRoot.getListA().remove(0);
- BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
-
- // clear.
- thisRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatAfterRemoveObject).cdoState());
- }
-
- public void testClearRemoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // create objects.
- BaseObject thatRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
- thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
- BaseObject thatAfterRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
-
- // clear.
- thisRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatAfterRemoveObject).cdoState());
- }
-
- public void testClearMoveHeadTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(0);
- BaseObject thisMoveObject = thisTransaction.getObject(thatMoveObject);
- thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
- BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
- BaseObject thisAfterMoveObject = thisTransaction.getObject(thatAfterMoveObject);
-
- // clear.
- thisRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisMoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisAfterMoveObject).cdoState());
- }
-
- public void testClearMoveTailTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- BaseObject thisMoveObject = thisTransaction.getObject(thatMoveObject);
- thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
- BaseObject thatAfterMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
- BaseObject thisAfterMoveObject = thisTransaction.getObject(thatAfterMoveObject);
-
- // clear.
- thisRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisMoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisAfterMoveObject).cdoState());
- }
-
- public void testClearClearTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // clear.
- BaseObject thisObject = thisRoot.getListA().get(0);
- thisRoot.getListA().clear();
-
- BaseObject thatObject = thatRoot.getListA().get(0);
- thatRoot.getListA().clear();
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatObject).cdoState());
- }
-
- public void testRemoveHeadMoveHeadRemoveMiddleTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(0);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- assertNotNull(thatRemoveObject);
-
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(0);
- BaseObject thatRemoveAfterMoveObject = thatRoot.getListA().get(2);
- BaseObject thatAfterRemoveAfterMoveObject = thatRoot.getListA().get(3);
- msg(thatAfterRemoveAfterMoveObject);
-
- thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
- BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
-
- // Remove object.
- thatRoot.getListA().remove(thatRemoveAfterMoveObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(0));
- assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(0));
- assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
- }
-
- public void testMoveHeadMoveHeadRemoveMiddleTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Move object.
- BaseObject thisMoveObject = thisRoot.getListA().get(0);
- assertNotNull(thisMoveObject);
- thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
- BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
- assertNotNull(thisAfterMoveObject);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(0);
- BaseObject thatRemoveAfterMoveObject = thatRoot.getListA().get(2);
- BaseObject thatAfterRemoveAfterMoveObject = thatRoot.getListA().get(3);
- thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
- BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
-
- // Remove object.
- BaseObject thisRemoveAfterMoveObject = thisTransaction.getObject(thatRemoveAfterMoveObject);
- thatRoot.getListA().remove(thatRemoveAfterMoveObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- int listSize = thisRoot.getListA().size();
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisMoveObject, thisRoot.getListA().get(listSize - 1));
- assertEquals(thatMoveObject, thatRoot.getListA().get(listSize - 1));
- assertEquals(thisAfterMoveObject, thisRoot.getListA().get(0));
- assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
- assertEquals(thisTransaction.getObject(thatAfterRemoveAfterMoveObject), thisRoot.getListA().get(1));
- assertEquals(thatAfterRemoveAfterMoveObject, thatRoot.getListA().get(1));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveAfterMoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveAfterMoveObject).cdoState());
- }
-
- public void testMoveHeadRemoveHeadRemoveMiddleTest() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // Remove object.
- BaseObject thisRemoveObject = thisRoot.getListA().get(0);
- assertNotNull(thisRemoveObject);
- BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemveObject = thisRoot.getListA().get(0);
- assertNotNull(thisAfterRemveObject);
-
- // Move object.
- BaseObject thatMoveObject = thatRoot.getListA().get(0);
- msg(thatMoveObject);
-
- BaseObject thatRemoveAfterMoveObject = thatRoot.getListA().get(2);
- BaseObject thatAfterRemoveAfterMoveObject = thatRoot.getListA().get(3);
- thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
- BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
-
- // Remove object.
- BaseObject thisRemoveAfterMoveObject = thisTransaction.getObject(thatRemoveAfterMoveObject);
- thatRoot.getListA().remove(thatRemoveAfterMoveObject);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListA()); //$NON-NLS-1$
- printList("That ", thatRoot.getListA()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemveObject, thisRoot.getListA().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemveObject), thatRoot.getListA().get(0));
- assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(0));
- assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
- assertEquals(thisTransaction.getObject(thatAfterRemoveAfterMoveObject), thisRoot.getListA().get(1));
- assertEquals(thatAfterRemoveAfterMoveObject, thatRoot.getListA().get(1));
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveAfterMoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveAfterMoveObject).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
- }
-
- public void testRemoveHeadAddChildHead() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove containment.
- ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
- assertNotNull(thisToRemoveContainment);
- ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
- thisRoot.getListB().remove(0);
-
- // add child to containment.
- BaseObject bcObject0 = createBaseObject("AddBaseContainmentObject 0"); //$NON-NLS-1$
- bcObject0.setAttributeRequired("AddBaseContainmentObject 0"); //$NON-NLS-1$
- ContainmentObject thatAddContainment = createContainmentObject("AddContainmentObject 0"); //$NON-NLS-1$
- thatAddContainment.setAttributeRequired("AddContainmentObject 0"); //$NON-NLS-1$
- thatAddContainment.setContainmentOptional(bcObject0);
-
- ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
- assertNotNull(thatParent);
- // detach an object.
- ContainmentObject thatReattachContainment = (ContainmentObject)thatParent.getContainmentList().remove(0);
- // add a new object.
- thatParent.getContainmentList().add(thatAddContainment);
- // reattach containment.
- thatParent.getContainmentList().add(thatReattachContainment);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListB()); //$NON-NLS-1$
- printList("That ", thatRoot.getListB()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
-
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatReattachContainment).cdoState());
- assertEquals(CDOState.NEW, CDOUtil.getCDOObject(thatAddContainment).cdoState());
- }
-
- public void testRemoveHeadSetChildHead() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove containment.
- ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
- assertNotNull(thisToRemoveContainment);
- ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
- thisRoot.getListB().remove(0);
-
- // add child to containment.
- BaseObject bcObject0 = createBaseObject("AddBaseContainmentObject 0"); //$NON-NLS-1$
- ContainmentObject thatAddContainment = createContainmentObject("AddContainmentObject 0"); //$NON-NLS-1$
- thatAddContainment.setAttributeRequired("AddContainmentObject 0"); //$NON-NLS-1$
- thatAddContainment.setContainmentOptional(bcObject0);
-
- ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
- assertNotNull(thatParent);
-
- // set a new object.
- BaseObject thatUnsetContainment = thatParent.getContainmentOptional();
- msg(thatUnsetContainment);
-
- thatParent.setContainmentOptional(thatAddContainment);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListB()); //$NON-NLS-1$
- printList("That ", thatRoot.getListB()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
-
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
- // assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatUnsetContainment).cdoState()); <-- NPE
- assertEquals(CDOState.NEW, CDOUtil.getCDOObject(thatAddContainment).cdoState());
- }
-
- public void testRemoveHeadRemoveChildHead() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove containment.
- ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
- assertNotNull(thisToRemoveContainment);
- ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
- thisRoot.getListB().remove(0);
-
- // get parent object.
- ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
- assertNotNull(thatParent);
- // remove child from containment.
- ContainmentObject thatDetachContainment = (ContainmentObject)thatParent.getContainmentList().remove(0);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListB()); //$NON-NLS-1$
- printList("That ", thatRoot.getListB()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
-
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatDetachContainment).cdoState());
- }
-
- public void testRemoveHeadRemoveChildChildHead() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove containment.
- ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
- assertNotNull(thisToRemoveContainment);
- ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
- thisRoot.getListB().remove(0);
-
- // get parent object.
- ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
- assertNotNull(thatParent);
- // get child from containment.
- ContainmentObject thatChildContainment = (ContainmentObject)thatParent.getContainmentList().get(0);
- assertNotNull(thatChildContainment);
- // remove child from containment child.
- BaseObject thatDetachContainment = thatChildContainment.getContainmentList().remove(0);
- assertNotNull(thatDetachContainment);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListB()); //$NON-NLS-1$
- printList("That ", thatRoot.getListB()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
-
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatDetachContainment).cdoState());
- }
-
- public void testRemoveHeadMoveChildHead() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove containment.
- ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
- assertNotNull(thisToRemoveContainment);
- ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
- thisRoot.getListB().remove(0);
-
- // add child to containment.
- BaseObject bcObject0 = createBaseObject("AddBaseContainmentObject 0"); //$NON-NLS-1$
- ContainmentObject thatAddContainment = createContainmentObject("AddContainmentObject 0"); //$NON-NLS-1$
- thatAddContainment.setContainmentOptional(bcObject0);
-
- ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
- assertNotNull(thatParent);
- // detach an object.
- ContainmentObject thatReattachContainment = (ContainmentObject)thatParent.getContainmentList().remove(0);
- // add a new object.
- thatParent.getContainmentList().add(thatAddContainment);
- // reattach containment.
- thatParent.getContainmentList().add(thatReattachContainment);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListB()); //$NON-NLS-1$
- printList("That ", thatRoot.getListB()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
-
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatReattachContainment).cdoState());
- assertEquals(CDOState.NEW, CDOUtil.getCDOObject(thatAddContainment).cdoState());
- }
-
- public void testRemoveHeadReAttachHead() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // access objects.
- Root thisRoot = getTestModelRoot(thisTransaction);
- assertNotNull(thisRoot);
- Root thatRoot = thatTransaction.getObject(thisRoot);
- assertNotNull(thatRoot);
-
- // attach adapters.
- thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
- thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
-
- // remove containment.
- ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
- assertNotNull(thisToRemoveContainment);
- ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
- thisRoot.getListB().remove(0);
-
- // detach and re-attach containment.
- ContainmentObject thatAddContainment = (ContainmentObject)thatRoot.getListB().get(0);
- thatRoot.getListB().add(thatAddContainment);
- // TODO: re-add at other position (add some objects in between)?
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // print contents of lists
- printList("This ", thisRoot.getListB()); //$NON-NLS-1$
- printList("That ", thatRoot.getListB()); //$NON-NLS-1$
-
- // -- check indices.
- assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
-
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatAddContainment).cdoState());
- }
-
- public void testContainerAddDifferentParent() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction thisTransaction = session.openTransaction();
- CDOTransaction thatTransaction = session.openTransaction();
- initTestModel();
- addConflictResolver(thatTransaction);
-
- // create initial model.
- Root root = getTestModelRoot(thisTransaction);
- ContainmentObject group1 = createContainmentObject("Group 1"); //$NON-NLS-1$
- group1.setAttributeRequired("Group 1"); //$NON-NLS-1$
-
- ContainmentObject group2 = createContainmentObject("Group 2"); //$NON-NLS-1$
- group2.setAttributeRequired("Group 2"); //$NON-NLS-1$
-
- BaseObject element0 = createBaseObject("Element 0"); //$NON-NLS-1$
- element0.setAttributeRequired("Element 0"); //$NON-NLS-1$
-
- BaseObject element1 = createBaseObject("Element 1"); //$NON-NLS-1$
- element1.setAttributeRequired("Element 1"); //$NON-NLS-1$
-
- BaseObject element2 = createBaseObject("Element 2"); //$NON-NLS-1$
- element2.setAttributeRequired("Element 2"); //$NON-NLS-1$
-
- root.getListC().add(group1);
- root.getListC().add(group2);
- root.getListC().add(element0);
- root.getListC().add(element1);
- root.getListC().add(element2);
-
- commitAndSync(thisTransaction, thatTransaction);
-
- // get objects from that transaction.
- ContainmentObject thatGroup1 = thatTransaction.getObject(group1);
- ContainmentObject thatGroup2 = thatTransaction.getObject(group2);
- BaseObject thatElement0 = thatTransaction.getObject(element0);
- BaseObject thatElement1 = thatTransaction.getObject(element1);
- BaseObject thatElement2 = thatTransaction.getObject(element2);
- Root thatRoot = thatTransaction.getObject(root);
-
- // create group 1 (element 0 & 1).
- root.getListC().remove(element0);
- group1.getContainmentList().add(element0);
- root.getListC().remove(element1);
- group1.getContainmentList().add(element1);
-
- // create group 2 (element 1 & 2).
- thatRoot.getListC().remove(thatElement1);
- thatGroup2.getContainmentList().add(thatElement1);
- thatRoot.getListC().remove(thatElement2);
- thatGroup2.getContainmentList().add(thatElement2);
-
- commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // -- Check:
- assertEquals(2, root.getListC().size()); // 2 groups.
- assertEquals(group1, element0.eContainer());
- assertEquals(group2, element1.eContainer());
- assertEquals(group2, element2.eContainer());
- assertEquals(1, group1.getContainmentList().size()); // 1 element.
- assertEquals(2, group2.getContainmentList().size()); // 2 elements.
-
- assertEquals(2, thatRoot.getListC().size()); // 2 groups.
- assertEquals(thatGroup1, thatElement0.eContainer());
- assertEquals(thatGroup2, thatElement1.eContainer());
- assertEquals(thatGroup2, thatElement2.eContainer());
- assertEquals(1, thatGroup1.getContainmentList().size()); // 1 element.
- assertEquals(2, thatGroup2.getContainmentList().size()); // 2 elements.
- }
-
- // --- container conflict resolver tests -----------------------------------
- // TODO: convert them into CDOTests
-
- // --- random conflict resolver tests --------------------------------------
- // TODO: convert them into CDOTests
-
- // ========== HELPERS ======================================================
-
- protected BaseObject createBaseObject(String attribute)
- {
- BaseObject baseObj = getModel6Factory().createBaseObject();
- baseObj.setAttributeRequired(attribute);
- return baseObj;
- }
-
- protected ReferenceObject createReferenceObject(String attribute)
- {
- ReferenceObject refObject = getModel6Factory().createReferenceObject();
- refObject.setAttributeRequired(attribute);
- return refObject;
- }
-
- protected ContainmentObject createContainmentObject(String attribute)
- {
- ContainmentObject contObject = getModel6Factory().createContainmentObject();
- contObject.setAttributeRequired(attribute);
- return contObject;
- }
-
- private Root getTestModelRoot(CDOTransaction transaction)
- {
- CDOResource resource = transaction.getResource(getResourcePath(TEST_RESOURCE_NAME));
- return (Root)resource.getContents().get(0);
- }
-
- private void printList(String identifier, List<BaseObject> list)
- {
- System.out.println(identifier + "List:"); //$NON-NLS-1$
- System.out.print("["); //$NON-NLS-1$
- boolean first = true;
-
- for (BaseObject bObj : list)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- System.out.print(", "); //$NON-NLS-1$
- }
-
- System.out.print(bObj.getAttributeRequired() + " (" + CDOUtil.getCDOObject(bObj).cdoID() + ")"); //$NON-NLS-1$//$NON-NLS-2$
- }
-
- System.out.println("]"); //$NON-NLS-1$
-
- }
-
- private void addConflictResolver(CDOTransaction transaction)
- {
- transaction.options().addConflictResolver(conflictResolver);
- }
-
- /**
- * @author Pascal Lehmann
- */
- private static class ListPrintingAdapter extends AdapterImpl
- {
- private String identifier;
-
- public ListPrintingAdapter(String identifier)
- {
- this.identifier = identifier;
- }
-
- @Override
- public void notifyChanged(Notification msg)
- {
- try
- {
- System.err.println(identifier + msg);
- }
- catch (Exception e)
- {
- // ignore.
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model6.BaseObject;
+import org.eclipse.emf.cdo.tests.model6.ContainmentObject;
+import org.eclipse.emf.cdo.tests.model6.ReferenceObject;
+import org.eclipse.emf.cdo.tests.model6.Root;
+import org.eclipse.emf.cdo.transaction.CDOConflictResolver;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.EList;
+
+import java.util.List;
+
+/**
+ * @author Pascal Lehmann
+ */
+public class ConflictResolverExtendedTest extends AbstractCDOTest
+{
+ private static final String TEST_RESOURCE_NAME = "/test1";
+
+ @SuppressWarnings("deprecation")
+ private CDOConflictResolver conflictResolver = new org.eclipse.emf.spi.cdo.CDOMergingConflictResolver();
+
+ // --- initialize model ----------------------------------------------------
+
+ private void initTestModelSimple() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(TEST_RESOURCE_NAME));
+
+ Root testRoot = getModel6Factory().createRoot();
+ resource.getContents().add(testRoot);
+
+ BaseObject bObject1 = createBaseObject("BaseObject 1"); //$NON-NLS-1$
+ BaseObject bObject2 = createBaseObject("BaseObject 2"); //$NON-NLS-1$
+ BaseObject bObject3 = createBaseObject("BaseObject 3"); //$NON-NLS-1$
+
+ testRoot.getListA().add(bObject1);
+ testRoot.getListA().add(bObject2);
+ testRoot.getListA().add(bObject3);
+
+ ContainmentObject cObject1L1 = createContainmentObject("ContainmentObject 1 - Level 1"); //$NON-NLS-1$
+ ContainmentObject cObject1L2 = createContainmentObject("ContainmentObject 1 - Level 2"); //$NON-NLS-1$
+ cObject1L1.getContainmentList().add(cObject1L2);
+
+ testRoot.getListB().add(cObject1L1);
+
+ transaction.commit();
+ }
+
+ private void initTestModel() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(TEST_RESOURCE_NAME));
+
+ Root root = getModel6Factory().createRoot();
+ resource.getContents().add(root);
+
+ // setup base objects.
+ BaseObject bObject0 = createBaseObject("BaseObject 0"); //$NON-NLS-1$
+ BaseObject bObject1 = createBaseObject("BaseObject 1"); //$NON-NLS-1$
+ BaseObject bObject2 = createBaseObject("BaseObject 2"); //$NON-NLS-1$
+ BaseObject bObject3 = createBaseObject("BaseObject 3"); //$NON-NLS-1$
+ BaseObject bObject4 = createBaseObject("BaseObject 4"); //$NON-NLS-1$
+
+ root.getListA().add(bObject0);
+ root.getListA().add(bObject1);
+ root.getListA().add(bObject2);
+ root.getListA().add(bObject3);
+ root.getListA().add(bObject4);
+
+ // containment objects.
+ ContainmentObject cObject0 = createContainmentObject("ContainmentObject 0"); //$NON-NLS-1$
+ ContainmentObject cObject00 = createContainmentObject("ContainmentObject 00"); //$NON-NLS-1$
+ BaseObject bcObject01 = createBaseObject("BaseContainmentObject 01"); //$NON-NLS-1$
+
+ cObject00.getContainmentList().add(bcObject01);
+ cObject0.getContainmentList().add(cObject00);
+
+ ContainmentObject cObject1 = createContainmentObject("ContainmentObject 1"); //$NON-NLS-1$
+
+ root.getListB().add(cObject0);
+ root.getListB().add(cObject1);
+
+ // commit the model.
+ transaction.commit();
+ }
+
+ // --- conflict test -------------------------------------------------------
+
+ public void _testProvokeConflictOnServerTest() throws Exception
+ {
+ // should provoke an "attempt to modify historical revision" error.
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+
+ initTestModelSimple();
+
+ BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
+ assertNotNull(thisObject);
+ BaseObject thatObject = thatTransaction.getObject(thisObject);
+
+ thisObject.setAttributeOptional("this"); //$NON-NLS-1$
+ thatObject.setAttributeOptional("that"); //$NON-NLS-1$
+
+ thisTransaction.commit();
+
+ try
+ {
+ commitAndSync(thatTransaction, thisTransaction);
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+ }
+
+ public void _testProvokeConflictLocalTest() throws Exception
+ {
+ // should provoke an "this transaction has conflicts" error.
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+
+ initTestModelSimple();
+
+ BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
+ assertNotNull(thisObject);
+ BaseObject thatObject = thatTransaction.getObject(thisObject);
+
+ thisObject.setAttributeOptional("this"); //$NON-NLS-1$
+ thatObject.setAttributeOptional("that"); //$NON-NLS-1$
+
+ commitAndSync(thisTransaction, thatTransaction);
+
+ try
+ {
+ commitAndSync(thatTransaction, thisTransaction);
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+ }
+
+ // --- single value conflict resolver tests --------------------------
+
+ public void testConflictResolverChangeChangeTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
+ thisObject.setAttributeOptional("this"); //$NON-NLS-1$
+
+ BaseObject thatObject = thatTransaction.getObject(thisObject);
+ thatObject.setAttributeOptional("that"); //$NON-NLS-1$
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ }
+
+ public void testConflictResolverRemoveChangeTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
+ assertNotNull(thisObject);
+
+ BaseObject thatObject = thatTransaction.getObject(thisObject);
+ assertNotNull(thatObject);
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // remove object.
+ getTestModelRoot(thisTransaction).getListA().remove(0);
+
+ // change object.
+ thatObject.setAttributeOptional("that"); //$NON-NLS-1$
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testConflictResolverChangeRemoveTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+
+ // add conflict resolver.
+ addConflictResolver(thatTransaction);
+
+ BaseObject thisObject = getTestModelRoot(thisTransaction).getListA().get(0);
+ assertNotNull(thisObject);
+ BaseObject thatObject = thatTransaction.getObject(thisObject);
+ assertNotNull(thatObject);
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // change object.
+ thisObject.setAttributeOptional("this"); //$NON-NLS-1$
+
+ // remove object.
+ Root thatRoot = thatTransaction.getObject(getTestModelRoot(thisTransaction));
+ thatRoot.getListA().remove(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testConflictResolverRemoveAddTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+
+ // add conflict resolver.
+ addConflictResolver(thatTransaction);
+
+ ContainmentObject thisObject = (ContainmentObject)getTestModelRoot(thisTransaction).getListB().get(0);
+ assertNotNull(thisObject);
+ ContainmentObject thatObject = thatTransaction.getObject(thisObject);
+ assertNotNull(thatObject);
+ int objects = getTestModelRoot(thisTransaction).getListB().size();
+
+ // remove object.
+ getTestModelRoot(thisTransaction).getListB().remove(0);
+
+ // add object.
+ BaseObject addObject = createBaseObject("AddObject"); //$NON-NLS-1$
+
+ ContainmentObject thatChild = (ContainmentObject)thatObject.getContainmentList().get(0);
+ assertNotNull(thatChild);
+ thatChild.getContainmentList().add(addObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListB().size());
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ }
+
+ public void testConflictResolverAddRemoveTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+
+ // add conflict resolver.
+ addConflictResolver(thatTransaction);
+
+ ContainmentObject thisObject = (ContainmentObject)getTestModelRoot(thisTransaction).getListB().get(0);
+ assertNotNull(thisObject);
+ ContainmentObject thatObject = thatTransaction.getObject(thisObject);
+ assertNotNull(thatObject);
+ int objects = getTestModelRoot(thisTransaction).getListB().size();
+
+ // add object.
+ BaseObject addObject = createBaseObject("AddObject"); //$NON-NLS-1$
+
+ ContainmentObject thisChild = (ContainmentObject)thisObject.getContainmentList().get(0);
+ assertNotNull(thisChild);
+ thisChild.getContainmentList().add(addObject);
+
+ // remove object.
+ Root thatRoot = thatTransaction.getObject(getTestModelRoot(thisTransaction));
+ thatRoot.getListB().remove(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListB().size());
+ }
+
+ public void testConflictResolverRemoveRemoveTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+
+ // add conflict resolver.
+ addConflictResolver(thatTransaction);
+
+ ContainmentObject thisObject = (ContainmentObject)getTestModelRoot(thisTransaction).getListB().get(0);
+ assertNotNull(thisObject);
+ ContainmentObject thatObject = thatTransaction.getObject(thisObject);
+ assertNotNull(thatObject);
+ int objects = getTestModelRoot(thisTransaction).getListB().size();
+
+ // remove object.
+ getTestModelRoot(thisTransaction).getListB().remove(0);
+
+ // remove object.
+ Root thatRoot = thatTransaction.getObject(getTestModelRoot(thisTransaction));
+ thatRoot.getListB().remove(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListB().size());
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ }
+
+ // --- resolve many valued changes -------------------------------------
+
+ public void testManyValuedAddAddTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // create new objects.
+ BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
+ BaseObject thatObject = createBaseObject("ThatObject"); //$NON-NLS-1$
+
+ // add elements.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().add(thisObject);
+
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(objects + 2, getTestModelRoot(thisTransaction).getListA().size());
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ }
+
+ public void testManyValuedAddChangeTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // create new objects.
+ BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
+
+ // add elements.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().add(thisObject);
+
+ // move element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ EList<BaseObject> containmentList = thatRoot.getListA();
+ containmentList.move(2, containmentList.get(0));
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects + 1, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedChangeAddTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // move element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ EList<BaseObject> containmentList = thisRoot.getListA();
+ containmentList.move(2, containmentList.get(0));
+
+ // create new objects.
+ BaseObject thatObject = createBaseObject("ThatObject"); //$NON-NLS-1$
+
+ // add elements.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects + 1, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedAddRemoveTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // create new objects.
+ BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
+
+ // add elements.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().add(thisObject);
+
+ // remove element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().remove(1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedRemoveAddTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // remove element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().remove(1);
+
+ // create new objects.
+ BaseObject thatObject = createBaseObject("ThatObject"); //$NON-NLS-1$
+
+ // add elements.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedChangeRemoveTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // move element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ EList<BaseObject> containmentList = thisRoot.getListA();
+ containmentList.move(2, containmentList.get(0));
+
+ // remove element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().remove(1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedChangeRemoveTest2() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // move element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ EList<BaseObject> containmentList = thisRoot.getListA();
+ containmentList.move(2, containmentList.get(0));
+
+ // remove same element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().remove(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedRemoveChangeTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // remove element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().remove(1);
+
+ // move element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ EList<BaseObject> listA = thatRoot.getListA();
+ listA.move(2, 0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedRemoveChangeTest2() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // remove same element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().remove(0);
+
+ // move element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ EList<BaseObject> containmentList = thatRoot.getListA();
+ containmentList.move(2, containmentList.get(0));
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedChangeChangeTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // move element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ EList<BaseObject> containmentList = thisRoot.getListA();
+ containmentList.move(2, containmentList.get(0));
+
+ // move element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ EList<BaseObject> thatContainmentList = thatRoot.getListA();
+ thatContainmentList.move(2, thatContainmentList.get(1));
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedChangeChangeTest2() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // move element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ EList<BaseObject> containmentList = thisRoot.getListA();
+ containmentList.move(2, containmentList.get(0));
+
+ // move element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ EList<BaseObject> thatContainmentList = thatRoot.getListA();
+ thatContainmentList.move(2, thatContainmentList.get(0));
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedRemoveRemoveTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // remove element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().remove(0);
+
+ // remove element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().remove(2);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects - 2, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedRemoveRemoveTest2() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // remove element.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().remove(0);
+
+ // remove same element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().remove(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects - 1, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedAddAddRemoveRemoveTest() throws Exception
+ {
+ // test to produce exception of bug #306710
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // add some elements.
+ BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
+ BaseObject thisObject2 = createBaseObject("ThisObject2"); //$NON-NLS-1$
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().add(0, thisObject);
+ thisRoot.getListA().add(0, thisObject2);
+
+ // remove element.
+ thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().remove(4);
+
+ // remove element.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().remove(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
+ }
+
+ public void testManyValuedAddAddRemoveRemove2Test() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // remove elements.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().remove(0);
+ thisRoot.getListA().remove(0);
+
+ // add elements.
+ BaseObject thatObject = createBaseObject("ThatObject"); //$NON-NLS-1$
+ BaseObject thatObject2 = createBaseObject("ThatObject2"); //$NON-NLS-1$
+
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().add(thatObject);
+ thatRoot.getListA().add(thatObject2);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
+
+ }
+
+ public void testManyValuedRemoveRemoveAddAddTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModelSimple();
+ addConflictResolver(thatTransaction);
+
+ int objects = getTestModelRoot(thisTransaction).getListA().size();
+
+ // add elements.
+ BaseObject thisObject = createBaseObject("ThisObject"); //$NON-NLS-1$
+ BaseObject thisObject2 = createBaseObject("ThisObject2"); //$NON-NLS-1$
+
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ thisRoot.getListA().add(thisObject);
+ thisRoot.getListA().add(thisObject2);
+
+ // remove elements.
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+ thatRoot.getListA().remove(0);
+ thatRoot.getListA().remove(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(objects, getTestModelRoot(thisTransaction).getListA().size());
+
+ }
+
+ // --- list conflict resolver tests ----------------------------------------
+
+ public void testAddHeadAddHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(0, thisObject);
+
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(0, thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(0), thisObject);
+ assertEquals(thisRoot.getListA().get(1), thisTransaction.getObject(thatObject));
+ assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(1), thatObject);
+ }
+
+ public void testAddHeadAddTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(0, thisObject);
+
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(0), thisObject);
+ assertEquals(thisRoot.getListA().get(size - 1), thisTransaction.getObject(thatObject));
+ assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(size - 1), thatObject);
+ }
+
+ public void testAddTailAddTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(thisObject);
+
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(size - 2), thisObject);
+ assertEquals(thisRoot.getListA().get(size - 1), thisTransaction.getObject(thatObject));
+ assertEquals(thatRoot.getListA().get(size - 2), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(size - 1), thatObject);
+ }
+
+ public void testAddTailAddHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(thisObject);
+
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(0, thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(size - 1), thisObject);
+ assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatObject));
+ assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(0), thatObject);
+ }
+
+ // add - remove
+
+ public void testAddHeadRemoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create object.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(0, thisObject);
+
+ // remove object (get it before deletion).
+ BaseObject thatRemoveObject = thatRoot.getListA().get(0);
+ assertNotNull(thatRemoveObject);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ assertNotNull(thisRemoveObject);
+
+ thatRoot.getListA().remove(0);
+ BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(0), thisObject);
+ assertEquals(thisRoot.getListA().get(1), thisTransaction.getObject(thatAfterRemoveObject));
+ assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(1), thatAfterRemoveObject);
+ assertEquals(CDOUtil.getCDOObject(thisRemoveObject).cdoState(), CDOState.INVALID);
+ assertEquals(CDOUtil.getCDOObject(thatRemoveObject).cdoState(), CDOState.TRANSIENT);
+ }
+
+ public void testAddHeadRemoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create object.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(0, thisObject);
+
+ // remove object (get it before deletion).
+ int listSize = thatRoot.getListA().size();
+ BaseObject thatRemoveObject = thatRoot.getListA().get(listSize - 1);
+ assertNotNull(thatRemoveObject);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ assertNotNull(thisRemoveObject);
+
+ thatRoot.getListA().remove(listSize - 1);
+ BaseObject thatBeforeRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(0), thisObject);
+ assertEquals(thisRoot.getListA().get(size - 1), thisTransaction.getObject(thatBeforeRemoveObject));
+ assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(size - 1), thatBeforeRemoveObject);
+ assertEquals(CDOUtil.getCDOObject(thisRemoveObject).cdoState(), CDOState.INVALID);
+ assertEquals(CDOUtil.getCDOObject(thatRemoveObject).cdoState(), CDOState.TRANSIENT);
+ }
+
+ public void testAddTailRemoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create object.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(thisObject);
+
+ // remove object (get it before deletion).
+ int listSize = thatRoot.getListA().size();
+ BaseObject thatRemoveObject = thatRoot.getListA().get(listSize - 1);
+ assertNotNull(thatRemoveObject);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ assertNotNull(thisRemoveObject);
+
+ thatRoot.getListA().remove(listSize - 1);
+ BaseObject thatBeforeRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(size - 1), thisObject);
+ assertEquals(thisRoot.getListA().get(size - 2), thisTransaction.getObject(thatBeforeRemoveObject));
+ assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(size - 2), thatBeforeRemoveObject);
+ assertEquals(CDOUtil.getCDOObject(thisRemoveObject).cdoState(), CDOState.INVALID);
+ assertEquals(CDOUtil.getCDOObject(thatRemoveObject).cdoState(), CDOState.TRANSIENT);
+ }
+
+ public void testAddTailRemoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(thisObject);
+
+ // remove object (get it before deletion).
+ BaseObject thatRemoveObject = thatRoot.getListA().get(0);
+ assertNotNull(thatRemoveObject);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ assertNotNull(thisRemoveObject);
+
+ thatRoot.getListA().remove(0);
+ BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(size - 1), thisObject);
+ assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatAfterRemoveObject));
+ assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(0), thatAfterRemoveObject);
+ assertEquals(CDOUtil.getCDOObject(thisRemoveObject).cdoState(), CDOState.INVALID);
+ assertEquals(CDOUtil.getCDOObject(thatRemoveObject).cdoState(), CDOState.TRANSIENT);
+ }
+
+ // add - move
+
+ public void testAddHeadMoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create object.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(0, thisObject);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(0);
+ thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(0), thisObject);
+ assertEquals(thisRoot.getListA().get(size - 1), thisTransaction.getObject(thatMoveObject));
+ assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(size - 1), thatMoveObject);
+ }
+
+ public void testAddHeadMoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create object.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(0, thisObject);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(0), thisObject);
+ assertEquals(thisRoot.getListA().get(1), thisTransaction.getObject(thatMoveObject));
+ assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(1), thatMoveObject);
+ }
+
+ public void testAddTailMoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create object.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(thisObject);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(size - 1), thisObject);
+ assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatMoveObject));
+ assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(0), thatMoveObject);
+ }
+
+ public void testAddTailMoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(thisObject);
+
+ // remove object.
+ thatRoot.getListA().remove(0);
+ BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(size - 1), thisObject);
+ assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatAfterRemoveObject));
+ assertEquals(thatRoot.getListA().get(size - 1), thatTransaction.getObject(thisObject));
+ assertEquals(thatRoot.getListA().get(0), thatAfterRemoveObject);
+ }
+
+ public void testAddHeadClearTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(0, thisObject);
+
+ // clear list.
+ thatRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisObject).cdoState());
+ }
+
+ public void testAddTailClearTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thisObject = createBaseObject("ThisBaseObject 0"); //$NON-NLS-1$
+ thisRoot.getListA().add(thisObject);
+
+ // clear list.
+ thatRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisObject).cdoState());
+ }
+
+ public void testRemoveHeadAddHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(0);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
+
+ // create object.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(0, thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatObject));
+ assertEquals(thisRoot.getListA().get(1), thisAfterRemoveObject);
+ assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thatObject));
+ assertEquals(thatRoot.getListA().get(1), thatTransaction.getObject(thisAfterRemoveObject));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ }
+
+ public void testRemoveHeadAddTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(0);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
+
+ // create object.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(listSize - 1), thisTransaction.getObject(thatObject));
+ assertEquals(thisRoot.getListA().get(0), thisAfterRemoveObject);
+ assertEquals(thatRoot.getListA().get(listSize - 1), thatTransaction.getObject(thatObject));
+ assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thisAfterRemoveObject));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ }
+
+ public void testRemoveTailAddHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // create object.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(0, thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(0), thisTransaction.getObject(thatObject));
+ assertEquals(thisRoot.getListA().get(listSize - 1), thisAfterRemoveObject);
+ assertEquals(thatRoot.getListA().get(0), thatTransaction.getObject(thatObject));
+ assertEquals(thatRoot.getListA().get(listSize - 1), thatTransaction.getObject(thisAfterRemoveObject));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ }
+
+ public void testRemoveTailAddTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // create object.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisRoot.getListA().get(listSize - 1), thisTransaction.getObject(thatObject));
+ assertEquals(thisRoot.getListA().get(listSize - 2), thisAfterRemoveObject);
+ assertEquals(thatRoot.getListA().get(listSize - 1), thatTransaction.getObject(thatObject));
+ assertEquals(thatRoot.getListA().get(listSize - 2), thatTransaction.getObject(thisAfterRemoveObject));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ }
+
+ public void testRemoveHeadRemoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject1 = thisRoot.getListA().get(0);
+ assertNotNull(thisRemoveObject1);
+ BaseObject thatRemoveObject1 = thatTransaction.getObject(thisRemoveObject1);
+ assertNotNull(thatRemoveObject1);
+
+ thisRoot.getListA().remove(0);
+ BaseObject thisAfterRemoveObject1 = thisRoot.getListA().get(0);
+
+ // // remove object (get it before deletion).
+ BaseObject thatRemoveObject2 = thatRoot.getListA().get(0);
+ assertNotNull(thatRemoveObject2);
+ BaseObject thisRemoveObject2 = thisTransaction.getObject(thatRemoveObject2);
+ assertNotNull(thisRemoveObject2);
+
+ thatRoot.getListA().remove(0);
+ BaseObject thatAfterRemoveObject2 = thatRoot.getListA().get(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveObject1, thisRoot.getListA().get(0));
+ assertEquals(thatAfterRemoveObject2, thatRoot.getListA().get(0));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject1).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject1).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject2).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject2).cdoState());
+ }
+
+ public void testRemoveHeadRemoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject1 = thisRoot.getListA().get(0);
+ assertNotNull(thisRemoveObject1);
+ BaseObject thatRemoveObject1 = thatTransaction.getObject(thisRemoveObject1);
+ assertNotNull(thatRemoveObject1);
+
+ thisRoot.getListA().remove(0);
+ BaseObject thisAfterRemoveObject1 = thisRoot.getListA().get(0);
+
+ // // remove object (get it before deletion).
+ BaseObject thatRemoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ assertNotNull(thatRemoveObject2);
+ BaseObject thisRemoveObject2 = thisTransaction.getObject(thatRemoveObject2);
+ assertNotNull(thisRemoveObject2);
+
+ thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
+ BaseObject thatAfterRemoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveObject1, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveObject1), thatRoot.getListA().get(0));
+ assertEquals(thisTransaction.getObject(thatAfterRemoveObject2), thisRoot.getListA().get(listSize - 1));
+ assertEquals(thatAfterRemoveObject2, thatRoot.getListA().get(listSize - 1));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject1).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject1).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject2).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject2).cdoState());
+ }
+
+ public void testRemoveTailRemoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ assertNotNull(thisRemoveObject1);
+ BaseObject thatRemoveObject1 = thatTransaction.getObject(thisRemoveObject1);
+ assertNotNull(thatRemoveObject1);
+
+ thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
+ BaseObject thisAfterRemoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // // remove object (get it before deletion).
+ BaseObject thatRemoveObject2 = thatRoot.getListA().get(0);
+ assertNotNull(thatRemoveObject2);
+ BaseObject thisRemoveObject2 = thisTransaction.getObject(thatRemoveObject2);
+ assertNotNull(thisRemoveObject2);
+
+ thatRoot.getListA().remove(0);
+ BaseObject thatAfterRemoveObject2 = thatRoot.getListA().get(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveObject1, thisRoot.getListA().get(listSize - 1));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveObject1), thatRoot.getListA().get(listSize - 1));
+ assertEquals(thisTransaction.getObject(thatAfterRemoveObject2), thisRoot.getListA().get(0));
+ assertEquals(thatAfterRemoveObject2, thatRoot.getListA().get(0));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject1).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject1).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject2).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject2).cdoState());
+ }
+
+ public void testRemoveTailRemoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ assertNotNull(thisRemoveObject1);
+ BaseObject thatRemoveObject1 = thatTransaction.getObject(thisRemoveObject1);
+ assertNotNull(thatRemoveObject1);
+
+ thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
+ BaseObject thisAfterRemoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // // remove object (get it before deletion).
+ BaseObject thatRemoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ assertNotNull(thatRemoveObject2);
+ BaseObject thisRemoveObject2 = thisTransaction.getObject(thatRemoveObject2);
+ assertNotNull(thisRemoveObject2);
+
+ thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
+ BaseObject thatAfterRemoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveObject1, thisRoot.getListA().get(listSize - 1));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveObject1), thatRoot.getListA().get(listSize - 1));
+ assertEquals(thisTransaction.getObject(thatAfterRemoveObject2), thisRoot.getListA().get(listSize - 1));
+ assertEquals(thatAfterRemoveObject2, thatRoot.getListA().get(listSize - 1));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject1).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject1).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject2).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject2).cdoState());
+ }
+
+ public void testRemoveHeadMoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(0);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(0);
+ thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
+ BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(0));
+ assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(0));
+ assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
+ }
+
+ public void testRemoveHeadMoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(0);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
+ BaseObject thatAfterMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(1));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(1));
+ assertEquals(thisTransaction.getObject(thatMoveObject), thisRoot.getListA().get(0));
+ assertEquals(thatMoveObject, thatRoot.getListA().get(0));
+ assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(listSize - 1));
+ assertEquals(thatAfterMoveObject, thatRoot.getListA().get(listSize - 1));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ }
+
+ public void testRemoveTailMoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(0);
+ thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
+ BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(listSize - 2));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(listSize - 2));
+ assertEquals(thisTransaction.getObject(thatMoveObject), thisRoot.getListA().get(listSize - 1));
+ assertEquals(thatMoveObject, thatRoot.getListA().get(listSize - 1));
+ assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(0));
+ assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ }
+
+ public void testRemoveTailMoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
+ BaseObject thatAfterMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(listSize - 1));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(listSize - 1));
+ assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(listSize - 1));
+ assertEquals(thatAfterMoveObject, thatRoot.getListA().get(listSize - 1));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
+ }
+
+ public void testRemoveHeadClearTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(0);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
+
+ // clear.
+ thatRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisAfterRemoveObject).cdoState());
+ }
+
+ public void testRemoveTailClearTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(thisRoot.getListA().size() - 1);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // clear.
+ thatRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisAfterRemoveObject).cdoState());
+ }
+
+ public void testMoveHeadAddHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(0);
+ thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
+
+ // create object.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(0, thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(0));
+ assertEquals(thatObject, thatRoot.getListA().get(0));
+ assertEquals(thisAfterMoveObject, thisRoot.getListA().get(1));
+ assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(1));
+ assertEquals(thisMoveObject, thisRoot.getListA().get(size - 1));
+ assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(size - 1));
+ }
+
+ public void testMoveHeadAddTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(0);
+ thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
+
+ // create object.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(size - 1));
+ assertEquals(thatObject, thatRoot.getListA().get(size - 1));
+ assertEquals(thisAfterMoveObject, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(0));
+ assertEquals(thisMoveObject, thisRoot.getListA().get(size - 2));
+ assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(size - 2));
+ }
+
+ public void testMoveTailAddHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // create object.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$);
+ thatRoot.getListA().add(0, thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(1));
+ assertEquals(thatObject, thatRoot.getListA().get(1));
+ assertEquals(thisAfterMoveObject, thisRoot.getListA().get(size - 1));
+ assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(size - 1));
+ assertEquals(thisMoveObject, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(0));
+ }
+
+ public void testMoveTailAddTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // create object.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$);
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(size - 1));
+ assertEquals(thatObject, thatRoot.getListA().get(size - 1));
+ assertEquals(thisAfterMoveObject, thisRoot.getListA().get(size - 2));
+ assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(size - 2));
+ assertEquals(thisMoveObject, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(0));
+ }
+
+ public void testMoveHeadRemoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(0);
+ thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
+
+ // remove object.
+ BaseObject thatRemoveObject = thatRoot.getListA().get(0);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ thatRoot.getListA().remove(0);
+ BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterMoveObject, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(0));
+ assertEquals(thisTransaction.getObject(thatAfterRemoveObject), thisRoot.getListA().get(0));
+ assertEquals(thatAfterRemoveObject, thatRoot.getListA().get(0));
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisMoveObject).cdoState());
+ }
+
+ public void testMoveHeadRemoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(0);
+ thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
+
+ // remove object.
+ BaseObject thatRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
+ BaseObject thatAfterRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterMoveObject, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(0));
+ assertEquals(thisMoveObject, thisRoot.getListA().get(size - 1));
+ assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(size - 1));
+ assertEquals(thisTransaction.getObject(thatAfterRemoveObject), thisRoot.getListA().get(size - 2));
+ assertEquals(thatAfterRemoveObject, thatRoot.getListA().get(size - 2));
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ }
+
+ public void testMoveTailRemoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // remove object.
+ BaseObject thatRemoveObject = thatRoot.getListA().get(0);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ thatRoot.getListA().remove(0);
+ BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterMoveObject, thisRoot.getListA().get(size - 1));
+ assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(size - 1));
+ assertEquals(thisMoveObject, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisMoveObject), thatRoot.getListA().get(0));
+ assertEquals(thisTransaction.getObject(thatAfterRemoveObject), thisRoot.getListA().get(1));
+ assertEquals(thatAfterRemoveObject, thatRoot.getListA().get(1));
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ }
+
+ public void testMoveTailRemoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+
+ // remove object.
+ BaseObject thatRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
+ BaseObject thatAfterRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterMoveObject, thisRoot.getListA().get(size - 1));
+ assertEquals(thatTransaction.getObject(thisAfterMoveObject), thatRoot.getListA().get(size - 1));
+ assertEquals(thisTransaction.getObject(thatAfterRemoveObject), thisRoot.getListA().get(size - 1));
+ assertEquals(thatAfterRemoveObject, thatRoot.getListA().get(size - 1));
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisMoveObject).cdoState());
+ }
+
+ public void testMoveHeadMoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject1 = thisRoot.getListA().get(0);
+ BaseObject thatMoveObject1 = thatTransaction.getObject(thisMoveObject1);
+ thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
+ BaseObject thisAfterMoveObject1 = thisRoot.getListA().get(0);
+ BaseObject thatAfterMoveObject1 = thatTransaction.getObject(thisAfterMoveObject1);
+
+ // Move object.
+ BaseObject thatMoveObject2 = thatRoot.getListA().get(0);
+ BaseObject thisMoveObject2 = thisTransaction.getObject(thatMoveObject2);
+ thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
+ BaseObject thatAfterMoveObject2 = thatRoot.getListA().get(0);
+ BaseObject thisAfterMoveObject2 = thisTransaction.getObject(thatAfterMoveObject2);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisMoveObject1, thisRoot.getListA().get(size - 1));
+ assertEquals(thatMoveObject1, thatRoot.getListA().get(size - 1));
+ assertEquals(thisMoveObject2, thisRoot.getListA().get(size - 1));
+ assertEquals(thatMoveObject2, thatRoot.getListA().get(size - 1));
+ assertEquals(thisAfterMoveObject1, thisRoot.getListA().get(0));
+ assertEquals(thatAfterMoveObject1, thatRoot.getListA().get(0));
+ assertEquals(thisAfterMoveObject2, thisRoot.getListA().get(0));
+ assertEquals(thatAfterMoveObject2, thatRoot.getListA().get(0));
+ }
+
+ public void testMoveHeadMoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject1 = thisRoot.getListA().get(0);
+ BaseObject thatMoveObject1 = thatTransaction.getObject(thisMoveObject1);
+ thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
+ BaseObject thisAfterMoveObject1 = thisRoot.getListA().get(0);
+ BaseObject thatAfterMoveObject1 = thatTransaction.getObject(thisAfterMoveObject1);
+
+ // Move object.
+ BaseObject thatMoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ BaseObject thisMoveObject2 = thisTransaction.getObject(thatMoveObject2);
+ thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
+ BaseObject thatAfterMoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject2 = thisTransaction.getObject(thatAfterMoveObject2);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisMoveObject1, thisRoot.getListA().get(size - 1));
+ assertEquals(thatMoveObject1, thatRoot.getListA().get(size - 1));
+ assertEquals(thisMoveObject2, thisRoot.getListA().get(0));
+ assertEquals(thatMoveObject2, thatRoot.getListA().get(0));
+ assertEquals(thisAfterMoveObject1, thisRoot.getListA().get(1));
+ assertEquals(thatAfterMoveObject1, thatRoot.getListA().get(1));
+ assertEquals(thisAfterMoveObject2, thisRoot.getListA().get(size - 2));
+ assertEquals(thatAfterMoveObject2, thatRoot.getListA().get(size - 2));
+ }
+
+ public void testMoveTailMoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ BaseObject thatMoveObject1 = thatTransaction.getObject(thisMoveObject1);
+ thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ BaseObject thatAfterMoveObject1 = thatTransaction.getObject(thisAfterMoveObject1);
+
+ // Move object.
+ BaseObject thatMoveObject2 = thatRoot.getListA().get(0);
+ BaseObject thisMoveObject2 = thisTransaction.getObject(thatMoveObject2);
+ thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
+ BaseObject thatAfterMoveObject2 = thatRoot.getListA().get(0);
+ BaseObject thisAfterMoveObject2 = thisTransaction.getObject(thatAfterMoveObject2);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisMoveObject1, thisRoot.getListA().get(0));
+ assertEquals(thatMoveObject1, thatRoot.getListA().get(0));
+ assertEquals(thisMoveObject2, thisRoot.getListA().get(size - 1));
+ assertEquals(thatMoveObject2, thatRoot.getListA().get(size - 1));
+ assertEquals(thisAfterMoveObject1, thisRoot.getListA().get(size - 2));
+ assertEquals(thatAfterMoveObject1, thatRoot.getListA().get(size - 2));
+ assertEquals(thisAfterMoveObject2, thisRoot.getListA().get(1));
+ assertEquals(thatAfterMoveObject2, thatRoot.getListA().get(1));
+ }
+
+ public void testMoveTailMoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ BaseObject thatMoveObject1 = thatTransaction.getObject(thisMoveObject1);
+ thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject1 = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ BaseObject thatAfterMoveObject1 = thatTransaction.getObject(thisAfterMoveObject1);
+
+ // Move object.
+ BaseObject thatMoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ BaseObject thisMoveObject2 = thisTransaction.getObject(thatMoveObject2);
+ thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
+ BaseObject thatAfterMoveObject2 = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject2 = thisTransaction.getObject(thatAfterMoveObject2);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int size = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisMoveObject1, thisRoot.getListA().get(0));
+ assertEquals(thatMoveObject1, thatRoot.getListA().get(0));
+ assertEquals(thisMoveObject2, thisRoot.getListA().get(0));
+ assertEquals(thatMoveObject2, thatRoot.getListA().get(0));
+ assertEquals(thisAfterMoveObject1, thisRoot.getListA().get(size - 1));
+ assertEquals(thatAfterMoveObject1, thatRoot.getListA().get(size - 1));
+ assertEquals(thisAfterMoveObject2, thisRoot.getListA().get(size - 1));
+ assertEquals(thatAfterMoveObject2, thatRoot.getListA().get(size - 1));
+ }
+
+ public void testMoveHeadClearTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(0);
+ BaseObject thatMoveObject = thatTransaction.getObject(thisMoveObject);
+ thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
+ BaseObject thatAfterMoveObject = thatTransaction.getObject(thisAfterMoveObject);
+
+ // clear.
+ thatRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisMoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisAfterMoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatMoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatAfterMoveObject).cdoState());
+ }
+
+ public void testMoveTailClearTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ BaseObject thatMoveObject = thatTransaction.getObject(thisMoveObject);
+ thisRoot.getListA().move(0, thisRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(thisRoot.getListA().size() - 1);
+ BaseObject thatAfterMoveObject = thatTransaction.getObject(thisAfterMoveObject);
+
+ // clear.
+ thatRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisMoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisAfterMoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatMoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatAfterMoveObject).cdoState());
+ }
+
+ public void testClearAddHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // clear.
+ thisRoot.getListA().clear();
+
+ // create objects.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(0, thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(1, thisRoot.getListA().size());
+ assertEquals(1, thatRoot.getListA().size());
+ assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(0));
+ assertEquals(thatObject, thatRoot.getListA().get(0));
+ }
+
+ public void testClearAddTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // clear.
+ thisRoot.getListA().clear();
+
+ // create objects.
+ BaseObject thatObject = createBaseObject("ThatBaseObject 0"); //$NON-NLS-1$
+ thatRoot.getListA().add(thatObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(1, thisRoot.getListA().size());
+ assertEquals(1, thatRoot.getListA().size());
+ assertEquals(thisTransaction.getObject(thatObject), thisRoot.getListA().get(0));
+ assertEquals(thatObject, thatRoot.getListA().get(0));
+ }
+
+ public void testClearRemoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thatRemoveObject = thatRoot.getListA().get(0);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ thatRoot.getListA().remove(0);
+ BaseObject thatAfterRemoveObject = thatRoot.getListA().get(0);
+
+ // clear.
+ thisRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatAfterRemoveObject).cdoState());
+ }
+
+ public void testClearRemoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // create objects.
+ BaseObject thatRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ BaseObject thisRemoveObject = thisTransaction.getObject(thatRemoveObject);
+ thatRoot.getListA().remove(thatRoot.getListA().size() - 1);
+ BaseObject thatAfterRemoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+
+ // clear.
+ thisRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatAfterRemoveObject).cdoState());
+ }
+
+ public void testClearMoveHeadTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(0);
+ BaseObject thisMoveObject = thisTransaction.getObject(thatMoveObject);
+ thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
+ BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
+ BaseObject thisAfterMoveObject = thisTransaction.getObject(thatAfterMoveObject);
+
+ // clear.
+ thisRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisMoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisAfterMoveObject).cdoState());
+ }
+
+ public void testClearMoveTailTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ BaseObject thisMoveObject = thisTransaction.getObject(thatMoveObject);
+ thatRoot.getListA().move(0, thatRoot.getListA().size() - 1);
+ BaseObject thatAfterMoveObject = thatRoot.getListA().get(thatRoot.getListA().size() - 1);
+ BaseObject thisAfterMoveObject = thisTransaction.getObject(thatAfterMoveObject);
+
+ // clear.
+ thisRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisMoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisAfterMoveObject).cdoState());
+ }
+
+ public void testClearClearTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // clear.
+ BaseObject thisObject = thisRoot.getListA().get(0);
+ thisRoot.getListA().clear();
+
+ BaseObject thatObject = thatRoot.getListA().get(0);
+ thatRoot.getListA().clear();
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(0, thisRoot.getListA().size());
+ assertEquals(0, thatRoot.getListA().size());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatObject).cdoState());
+ }
+
+ public void testRemoveHeadMoveHeadRemoveMiddleTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove object (get it before deletion).
+ BaseObject thisRemoveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ assertNotNull(thatRemoveObject);
+
+ thisRoot.getListA().remove(0);
+ BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(0);
+ BaseObject thatRemoveAfterMoveObject = thatRoot.getListA().get(2);
+ BaseObject thatAfterRemoveAfterMoveObject = thatRoot.getListA().get(3);
+ msg(thatAfterRemoveAfterMoveObject);
+
+ thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
+ BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
+
+ // Remove object.
+ thatRoot.getListA().remove(thatRemoveAfterMoveObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveObject, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveObject), thatRoot.getListA().get(0));
+ assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(0));
+ assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatMoveObject).cdoState());
+ }
+
+ public void testMoveHeadMoveHeadRemoveMiddleTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Move object.
+ BaseObject thisMoveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisMoveObject);
+ thisRoot.getListA().move(thisRoot.getListA().size() - 1, 0);
+ BaseObject thisAfterMoveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisAfterMoveObject);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(0);
+ BaseObject thatRemoveAfterMoveObject = thatRoot.getListA().get(2);
+ BaseObject thatAfterRemoveAfterMoveObject = thatRoot.getListA().get(3);
+ thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
+ BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
+
+ // Remove object.
+ BaseObject thisRemoveAfterMoveObject = thisTransaction.getObject(thatRemoveAfterMoveObject);
+ thatRoot.getListA().remove(thatRemoveAfterMoveObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ int listSize = thisRoot.getListA().size();
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisMoveObject, thisRoot.getListA().get(listSize - 1));
+ assertEquals(thatMoveObject, thatRoot.getListA().get(listSize - 1));
+ assertEquals(thisAfterMoveObject, thisRoot.getListA().get(0));
+ assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
+ assertEquals(thisTransaction.getObject(thatAfterRemoveAfterMoveObject), thisRoot.getListA().get(1));
+ assertEquals(thatAfterRemoveAfterMoveObject, thatRoot.getListA().get(1));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveAfterMoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveAfterMoveObject).cdoState());
+ }
+
+ public void testMoveHeadRemoveHeadRemoveMiddleTest() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // Remove object.
+ BaseObject thisRemoveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisRemoveObject);
+ BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
+ thisRoot.getListA().remove(0);
+ BaseObject thisAfterRemveObject = thisRoot.getListA().get(0);
+ assertNotNull(thisAfterRemveObject);
+
+ // Move object.
+ BaseObject thatMoveObject = thatRoot.getListA().get(0);
+ msg(thatMoveObject);
+
+ BaseObject thatRemoveAfterMoveObject = thatRoot.getListA().get(2);
+ BaseObject thatAfterRemoveAfterMoveObject = thatRoot.getListA().get(3);
+ thatRoot.getListA().move(thatRoot.getListA().size() - 1, 0);
+ BaseObject thatAfterMoveObject = thatRoot.getListA().get(0);
+
+ // Remove object.
+ BaseObject thisRemoveAfterMoveObject = thisTransaction.getObject(thatRemoveAfterMoveObject);
+ thatRoot.getListA().remove(thatRemoveAfterMoveObject);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListA()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListA()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemveObject, thisRoot.getListA().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemveObject), thatRoot.getListA().get(0));
+ assertEquals(thisTransaction.getObject(thatAfterMoveObject), thisRoot.getListA().get(0));
+ assertEquals(thatAfterMoveObject, thatRoot.getListA().get(0));
+ assertEquals(thisTransaction.getObject(thatAfterRemoveAfterMoveObject), thisRoot.getListA().get(1));
+ assertEquals(thatAfterRemoveAfterMoveObject, thatRoot.getListA().get(1));
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveAfterMoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisRemoveAfterMoveObject).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
+ }
+
+ public void testRemoveHeadAddChildHead() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove containment.
+ ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
+ assertNotNull(thisToRemoveContainment);
+ ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
+ thisRoot.getListB().remove(0);
+
+ // add child to containment.
+ BaseObject bcObject0 = createBaseObject("AddBaseContainmentObject 0"); //$NON-NLS-1$
+ bcObject0.setAttributeRequired("AddBaseContainmentObject 0"); //$NON-NLS-1$
+ ContainmentObject thatAddContainment = createContainmentObject("AddContainmentObject 0"); //$NON-NLS-1$
+ thatAddContainment.setAttributeRequired("AddContainmentObject 0"); //$NON-NLS-1$
+ thatAddContainment.setContainmentOptional(bcObject0);
+
+ ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
+ assertNotNull(thatParent);
+ // detach an object.
+ ContainmentObject thatReattachContainment = (ContainmentObject)thatParent.getContainmentList().remove(0);
+ // add a new object.
+ thatParent.getContainmentList().add(thatAddContainment);
+ // reattach containment.
+ thatParent.getContainmentList().add(thatReattachContainment);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListB()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListB()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
+
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatReattachContainment).cdoState());
+ assertEquals(CDOState.NEW, CDOUtil.getCDOObject(thatAddContainment).cdoState());
+ }
+
+ public void testRemoveHeadSetChildHead() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove containment.
+ ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
+ assertNotNull(thisToRemoveContainment);
+ ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
+ thisRoot.getListB().remove(0);
+
+ // add child to containment.
+ BaseObject bcObject0 = createBaseObject("AddBaseContainmentObject 0"); //$NON-NLS-1$
+ ContainmentObject thatAddContainment = createContainmentObject("AddContainmentObject 0"); //$NON-NLS-1$
+ thatAddContainment.setAttributeRequired("AddContainmentObject 0"); //$NON-NLS-1$
+ thatAddContainment.setContainmentOptional(bcObject0);
+
+ ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
+ assertNotNull(thatParent);
+
+ // set a new object.
+ BaseObject thatUnsetContainment = thatParent.getContainmentOptional();
+ msg(thatUnsetContainment);
+
+ thatParent.setContainmentOptional(thatAddContainment);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListB()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListB()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
+
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
+ // assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatUnsetContainment).cdoState()); <-- NPE
+ assertEquals(CDOState.NEW, CDOUtil.getCDOObject(thatAddContainment).cdoState());
+ }
+
+ public void testRemoveHeadRemoveChildHead() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove containment.
+ ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
+ assertNotNull(thisToRemoveContainment);
+ ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
+ thisRoot.getListB().remove(0);
+
+ // get parent object.
+ ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
+ assertNotNull(thatParent);
+ // remove child from containment.
+ ContainmentObject thatDetachContainment = (ContainmentObject)thatParent.getContainmentList().remove(0);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListB()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListB()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
+
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatDetachContainment).cdoState());
+ }
+
+ public void testRemoveHeadRemoveChildChildHead() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove containment.
+ ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
+ assertNotNull(thisToRemoveContainment);
+ ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
+ thisRoot.getListB().remove(0);
+
+ // get parent object.
+ ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
+ assertNotNull(thatParent);
+ // get child from containment.
+ ContainmentObject thatChildContainment = (ContainmentObject)thatParent.getContainmentList().get(0);
+ assertNotNull(thatChildContainment);
+ // remove child from containment child.
+ BaseObject thatDetachContainment = thatChildContainment.getContainmentList().remove(0);
+ assertNotNull(thatDetachContainment);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListB()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListB()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
+
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatDetachContainment).cdoState());
+ }
+
+ public void testRemoveHeadMoveChildHead() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove containment.
+ ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
+ assertNotNull(thisToRemoveContainment);
+ ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
+ thisRoot.getListB().remove(0);
+
+ // add child to containment.
+ BaseObject bcObject0 = createBaseObject("AddBaseContainmentObject 0"); //$NON-NLS-1$
+ ContainmentObject thatAddContainment = createContainmentObject("AddContainmentObject 0"); //$NON-NLS-1$
+ thatAddContainment.setContainmentOptional(bcObject0);
+
+ ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
+ assertNotNull(thatParent);
+ // detach an object.
+ ContainmentObject thatReattachContainment = (ContainmentObject)thatParent.getContainmentList().remove(0);
+ // add a new object.
+ thatParent.getContainmentList().add(thatAddContainment);
+ // reattach containment.
+ thatParent.getContainmentList().add(thatReattachContainment);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListB()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListB()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
+
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatReattachContainment).cdoState());
+ assertEquals(CDOState.NEW, CDOUtil.getCDOObject(thatAddContainment).cdoState());
+ }
+
+ public void testRemoveHeadReAttachHead() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // access objects.
+ Root thisRoot = getTestModelRoot(thisTransaction);
+ assertNotNull(thisRoot);
+ Root thatRoot = thatTransaction.getObject(thisRoot);
+ assertNotNull(thatRoot);
+
+ // attach adapters.
+ thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
+ thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
+
+ // remove containment.
+ ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
+ assertNotNull(thisToRemoveContainment);
+ ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
+ thisRoot.getListB().remove(0);
+
+ // detach and re-attach containment.
+ ContainmentObject thatAddContainment = (ContainmentObject)thatRoot.getListB().get(0);
+ thatRoot.getListB().add(thatAddContainment);
+ // TODO: re-add at other position (add some objects in between)?
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // print contents of lists
+ printList("This ", thisRoot.getListB()); //$NON-NLS-1$
+ printList("That ", thatRoot.getListB()); //$NON-NLS-1$
+
+ // -- check indices.
+ assertEquals(false, thisTransaction.isDirty());
+ assertEquals(false, thatTransaction.isDirty());
+ assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
+ assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
+
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatAddContainment).cdoState());
+ }
+
+ public void testContainerAddDifferentParent() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction thisTransaction = session.openTransaction();
+ CDOTransaction thatTransaction = session.openTransaction();
+ initTestModel();
+ addConflictResolver(thatTransaction);
+
+ // create initial model.
+ Root root = getTestModelRoot(thisTransaction);
+ ContainmentObject group1 = createContainmentObject("Group 1"); //$NON-NLS-1$
+ group1.setAttributeRequired("Group 1"); //$NON-NLS-1$
+
+ ContainmentObject group2 = createContainmentObject("Group 2"); //$NON-NLS-1$
+ group2.setAttributeRequired("Group 2"); //$NON-NLS-1$
+
+ BaseObject element0 = createBaseObject("Element 0"); //$NON-NLS-1$
+ element0.setAttributeRequired("Element 0"); //$NON-NLS-1$
+
+ BaseObject element1 = createBaseObject("Element 1"); //$NON-NLS-1$
+ element1.setAttributeRequired("Element 1"); //$NON-NLS-1$
+
+ BaseObject element2 = createBaseObject("Element 2"); //$NON-NLS-1$
+ element2.setAttributeRequired("Element 2"); //$NON-NLS-1$
+
+ root.getListC().add(group1);
+ root.getListC().add(group2);
+ root.getListC().add(element0);
+ root.getListC().add(element1);
+ root.getListC().add(element2);
+
+ commitAndSync(thisTransaction, thatTransaction);
+
+ // get objects from that transaction.
+ ContainmentObject thatGroup1 = thatTransaction.getObject(group1);
+ ContainmentObject thatGroup2 = thatTransaction.getObject(group2);
+ BaseObject thatElement0 = thatTransaction.getObject(element0);
+ BaseObject thatElement1 = thatTransaction.getObject(element1);
+ BaseObject thatElement2 = thatTransaction.getObject(element2);
+ Root thatRoot = thatTransaction.getObject(root);
+
+ // create group 1 (element 0 & 1).
+ root.getListC().remove(element0);
+ group1.getContainmentList().add(element0);
+ root.getListC().remove(element1);
+ group1.getContainmentList().add(element1);
+
+ // create group 2 (element 1 & 2).
+ thatRoot.getListC().remove(thatElement1);
+ thatGroup2.getContainmentList().add(thatElement1);
+ thatRoot.getListC().remove(thatElement2);
+ thatGroup2.getContainmentList().add(thatElement2);
+
+ commitAndSync(thisTransaction, thatTransaction);
+ commitAndSync(thatTransaction, thisTransaction);
+
+ // -- Check:
+ assertEquals(2, root.getListC().size()); // 2 groups.
+ assertEquals(group1, element0.eContainer());
+ assertEquals(group2, element1.eContainer());
+ assertEquals(group2, element2.eContainer());
+ assertEquals(1, group1.getContainmentList().size()); // 1 element.
+ assertEquals(2, group2.getContainmentList().size()); // 2 elements.
+
+ assertEquals(2, thatRoot.getListC().size()); // 2 groups.
+ assertEquals(thatGroup1, thatElement0.eContainer());
+ assertEquals(thatGroup2, thatElement1.eContainer());
+ assertEquals(thatGroup2, thatElement2.eContainer());
+ assertEquals(1, thatGroup1.getContainmentList().size()); // 1 element.
+ assertEquals(2, thatGroup2.getContainmentList().size()); // 2 elements.
+ }
+
+ // --- container conflict resolver tests -----------------------------------
+ // TODO: convert them into CDOTests
+
+ // --- random conflict resolver tests --------------------------------------
+ // TODO: convert them into CDOTests
+
+ // ========== HELPERS ======================================================
+
+ protected BaseObject createBaseObject(String attribute)
+ {
+ BaseObject baseObj = getModel6Factory().createBaseObject();
+ baseObj.setAttributeRequired(attribute);
+ return baseObj;
+ }
+
+ protected ReferenceObject createReferenceObject(String attribute)
+ {
+ ReferenceObject refObject = getModel6Factory().createReferenceObject();
+ refObject.setAttributeRequired(attribute);
+ return refObject;
+ }
+
+ protected ContainmentObject createContainmentObject(String attribute)
+ {
+ ContainmentObject contObject = getModel6Factory().createContainmentObject();
+ contObject.setAttributeRequired(attribute);
+ return contObject;
+ }
+
+ private Root getTestModelRoot(CDOTransaction transaction)
+ {
+ CDOResource resource = transaction.getResource(getResourcePath(TEST_RESOURCE_NAME));
+ return (Root)resource.getContents().get(0);
+ }
+
+ private void printList(String identifier, List<BaseObject> list)
+ {
+ System.out.println(identifier + "List:"); //$NON-NLS-1$
+ System.out.print("["); //$NON-NLS-1$
+ boolean first = true;
+
+ for (BaseObject bObj : list)
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ System.out.print(", "); //$NON-NLS-1$
+ }
+
+ System.out.print(bObj.getAttributeRequired() + " (" + CDOUtil.getCDOObject(bObj).cdoID() + ")"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ System.out.println("]"); //$NON-NLS-1$
+
+ }
+
+ private void addConflictResolver(CDOTransaction transaction)
+ {
+ transaction.options().addConflictResolver(conflictResolver);
+ }
+
+ /**
+ * @author Pascal Lehmann
+ */
+ private static class ListPrintingAdapter extends AdapterImpl
+ {
+ private String identifier;
+
+ public ListPrintingAdapter(String identifier)
+ {
+ this.identifier = identifier;
+ }
+
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ try
+ {
+ System.err.println(identifier + msg);
+ }
+ catch (Exception e)
+ {
+ // ignore.
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverMergingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverMergingTest.java
index 1ff8225eaa..175cf70bf9 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverMergingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverMergingTest.java
@@ -1,141 +1,141 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOConflictResolver;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * @author Simon McDuff
- */
-public class ConflictResolverMergingTest extends ConflictResolverTest
-{
- public void testMergeLocalChangesPerFeature_Bug1() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- CDOTransaction transaction1 = session.openTransaction();
- EList<EObject> contents1 = transaction1.getOrCreateResource(getResourcePath("/res1")).getContents();
-
- contents1.add(getModel1Factory().createAddress());
- transaction1.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- transaction2.options().addConflictResolver(createConflictResolver());
- EList<EObject> contents2 = transaction2.getOrCreateResource(getResourcePath("/res1")).getContents();
-
- // ----------------------------
- contents1.add(getModel1Factory().createAddress());
- contents2.add(getModel1Factory().createAddress());
-
- // Resolver should be triggered.
- commitAndSync(transaction1, transaction2);
- commitAndSync(transaction2, transaction1);
-
- // ----------------------------
- contents1.add(getModel1Factory().createAddress());
- contents2.add(getModel1Factory().createAddress());
-
- // Resolver should be triggered.
- commitAndSync(transaction1, transaction2);
- commitAndSync(transaction2, transaction1);
-
- // ----------------------------
- contents1.add(getModel1Factory().createAddress());
- contents2.add(getModel1Factory().createAddress());
-
- // Resolver should be triggered.
- commitAndSync(transaction1, transaction2);
- commitAndSync(transaction2, transaction1);
- }
-
- public void testMergeLocalChangesPerFeature_Bug2() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- CDOTransaction transaction1 = session.openTransaction();
- transaction1.options().addConflictResolver(createConflictResolver());
- EList<EObject> contents1 = transaction1.getOrCreateResource(getResourcePath("/res1")).getContents();
-
- contents1.add(getModel1Factory().createAddress());
- transaction1.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- transaction2.options().addConflictResolver(createConflictResolver());
- EList<EObject> contents2 = transaction2.getOrCreateResource(getResourcePath("/res1")).getContents();
-
- contents1.add(getModel1Factory().createAddress());
- contents2.add(getModel1Factory().createAddress());
-
- // Resolver should be triggered.
- commitAndSync(transaction1, transaction2);
- commitAndSync(transaction2, transaction1);
-
- contents1.add(getModel1Factory().createAddress());
- contents2.add(getModel1Factory().createAddress());
-
- // Resolver should be triggered.
- commitAndSync(transaction2, transaction1);
- commitAndSync(transaction1, transaction2);
- }
-
- public void testMerge_ManyValue() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- CDOTransaction transaction1 = session.openTransaction();
- transaction1.options().addConflictResolver(createConflictResolver());
- EList<EObject> contents1 = transaction1.getOrCreateResource(getResourcePath("/res1")).getContents();
-
- SalesOrder c1 = getModel1Factory().createSalesOrder();
- contents1.add(c1);
- transaction1.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- transaction2.options().addConflictResolver(createConflictResolver());
- EList<EObject> contents2 = transaction2.getOrCreateResource(getResourcePath("/res1")).getContents();
-
- SalesOrder c2 = (SalesOrder)contents2.get(0);
-
- OrderDetail s1 = getModel1Factory().createOrderDetail();
- c1.getOrderDetails().add(s1);
-
- OrderDetail s2 = getModel1Factory().createOrderDetail();
- c2.getOrderDetails().add(s2);
-
- commitAndSync(transaction1, transaction2);
- commitAndSync(transaction2, transaction1);
-
- EList<OrderDetail> list = c1.getOrderDetails();
- System.out.println(list);
- assertEquals(2, list.size());
- assertEquals(CDOUtil.getCDOObject(s2).cdoID(), CDOUtil.getCDOObject(list.get(0)).cdoID());
- assertEquals(CDOUtil.getCDOObject(s1).cdoID(), CDOUtil.getCDOObject(list.get(1)).cdoID());
- }
-
- @SuppressWarnings("deprecation")
- @Override
- protected CDOConflictResolver createConflictResolver()
- {
- return new org.eclipse.emf.spi.cdo.CDOMergingConflictResolver();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOConflictResolver;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * @author Simon McDuff
+ */
+public class ConflictResolverMergingTest extends ConflictResolverTest
+{
+ public void testMergeLocalChangesPerFeature_Bug1() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ EList<EObject> contents1 = transaction1.getOrCreateResource(getResourcePath("/res1")).getContents();
+
+ contents1.add(getModel1Factory().createAddress());
+ transaction1.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ transaction2.options().addConflictResolver(createConflictResolver());
+ EList<EObject> contents2 = transaction2.getOrCreateResource(getResourcePath("/res1")).getContents();
+
+ // ----------------------------
+ contents1.add(getModel1Factory().createAddress());
+ contents2.add(getModel1Factory().createAddress());
+
+ // Resolver should be triggered.
+ commitAndSync(transaction1, transaction2);
+ commitAndSync(transaction2, transaction1);
+
+ // ----------------------------
+ contents1.add(getModel1Factory().createAddress());
+ contents2.add(getModel1Factory().createAddress());
+
+ // Resolver should be triggered.
+ commitAndSync(transaction1, transaction2);
+ commitAndSync(transaction2, transaction1);
+
+ // ----------------------------
+ contents1.add(getModel1Factory().createAddress());
+ contents2.add(getModel1Factory().createAddress());
+
+ // Resolver should be triggered.
+ commitAndSync(transaction1, transaction2);
+ commitAndSync(transaction2, transaction1);
+ }
+
+ public void testMergeLocalChangesPerFeature_Bug2() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ transaction1.options().addConflictResolver(createConflictResolver());
+ EList<EObject> contents1 = transaction1.getOrCreateResource(getResourcePath("/res1")).getContents();
+
+ contents1.add(getModel1Factory().createAddress());
+ transaction1.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ transaction2.options().addConflictResolver(createConflictResolver());
+ EList<EObject> contents2 = transaction2.getOrCreateResource(getResourcePath("/res1")).getContents();
+
+ contents1.add(getModel1Factory().createAddress());
+ contents2.add(getModel1Factory().createAddress());
+
+ // Resolver should be triggered.
+ commitAndSync(transaction1, transaction2);
+ commitAndSync(transaction2, transaction1);
+
+ contents1.add(getModel1Factory().createAddress());
+ contents2.add(getModel1Factory().createAddress());
+
+ // Resolver should be triggered.
+ commitAndSync(transaction2, transaction1);
+ commitAndSync(transaction1, transaction2);
+ }
+
+ public void testMerge_ManyValue() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ transaction1.options().addConflictResolver(createConflictResolver());
+ EList<EObject> contents1 = transaction1.getOrCreateResource(getResourcePath("/res1")).getContents();
+
+ SalesOrder c1 = getModel1Factory().createSalesOrder();
+ contents1.add(c1);
+ transaction1.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ transaction2.options().addConflictResolver(createConflictResolver());
+ EList<EObject> contents2 = transaction2.getOrCreateResource(getResourcePath("/res1")).getContents();
+
+ SalesOrder c2 = (SalesOrder)contents2.get(0);
+
+ OrderDetail s1 = getModel1Factory().createOrderDetail();
+ c1.getOrderDetails().add(s1);
+
+ OrderDetail s2 = getModel1Factory().createOrderDetail();
+ c2.getOrderDetails().add(s2);
+
+ commitAndSync(transaction1, transaction2);
+ commitAndSync(transaction2, transaction1);
+
+ EList<OrderDetail> list = c1.getOrderDetails();
+ System.out.println(list);
+ assertEquals(2, list.size());
+ assertEquals(CDOUtil.getCDOObject(s2).cdoID(), CDOUtil.getCDOObject(list.get(0)).cdoID());
+ assertEquals(CDOUtil.getCDOObject(s1).cdoID(), CDOUtil.getCDOObject(list.get(1)).cdoID());
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected CDOConflictResolver createConflictResolver()
+ {
+ return new org.eclipse.emf.spi.cdo.CDOMergingConflictResolver();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverTest.java
index af3250d534..55240c0827 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverTest.java
@@ -1,124 +1,124 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Address;
-import org.eclipse.emf.cdo.transaction.CDOConflictResolver;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * @author Simon McDuff
- */
-@CleanRepositoriesBefore
-public class ConflictResolverTest extends AbstractCDOTest
-{
- public void testMergeLocalChangesPerFeature_Basic() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
-
- Address address = getModel1Factory().createAddress();
-
- transaction.getOrCreateResource(getResourcePath("/res1")).getContents().add(address);
-
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- transaction2.options().addConflictResolver(createConflictResolver());
- Address address2 = (Address)transaction2.getOrCreateResource(getResourcePath("/res1")).getContents().get(0);
-
- address2.setCity("OTTAWA");
-
- address.setName("NAME1");
-
- // Resolver should be triggered.
- commitAndSync(transaction, transaction2);
-
- assertEquals(false, CDOUtil.getCDOObject(address2).cdoConflict());
- assertEquals(false, transaction2.hasConflict());
-
- assertEquals("NAME1", address2.getName());
- assertEquals("OTTAWA", address2.getCity());
-
- transaction2.commit();
- }
-
- // Does not work in legacy as long as there is not getter interception
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void testMergeLocalChangesPerFeature_BasicException() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
-
- Address address = getModel1Factory().createAddress();
-
- transaction.getOrCreateResource(getResourcePath("/res1")).getContents().add(address);
-
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- transaction2.options().addConflictResolver(createConflictResolver());
- final Address address2 = (Address)transaction2.getOrCreateResource(getResourcePath("/res1")).getContents().get(0);
-
- address2.setCity("OTTAWA");
-
- address.setCity("NAME1");
- commitAndSync(transaction, transaction2);
-
- assertEquals(true, transaction2.hasConflict());
- assertEquals(true, CDOUtil.getCDOObject(address2).cdoConflict());
- assertEquals("OTTAWA", address2.getCity());
- }
-
- public void testCDOMergingConflictResolver() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- Address address = getModel1Factory().createAddress();
- transaction.getOrCreateResource(getResourcePath("/res1")).getContents().add(address);
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- transaction2.options().addConflictResolver(createConflictResolver());
-
- Address address2 = (Address)transaction2.getOrCreateResource(getResourcePath("/res1")).getContents().get(0);
- address2.setCity("OTTAWA");
-
- address.setName("NAME1");
-
- // Resolver should be triggered.
- commitAndSync(transaction, transaction2);
-
- assertEquals(false, CDOUtil.getCDOObject(address2).cdoConflict());
- assertEquals(false, transaction2.hasConflict());
-
- assertEquals("NAME1", address2.getName());
- assertEquals("OTTAWA", address2.getCity());
-
- transaction2.commit();
- }
-
- @SuppressWarnings("deprecation")
- protected CDOConflictResolver createConflictResolver()
- {
- return new org.eclipse.emf.spi.cdo.AbstractObjectConflictResolver.MergeLocalChangesPerFeature();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Address;
+import org.eclipse.emf.cdo.transaction.CDOConflictResolver;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * @author Simon McDuff
+ */
+@CleanRepositoriesBefore
+public class ConflictResolverTest extends AbstractCDOTest
+{
+ public void testMergeLocalChangesPerFeature_Basic() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+
+ Address address = getModel1Factory().createAddress();
+
+ transaction.getOrCreateResource(getResourcePath("/res1")).getContents().add(address);
+
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ transaction2.options().addConflictResolver(createConflictResolver());
+ Address address2 = (Address)transaction2.getOrCreateResource(getResourcePath("/res1")).getContents().get(0);
+
+ address2.setCity("OTTAWA");
+
+ address.setName("NAME1");
+
+ // Resolver should be triggered.
+ commitAndSync(transaction, transaction2);
+
+ assertEquals(false, CDOUtil.getCDOObject(address2).cdoConflict());
+ assertEquals(false, transaction2.hasConflict());
+
+ assertEquals("NAME1", address2.getName());
+ assertEquals("OTTAWA", address2.getCity());
+
+ transaction2.commit();
+ }
+
+ // Does not work in legacy as long as there is not getter interception
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void testMergeLocalChangesPerFeature_BasicException() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+
+ Address address = getModel1Factory().createAddress();
+
+ transaction.getOrCreateResource(getResourcePath("/res1")).getContents().add(address);
+
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ transaction2.options().addConflictResolver(createConflictResolver());
+ final Address address2 = (Address)transaction2.getOrCreateResource(getResourcePath("/res1")).getContents().get(0);
+
+ address2.setCity("OTTAWA");
+
+ address.setCity("NAME1");
+ commitAndSync(transaction, transaction2);
+
+ assertEquals(true, transaction2.hasConflict());
+ assertEquals(true, CDOUtil.getCDOObject(address2).cdoConflict());
+ assertEquals("OTTAWA", address2.getCity());
+ }
+
+ public void testCDOMergingConflictResolver() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ Address address = getModel1Factory().createAddress();
+ transaction.getOrCreateResource(getResourcePath("/res1")).getContents().add(address);
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ transaction2.options().addConflictResolver(createConflictResolver());
+
+ Address address2 = (Address)transaction2.getOrCreateResource(getResourcePath("/res1")).getContents().get(0);
+ address2.setCity("OTTAWA");
+
+ address.setName("NAME1");
+
+ // Resolver should be triggered.
+ commitAndSync(transaction, transaction2);
+
+ assertEquals(false, CDOUtil.getCDOObject(address2).cdoConflict());
+ assertEquals(false, transaction2.hasConflict());
+
+ assertEquals("NAME1", address2.getName());
+ assertEquals("OTTAWA", address2.getCity());
+
+ transaction2.commit();
+ }
+
+ @SuppressWarnings("deprecation")
+ protected CDOConflictResolver createConflictResolver()
+ {
+ return new org.eclipse.emf.spi.cdo.AbstractObjectConflictResolver.MergeLocalChangesPerFeature();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java
index e7f14b76ce..74ef3aafbb 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java
@@ -1,586 +1,586 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Address;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.tests.model2.PersistentContainment;
-import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
-import org.eclipse.emf.cdo.tests.model2.Task;
-import org.eclipse.emf.cdo.tests.model2.TaskContainer;
-import org.eclipse.emf.cdo.tests.model2.TransientContainer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-/**
- * @author Eike Stepper
- */
-public class ContainmentTest extends AbstractCDOTest
-{
- public void testTransientContainment() throws Exception
- {
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Creating company");
- Company company = getModel1Factory().createCompany();
-
- msg("Adding supplier");
- company.getSuppliers().add(supplier);
-
- assertTransient(company);
- assertTransient(supplier);
- assertContent(company, supplier);
- }
-
- public void testBasicContainment() throws Exception
- {
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Creating company");
- Company company = getModel1Factory().createCompany();
-
- msg("Adding supplier");
- company.getSuppliers().add(supplier);
-
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resource.getContents().add(company);
-
- msg("Committing");
- transaction.commit();
-
- assertClean(resource, transaction);
- assertClean(company, transaction);
- assertClean(supplier, transaction);
- assertContent(resource, company);
- assertContent(company, supplier);
- }
-
- public void test3Levels() throws Exception
- {
- msg("Creating category1");
- Category category1 = getModel1Factory().createCategory();
- category1.setName("category1");
-
- msg("Creating category2");
- Category category2 = getModel1Factory().createCategory();
- category2.setName("category2");
-
- msg("Creating category3");
- Category category3 = getModel1Factory().createCategory();
- category3.setName("category3");
-
- msg("Creating company");
- Company company = getModel1Factory().createCompany();
-
- msg("Adding categories");
- company.getCategories().add(category1);
- category1.getCategories().add(category2);
- category2.getCategories().add(category3);
-
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resource.getContents().add(company);
-
- msg("Committing");
- transaction.commit();
-
- assertClean(resource, transaction);
- assertClean(company, transaction);
- assertClean(category1, transaction);
- assertClean(category2, transaction);
- assertClean(category3, transaction);
- assertContent(resource, company);
- assertContent(company, category1);
- assertContent(category1, category2);
- assertContent(category2, category3);
- }
-
- public void testSeparateView() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- {
- msg("Creating category1");
- Category category1 = getModel1Factory().createCategory();
- category1.setName("category1");
-
- msg("Creating category2");
- Category category2 = getModel1Factory().createCategory();
- category2.setName("category2");
-
- msg("Creating category3");
- Category category3 = getModel1Factory().createCategory();
- category3.setName("category3");
-
- msg("Creating company");
- Company company = getModel1Factory().createCompany();
-
- msg("Adding categories");
- company.getCategories().add(category1);
- category1.getCategories().add(category2);
- category2.getCategories().add(category3);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resource.getContents().add(company);
-
- msg("Committing");
- transaction.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Loading resource");
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
- assertProxy(resource);
-
- EList<EObject> contents = resource.getContents();
- Company company = (Company)contents.get(0);
- assertClean(company, transaction);
- assertClean(resource, transaction);
- assertContent(resource, company);
-
- Category category1 = company.getCategories().get(0);
- assertClean(category1, transaction);
- assertClean(company, transaction);
- assertContent(company, category1);
-
- Category category2 = category1.getCategories().get(0);
- assertClean(category2, transaction);
- assertClean(category1, transaction);
- assertContent(category1, category2);
-
- Category category3 = category2.getCategories().get(0);
- assertClean(category3, transaction);
- assertClean(category2, transaction);
- assertContent(category2, category3);
- assertClean(category3, transaction);
- }
-
- public void testSeparateSession() throws Exception
- {
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Creating category1");
- Category category1 = getModel1Factory().createCategory();
- category1.setName("category1");
-
- msg("Creating category2");
- Category category2 = getModel1Factory().createCategory();
- category2.setName("category2");
-
- msg("Creating category3");
- Category category3 = getModel1Factory().createCategory();
- category3.setName("category3");
-
- msg("Creating company");
- Company company = getModel1Factory().createCompany();
-
- msg("Adding categories");
- company.getCategories().add(category1);
- category1.getCategories().add(category2);
- category2.getCategories().add(category3);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resource.getContents().add(company);
-
- msg("Committing");
- transaction.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Loading resource");
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
- assertProxy(resource);
-
- EList<EObject> contents = resource.getContents();
- Company company = (Company)contents.get(0);
- assertClean(company, transaction);
- assertClean(resource, transaction);
- assertContent(resource, company);
-
- Category category1 = company.getCategories().get(0);
- assertClean(category1, transaction);
- assertClean(company, transaction);
- assertContent(company, category1);
-
- Category category2 = category1.getCategories().get(0);
- assertClean(category2, transaction);
- assertClean(category1, transaction);
- assertContent(category1, category2);
-
- Category category3 = category2.getCategories().get(0);
- assertClean(category3, transaction);
- assertClean(category2, transaction);
- assertContent(category2, category3);
- assertClean(category3, transaction);
- }
-
- public void testSetSingleContainment() throws Exception
- {
- Address address = getModel1Factory().createAddress();
- address.setName("Stepper");
- address.setStreet("Home Ave. 007");
- address.setCity("Berlin");
-
- SpecialPurchaseOrder order = getModel2Factory().createSpecialPurchaseOrder();
- order.setShippingAddress(address);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- resource.getContents().add(order);
- transaction.commit();
-
- assertClean(resource, transaction);
- assertClean(order, transaction);
- assertClean(address, transaction);
- assertContent(resource, order);
- assertContent(order, address);
- }
-
- public void testUnsetSingleContainment() throws Exception
- {
- Address address = getModel1Factory().createAddress();
- address.setName("Stepper");
- address.setStreet("Home Ave. 007");
- address.setCity("Berlin");
-
- SpecialPurchaseOrder order = getModel2Factory().createSpecialPurchaseOrder();
- order.setShippingAddress(address);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- resource.getContents().add(order);
- transaction.commit();
-
- order.setShippingAddress(null);
- transaction.commit();
-
- assertClean(resource, transaction);
- assertClean(order, transaction);
- assertTransient(address);
- assertContent(resource, order);
- assertNull(order.getShippingAddress());
- }
-
- public void testObjectNotSameResourceThanItsContainerCDO() throws Exception
- {
- {
- CDOSession session = openSession();
- ResourceSet resourceSet = new ResourceSetImpl();
-
- CDOTransaction transaction = session.openTransaction(resourceSet);
- Resource resource1 = transaction.createResource(getResourcePath("testA"));
- Resource resource2 = transaction.createResource(getResourcePath("testB"));
-
- EPackage packageObject = createDynamicEPackage();
- session.getPackageRegistry().putEPackage(packageObject);
- EClass eClass = (EClass)packageObject.getEClassifier("SchoolBook");
-
- EObject container = packageObject.getEFactoryInstance().create(eClass);
- Order contained = getModel1Factory().createPurchaseOrder();
-
- resource1.getContents().add(container);
- resource2.getContents().add(contained);
-
- container.eSet(container.eClass().getEStructuralFeature("proxyElement"), contained);
-
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, contained.eResource());
-
- // If the relationship is define has resolveProxy this is true if not.. this is false.
- assertEquals(container, contained.eContainer());
- transaction.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- ResourceSet resourceSet = new ResourceSetImpl();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction(resourceSet);
- Resource resource1 = transaction.getResource(getResourcePath("testA"));
- Resource resource2 = transaction.getResource(getResourcePath("testB"));
-
- EObject container = resource1.getContents().get(0);
- Order order = (Order)resource2.getContents().get(0);
-
- assertEquals(resource1.getContents().get(0), order.eContainer());
- resource2.getContents().remove(order);
-
- Order order2 = (Order)CDOUtil.getEObject((EObject)container.eGet(container.eClass().getEStructuralFeature(
- "proxyElement")));
- assertSame(order, order2);
- }
-
- public void testObjectNotSameResourceThanItsContainer_WithoutCDO() throws Exception
- {
- ResourceSet resourceSet = new ResourceSetImpl();
-
- resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
-
- Resource resource1 = resourceSet.createResource(URI.createURI("test://1"));
- Resource resource2 = resourceSet.createResource(URI.createURI("test://2"));
- EPackage packageObject = createDynamicEPackage();
- EClass eClass = (EClass)packageObject.getEClassifier("SchoolBook");
-
- EObject container = packageObject.getEFactoryInstance().create(eClass);
- EObject contained = packageObject.getEFactoryInstance().create(eClass);
-
- resource1.getContents().add(container);
- resource2.getContents().add(contained);
-
- container.eSet(container.eClass().getEStructuralFeature("proxyElement"), contained);
- // resource1.getContents().add(container);
-
- assertEquals(resource1, container.eResource());
- assertEquals(resource2, contained.eResource());
-
- // If the relationship is define has resolveProxy this is true if not.. this is false.
- assertEquals(container, contained.eContainer());
- }
-
- public void testModeledBackPointer() throws Exception
- {
- Task task = getModel2Factory().createTask();
- task.setDescription("Task 1");
-
- TaskContainer taskContainer = getModel2Factory().createTaskContainer();
- taskContainer.getTasks().add(task);
- assertEquals(taskContainer, task.eContainer());
- assertEquals(taskContainer, task.getTaskContainer());
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/resource1"));
- resource.getContents().add(taskContainer);
-
- transaction.commit();
- assertEquals(taskContainer, task.eContainer());
- assertEquals(taskContainer, task.getTaskContainer());
- session.close();
- }
-
- public void testModeledBackPointer_Transient() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/resource1"));
-
- PersistentContainment parent1 = createPersistentContainment();
- parent1.getChildren().add(createTransientContainer());
- parent1.getChildren().add(createTransientContainer());
- parent1.getChildren().add(createTransientContainer());
- resource.getContents().add(parent1);
- transaction.commit();
-
- // Move child
- PersistentContainment parent2 = createPersistentContainment();
- parent2.getChildren().add(parent1.getChildren().get(0));
- transaction.commit();
-
- // Remove child
- parent1.getChildren().remove(0);
- transaction.commit();
-
- // Remove child
- parent1.getChildren().remove(0);
- transaction.commit();
- }
-
- public void testModeledBackPointer_Transient_Load() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/resource1"));
-
- PersistentContainment parent1 = createPersistentContainment();
- parent1.getChildren().add(createTransientContainer());
- parent1.getChildren().add(createTransientContainer());
- parent1.getChildren().add(createTransientContainer());
- resource.getContents().add(parent1);
- transaction.commit();
-
- session.close();
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/resource1"));
- parent1 = (PersistentContainment)resource.getContents().get(0);
-
- // Move child
- PersistentContainment parent2 = createPersistentContainment();
- parent2.getChildren().add(parent1.getChildren().get(0));
- transaction.commit();
-
- // Remove child
- parent1.getChildren().remove(0);
- transaction.commit();
-
- // Remove child
- parent1.getChildren().remove(0);
- transaction.commit();
- }
-
- private PersistentContainment createPersistentContainment()
- {
- PersistentContainment result = getModel2Factory().createPersistentContainment();
- result.setAttrBefore("BEFORE");
- result.setAttrAfter("AFTER");
- return result;
- }
-
- private TransientContainer createTransientContainer()
- {
- TransientContainer result = getModel2Factory().createTransientContainer();
- result.setAttrBefore("BEFORE");
- result.setAttrAfter("AFTER");
- return result;
- }
-
- private EPackage createDynamicEPackage()
- {
- final EcoreFactory efactory = EcoreFactory.eINSTANCE;
- final EcorePackage epackage = EcorePackage.eINSTANCE;
-
- EClass schoolBookEClass = efactory.createEClass();
- schoolBookEClass.setName("SchoolBook");
-
- // create a new attribute for this EClass
- EAttribute level = efactory.createEAttribute();
- level.setName("level");
- level.setEType(epackage.getEInt());
- schoolBookEClass.getEStructuralFeatures().add(level);
-
- EReference proxyElement = efactory.createEReference();
- proxyElement.setName("proxyElement");
- proxyElement.setEType(epackage.getEObject());
- proxyElement.setResolveProxies(true);
- proxyElement.setContainment(true);
- schoolBookEClass.getEStructuralFeatures().add(proxyElement);
-
- EReference element = efactory.createEReference();
- element.setName("element");
- element.setEType(epackage.getEObject());
- element.setContainment(true);
- element.setResolveProxies(false);
- schoolBookEClass.getEStructuralFeatures().add(element);
-
- // Create a new EPackage and add the new EClasses
- EPackage schoolPackage = efactory.createEPackage();
- schoolPackage.setName("elv");
- schoolPackage.setNsPrefix("elv");
- schoolPackage.setNsURI("http:///www.elver.org/School");
- schoolPackage.getEClassifiers().add(schoolBookEClass);
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(schoolPackage);
- }
-
- return schoolPackage;
- }
-
- public void testRemovedContainment() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("res1"));
-
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
-
- Category category = getModel1Factory().createCategory();
- company.getCategories().add(category);
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("supplier" + System.currentTimeMillis());
- resource.getContents().add(supplier);
- company.getSuppliers().add(supplier);
-
- // transaction.commit();
-
- resource.getContents().addAll(resource.getContents().get(0).eContents());
- resource.getContents().remove(0);
-
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Address;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.tests.model2.PersistentContainment;
+import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
+import org.eclipse.emf.cdo.tests.model2.Task;
+import org.eclipse.emf.cdo.tests.model2.TaskContainer;
+import org.eclipse.emf.cdo.tests.model2.TransientContainer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+/**
+ * @author Eike Stepper
+ */
+public class ContainmentTest extends AbstractCDOTest
+{
+ public void testTransientContainment() throws Exception
+ {
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Creating company");
+ Company company = getModel1Factory().createCompany();
+
+ msg("Adding supplier");
+ company.getSuppliers().add(supplier);
+
+ assertTransient(company);
+ assertTransient(supplier);
+ assertContent(company, supplier);
+ }
+
+ public void testBasicContainment() throws Exception
+ {
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Creating company");
+ Company company = getModel1Factory().createCompany();
+
+ msg("Adding supplier");
+ company.getSuppliers().add(supplier);
+
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resource.getContents().add(company);
+
+ msg("Committing");
+ transaction.commit();
+
+ assertClean(resource, transaction);
+ assertClean(company, transaction);
+ assertClean(supplier, transaction);
+ assertContent(resource, company);
+ assertContent(company, supplier);
+ }
+
+ public void test3Levels() throws Exception
+ {
+ msg("Creating category1");
+ Category category1 = getModel1Factory().createCategory();
+ category1.setName("category1");
+
+ msg("Creating category2");
+ Category category2 = getModel1Factory().createCategory();
+ category2.setName("category2");
+
+ msg("Creating category3");
+ Category category3 = getModel1Factory().createCategory();
+ category3.setName("category3");
+
+ msg("Creating company");
+ Company company = getModel1Factory().createCompany();
+
+ msg("Adding categories");
+ company.getCategories().add(category1);
+ category1.getCategories().add(category2);
+ category2.getCategories().add(category3);
+
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resource.getContents().add(company);
+
+ msg("Committing");
+ transaction.commit();
+
+ assertClean(resource, transaction);
+ assertClean(company, transaction);
+ assertClean(category1, transaction);
+ assertClean(category2, transaction);
+ assertClean(category3, transaction);
+ assertContent(resource, company);
+ assertContent(company, category1);
+ assertContent(category1, category2);
+ assertContent(category2, category3);
+ }
+
+ public void testSeparateView() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ {
+ msg("Creating category1");
+ Category category1 = getModel1Factory().createCategory();
+ category1.setName("category1");
+
+ msg("Creating category2");
+ Category category2 = getModel1Factory().createCategory();
+ category2.setName("category2");
+
+ msg("Creating category3");
+ Category category3 = getModel1Factory().createCategory();
+ category3.setName("category3");
+
+ msg("Creating company");
+ Company company = getModel1Factory().createCompany();
+
+ msg("Adding categories");
+ company.getCategories().add(category1);
+ category1.getCategories().add(category2);
+ category2.getCategories().add(category3);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resource.getContents().add(company);
+
+ msg("Committing");
+ transaction.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Loading resource");
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+ assertProxy(resource);
+
+ EList<EObject> contents = resource.getContents();
+ Company company = (Company)contents.get(0);
+ assertClean(company, transaction);
+ assertClean(resource, transaction);
+ assertContent(resource, company);
+
+ Category category1 = company.getCategories().get(0);
+ assertClean(category1, transaction);
+ assertClean(company, transaction);
+ assertContent(company, category1);
+
+ Category category2 = category1.getCategories().get(0);
+ assertClean(category2, transaction);
+ assertClean(category1, transaction);
+ assertContent(category1, category2);
+
+ Category category3 = category2.getCategories().get(0);
+ assertClean(category3, transaction);
+ assertClean(category2, transaction);
+ assertContent(category2, category3);
+ assertClean(category3, transaction);
+ }
+
+ public void testSeparateSession() throws Exception
+ {
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Creating category1");
+ Category category1 = getModel1Factory().createCategory();
+ category1.setName("category1");
+
+ msg("Creating category2");
+ Category category2 = getModel1Factory().createCategory();
+ category2.setName("category2");
+
+ msg("Creating category3");
+ Category category3 = getModel1Factory().createCategory();
+ category3.setName("category3");
+
+ msg("Creating company");
+ Company company = getModel1Factory().createCompany();
+
+ msg("Adding categories");
+ company.getCategories().add(category1);
+ category1.getCategories().add(category2);
+ category2.getCategories().add(category3);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resource.getContents().add(company);
+
+ msg("Committing");
+ transaction.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Loading resource");
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+ assertProxy(resource);
+
+ EList<EObject> contents = resource.getContents();
+ Company company = (Company)contents.get(0);
+ assertClean(company, transaction);
+ assertClean(resource, transaction);
+ assertContent(resource, company);
+
+ Category category1 = company.getCategories().get(0);
+ assertClean(category1, transaction);
+ assertClean(company, transaction);
+ assertContent(company, category1);
+
+ Category category2 = category1.getCategories().get(0);
+ assertClean(category2, transaction);
+ assertClean(category1, transaction);
+ assertContent(category1, category2);
+
+ Category category3 = category2.getCategories().get(0);
+ assertClean(category3, transaction);
+ assertClean(category2, transaction);
+ assertContent(category2, category3);
+ assertClean(category3, transaction);
+ }
+
+ public void testSetSingleContainment() throws Exception
+ {
+ Address address = getModel1Factory().createAddress();
+ address.setName("Stepper");
+ address.setStreet("Home Ave. 007");
+ address.setCity("Berlin");
+
+ SpecialPurchaseOrder order = getModel2Factory().createSpecialPurchaseOrder();
+ order.setShippingAddress(address);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ resource.getContents().add(order);
+ transaction.commit();
+
+ assertClean(resource, transaction);
+ assertClean(order, transaction);
+ assertClean(address, transaction);
+ assertContent(resource, order);
+ assertContent(order, address);
+ }
+
+ public void testUnsetSingleContainment() throws Exception
+ {
+ Address address = getModel1Factory().createAddress();
+ address.setName("Stepper");
+ address.setStreet("Home Ave. 007");
+ address.setCity("Berlin");
+
+ SpecialPurchaseOrder order = getModel2Factory().createSpecialPurchaseOrder();
+ order.setShippingAddress(address);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ resource.getContents().add(order);
+ transaction.commit();
+
+ order.setShippingAddress(null);
+ transaction.commit();
+
+ assertClean(resource, transaction);
+ assertClean(order, transaction);
+ assertTransient(address);
+ assertContent(resource, order);
+ assertNull(order.getShippingAddress());
+ }
+
+ public void testObjectNotSameResourceThanItsContainerCDO() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+ Resource resource1 = transaction.createResource(getResourcePath("testA"));
+ Resource resource2 = transaction.createResource(getResourcePath("testB"));
+
+ EPackage packageObject = createDynamicEPackage();
+ session.getPackageRegistry().putEPackage(packageObject);
+ EClass eClass = (EClass)packageObject.getEClassifier("SchoolBook");
+
+ EObject container = packageObject.getEFactoryInstance().create(eClass);
+ Order contained = getModel1Factory().createPurchaseOrder();
+
+ resource1.getContents().add(container);
+ resource2.getContents().add(contained);
+
+ container.eSet(container.eClass().getEStructuralFeature("proxyElement"), contained);
+
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, contained.eResource());
+
+ // If the relationship is define has resolveProxy this is true if not.. this is false.
+ assertEquals(container, contained.eContainer());
+ transaction.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+ Resource resource1 = transaction.getResource(getResourcePath("testA"));
+ Resource resource2 = transaction.getResource(getResourcePath("testB"));
+
+ EObject container = resource1.getContents().get(0);
+ Order order = (Order)resource2.getContents().get(0);
+
+ assertEquals(resource1.getContents().get(0), order.eContainer());
+ resource2.getContents().remove(order);
+
+ Order order2 = (Order)CDOUtil.getEObject((EObject)container.eGet(container.eClass().getEStructuralFeature(
+ "proxyElement")));
+ assertSame(order, order2);
+ }
+
+ public void testObjectNotSameResourceThanItsContainer_WithoutCDO() throws Exception
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
+
+ Resource resource1 = resourceSet.createResource(URI.createURI("test://1"));
+ Resource resource2 = resourceSet.createResource(URI.createURI("test://2"));
+ EPackage packageObject = createDynamicEPackage();
+ EClass eClass = (EClass)packageObject.getEClassifier("SchoolBook");
+
+ EObject container = packageObject.getEFactoryInstance().create(eClass);
+ EObject contained = packageObject.getEFactoryInstance().create(eClass);
+
+ resource1.getContents().add(container);
+ resource2.getContents().add(contained);
+
+ container.eSet(container.eClass().getEStructuralFeature("proxyElement"), contained);
+ // resource1.getContents().add(container);
+
+ assertEquals(resource1, container.eResource());
+ assertEquals(resource2, contained.eResource());
+
+ // If the relationship is define has resolveProxy this is true if not.. this is false.
+ assertEquals(container, contained.eContainer());
+ }
+
+ public void testModeledBackPointer() throws Exception
+ {
+ Task task = getModel2Factory().createTask();
+ task.setDescription("Task 1");
+
+ TaskContainer taskContainer = getModel2Factory().createTaskContainer();
+ taskContainer.getTasks().add(task);
+ assertEquals(taskContainer, task.eContainer());
+ assertEquals(taskContainer, task.getTaskContainer());
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/resource1"));
+ resource.getContents().add(taskContainer);
+
+ transaction.commit();
+ assertEquals(taskContainer, task.eContainer());
+ assertEquals(taskContainer, task.getTaskContainer());
+ session.close();
+ }
+
+ public void testModeledBackPointer_Transient() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/resource1"));
+
+ PersistentContainment parent1 = createPersistentContainment();
+ parent1.getChildren().add(createTransientContainer());
+ parent1.getChildren().add(createTransientContainer());
+ parent1.getChildren().add(createTransientContainer());
+ resource.getContents().add(parent1);
+ transaction.commit();
+
+ // Move child
+ PersistentContainment parent2 = createPersistentContainment();
+ parent2.getChildren().add(parent1.getChildren().get(0));
+ transaction.commit();
+
+ // Remove child
+ parent1.getChildren().remove(0);
+ transaction.commit();
+
+ // Remove child
+ parent1.getChildren().remove(0);
+ transaction.commit();
+ }
+
+ public void testModeledBackPointer_Transient_Load() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/resource1"));
+
+ PersistentContainment parent1 = createPersistentContainment();
+ parent1.getChildren().add(createTransientContainer());
+ parent1.getChildren().add(createTransientContainer());
+ parent1.getChildren().add(createTransientContainer());
+ resource.getContents().add(parent1);
+ transaction.commit();
+
+ session.close();
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/resource1"));
+ parent1 = (PersistentContainment)resource.getContents().get(0);
+
+ // Move child
+ PersistentContainment parent2 = createPersistentContainment();
+ parent2.getChildren().add(parent1.getChildren().get(0));
+ transaction.commit();
+
+ // Remove child
+ parent1.getChildren().remove(0);
+ transaction.commit();
+
+ // Remove child
+ parent1.getChildren().remove(0);
+ transaction.commit();
+ }
+
+ private PersistentContainment createPersistentContainment()
+ {
+ PersistentContainment result = getModel2Factory().createPersistentContainment();
+ result.setAttrBefore("BEFORE");
+ result.setAttrAfter("AFTER");
+ return result;
+ }
+
+ private TransientContainer createTransientContainer()
+ {
+ TransientContainer result = getModel2Factory().createTransientContainer();
+ result.setAttrBefore("BEFORE");
+ result.setAttrAfter("AFTER");
+ return result;
+ }
+
+ private EPackage createDynamicEPackage()
+ {
+ final EcoreFactory efactory = EcoreFactory.eINSTANCE;
+ final EcorePackage epackage = EcorePackage.eINSTANCE;
+
+ EClass schoolBookEClass = efactory.createEClass();
+ schoolBookEClass.setName("SchoolBook");
+
+ // create a new attribute for this EClass
+ EAttribute level = efactory.createEAttribute();
+ level.setName("level");
+ level.setEType(epackage.getEInt());
+ schoolBookEClass.getEStructuralFeatures().add(level);
+
+ EReference proxyElement = efactory.createEReference();
+ proxyElement.setName("proxyElement");
+ proxyElement.setEType(epackage.getEObject());
+ proxyElement.setResolveProxies(true);
+ proxyElement.setContainment(true);
+ schoolBookEClass.getEStructuralFeatures().add(proxyElement);
+
+ EReference element = efactory.createEReference();
+ element.setName("element");
+ element.setEType(epackage.getEObject());
+ element.setContainment(true);
+ element.setResolveProxies(false);
+ schoolBookEClass.getEStructuralFeatures().add(element);
+
+ // Create a new EPackage and add the new EClasses
+ EPackage schoolPackage = efactory.createEPackage();
+ schoolPackage.setName("elv");
+ schoolPackage.setNsPrefix("elv");
+ schoolPackage.setNsURI("http:///www.elver.org/School");
+ schoolPackage.getEClassifiers().add(schoolBookEClass);
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(schoolPackage);
+ }
+
+ return schoolPackage;
+ }
+
+ public void testRemovedContainment() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("res1"));
+
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+
+ Category category = getModel1Factory().createCategory();
+ company.getCategories().add(category);
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("supplier" + System.currentTimeMillis());
+ resource.getContents().add(supplier);
+ company.getSuppliers().add(supplier);
+
+ // transaction.commit();
+
+ resource.getContents().addAll(resource.getContents().get(0).eContents());
+ resource.getContents().remove(0);
+
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java
index 401d2d5b9a..686a50ac8b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java
@@ -1,488 +1,488 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
-
-/**
- * @author Eike Stepper
- */
-public class CrossReferenceTest extends AbstractCDOTest
-{
- public void testLoadViaContainment() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- // ************************************************************* //
-
- msg("Creating customer");
- Customer customerA = getModel1Factory().createCustomer();
- customerA.setName("customer");
-
- msg("Creating salesOrder1");
- SalesOrder salesOrder1A = getModel1Factory().createSalesOrder();
- salesOrder1A.setId(1);
- salesOrder1A.setCustomer(customerA);
-
- msg("Creating salesOrder2");
- SalesOrder salesOrder2A = getModel1Factory().createSalesOrder();
- salesOrder2A.setId(2);
- salesOrder2A.setCustomer(customerA);
-
- msg("Creating company");
- Company companyA = getModel1Factory().createCompany();
- companyA.getCustomers().add(customerA);
- companyA.getSalesOrders().add(salesOrder1A);
- companyA.getSalesOrders().add(salesOrder2A);
-
- msg("Attaching transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resourceA.getContents().add(companyA);
-
- msg("Committing");
- transaction.commit();
-
- assertEquals(2, customerA.getSalesOrders().size());
-
- // ************************************************************* //
-
- msg("Attaching viewB");
- CDOView viewB = session.openTransaction();
-
- msg("Loading resource");
- CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
- assertProxy(resourceB);
-
- EList<EObject> contents = resourceB.getContents();
- Company companyB = (Company)contents.get(0);
- assertClean(companyB, viewB);
- assertClean(resourceB, viewB);
- assertContent(resourceB, companyB);
-
- Customer customerB = companyB.getCustomers().get(0);
- assertClean(customerB, viewB);
- assertClean(companyB, viewB);
- assertContent(companyB, customerB);
-
- SalesOrder salesOrder1B = companyB.getSalesOrders().get(0);
- assertClean(salesOrder1B, viewB);
- assertClean(companyB, viewB);
- assertContent(companyB, salesOrder1B);
-
- SalesOrder salesOrder2B = companyB.getSalesOrders().get(1);
- assertClean(salesOrder2B, viewB);
- assertClean(companyB, viewB);
- assertContent(companyB, salesOrder2B);
- assertClean(salesOrder2B, viewB);
-
- assertEquals(2, customerB.getSalesOrders().size());
- }
-
- public void testLoadViaXRef() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- // ************************************************************* //
-
- msg("Creating customer");
- Customer customerA = getModel1Factory().createCustomer();
- customerA.setName("customer");
-
- msg("Creating salesOrder1");
- SalesOrder salesOrder1A = getModel1Factory().createSalesOrder();
- salesOrder1A.setId(1);
- salesOrder1A.setCustomer(customerA);
-
- msg("Creating salesOrder2");
- SalesOrder salesOrder2A = getModel1Factory().createSalesOrder();
- salesOrder2A.setId(2);
- salesOrder2A.setCustomer(customerA);
-
- msg("Creating company");
- Company companyA = getModel1Factory().createCompany();
- companyA.getCustomers().add(customerA);
- companyA.getSalesOrders().add(salesOrder1A);
- companyA.getSalesOrders().add(salesOrder2A);
-
- msg("Attaching transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resourceA.getContents().add(companyA);
-
- msg("Committing");
- transaction.commit();
-
- assertEquals(2, customerA.getSalesOrders().size());
-
- // ************************************************************* //
-
- msg("Attaching viewB");
- CDOView viewB = session.openTransaction();
-
- msg("Loading resource");
- CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
- assertProxy(resourceB);
-
- EList<EObject> contents = resourceB.getContents();
- Company companyB = (Company)contents.get(0);
- assertClean(companyB, viewB);
- assertClean(resourceB, viewB);
- assertContent(resourceB, companyB);
-
- Customer customerB = companyB.getCustomers().get(0);
- assertClean(customerB, viewB);
- assertClean(companyB, viewB);
- assertContent(companyB, customerB);
-
- SalesOrder salesOrder1B = customerB.getSalesOrders().get(0);
- assertClean(salesOrder1B, viewB);
- assertClean(companyB, viewB);
- assertContent(companyB, salesOrder1B);
-
- SalesOrder salesOrder2B = customerB.getSalesOrders().get(1);
- assertClean(salesOrder2B, viewB);
- assertClean(companyB, viewB);
- assertContent(companyB, salesOrder2B);
- assertClean(salesOrder2B, viewB);
- }
-
- public void testTwoResources() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Attaching transaction");
- CDOTransaction transaction = session.openTransaction();
-
- // ************************************************************* //
-
- msg("Creating customer");
- Customer customerA = getModel1Factory().createCustomer();
- customerA.setName("customer");
-
- msg("Creating company1");
- Company company1A = getModel1Factory().createCompany();
- company1A.getCustomers().add(customerA);
-
- msg("Creating resource1");
- CDOResource resource1A = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company1");
- resource1A.getContents().add(company1A);
-
- // ************************************************************* //
-
- msg("Creating salesOrder1");
- SalesOrder salesOrder1A = getModel1Factory().createSalesOrder();
- assertTransient(salesOrder1A);
- salesOrder1A.setId(1);
- salesOrder1A.setCustomer(customerA);
- assertTransient(salesOrder1A);
-
- msg("Creating salesOrder2");
- SalesOrder salesOrder2A = getModel1Factory().createSalesOrder();
- assertTransient(salesOrder2A);
- salesOrder2A.setId(2);
- salesOrder2A.setCustomer(customerA);
- assertTransient(salesOrder2A);
-
- msg("Creating company2");
- Company company2A = getModel1Factory().createCompany();
- company2A.getSalesOrders().add(salesOrder1A);
- company2A.getSalesOrders().add(salesOrder2A);
-
- msg("Creating resource2");
- CDOResource resource2A = transaction.createResource(getResourcePath("/test2"));
-
- msg("Adding company");
- resource2A.getContents().add(company2A);
-
- // ************************************************************* //
-
- msg("Committing");
- transaction.commit();
-
- assertEquals(2, customerA.getSalesOrders().size());
-
- // ************************************************************* //
-
- msg("Attaching viewB");
- CDOView viewB = session.openTransaction();
-
- msg("Loading resource1");
- CDOResource resource1B = viewB.getResource(getResourcePath("/test1"));
- assertProxy(resource1B);
-
- EList<EObject> contents = resource1B.getContents();
- Company company1B = (Company)contents.get(0);
- assertClean(company1B, viewB);
- assertClean(resource1B, viewB);
- assertContent(resource1B, company1B);
-
- Customer customerB = company1B.getCustomers().get(0);
- assertClean(customerB, viewB);
- assertClean(company1B, viewB);
- assertContent(company1B, customerB);
-
- SalesOrder salesOrder1B = customerB.getSalesOrders().get(0);
- assertClean(salesOrder1B, viewB);
-
- SalesOrder salesOrder2B = customerB.getSalesOrders().get(1);
- assertClean(salesOrder2B, viewB);
- }
-
- public void testDetachXRef() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(4711);
- salesOrder.setCustomer(customer);
-
- Company company = getModel1Factory().createCompany();
- company.getCustomers().add(customer);
- company.getSalesOrders().add(salesOrder);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
- resource.getContents().add(company);
- transaction.commit();
-
- company.getCustomers().remove(customer);
-
- try
- {
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- }
- }
-
- public void testDetachXRefReattach() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(4711);
- salesOrder.setCustomer(customer);
-
- Company company = getModel1Factory().createCompany();
- company.getCustomers().add(customer);
- company.getSalesOrders().add(salesOrder);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
- resource.getContents().add(company);
- transaction.commit();
-
- company.getCustomers().remove(customer);
- company.getCustomers().add(customer);
- assertEquals(1, company.getCustomers().size());
- transaction.commit();
- }
-
- @Skips("Hibernate")
- public void testDetachXRefExternal() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(4711);
- salesOrder.setCustomer(customer);
-
- Company company = getModel1Factory().createCompany();
- company.getCustomers().add(customer);
- company.getSalesOrders().add(salesOrder);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
- resource.getContents().add(company);
- transaction.commit();
-
- Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
- transaction.getResourceSet().getResources().add(externalResource);
- externalResource.getContents().add(customer);
-
- transaction.commit();
- CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
- CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
- assertEquals(true, id.isExternal());
- }
-
- public void _testDetachXRefExternalReattach() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(4711);
- salesOrder.setCustomer(customer);
-
- Company company = getModel1Factory().createCompany();
- company.getCustomers().add(customer);
- company.getSalesOrders().add(salesOrder);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
- resource.getContents().add(company);
- transaction.commit();
-
- Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
- transaction.getResourceSet().getResources().add(externalResource);
- externalResource.getContents().add(customer);
-
- transaction.commit();
- CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
- CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
- assertEquals(true, id.isExternal());
-
- company.getCustomers().add(customer);
- transaction.commit();
- data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
- id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
- assertEquals(false, id.isExternal());
- }
-
- @Skips("Hibernate")
- public void testNewMakeExternal() throws Exception
- {
- skipStoreWithoutExternalReferences();
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(4711);
- salesOrder.setCustomer(customer);
-
- Company company = getModel1Factory().createCompany();
- company.getCustomers().add(customer);
- company.getSalesOrders().add(salesOrder);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
- resource.getContents().add(company);
- // DO NOT: transaction.commit();
-
- Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
- transaction.getResourceSet().getResources().add(externalResource);
- externalResource.getContents().add(customer);
-
- transaction.commit();
- CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
- CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
- assertEquals(true, id.isExternal());
- }
-
- public void testExternalMakeNew() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(4711);
- salesOrder.setCustomer(customer);
-
- Company company = getModel1Factory().createCompany();
- // DO NOT: company.getCustomers().add(customer);
- company.getSalesOrders().add(salesOrder);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
- resource.getContents().add(company);
- // DO NOT: transaction.commit();
-
- Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
- transaction.getResourceSet().getResources().add(externalResource);
- externalResource.getContents().add(customer);
-
- company.getCustomers().add(customer);
-
- transaction.commit();
- CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
- CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
- assertEquals(false, id.isExternal());
- }
-
- @Skips("Hibernate")
- public void testExternalMakeDangling() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(4711);
- salesOrder.setCustomer(customer);
-
- Company company = getModel1Factory().createCompany();
- // DO NOT: company.getCustomers().add(customer);
- company.getSalesOrders().add(salesOrder);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
- resource.getContents().add(company);
- // DO NOT: transaction.commit();
-
- Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
- transaction.getResourceSet().getResources().add(externalResource);
- externalResource.getContents().add(customer);
-
- transaction.commit();
- CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
- CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
- assertEquals(true, id.isExternal());
-
- externalResource.getContents().remove(customer);
- transaction.commit(); // Should be dangling reference now, but we can not detect ;-(
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
+
+/**
+ * @author Eike Stepper
+ */
+public class CrossReferenceTest extends AbstractCDOTest
+{
+ public void testLoadViaContainment() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ // ************************************************************* //
+
+ msg("Creating customer");
+ Customer customerA = getModel1Factory().createCustomer();
+ customerA.setName("customer");
+
+ msg("Creating salesOrder1");
+ SalesOrder salesOrder1A = getModel1Factory().createSalesOrder();
+ salesOrder1A.setId(1);
+ salesOrder1A.setCustomer(customerA);
+
+ msg("Creating salesOrder2");
+ SalesOrder salesOrder2A = getModel1Factory().createSalesOrder();
+ salesOrder2A.setId(2);
+ salesOrder2A.setCustomer(customerA);
+
+ msg("Creating company");
+ Company companyA = getModel1Factory().createCompany();
+ companyA.getCustomers().add(customerA);
+ companyA.getSalesOrders().add(salesOrder1A);
+ companyA.getSalesOrders().add(salesOrder2A);
+
+ msg("Attaching transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resourceA.getContents().add(companyA);
+
+ msg("Committing");
+ transaction.commit();
+
+ assertEquals(2, customerA.getSalesOrders().size());
+
+ // ************************************************************* //
+
+ msg("Attaching viewB");
+ CDOView viewB = session.openTransaction();
+
+ msg("Loading resource");
+ CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
+ assertProxy(resourceB);
+
+ EList<EObject> contents = resourceB.getContents();
+ Company companyB = (Company)contents.get(0);
+ assertClean(companyB, viewB);
+ assertClean(resourceB, viewB);
+ assertContent(resourceB, companyB);
+
+ Customer customerB = companyB.getCustomers().get(0);
+ assertClean(customerB, viewB);
+ assertClean(companyB, viewB);
+ assertContent(companyB, customerB);
+
+ SalesOrder salesOrder1B = companyB.getSalesOrders().get(0);
+ assertClean(salesOrder1B, viewB);
+ assertClean(companyB, viewB);
+ assertContent(companyB, salesOrder1B);
+
+ SalesOrder salesOrder2B = companyB.getSalesOrders().get(1);
+ assertClean(salesOrder2B, viewB);
+ assertClean(companyB, viewB);
+ assertContent(companyB, salesOrder2B);
+ assertClean(salesOrder2B, viewB);
+
+ assertEquals(2, customerB.getSalesOrders().size());
+ }
+
+ public void testLoadViaXRef() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ // ************************************************************* //
+
+ msg("Creating customer");
+ Customer customerA = getModel1Factory().createCustomer();
+ customerA.setName("customer");
+
+ msg("Creating salesOrder1");
+ SalesOrder salesOrder1A = getModel1Factory().createSalesOrder();
+ salesOrder1A.setId(1);
+ salesOrder1A.setCustomer(customerA);
+
+ msg("Creating salesOrder2");
+ SalesOrder salesOrder2A = getModel1Factory().createSalesOrder();
+ salesOrder2A.setId(2);
+ salesOrder2A.setCustomer(customerA);
+
+ msg("Creating company");
+ Company companyA = getModel1Factory().createCompany();
+ companyA.getCustomers().add(customerA);
+ companyA.getSalesOrders().add(salesOrder1A);
+ companyA.getSalesOrders().add(salesOrder2A);
+
+ msg("Attaching transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resourceA.getContents().add(companyA);
+
+ msg("Committing");
+ transaction.commit();
+
+ assertEquals(2, customerA.getSalesOrders().size());
+
+ // ************************************************************* //
+
+ msg("Attaching viewB");
+ CDOView viewB = session.openTransaction();
+
+ msg("Loading resource");
+ CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
+ assertProxy(resourceB);
+
+ EList<EObject> contents = resourceB.getContents();
+ Company companyB = (Company)contents.get(0);
+ assertClean(companyB, viewB);
+ assertClean(resourceB, viewB);
+ assertContent(resourceB, companyB);
+
+ Customer customerB = companyB.getCustomers().get(0);
+ assertClean(customerB, viewB);
+ assertClean(companyB, viewB);
+ assertContent(companyB, customerB);
+
+ SalesOrder salesOrder1B = customerB.getSalesOrders().get(0);
+ assertClean(salesOrder1B, viewB);
+ assertClean(companyB, viewB);
+ assertContent(companyB, salesOrder1B);
+
+ SalesOrder salesOrder2B = customerB.getSalesOrders().get(1);
+ assertClean(salesOrder2B, viewB);
+ assertClean(companyB, viewB);
+ assertContent(companyB, salesOrder2B);
+ assertClean(salesOrder2B, viewB);
+ }
+
+ public void testTwoResources() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Attaching transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ // ************************************************************* //
+
+ msg("Creating customer");
+ Customer customerA = getModel1Factory().createCustomer();
+ customerA.setName("customer");
+
+ msg("Creating company1");
+ Company company1A = getModel1Factory().createCompany();
+ company1A.getCustomers().add(customerA);
+
+ msg("Creating resource1");
+ CDOResource resource1A = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company1");
+ resource1A.getContents().add(company1A);
+
+ // ************************************************************* //
+
+ msg("Creating salesOrder1");
+ SalesOrder salesOrder1A = getModel1Factory().createSalesOrder();
+ assertTransient(salesOrder1A);
+ salesOrder1A.setId(1);
+ salesOrder1A.setCustomer(customerA);
+ assertTransient(salesOrder1A);
+
+ msg("Creating salesOrder2");
+ SalesOrder salesOrder2A = getModel1Factory().createSalesOrder();
+ assertTransient(salesOrder2A);
+ salesOrder2A.setId(2);
+ salesOrder2A.setCustomer(customerA);
+ assertTransient(salesOrder2A);
+
+ msg("Creating company2");
+ Company company2A = getModel1Factory().createCompany();
+ company2A.getSalesOrders().add(salesOrder1A);
+ company2A.getSalesOrders().add(salesOrder2A);
+
+ msg("Creating resource2");
+ CDOResource resource2A = transaction.createResource(getResourcePath("/test2"));
+
+ msg("Adding company");
+ resource2A.getContents().add(company2A);
+
+ // ************************************************************* //
+
+ msg("Committing");
+ transaction.commit();
+
+ assertEquals(2, customerA.getSalesOrders().size());
+
+ // ************************************************************* //
+
+ msg("Attaching viewB");
+ CDOView viewB = session.openTransaction();
+
+ msg("Loading resource1");
+ CDOResource resource1B = viewB.getResource(getResourcePath("/test1"));
+ assertProxy(resource1B);
+
+ EList<EObject> contents = resource1B.getContents();
+ Company company1B = (Company)contents.get(0);
+ assertClean(company1B, viewB);
+ assertClean(resource1B, viewB);
+ assertContent(resource1B, company1B);
+
+ Customer customerB = company1B.getCustomers().get(0);
+ assertClean(customerB, viewB);
+ assertClean(company1B, viewB);
+ assertContent(company1B, customerB);
+
+ SalesOrder salesOrder1B = customerB.getSalesOrders().get(0);
+ assertClean(salesOrder1B, viewB);
+
+ SalesOrder salesOrder2B = customerB.getSalesOrders().get(1);
+ assertClean(salesOrder2B, viewB);
+ }
+
+ public void testDetachXRef() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(4711);
+ salesOrder.setCustomer(customer);
+
+ Company company = getModel1Factory().createCompany();
+ company.getCustomers().add(customer);
+ company.getSalesOrders().add(salesOrder);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ company.getCustomers().remove(customer);
+
+ try
+ {
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+ }
+
+ public void testDetachXRefReattach() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(4711);
+ salesOrder.setCustomer(customer);
+
+ Company company = getModel1Factory().createCompany();
+ company.getCustomers().add(customer);
+ company.getSalesOrders().add(salesOrder);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ company.getCustomers().remove(customer);
+ company.getCustomers().add(customer);
+ assertEquals(1, company.getCustomers().size());
+ transaction.commit();
+ }
+
+ @Skips("Hibernate")
+ public void testDetachXRefExternal() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(4711);
+ salesOrder.setCustomer(customer);
+
+ Company company = getModel1Factory().createCompany();
+ company.getCustomers().add(customer);
+ company.getSalesOrders().add(salesOrder);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
+ transaction.getResourceSet().getResources().add(externalResource);
+ externalResource.getContents().add(customer);
+
+ transaction.commit();
+ CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
+ CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
+ assertEquals(true, id.isExternal());
+ }
+
+ public void _testDetachXRefExternalReattach() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(4711);
+ salesOrder.setCustomer(customer);
+
+ Company company = getModel1Factory().createCompany();
+ company.getCustomers().add(customer);
+ company.getSalesOrders().add(salesOrder);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
+ transaction.getResourceSet().getResources().add(externalResource);
+ externalResource.getContents().add(customer);
+
+ transaction.commit();
+ CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
+ CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
+ assertEquals(true, id.isExternal());
+
+ company.getCustomers().add(customer);
+ transaction.commit();
+ data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
+ id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
+ assertEquals(false, id.isExternal());
+ }
+
+ @Skips("Hibernate")
+ public void testNewMakeExternal() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(4711);
+ salesOrder.setCustomer(customer);
+
+ Company company = getModel1Factory().createCompany();
+ company.getCustomers().add(customer);
+ company.getSalesOrders().add(salesOrder);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
+ resource.getContents().add(company);
+ // DO NOT: transaction.commit();
+
+ Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
+ transaction.getResourceSet().getResources().add(externalResource);
+ externalResource.getContents().add(customer);
+
+ transaction.commit();
+ CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
+ CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
+ assertEquals(true, id.isExternal());
+ }
+
+ public void testExternalMakeNew() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(4711);
+ salesOrder.setCustomer(customer);
+
+ Company company = getModel1Factory().createCompany();
+ // DO NOT: company.getCustomers().add(customer);
+ company.getSalesOrders().add(salesOrder);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
+ resource.getContents().add(company);
+ // DO NOT: transaction.commit();
+
+ Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
+ transaction.getResourceSet().getResources().add(externalResource);
+ externalResource.getContents().add(customer);
+
+ company.getCustomers().add(customer);
+
+ transaction.commit();
+ CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
+ CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
+ assertEquals(false, id.isExternal());
+ }
+
+ @Skips("Hibernate")
+ public void testExternalMakeDangling() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(4711);
+ salesOrder.setCustomer(customer);
+
+ Company company = getModel1Factory().createCompany();
+ // DO NOT: company.getCustomers().add(customer);
+ company.getSalesOrders().add(salesOrder);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/company/resource"));
+ resource.getContents().add(company);
+ // DO NOT: transaction.commit();
+
+ Resource externalResource = new ResourceImpl(URI.createFileURI("/x/y/z"));
+ transaction.getResourceSet().getResources().add(externalResource);
+ externalResource.getContents().add(customer);
+
+ transaction.commit();
+ CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
+ CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
+ assertEquals(true, id.isExternal());
+
+ externalResource.getContents().remove(customer);
+ transaction.commit(); // Should be dangling reference now, but we can not detect ;-(
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java
index 17a4255832..5715d2a6fe 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java
@@ -1,403 +1,403 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.transaction.CDOUserSavepoint;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.ObjectNotFoundException;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.spi.cdo.FSMUtil;
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-/**
- * @author Simon McDuff
- */
-public class DetachTest extends AbstractCDOTest
-{
- public void testNewObjectDeletion() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company c1 = getModel1Factory().createCompany();
- c1.setName("Test");
- resource.getContents().add(c1);
-
- final URI uriC1 = EcoreUtil.getURI(c1);
- assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
-
- resource.getContents().remove(0); // remove object by index
- assertNull(transaction.getResourceSet().getEObject(uriC1, false));
-
- transaction.commit();
- assertNull(transaction.getResourceSet().getEObject(uriC1, false));
- session.close();
- }
-
- public void testCleanObjectDeletion() throws Exception
- {
- CDOSession session = openSession();
- // ((org.eclipse.emf.cdo.net4j.CDOSession)session).options().setCommitTimeout(1000);
- // ((org.eclipse.emf.cdo.net4j.CDOSession)session).options().setProgressInterval(100);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company c1 = getModel1Factory().createCompany();
- c1.setName("Test");
- resource.getContents().add(c1);
- transaction.commit(); // (1)
-
- final URI uriC1 = EcoreUtil.getURI(c1);
- final CDOID id = CDOUtil.getCDOObject(c1).cdoID();
- assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
-
- resource.getContents().remove(c1);
- assertTransient(c1);
- assertSame(c1, CDOUtil.getEObject(transaction.getObject(id)));
- assertSame(c1, transaction.getResourceSet().getEObject(uriC1, false));
-
- transaction.commit();
- assertTransient(c1);
-
- try
- {
- CDOObject object = transaction.getObject(id);
- System.out.println(object);
- fail("ObjectNotFoundException expected");
- }
- catch (ObjectNotFoundException expected)
- {
- // SUCCESS
- }
-
- assertNull(transaction.getResourceSet().getEObject(uriC1, false));
- session.close();
- }
-
- public void testSavePointNewObjectDeletion() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company c1 = getModel1Factory().createCompany();
- c1.setName("Test");
- resource.getContents().add(c1);
-
- savePointObjectDeletion(transaction, resource);
- }
-
- public void testSavePointCleanObjectDeletion() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company c1 = getModel1Factory().createCompany();
- c1.setName("Test");
- resource.getContents().add(c1);
-
- URI uriC1 = EcoreUtil.getURI(c1);
- assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
-
- transaction.commit();
- savePointObjectDeletion(transaction, resource);
- }
-
- private void savePointObjectDeletion(CDOTransaction transaction, CDOResource resource)
- {
- Company c1 = (Company)resource.getContents().get(0);
-
- URI uriC1 = EcoreUtil.getURI(c1);
- CDOObject companyCDOObject = CDOUtil.getCDOObject(c1);
- boolean isPersisted = !FSMUtil.isNew(companyCDOObject);
- c1.setName("SIMON");
-
- CDOUserSavepoint savepoint = transaction.setSavepoint();
- resource.getContents().remove(0); // remove object by index
- assertTransient(c1);
-
- CDOUserSavepoint savepoint2 = transaction.setSavepoint();
- c1.setName("SIMON2");
- if (isPersisted)
- {
- assertNotNull(transaction.getResourceSet().getEObject(uriC1, false));
- }
- else
- {
- assertNull(transaction.getResourceSet().getEObject(uriC1, false));
- }
-
- savepoint2.rollback();
- assertEquals("SIMON2", c1.getName());
- assertTransient(c1);
-
- if (isPersisted)
- {
- assertNotNull(transaction.getResourceSet().getEObject(uriC1, false));
- }
- else
- {
- assertNull(transaction.getResourceSet().getEObject(uriC1, false));
- }
-
- savepoint.rollback();
- assertEquals("SIMON", c1.getName());
- assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
-
- if (isPersisted)
- {
- assertDirty(c1, transaction);
- }
- else
- {
- assertNew(c1, transaction);
- }
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- public void testKeepValue() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company c1 = getModel1Factory().createCompany();
- c1.setName("Test");
- resource.getContents().add(c1);
-
- transaction.commit();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/my/resource"));
-
- Company c1 = (Company)resource.getContents().get(0); // remove object by index
- assertEquals("Test", c1.getName());
-
- resource.getContents().remove(0);
- assertEquals("Test", c1.getName());
-
- transaction.commit();
- assertEquals("Test", c1.getName());
- }
-
- private void detachResource(ResourceSet rset, CDOResource resource, boolean commitBeforeDelete) throws Exception
- {
- CDOTransaction transaction = (CDOTransaction)resource.cdoView();
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- Product1 product1 = getModel1Factory().createProduct1();
- product1.setName("product1");
-
- resource.getContents().add(product1);
- resource.getContents().add(order);
-
- order.getOrderDetails().add(orderDetail);
- orderDetail.setProduct(product1);
- assertActive(resource);
- assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
- assertEquals(1, rset.getResources().size());// Bug 346636
- if (commitBeforeDelete == true)
- {
- transaction.commit();
- }
-
- InternalCDOObject orderInternal = FSMUtil.adapt(order, resource.cdoView());
- CDOID orderID = orderInternal.cdoID();
-
- resource.delete(null);
- assertTransient(resource);
- assertTransient(order);
- assertTransient(orderDetail);
- assertTransient(product1);
-
- assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
- assertEquals(0, rset.getResources().size());// Bug 346636
- assertEquals(2, resource.getContents().size());
- assertEquals(true, resource.getContents().contains(order));
- assertEquals(true, resource.getContents().contains(product1));
- assertEquals(true, order.getOrderDetails().contains(orderDetail));
- assertEquals(order, orderDetail.eContainer());
- assertEquals(resource, ((InternalEObject)order).eDirectResource());
- assertEquals(resource, ((InternalEObject)product1).eDirectResource());
-
- assertEquals(true && commitBeforeDelete, transaction.getDetachedObjects().containsKey(orderID));
- assertEquals(false, transaction.getRevisionDeltas().containsKey(orderID));
- }
-
- public void testDetachNewResource() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
- ResourceSet rset = transaction.getResourceSet();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- detachResource(rset, resource, false);
-
- transaction.commit();
- }
-
- public void testDetachPersistedResource() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- ResourceSet rset = transaction.getResourceSet();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- transaction.commit();
- CDOID resourceID = resource.cdoID();
- detachResource(rset, resource, false);
- assertEquals(true, transaction.getDetachedObjects().containsKey(resourceID));
-
- transaction.commit();
- }
-
- public void testDetachPersistedResourceWithPersistedData() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- ResourceSet rset = transaction.getResourceSet();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- transaction.commit();
- CDOID resourceID = resource.cdoID();
- detachResource(rset, resource, true);
- assertEquals(true, transaction.getDetachedObjects().containsKey(resourceID));
-
- transaction.commit();
- }
-
- public void testDetachEmptyNewResource() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Deleting resource");
- resource.delete(null);
- assertTransient(resource);
- }
-
- public void testDetachEmptyPersistedResource() throws Exception
- {
- CDOSession session = openSession();
-
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = getResourcePath("/test1");
- CDOResource res = transaction1.createResource(resourcePath);
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- CDOResource res2 = transaction2.getResource(resourcePath);
-
- ResourceSet rSet1 = res.getResourceSet();
- final ResourceSet rSet2 = res2.getResourceSet();
-
- res.delete(null);
- assertEquals(true, transaction1.isDirty());
- transaction1.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return rSet2.getResources().isEmpty();
- }
- }.assertNoTimeOut();
-
- assertEquals(0, rSet1.getResources().size());// Bug 346636
- assertTransient(res);
- assertInvalid(res2);
- }
-
- public void testDetachProxyResource() throws Exception
- {
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- transaction.createResource(getResourcePath("/test1"));
- transaction.commit();
- }
-
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- msg("Deleting resource");
- resource.delete(null);
- assertEquals(true, resource.isExisting());
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOUserSavepoint;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.spi.cdo.FSMUtil;
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
+
+/**
+ * @author Simon McDuff
+ */
+public class DetachTest extends AbstractCDOTest
+{
+ public void testNewObjectDeletion() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company c1 = getModel1Factory().createCompany();
+ c1.setName("Test");
+ resource.getContents().add(c1);
+
+ final URI uriC1 = EcoreUtil.getURI(c1);
+ assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
+
+ resource.getContents().remove(0); // remove object by index
+ assertNull(transaction.getResourceSet().getEObject(uriC1, false));
+
+ transaction.commit();
+ assertNull(transaction.getResourceSet().getEObject(uriC1, false));
+ session.close();
+ }
+
+ public void testCleanObjectDeletion() throws Exception
+ {
+ CDOSession session = openSession();
+ // ((org.eclipse.emf.cdo.net4j.CDOSession)session).options().setCommitTimeout(1000);
+ // ((org.eclipse.emf.cdo.net4j.CDOSession)session).options().setProgressInterval(100);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company c1 = getModel1Factory().createCompany();
+ c1.setName("Test");
+ resource.getContents().add(c1);
+ transaction.commit(); // (1)
+
+ final URI uriC1 = EcoreUtil.getURI(c1);
+ final CDOID id = CDOUtil.getCDOObject(c1).cdoID();
+ assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
+
+ resource.getContents().remove(c1);
+ assertTransient(c1);
+ assertSame(c1, CDOUtil.getEObject(transaction.getObject(id)));
+ assertSame(c1, transaction.getResourceSet().getEObject(uriC1, false));
+
+ transaction.commit();
+ assertTransient(c1);
+
+ try
+ {
+ CDOObject object = transaction.getObject(id);
+ System.out.println(object);
+ fail("ObjectNotFoundException expected");
+ }
+ catch (ObjectNotFoundException expected)
+ {
+ // SUCCESS
+ }
+
+ assertNull(transaction.getResourceSet().getEObject(uriC1, false));
+ session.close();
+ }
+
+ public void testSavePointNewObjectDeletion() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company c1 = getModel1Factory().createCompany();
+ c1.setName("Test");
+ resource.getContents().add(c1);
+
+ savePointObjectDeletion(transaction, resource);
+ }
+
+ public void testSavePointCleanObjectDeletion() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company c1 = getModel1Factory().createCompany();
+ c1.setName("Test");
+ resource.getContents().add(c1);
+
+ URI uriC1 = EcoreUtil.getURI(c1);
+ assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
+
+ transaction.commit();
+ savePointObjectDeletion(transaction, resource);
+ }
+
+ private void savePointObjectDeletion(CDOTransaction transaction, CDOResource resource)
+ {
+ Company c1 = (Company)resource.getContents().get(0);
+
+ URI uriC1 = EcoreUtil.getURI(c1);
+ CDOObject companyCDOObject = CDOUtil.getCDOObject(c1);
+ boolean isPersisted = !FSMUtil.isNew(companyCDOObject);
+ c1.setName("SIMON");
+
+ CDOUserSavepoint savepoint = transaction.setSavepoint();
+ resource.getContents().remove(0); // remove object by index
+ assertTransient(c1);
+
+ CDOUserSavepoint savepoint2 = transaction.setSavepoint();
+ c1.setName("SIMON2");
+ if (isPersisted)
+ {
+ assertNotNull(transaction.getResourceSet().getEObject(uriC1, false));
+ }
+ else
+ {
+ assertNull(transaction.getResourceSet().getEObject(uriC1, false));
+ }
+
+ savepoint2.rollback();
+ assertEquals("SIMON2", c1.getName());
+ assertTransient(c1);
+
+ if (isPersisted)
+ {
+ assertNotNull(transaction.getResourceSet().getEObject(uriC1, false));
+ }
+ else
+ {
+ assertNull(transaction.getResourceSet().getEObject(uriC1, false));
+ }
+
+ savepoint.rollback();
+ assertEquals("SIMON", c1.getName());
+ assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
+
+ if (isPersisted)
+ {
+ assertDirty(c1, transaction);
+ }
+ else
+ {
+ assertNew(c1, transaction);
+ }
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ public void testKeepValue() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company c1 = getModel1Factory().createCompany();
+ c1.setName("Test");
+ resource.getContents().add(c1);
+
+ transaction.commit();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/my/resource"));
+
+ Company c1 = (Company)resource.getContents().get(0); // remove object by index
+ assertEquals("Test", c1.getName());
+
+ resource.getContents().remove(0);
+ assertEquals("Test", c1.getName());
+
+ transaction.commit();
+ assertEquals("Test", c1.getName());
+ }
+
+ private void detachResource(ResourceSet rset, CDOResource resource, boolean commitBeforeDelete) throws Exception
+ {
+ CDOTransaction transaction = (CDOTransaction)resource.cdoView();
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ Product1 product1 = getModel1Factory().createProduct1();
+ product1.setName("product1");
+
+ resource.getContents().add(product1);
+ resource.getContents().add(order);
+
+ order.getOrderDetails().add(orderDetail);
+ orderDetail.setProduct(product1);
+ assertActive(resource);
+ assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
+ assertEquals(1, rset.getResources().size());// Bug 346636
+ if (commitBeforeDelete == true)
+ {
+ transaction.commit();
+ }
+
+ InternalCDOObject orderInternal = FSMUtil.adapt(order, resource.cdoView());
+ CDOID orderID = orderInternal.cdoID();
+
+ resource.delete(null);
+ assertTransient(resource);
+ assertTransient(order);
+ assertTransient(orderDetail);
+ assertTransient(product1);
+
+ assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
+ assertEquals(0, rset.getResources().size());// Bug 346636
+ assertEquals(2, resource.getContents().size());
+ assertEquals(true, resource.getContents().contains(order));
+ assertEquals(true, resource.getContents().contains(product1));
+ assertEquals(true, order.getOrderDetails().contains(orderDetail));
+ assertEquals(order, orderDetail.eContainer());
+ assertEquals(resource, ((InternalEObject)order).eDirectResource());
+ assertEquals(resource, ((InternalEObject)product1).eDirectResource());
+
+ assertEquals(true && commitBeforeDelete, transaction.getDetachedObjects().containsKey(orderID));
+ assertEquals(false, transaction.getRevisionDeltas().containsKey(orderID));
+ }
+
+ public void testDetachNewResource() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+ ResourceSet rset = transaction.getResourceSet();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ detachResource(rset, resource, false);
+
+ transaction.commit();
+ }
+
+ public void testDetachPersistedResource() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ ResourceSet rset = transaction.getResourceSet();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ transaction.commit();
+ CDOID resourceID = resource.cdoID();
+ detachResource(rset, resource, false);
+ assertEquals(true, transaction.getDetachedObjects().containsKey(resourceID));
+
+ transaction.commit();
+ }
+
+ public void testDetachPersistedResourceWithPersistedData() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ ResourceSet rset = transaction.getResourceSet();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ transaction.commit();
+ CDOID resourceID = resource.cdoID();
+ detachResource(rset, resource, true);
+ assertEquals(true, transaction.getDetachedObjects().containsKey(resourceID));
+
+ transaction.commit();
+ }
+
+ public void testDetachEmptyNewResource() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Deleting resource");
+ resource.delete(null);
+ assertTransient(resource);
+ }
+
+ public void testDetachEmptyPersistedResource() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = getResourcePath("/test1");
+ CDOResource res = transaction1.createResource(resourcePath);
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ CDOResource res2 = transaction2.getResource(resourcePath);
+
+ ResourceSet rSet1 = res.getResourceSet();
+ final ResourceSet rSet2 = res2.getResourceSet();
+
+ res.delete(null);
+ assertEquals(true, transaction1.isDirty());
+ transaction1.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return rSet2.getResources().isEmpty();
+ }
+ }.assertNoTimeOut();
+
+ assertEquals(0, rSet1.getResources().size());// Bug 346636
+ assertTransient(res);
+ assertInvalid(res2);
+ }
+
+ public void testDetachProxyResource() throws Exception
+ {
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ transaction.createResource(getResourcePath("/test1"));
+ transaction.commit();
+ }
+
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ msg("Deleting resource");
+ resource.delete(null);
+ assertEquals(true, resource.isExisting());
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicEcoreTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicEcoreTest.java
index 3166fc2250..1608411eab 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicEcoreTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicEcoreTest.java
@@ -1,79 +1,79 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class DymamicEcoreTest extends AbstractCDOTest
-{
- public void testDynamicEcore() throws Exception
- {
- {
- // Obtain model
- EPackage ecore = (EPackage)loadModel("ecore/Ecore.ecore", EPackage.Registry.INSTANCE);
-
- // Create resource in session 1
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(ecore);
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- EObject root = loadModel("model1.ecore", session.getPackageRegistry());
- res.getContents().add(root);
- transaction.commit();
- session.close();
- }
-
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- EObject root = res.getContents().get(0);
- saveModel("model1X.ecore", root);
- session.close();
- }
-
- private static EObject loadModel(String fileName, EPackage.Registry packageRegistry) throws IOException
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
- resourceSet.setPackageRegistry(packageRegistry);
-
- Resource resource = resourceSet.getResource(URI.createFileURI(fileName), true);
- return resource.getContents().get(0);
- }
-
- private static void saveModel(String fileName, EObject root) throws IOException
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
- Resource resource = resourceSet.getResource(URI.createFileURI(fileName), true);
- resource.getContents().add(EcoreUtil.copy(root));
- resource.save(null);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class DymamicEcoreTest extends AbstractCDOTest
+{
+ public void testDynamicEcore() throws Exception
+ {
+ {
+ // Obtain model
+ EPackage ecore = (EPackage)loadModel("ecore/Ecore.ecore", EPackage.Registry.INSTANCE);
+
+ // Create resource in session 1
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(ecore);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ EObject root = loadModel("model1.ecore", session.getPackageRegistry());
+ res.getContents().add(root);
+ transaction.commit();
+ session.close();
+ }
+
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ EObject root = res.getContents().get(0);
+ saveModel("model1X.ecore", root);
+ session.close();
+ }
+
+ private static EObject loadModel(String fileName, EPackage.Registry packageRegistry) throws IOException
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
+ resourceSet.setPackageRegistry(packageRegistry);
+
+ Resource resource = resourceSet.getResource(URI.createFileURI(fileName), true);
+ return resource.getContents().get(0);
+ }
+
+ private static void saveModel(String fileName, EObject root) throws IOException
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
+ Resource resource = resourceSet.getResource(URI.createFileURI(fileName), true);
+ resource.getContents().add(EcoreUtil.copy(root));
+ resource.save(null);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicUmlTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicUmlTest.java
index b0504cdd1d..8854b07280 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicUmlTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DymamicUmlTest.java
@@ -1,103 +1,103 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class DymamicUmlTest extends AbstractCDOTest
-{
- public void testGeneratedPackage() throws Exception
- {
- {
- // Create resource in session 1
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Eike");
- res.getContents().add(company);
- transaction.commit();
- }
-
- {
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- Company company = (Company)res.getContents().get(0);
- assertEquals("Eike", company.getName());
- }
- }
-
- public void testDynamicPackage() throws Exception
- {
- {
- // Obtain model
- EPackage model1 = loadModel("model1.ecore");
- EClass companyClass = (EClass)model1.getEClassifier("Company");
- EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
-
- // Create resource in session 1
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- EObject company = EcoreUtil.create(companyClass);
- company.eSet(nameAttribute, "Eike");
- res.getContents().add(company);
- transaction.commit();
- }
-
- {
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- CDOObject company = CDOUtil.getCDOObject(res.getContents().get(0));
- EClass companyClass = company.eClass();
- EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
- String name = (String)company.eGet(nameAttribute);
- assertEquals("Eike", name);
- }
- }
-
- private static EPackage loadModel(String fileName) throws IOException
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
- Resource resource = resourceSet.getResource(URI.createFileURI(fileName), true);
- return (EPackage)resource.getContents().get(0);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class DymamicUmlTest extends AbstractCDOTest
+{
+ public void testGeneratedPackage() throws Exception
+ {
+ {
+ // Create resource in session 1
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+
+ {
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ Company company = (Company)res.getContents().get(0);
+ assertEquals("Eike", company.getName());
+ }
+ }
+
+ public void testDynamicPackage() throws Exception
+ {
+ {
+ // Obtain model
+ EPackage model1 = loadModel("model1.ecore");
+ EClass companyClass = (EClass)model1.getEClassifier("Company");
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+
+ // Create resource in session 1
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ EObject company = EcoreUtil.create(companyClass);
+ company.eSet(nameAttribute, "Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+
+ {
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ CDOObject company = CDOUtil.getCDOObject(res.getContents().get(0));
+ EClass companyClass = company.eClass();
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+ String name = (String)company.eGet(nameAttribute);
+ assertEquals("Eike", name);
+ }
+ }
+
+ private static EPackage loadModel(String fileName) throws IOException
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
+ Resource resource = resourceSet.getResource(URI.createFileURI(fileName), true);
+ return (EPackage)resource.getContents().get(0);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicPackageTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicPackageTest.java
index f06dbca548..b9c934c6bc 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicPackageTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicPackageTest.java
@@ -1,87 +1,87 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.internal.cdo.object.DynamicCDOObjectImpl;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.impl.DynamicEObjectImpl;
-
-/**
- * @author Martin Fluegge
- */
-public class DynamicPackageTest extends AbstractCDOTest
-{
- protected static EClass mapContainerEClass;
-
- public void testDynamicMaps() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- EPackage dynamicMapEPackge = createPackage();
- EFactory dynamicMapEFactoryInstance = dynamicMapEPackge.getEFactoryInstance();
-
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- EObject mapContainer = dynamicMapEFactoryInstance.create((EClass)dynamicMapEPackge.getEClassifier("MapContainer"));
-
- resource.getContents().add(mapContainer);
- transaction.commit();
-
- if (!isConfig(LEGACY))
- {
- assertEquals(true, mapContainer instanceof DynamicCDOObjectImpl);
- }
- else
- {
- assertEquals(true, mapContainer instanceof DynamicEObjectImpl);
- }
- }
-
- public EPackage createPackage()
- {
- EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
- EcorePackage theCorePackage = EcorePackage.eINSTANCE;
-
- mapContainerEClass = theCoreFactory.createEClass();
- mapContainerEClass.setName("MapContainer");
-
- EPackage dynamicMapEPackage = theCoreFactory.createEPackage();
- dynamicMapEPackage.setName("DynamicMapPackage");
- dynamicMapEPackage.setNsPrefix("dynamicmap");
- dynamicMapEPackage.setNsURI("http:///org.mftech.examples.emf.dynamic.map");
-
- dynamicMapEPackage.getEClassifiers().add(mapContainerEClass);
-
- EStructuralFeature name = theCoreFactory.createEAttribute();
- name.setName("name");
- name.setEType(theCorePackage.getEString());
-
- mapContainerEClass.getEStructuralFeatures().add(name);
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(dynamicMapEPackage);
- }
-
- return dynamicMapEPackage;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.internal.cdo.object.DynamicCDOObjectImpl;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.impl.DynamicEObjectImpl;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DynamicPackageTest extends AbstractCDOTest
+{
+ protected static EClass mapContainerEClass;
+
+ public void testDynamicMaps() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ EPackage dynamicMapEPackge = createPackage();
+ EFactory dynamicMapEFactoryInstance = dynamicMapEPackge.getEFactoryInstance();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ EObject mapContainer = dynamicMapEFactoryInstance.create((EClass)dynamicMapEPackge.getEClassifier("MapContainer"));
+
+ resource.getContents().add(mapContainer);
+ transaction.commit();
+
+ if (!isConfig(LEGACY))
+ {
+ assertEquals(true, mapContainer instanceof DynamicCDOObjectImpl);
+ }
+ else
+ {
+ assertEquals(true, mapContainer instanceof DynamicEObjectImpl);
+ }
+ }
+
+ public EPackage createPackage()
+ {
+ EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
+ EcorePackage theCorePackage = EcorePackage.eINSTANCE;
+
+ mapContainerEClass = theCoreFactory.createEClass();
+ mapContainerEClass.setName("MapContainer");
+
+ EPackage dynamicMapEPackage = theCoreFactory.createEPackage();
+ dynamicMapEPackage.setName("DynamicMapPackage");
+ dynamicMapEPackage.setNsPrefix("dynamicmap");
+ dynamicMapEPackage.setNsURI("http:///org.mftech.examples.emf.dynamic.map");
+
+ dynamicMapEPackage.getEClassifiers().add(mapContainerEClass);
+
+ EStructuralFeature name = theCoreFactory.createEAttribute();
+ name.setName("name");
+ name.setEType(theCorePackage.getEString());
+
+ mapContainerEClass.getEStructuralFeatures().add(name);
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(dynamicMapEPackage);
+ }
+
+ return dynamicMapEPackage;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicXSDTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicXSDTest.java
index f43ccc0021..709bd95829 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicXSDTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DynamicXSDTest.java
@@ -1,83 +1,83 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Christopher Albert - adaption to XSD
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.util.ExtendedMetaData;
-import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
-
-/**
- * @author Eike Stepper
- */
-public class DynamicXSDTest extends AbstractCDOTest
-{
- public void testDynamicEcore() throws Exception
- {
- {
- // Obtain model
- EPackage ecore = createPackage();
- EClass companyClass = (EClass)ecore.getEClassifier("Company");
- EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
-
- // Create resource in session 1
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(ecore);
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- EObject company = EcoreUtil.create(companyClass);
- company.eSet(nameAttribute, "Eike");
- res.getContents().add(company);
- transaction.commit();
- }
-
- {
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- CDOObject company = CDOUtil.getCDOObject(res.getContents().get(0));
- EClass companyClass = company.eClass();
- EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
- String name = (String)company.eGet(nameAttribute);
- assertEquals("Eike", name);
- }
- }
-
- private static EPackage createPackage()
- {
- EPackage result = EMFUtil.createEPackage("xsdmodel", "xsdmodel",
- "http://www.eclipse.org/emf/CDO/tests/xsdmodel/1.0.0");
- EClass company = EMFUtil.createEClass(result, "Company", false, false);
- ExtendedMetaData.INSTANCE.setName(company, "Company");
- ExtendedMetaData.INSTANCE.setContentKind(company, ExtendedMetaData.ELEMENT_ONLY_CONTENT);
-
- EAttribute att = EMFUtil.createEAttribute(company, "name", XMLTypePackage.eINSTANCE.getString());
- att.setLowerBound(1);
- ExtendedMetaData.INSTANCE.setName(att, "name");
- ExtendedMetaData.INSTANCE.setFeatureKind(att, ExtendedMetaData.ELEMENT_FEATURE);
-
- return result;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Christopher Albert - adaption to XSD
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+
+/**
+ * @author Eike Stepper
+ */
+public class DynamicXSDTest extends AbstractCDOTest
+{
+ public void testDynamicEcore() throws Exception
+ {
+ {
+ // Obtain model
+ EPackage ecore = createPackage();
+ EClass companyClass = (EClass)ecore.getEClassifier("Company");
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+
+ // Create resource in session 1
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(ecore);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ EObject company = EcoreUtil.create(companyClass);
+ company.eSet(nameAttribute, "Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+
+ {
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ CDOObject company = CDOUtil.getCDOObject(res.getContents().get(0));
+ EClass companyClass = company.eClass();
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+ String name = (String)company.eGet(nameAttribute);
+ assertEquals("Eike", name);
+ }
+ }
+
+ private static EPackage createPackage()
+ {
+ EPackage result = EMFUtil.createEPackage("xsdmodel", "xsdmodel",
+ "http://www.eclipse.org/emf/CDO/tests/xsdmodel/1.0.0");
+ EClass company = EMFUtil.createEClass(result, "Company", false, false);
+ ExtendedMetaData.INSTANCE.setName(company, "Company");
+ ExtendedMetaData.INSTANCE.setContentKind(company, ExtendedMetaData.ELEMENT_ONLY_CONTENT);
+
+ EAttribute att = EMFUtil.createEAttribute(company, "name", XMLTypePackage.eINSTANCE.getString());
+ att.setLowerBound(1);
+ ExtendedMetaData.INSTANCE.setName(att, "name");
+ ExtendedMetaData.INSTANCE.setFeatureKind(att, ExtendedMetaData.ELEMENT_FEATURE);
+
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFComplianceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFComplianceTest.java
index feff667b83..4739faeec3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFComplianceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFComplianceTest.java
@@ -1,55 +1,55 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author Eike Stepper
- */
-public class EMFComplianceTest extends AbstractOMTest
-{
- public void testResourceConstants() throws Exception
- {
- assertEquals(Resource.RESOURCE__RESOURCE_SET, EresourcePackage.CDO_RESOURCE__RESOURCE_SET);
- assertEquals(Resource.RESOURCE__URI, EresourcePackage.CDO_RESOURCE__URI);
- assertEquals(Resource.RESOURCE__CONTENTS, EresourcePackage.CDO_RESOURCE__CONTENTS);
- assertEquals(Resource.RESOURCE__IS_MODIFIED, EresourcePackage.CDO_RESOURCE__MODIFIED);
- assertEquals(Resource.RESOURCE__IS_LOADED, EresourcePackage.CDO_RESOURCE__LOADED);
- assertEquals(Resource.RESOURCE__IS_TRACKING_MODIFICATION, EresourcePackage.CDO_RESOURCE__TRACKING_MODIFICATION);
- assertEquals(Resource.RESOURCE__ERRORS, EresourcePackage.CDO_RESOURCE__ERRORS);
- assertEquals(Resource.RESOURCE__WARNINGS, EresourcePackage.CDO_RESOURCE__WARNINGS);
- assertEquals(Resource.RESOURCE__TIME_STAMP, EresourcePackage.CDO_RESOURCE__TIME_STAMP);
-
- assertEquals(EresourcePackage.eINSTANCE.getCDOResource_ResourceSet(), EresourcePackage.eINSTANCE.getCDOResource()
- .getEStructuralFeature(Resource.RESOURCE__RESOURCE_SET));
- assertEquals(EresourcePackage.eINSTANCE.getCDOResource_URI(), EresourcePackage.eINSTANCE.getCDOResource()
- .getEStructuralFeature(Resource.RESOURCE__URI));
- assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Contents(), EresourcePackage.eINSTANCE.getCDOResource()
- .getEStructuralFeature(Resource.RESOURCE__CONTENTS));
- assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Modified(), EresourcePackage.eINSTANCE.getCDOResource()
- .getEStructuralFeature(Resource.RESOURCE__IS_MODIFIED));
- assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Loaded(), EresourcePackage.eINSTANCE.getCDOResource()
- .getEStructuralFeature(Resource.RESOURCE__IS_LOADED));
- assertEquals(EresourcePackage.eINSTANCE.getCDOResource_TrackingModification(), EresourcePackage.eINSTANCE
- .getCDOResource().getEStructuralFeature(Resource.RESOURCE__IS_TRACKING_MODIFICATION));
- assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Errors(), EresourcePackage.eINSTANCE.getCDOResource()
- .getEStructuralFeature(Resource.RESOURCE__ERRORS));
- assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Warnings(), EresourcePackage.eINSTANCE.getCDOResource()
- .getEStructuralFeature(Resource.RESOURCE__WARNINGS));
- assertEquals(EresourcePackage.eINSTANCE.getCDOResource_TimeStamp(), EresourcePackage.eINSTANCE.getCDOResource()
- .getEStructuralFeature(Resource.RESOURCE__TIME_STAMP));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.EresourcePackage;
+
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * @author Eike Stepper
+ */
+public class EMFComplianceTest extends AbstractOMTest
+{
+ public void testResourceConstants() throws Exception
+ {
+ assertEquals(Resource.RESOURCE__RESOURCE_SET, EresourcePackage.CDO_RESOURCE__RESOURCE_SET);
+ assertEquals(Resource.RESOURCE__URI, EresourcePackage.CDO_RESOURCE__URI);
+ assertEquals(Resource.RESOURCE__CONTENTS, EresourcePackage.CDO_RESOURCE__CONTENTS);
+ assertEquals(Resource.RESOURCE__IS_MODIFIED, EresourcePackage.CDO_RESOURCE__MODIFIED);
+ assertEquals(Resource.RESOURCE__IS_LOADED, EresourcePackage.CDO_RESOURCE__LOADED);
+ assertEquals(Resource.RESOURCE__IS_TRACKING_MODIFICATION, EresourcePackage.CDO_RESOURCE__TRACKING_MODIFICATION);
+ assertEquals(Resource.RESOURCE__ERRORS, EresourcePackage.CDO_RESOURCE__ERRORS);
+ assertEquals(Resource.RESOURCE__WARNINGS, EresourcePackage.CDO_RESOURCE__WARNINGS);
+ assertEquals(Resource.RESOURCE__TIME_STAMP, EresourcePackage.CDO_RESOURCE__TIME_STAMP);
+
+ assertEquals(EresourcePackage.eINSTANCE.getCDOResource_ResourceSet(), EresourcePackage.eINSTANCE.getCDOResource()
+ .getEStructuralFeature(Resource.RESOURCE__RESOURCE_SET));
+ assertEquals(EresourcePackage.eINSTANCE.getCDOResource_URI(), EresourcePackage.eINSTANCE.getCDOResource()
+ .getEStructuralFeature(Resource.RESOURCE__URI));
+ assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Contents(), EresourcePackage.eINSTANCE.getCDOResource()
+ .getEStructuralFeature(Resource.RESOURCE__CONTENTS));
+ assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Modified(), EresourcePackage.eINSTANCE.getCDOResource()
+ .getEStructuralFeature(Resource.RESOURCE__IS_MODIFIED));
+ assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Loaded(), EresourcePackage.eINSTANCE.getCDOResource()
+ .getEStructuralFeature(Resource.RESOURCE__IS_LOADED));
+ assertEquals(EresourcePackage.eINSTANCE.getCDOResource_TrackingModification(), EresourcePackage.eINSTANCE
+ .getCDOResource().getEStructuralFeature(Resource.RESOURCE__IS_TRACKING_MODIFICATION));
+ assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Errors(), EresourcePackage.eINSTANCE.getCDOResource()
+ .getEStructuralFeature(Resource.RESOURCE__ERRORS));
+ assertEquals(EresourcePackage.eINSTANCE.getCDOResource_Warnings(), EresourcePackage.eINSTANCE.getCDOResource()
+ .getEStructuralFeature(Resource.RESOURCE__WARNINGS));
+ assertEquals(EresourcePackage.eINSTANCE.getCDOResource_TimeStamp(), EresourcePackage.eINSTANCE.getCDOResource()
+ .getEStructuralFeature(Resource.RESOURCE__TIME_STAMP));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java
index 4fb16b0370..4cad8291ef 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java
@@ -1,133 +1,133 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.tests.util.TestEMFUtil;
-
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.InternalEObject;
-
-/**
- * @author Eike Stepper
- */
-public class EMFTest extends AbstractOMTest
-{
- public EMFTest()
- {
- }
-
- public void testProxy() throws Exception
- {
- EPackage model2 = (EPackage)TestEMFUtil.loadXMI("model2.ecore");
- EClass companyProxy = (EClass)model2.getEClassifier("CompanyProxy");
- EReference reference = (EReference)companyProxy.getEStructuralFeature("company");
-
- EClass type = (EClass)reference.getEType();
- dumpProxy(type);
- IOUtil.OUT().println(type.getName());
- dumpProxy(type);
-
- IOUtil.OUT().println();
-
- // if (false)
- // {
- // model2.eResource().getResourceSet().getResources().get(1).unload();
- // }
- // else
- {
- ((InternalEObject)type).eSetProxyURI(URI.createURI("model1.ecore#//Company"));
- }
-
- if (true)
- {
- type = (EClass)reference.getEType();
- }
-
- dumpProxy(type);
- IOUtil.OUT().println(type.getName());
- dumpProxy(type);
- }
-
- public void testDefaultValue() throws Exception
- {
- final String DEFAULT = "Simon";
-
- EAttribute assignee = EcoreFactory.eINSTANCE.createEAttribute();
- assignee.setName("assignee");
- assignee.setEType(EcorePackage.eINSTANCE.getEString());
- assignee.setDefaultValueLiteral(DEFAULT);
- assignee.setUnsettable(true);
-
- EClass bugzilla = EcoreFactory.eINSTANCE.createEClass();
- bugzilla.setName("Bugzilla");
- bugzilla.getEStructuralFeatures().add(assignee);
-
- EPackage p = EcoreFactory.eINSTANCE.createEPackage();
- p.setName("p");
- p.getEClassifiers().add(bugzilla);
-
- EFactory f = p.getEFactoryInstance();
- EObject object = f.create(bugzilla);
- assertEquals(DEFAULT, object.eGet(assignee));
- assertEquals(false, object.eIsSet(assignee));
-
- object.eSet(assignee, DEFAULT);
- assertEquals(DEFAULT, object.eGet(assignee));
- assertEquals(true, object.eIsSet(assignee));
-
- object.eUnset(assignee);
- assertEquals(DEFAULT, object.eGet(assignee));
- assertEquals(false, object.eIsSet(assignee));
- }
-
- private void dumpProxy(EObject object)
- {
- InternalEObject eObject = (InternalEObject)object;
- String label = eObject.eClass().getName();
-
- IOUtil.OUT().println(label + ": " + eObject.eIsProxy());
- IOUtil.OUT().println(label + ": " + eObject.eProxyURI());
- }
-
- public static void main(String[] args)
- {
- dump(URI.createURI("cdo:///a/b/c"));
- dump(URI.createURI("cdo://a/b/c"));
- dump(URI.createURI("cdo:/a/b/c"));
- dump(URI.createURI("cdo:a/b/c"));
- }
-
- private static void dump(URI uri)
- {
- System.out.println(uri);
- System.out.println();
- System.out.println(" isHierarchical: " + uri.isHierarchical());
- System.out.println(" isPrefix: " + uri.isPrefix());
- System.out.println(" isRelative: " + uri.isRelative());
- System.out.println(" authority: " + uri.authority());
- System.out.println(" path: " + uri.path());
- System.out.println(" devicePath: " + uri.devicePath());
- System.out.println(" segmentsList: " + uri.segmentsList());
- System.out.println(" opaquePart: " + uri.opaquePart());
- System.out.println();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.tests.util.TestEMFUtil;
+
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.InternalEObject;
+
+/**
+ * @author Eike Stepper
+ */
+public class EMFTest extends AbstractOMTest
+{
+ public EMFTest()
+ {
+ }
+
+ public void testProxy() throws Exception
+ {
+ EPackage model2 = (EPackage)TestEMFUtil.loadXMI("model2.ecore");
+ EClass companyProxy = (EClass)model2.getEClassifier("CompanyProxy");
+ EReference reference = (EReference)companyProxy.getEStructuralFeature("company");
+
+ EClass type = (EClass)reference.getEType();
+ dumpProxy(type);
+ IOUtil.OUT().println(type.getName());
+ dumpProxy(type);
+
+ IOUtil.OUT().println();
+
+ // if (false)
+ // {
+ // model2.eResource().getResourceSet().getResources().get(1).unload();
+ // }
+ // else
+ {
+ ((InternalEObject)type).eSetProxyURI(URI.createURI("model1.ecore#//Company"));
+ }
+
+ if (true)
+ {
+ type = (EClass)reference.getEType();
+ }
+
+ dumpProxy(type);
+ IOUtil.OUT().println(type.getName());
+ dumpProxy(type);
+ }
+
+ public void testDefaultValue() throws Exception
+ {
+ final String DEFAULT = "Simon";
+
+ EAttribute assignee = EcoreFactory.eINSTANCE.createEAttribute();
+ assignee.setName("assignee");
+ assignee.setEType(EcorePackage.eINSTANCE.getEString());
+ assignee.setDefaultValueLiteral(DEFAULT);
+ assignee.setUnsettable(true);
+
+ EClass bugzilla = EcoreFactory.eINSTANCE.createEClass();
+ bugzilla.setName("Bugzilla");
+ bugzilla.getEStructuralFeatures().add(assignee);
+
+ EPackage p = EcoreFactory.eINSTANCE.createEPackage();
+ p.setName("p");
+ p.getEClassifiers().add(bugzilla);
+
+ EFactory f = p.getEFactoryInstance();
+ EObject object = f.create(bugzilla);
+ assertEquals(DEFAULT, object.eGet(assignee));
+ assertEquals(false, object.eIsSet(assignee));
+
+ object.eSet(assignee, DEFAULT);
+ assertEquals(DEFAULT, object.eGet(assignee));
+ assertEquals(true, object.eIsSet(assignee));
+
+ object.eUnset(assignee);
+ assertEquals(DEFAULT, object.eGet(assignee));
+ assertEquals(false, object.eIsSet(assignee));
+ }
+
+ private void dumpProxy(EObject object)
+ {
+ InternalEObject eObject = (InternalEObject)object;
+ String label = eObject.eClass().getName();
+
+ IOUtil.OUT().println(label + ": " + eObject.eIsProxy());
+ IOUtil.OUT().println(label + ": " + eObject.eProxyURI());
+ }
+
+ public static void main(String[] args)
+ {
+ dump(URI.createURI("cdo:///a/b/c"));
+ dump(URI.createURI("cdo://a/b/c"));
+ dump(URI.createURI("cdo:/a/b/c"));
+ dump(URI.createURI("cdo:a/b/c"));
+ }
+
+ private static void dump(URI uri)
+ {
+ System.out.println(uri);
+ System.out.println();
+ System.out.println(" isHierarchical: " + uri.isHierarchical());
+ System.out.println(" isPrefix: " + uri.isPrefix());
+ System.out.println(" isRelative: " + uri.isRelative());
+ System.out.println(" authority: " + uri.authority());
+ System.out.println(" path: " + uri.path());
+ System.out.println(" devicePath: " + uri.devicePath());
+ System.out.println(" segmentsList: " + uri.segmentsList());
+ System.out.println(" opaquePart: " + uri.opaquePart());
+ System.out.println();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMapTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMapTest.java
index 7a96f297a5..0edf8fa481 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMapTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMapTest.java
@@ -1,122 +1,122 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * Test EMap with an EObject in both the key and value
- *
- * @author Martin Taal
- */
-public class EMapTest extends AbstractCDOTest
-{
- private static final int NUM_OF_CUSTOMERS = 5;
-
- private static final int NUM_OF_SALES_ORDERS = 5;
-
- public void testEMap() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- Resource res = transaction.getResource(getResourcePath("/test1"));
- for (EObject eObject : res.getContents())
- {
- if (eObject instanceof Customer)
- {
- Customer customer = (Customer)eObject;
- for (Product1 product : customer.getOrderByProduct().keySet())
- {
- assertEquals(true, res.getContents().contains(product));
- SalesOrder order = customer.getOrderByProduct().get(product);
- assertNotNull(order);
- assertEquals(product.getName(), order.getId() + "");
- assertEquals(true, res.getContents().contains(order));
- }
- }
- }
-
- transaction.commit();
- enableConsole();
- }
-
- private void createTestSet(CDOSession session)
- {
- disableConsole();
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- fillResource(resource);
-
- try
- {
- msg("Committing");
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- enableConsole();
- }
-
- private void fillResource(CDOResource resource)
- {
- msg("Creating Testset");
- for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
- {
- final Customer customer = getModel1Factory().createCustomer();
- customer.setCity("City " + i);
- customer.setName(i + "");
- customer.setStreet("Street " + i);
- resource.getContents().add(customer);
-
- for (int k = 0; k < NUM_OF_SALES_ORDERS; k++)
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setDescription("Description " + k);
- product.setName("" + (i * 10 + k));
- product.setVat(VAT.VAT15);
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setCustomer(customer);
- salesOrder.setId(i * 10 + k);
-
- resource.getContents().add(salesOrder);
- resource.getContents().add(product);
-
- customer.getOrderByProduct().put(product, salesOrder);
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * Test EMap with an EObject in both the key and value
+ *
+ * @author Martin Taal
+ */
+public class EMapTest extends AbstractCDOTest
+{
+ private static final int NUM_OF_CUSTOMERS = 5;
+
+ private static final int NUM_OF_SALES_ORDERS = 5;
+
+ public void testEMap() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ Resource res = transaction.getResource(getResourcePath("/test1"));
+ for (EObject eObject : res.getContents())
+ {
+ if (eObject instanceof Customer)
+ {
+ Customer customer = (Customer)eObject;
+ for (Product1 product : customer.getOrderByProduct().keySet())
+ {
+ assertEquals(true, res.getContents().contains(product));
+ SalesOrder order = customer.getOrderByProduct().get(product);
+ assertNotNull(order);
+ assertEquals(product.getName(), order.getId() + "");
+ assertEquals(true, res.getContents().contains(order));
+ }
+ }
+ }
+
+ transaction.commit();
+ enableConsole();
+ }
+
+ private void createTestSet(CDOSession session)
+ {
+ disableConsole();
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ fillResource(resource);
+
+ try
+ {
+ msg("Committing");
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ enableConsole();
+ }
+
+ private void fillResource(CDOResource resource)
+ {
+ msg("Creating Testset");
+ for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
+ {
+ final Customer customer = getModel1Factory().createCustomer();
+ customer.setCity("City " + i);
+ customer.setName(i + "");
+ customer.setStreet("Street " + i);
+ resource.getContents().add(customer);
+
+ for (int k = 0; k < NUM_OF_SALES_ORDERS; k++)
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setDescription("Description " + k);
+ product.setName("" + (i * 10 + k));
+ product.setVat(VAT.VAT15);
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setCustomer(customer);
+ salesOrder.setId(i * 10 + k);
+
+ resource.getContents().add(salesOrder);
+ resource.getContents().add(product);
+
+ customer.getOrderByProduct().put(product, salesOrder);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EnumTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EnumTest.java
index f9bccac2fa..08e6ada0c4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EnumTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EnumTest.java
@@ -1,190 +1,190 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * @author Eike Stepper
- */
-public class EnumTest extends AbstractCDOTest
-{
- public void testTransient() throws Exception
- {
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Normal Product");
- product.setVat(VAT.VAT7);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(product);
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
- Product1 product = (Product1)resource.getContents().get(0);
- assertEquals(VAT.VAT7, product.getVat());
-
- product.setVat(VAT.VAT15);
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
- Product1 product = (Product1)resource.getContents().get(0);
- assertEquals(VAT.VAT15, product.getVat());
- session.close();
- }
- }
-
- public void testTransientFresh() throws Exception
- {
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Normal Product");
- product.setVat(VAT.VAT7);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(product);
- transaction.commit();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
- Product1 product = (Product1)resource.getContents().get(0);
- assertEquals(VAT.VAT7, product.getVat());
-
- product.setVat(VAT.VAT15);
- transaction.commit();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
- Product1 product = (Product1)resource.getContents().get(0);
- assertEquals(VAT.VAT15, product.getVat());
- session.close();
- }
- }
-
- public void testAttached() throws Exception
- {
- {
- Category category = getModel1Factory().createCategory();
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(category);
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Normal Product");
- product.setVat(VAT.VAT7);
- category.getProducts().add(product);
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
- Category category = (Category)resource.getContents().get(0);
- Product1 product = category.getProducts().get(0);
- assertEquals(VAT.VAT7, product.getVat());
-
- product.setVat(VAT.VAT15);
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
- Category category = (Category)resource.getContents().get(0);
- Product1 product = category.getProducts().get(0);
- assertEquals(VAT.VAT15, product.getVat());
- session.close();
- }
- }
-
- public void testAttachedFresh() throws Exception
- {
- {
- Category category = getModel1Factory().createCategory();
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
- resource.getContents().add(category);
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Normal Product");
- product.setVat(VAT.VAT7);
- category.getProducts().add(product);
-
- transaction.commit();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
- Category category = (Category)resource.getContents().get(0);
- Product1 product = category.getProducts().get(0);
- assertEquals(VAT.VAT7, product.getVat());
-
- product.setVat(VAT.VAT15);
- transaction.commit();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
- Category category = (Category)resource.getContents().get(0);
- Product1 product = category.getProducts().get(0);
- assertEquals(VAT.VAT15, product.getVat());
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * @author Eike Stepper
+ */
+public class EnumTest extends AbstractCDOTest
+{
+ public void testTransient() throws Exception
+ {
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Normal Product");
+ product.setVat(VAT.VAT7);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(product);
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
+ Product1 product = (Product1)resource.getContents().get(0);
+ assertEquals(VAT.VAT7, product.getVat());
+
+ product.setVat(VAT.VAT15);
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
+ Product1 product = (Product1)resource.getContents().get(0);
+ assertEquals(VAT.VAT15, product.getVat());
+ session.close();
+ }
+ }
+
+ public void testTransientFresh() throws Exception
+ {
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Normal Product");
+ product.setVat(VAT.VAT7);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(product);
+ transaction.commit();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
+ Product1 product = (Product1)resource.getContents().get(0);
+ assertEquals(VAT.VAT7, product.getVat());
+
+ product.setVat(VAT.VAT15);
+ transaction.commit();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
+ Product1 product = (Product1)resource.getContents().get(0);
+ assertEquals(VAT.VAT15, product.getVat());
+ session.close();
+ }
+ }
+
+ public void testAttached() throws Exception
+ {
+ {
+ Category category = getModel1Factory().createCategory();
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(category);
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Normal Product");
+ product.setVat(VAT.VAT7);
+ category.getProducts().add(product);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
+ Category category = (Category)resource.getContents().get(0);
+ Product1 product = category.getProducts().get(0);
+ assertEquals(VAT.VAT7, product.getVat());
+
+ product.setVat(VAT.VAT15);
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
+ Category category = (Category)resource.getContents().get(0);
+ Product1 product = category.getProducts().get(0);
+ assertEquals(VAT.VAT15, product.getVat());
+ session.close();
+ }
+ }
+
+ public void testAttachedFresh() throws Exception
+ {
+ {
+ Category category = getModel1Factory().createCategory();
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ resource.getContents().add(category);
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Normal Product");
+ product.setVat(VAT.VAT7);
+ category.getProducts().add(product);
+
+ transaction.commit();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
+ Category category = (Category)resource.getContents().get(0);
+ Product1 product = category.getProducts().get(0);
+ assertEquals(VAT.VAT7, product.getVat());
+
+ product.setVat(VAT.VAT15);
+ transaction.commit();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/my/resource"));
+ Category category = (Category)resource.getContents().get(0);
+ Product1 product = category.getProducts().get(0);
+ assertEquals(VAT.VAT15, product.getVat());
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java
index b0eb3b0443..d60da05eaa 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java
@@ -1,513 +1,513 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.id.CDOIDExternal;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.net4j.protocol.LoadRevisionsRequest;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.tests.model2.Model2Package;
-import org.eclipse.emf.cdo.tests.model4.GenRefSingleNonContained;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.transaction.CDOXATransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.DanglingReferenceException;
-import org.eclipse.emf.cdo.view.CDOViewSet;
-
-import org.eclipse.net4j.signal.ISignalProtocol;
-import org.eclipse.net4j.signal.SignalCounter;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Map;
-
-/**
- * @author Simon McDuff
- */
-public class ExternalReferenceTest extends AbstractCDOTest
-{
- final static public String REPOSITORY_B_NAME = "repo2";
-
- @CleanRepositoriesBefore
- public void testExternalWithDynamicEObject() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
-
- CDOSession sessionA = openSession();
- sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- sessionA.getPackageRegistry().putEPackage(getModel4Package());
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
-
- CDOResource resA = transactionA1.createResource("/resA");
- Resource resD = resourceSet.createResource(URI.createURI("test://1"));
-
- EPackage schoolPackage = createDynamicEPackage();
- resourceSet.getPackageRegistry().put(schoolPackage.getNsURI(), schoolPackage);
-
- EClass eClass = (EClass)schoolPackage.getEClassifier("SchoolBook");
- EObject schoolbook = EcoreUtil.create(eClass);
-
- GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
- objectFromResA.setElement(schoolbook);
- resD.getContents().add(schoolbook);
-
- resA.getContents().add(objectFromResA);
- transactionA1.commit();
-
- }
-
- public void testExternalWithEClass() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- {
- ResourceSet resourceSet = new ResourceSetImpl();
-
- CDOSession sessionA = openSession();
- sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- sessionA.getPackageRegistry().putEPackage(getModel4Package());
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
-
- CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
- GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
- objectFromResA.setElement(getModel1Package().getAddress());
- resA.getContents().add(objectFromResA);
- transactionA1.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession sessionA = openSession();
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getPackageRegistry().put(getModel1Package().getNsURI(), getModel1Package());
-
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
- CDOResource resA = transactionA1.getResource(getResourcePath("/resA"));
-
- GenRefSingleNonContained objectFromResA = (GenRefSingleNonContained)resA.getContents().get(0);
- assertEquals(getModel1Package().getAddress(), objectFromResA.getElement());
- transactionA1.commit();
- }
- }
-
- public void testExternalWithEPackage() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- {
- CDOSession sessionA = openSession();
-
- ResourceSet resourceSet = new ResourceSetImpl();
-
- sessionA.getPackageRegistry().putEPackage(getModel4Package());
- sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
-
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
- CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
- GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
- objectFromResA.setElement(getModel1Package());
- resA.getContents().add(objectFromResA);
- transactionA1.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
- {
- CDOSession sessionA = openSession();
-
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getPackageRegistry().put(getModel1Package().getNsURI(), getModel1Package());
-
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
- CDOResource resA = transactionA1.getResource(getResourcePath("/resA"));
-
- GenRefSingleNonContained objectFromResA = (GenRefSingleNonContained)resA.getContents().get(0);
- assertEquals(getModel1Package(), objectFromResA.getElement());
- transactionA1.commit();
- }
- }
-
- // XXX disabled because of Bug 290097
- @Skips("Postgresql")
- public void testOneXMIResourceManyViewsOnOneResourceSet() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- byte[] dataOfresD = null;
- getRepository(REPOSITORY_B_NAME);
-
- {
- CDOSession sessionA = openSession();
- CDOSession sessionB = openSession(REPOSITORY_B_NAME);
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
-
- sessionA.getPackageRegistry().putEPackage(getModel1Package());
- sessionA.getPackageRegistry().putEPackage(Model2Package.eINSTANCE);
- sessionB.getPackageRegistry().putEPackage(getModel1Package());
- sessionB.getPackageRegistry().putEPackage(Model2Package.eINSTANCE);
-
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
- CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
-
- CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
- CDOResource resB = transactionB1.createResource(getResourcePath("/resB"));
-
- EList<Resource> resources = resourceSet.getResources();
- assertEquals(2, resources.size());// Bug 346636
-
- CDOResource resC = transactionA1.createResource(getResourcePath("/resC"));
- assertNotNull(resC);
- assertEquals(3, resources.size());// Bug 346636
-
- Resource resD = resourceSet.createResource(URI.createURI("test://1"));
- assertEquals(4, resources.size());// Bug 346636
- assertEquals(false, resD instanceof CDOResource);
-
- Company companyA = getModel1Factory().createCompany();
- companyA.setName("VALUEA");
-
- Company companyB = getModel1Factory().createCompany();
- companyB.setName("VALUEB");
-
- Company companyD = getModel1Factory().createCompany();
- companyD.setName("VALUED");
-
- resD.getContents().add(companyD);
- resA.getContents().add(companyA);
- resB.getContents().add(companyB);
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
-
- supplier.getPurchaseOrders().add(purchaseOrder);
- resD.getContents().add(supplier);
- resA.getContents().add(purchaseOrder);
-
- CDOXATransaction transSet = CDOUtil.createXATransaction();
-
- transSet.add(CDOUtil.getViewSet(resourceSet));
-
- transactionA1.commit();
-
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- resD.save(outputStream, null);
- dataOfresD = outputStream.toByteArray();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction(resourceSet);
-
- CDOSession session2 = openSession(REPOSITORY_B_NAME);
- CDOTransaction transaction2 = session2.openTransaction(resourceSet);
-
- CDOViewSet set = CDOUtil.getViewSet(resourceSet);
- assertNotNull(set);
-
- resourceSet.getPackageRegistry().put(getModel1Package().getNsURI(), getModel1Package());
- resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
-
- Resource resD = resourceSet.createResource(URI.createURI("test://1"));
- resD.load(new ByteArrayInputStream(dataOfresD), null);
-
- CDOResource resA = transaction.getResource(getResourcePath("/resA"));
- CDOResource resB = transaction2.getResource(getResourcePath("/resB"));
- Company companyA = (Company)resA.getContents().get(0);
- Company companyB = (Company)resB.getContents().get(0);
- Company companyD = (Company)resD.getContents().get(0);
-
- assertNotSame(resA.getURI(), resB.getURI());
- assertNotSame(resA.getPath(), "/resA");
- assertNotSame(resB.getPath(), "/resB");
- assertNotSame(resA.cdoView(), transaction2);
- assertNotSame(resB.cdoView(), transaction);
-
- assertEquals("VALUEA", companyA.getName());
- assertEquals("VALUEB", companyB.getName());
- assertEquals("VALUED", companyD.getName());
-
- Supplier supplierD = (Supplier)resD.getContents().get(1);
- PurchaseOrder pO = supplierD.getPurchaseOrders().get(0);
- assertEquals(transaction, CDOUtil.getCDOObject(pO).cdoView());
- assertEquals(supplierD, pO.getSupplier());
- }
- }
-
- // Skip this test until the problems with XATransactions are solved.
- // XXX disabled because of Bug 290097
- @Skips({ IModelConfig.CAPABILITY_LEGACY, "Postgresql" })
- public void testManyViewsOnOneResourceSet() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- getRepository(REPOSITORY_B_NAME);
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOSession sessionB = openSession(REPOSITORY_B_NAME);
-
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOTransaction transaction = session.openTransaction(resourceSet);
- CDOTransaction transactionB = sessionB.openTransaction(resourceSet);
-
- CDOResource res = transaction.createResource(getResourcePath("/resA"));
- CDOResource resB = transactionB.createResource(getResourcePath("/resB"));
-
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.getPurchaseOrders().add(purchaseOrder);
-
- resB.getContents().add(supplier);
- res.getContents().add(purchaseOrder);
-
- CDOXATransaction transSet = CDOUtil.createXATransaction();
- transSet.add(CDOUtil.getViewSet(resourceSet));
-
- transaction.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOSession sessionA = openSession();
- CDOTransaction transactionA = sessionA.openTransaction(resourceSet);
-
- CDOSession sessionB = openSession(REPOSITORY_B_NAME);
- CDOTransaction transactionB = sessionB.openTransaction(resourceSet);
-
- CDOResource resA = transactionA.getResource(getResourcePath("/resA"));
- assertNotNull(resA);
-
- CDOResource resB = transactionB.getResource(getResourcePath("/resB"));
- assertNotNull(resB);
-
- Supplier supplierB = (Supplier)resB.getContents().get(0);
- PurchaseOrder pO = supplierB.getPurchaseOrders().get(0);
-
- assertEquals(transactionA, CDOUtil.getCDOObject(pO).cdoView());
-
- assertEquals(transactionB, CDOUtil.getCDOObject(supplierB).cdoView());
-
- assertEquals(supplierB, pO.getSupplier());
- assertEquals(supplierB.getPurchaseOrders().get(0), pO);
- }
- }
-
- public void testObjectNotAttached() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- supplier.getPurchaseOrders().add(purchaseOrder);
-
- resource1.getContents().add(supplier);
-
- try
- {
- msg("Committing");
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException success)
- {
- assertEquals(true, success.getCause() instanceof DanglingReferenceException);
- assertSame(purchaseOrder, ((DanglingReferenceException)success.getCause()).getTarget());
- }
- }
-
- @CleanRepositoriesBefore
- public void testUsingObjectsBetweenSameTransaction() throws Exception
- {
- CDOSession session = openSession();
-
- CDOTransaction transaction1 = session.openTransaction();
- CDOTransaction transaction2 = session.openTransaction();
-
- CDOResource resource1 = transaction1.createResource("/test1");
- CDOResource resource2 = transaction2.createResource("/test2");
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- supplier.getPurchaseOrders().add(purchaseOrder);
-
- resource1.getContents().add(supplier);
- resource2.getContents().add(purchaseOrder);
-
- transaction1.commit();
- }
-
- public void testWithXML() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- ResourceSet resourceSet = new ResourceSetImpl();
- Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
- map.put("xml", new XMLResourceFactoryImpl());
-
- PurchaseOrder externalObject = getModel1Factory().createPurchaseOrder();
- Resource externalResource = resourceSet.createResource(URI.createFileURI("/com/foo/bar.xml"));
- externalResource.getContents().add(externalObject);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction(resourceSet);
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.getPurchaseOrders().add(externalObject);
-
- CDOResource resource = transaction.createResource(getResourcePath("/internal"));
- resource.getContents().add(supplier);
- transaction.commit();
-
- CDORevision salesOrderRevision = CDOUtil.getCDOObject(supplier).cdoRevision();
- Object externalReference = salesOrderRevision.data().get(getModel1Package().getSupplier_PurchaseOrders(), 0);
- assertInstanceOf(CDOIDExternal.class, externalReference);
- }
-
- public void testWithXMLAndPrefetching() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
- map.put("xml", new XMLResourceFactoryImpl());
-
- Resource externalResource = resourceSet.createResource(URI.createFileURI("/com/foo/bar.xml"));
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction(resourceSet);
-
- Supplier supplier = getModel1Factory().createSupplier();
-
- for (int i = 0; i < 200; i++)
- {
- PurchaseOrder externalObject = getModel1Factory().createPurchaseOrder();
- externalResource.getContents().add(externalObject);
-
- supplier.getPurchaseOrders().add(externalObject);
- }
-
- CDOResource resource = transaction.createResource(getResourcePath("/internal"));
- resource.getContents().add(supplier);
- transaction.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
- map.put("xml", new XMLResourceFactoryImpl());
-
- Resource externalResource = resourceSet.createResource(URI.createFileURI("/com/foo/bar.xml"));
- for (int i = 0; i < 200; i++)
- {
- PurchaseOrder externalObject = getModel1Factory().createPurchaseOrder();
- externalResource.getContents().add(externalObject);
- }
-
- SignalCounter signalCounter = new SignalCounter();
-
- CDOSession session = openSession();
- ISignalProtocol<?> protocol = ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol();
- protocol.addListener(signalCounter);
-
- CDOTransaction transaction = session.openTransaction(resourceSet);
- transaction.options().setRevisionPrefetchingPolicy(CDOUtil.createRevisionPrefetchingPolicy(10));
-
- CDOResource resource = transaction.getResource(getResourcePath("/internal"));
- Supplier supplier = (Supplier)resource.getContents().get(0);
-
- for (int i = 0; i < 200; i++)
- {
- PurchaseOrder externalObject = supplier.getPurchaseOrders().get(i);
- System.out.println(externalObject);
- }
-
- int count = signalCounter.getCountFor(LoadRevisionsRequest.class);
- assertEquals(3, count); // Resource + top folder + top object (supplier)
-
- CDORevisionData data = CDOUtil.getCDOObject(supplier).cdoRevision().data();
- EReference reference = getModel1Package().getSupplier_PurchaseOrders();
- for (int i = 0; i < 200; i++)
- {
- Object value = data.get(reference, i);
- assertInstanceOf(CDOIDExternal.class, value);
- }
- }
- }
-
- private EPackage createDynamicEPackage()
- {
- final EcoreFactory eFactory = EcoreFactory.eINSTANCE;
- final EcorePackage ePackage = EcorePackage.eINSTANCE;
-
- EClass schoolBookEClass = eFactory.createEClass();
- schoolBookEClass.setName("SchoolBook");
-
- // create a new attribute for this EClass
- EAttribute level = eFactory.createEAttribute();
- level.setName("level");
- level.setEType(ePackage.getEInt());
- schoolBookEClass.getEStructuralFeatures().add(level);
-
- // Create a new EPackage and add the new EClasses
- EPackage schoolPackage = eFactory.createEPackage();
- schoolPackage.setName("elv");
- schoolPackage.setNsPrefix("elv");
- schoolPackage.setNsURI("http:///www.elver.org/School");
- schoolPackage.getEClassifiers().add(schoolBookEClass);
- return schoolPackage;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.id.CDOIDExternal;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.net4j.protocol.LoadRevisionsRequest;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.tests.model2.Model2Package;
+import org.eclipse.emf.cdo.tests.model4.GenRefSingleNonContained;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOXATransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.DanglingReferenceException;
+import org.eclipse.emf.cdo.view.CDOViewSet;
+
+import org.eclipse.net4j.signal.ISignalProtocol;
+import org.eclipse.net4j.signal.SignalCounter;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Map;
+
+/**
+ * @author Simon McDuff
+ */
+public class ExternalReferenceTest extends AbstractCDOTest
+{
+ final static public String REPOSITORY_B_NAME = "repo2";
+
+ @CleanRepositoriesBefore
+ public void testExternalWithDynamicEObject() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
+
+ CDOSession sessionA = openSession();
+ sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ sessionA.getPackageRegistry().putEPackage(getModel4Package());
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA1.createResource("/resA");
+ Resource resD = resourceSet.createResource(URI.createURI("test://1"));
+
+ EPackage schoolPackage = createDynamicEPackage();
+ resourceSet.getPackageRegistry().put(schoolPackage.getNsURI(), schoolPackage);
+
+ EClass eClass = (EClass)schoolPackage.getEClassifier("SchoolBook");
+ EObject schoolbook = EcoreUtil.create(eClass);
+
+ GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
+ objectFromResA.setElement(schoolbook);
+ resD.getContents().add(schoolbook);
+
+ resA.getContents().add(objectFromResA);
+ transactionA1.commit();
+
+ }
+
+ public void testExternalWithEClass() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ CDOSession sessionA = openSession();
+ sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ sessionA.getPackageRegistry().putEPackage(getModel4Package());
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
+ GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
+ objectFromResA.setElement(getModel1Package().getAddress());
+ resA.getContents().add(objectFromResA);
+ transactionA1.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession sessionA = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getPackageRegistry().put(getModel1Package().getNsURI(), getModel1Package());
+
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+ CDOResource resA = transactionA1.getResource(getResourcePath("/resA"));
+
+ GenRefSingleNonContained objectFromResA = (GenRefSingleNonContained)resA.getContents().get(0);
+ assertEquals(getModel1Package().getAddress(), objectFromResA.getElement());
+ transactionA1.commit();
+ }
+ }
+
+ public void testExternalWithEPackage() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ {
+ CDOSession sessionA = openSession();
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ sessionA.getPackageRegistry().putEPackage(getModel4Package());
+ sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+ CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
+ GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
+ objectFromResA.setElement(getModel1Package());
+ resA.getContents().add(objectFromResA);
+ transactionA1.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+ {
+ CDOSession sessionA = openSession();
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getPackageRegistry().put(getModel1Package().getNsURI(), getModel1Package());
+
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+ CDOResource resA = transactionA1.getResource(getResourcePath("/resA"));
+
+ GenRefSingleNonContained objectFromResA = (GenRefSingleNonContained)resA.getContents().get(0);
+ assertEquals(getModel1Package(), objectFromResA.getElement());
+ transactionA1.commit();
+ }
+ }
+
+ // XXX disabled because of Bug 290097
+ @Skips("Postgresql")
+ public void testOneXMIResourceManyViewsOnOneResourceSet() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ byte[] dataOfresD = null;
+ getRepository(REPOSITORY_B_NAME);
+
+ {
+ CDOSession sessionA = openSession();
+ CDOSession sessionB = openSession(REPOSITORY_B_NAME);
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
+
+ sessionA.getPackageRegistry().putEPackage(getModel1Package());
+ sessionA.getPackageRegistry().putEPackage(Model2Package.eINSTANCE);
+ sessionB.getPackageRegistry().putEPackage(getModel1Package());
+ sessionB.getPackageRegistry().putEPackage(Model2Package.eINSTANCE);
+
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+ CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
+ CDOResource resB = transactionB1.createResource(getResourcePath("/resB"));
+
+ EList<Resource> resources = resourceSet.getResources();
+ assertEquals(2, resources.size());// Bug 346636
+
+ CDOResource resC = transactionA1.createResource(getResourcePath("/resC"));
+ assertNotNull(resC);
+ assertEquals(3, resources.size());// Bug 346636
+
+ Resource resD = resourceSet.createResource(URI.createURI("test://1"));
+ assertEquals(4, resources.size());// Bug 346636
+ assertEquals(false, resD instanceof CDOResource);
+
+ Company companyA = getModel1Factory().createCompany();
+ companyA.setName("VALUEA");
+
+ Company companyB = getModel1Factory().createCompany();
+ companyB.setName("VALUEB");
+
+ Company companyD = getModel1Factory().createCompany();
+ companyD.setName("VALUED");
+
+ resD.getContents().add(companyD);
+ resA.getContents().add(companyA);
+ resB.getContents().add(companyB);
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ resD.getContents().add(supplier);
+ resA.getContents().add(purchaseOrder);
+
+ CDOXATransaction transSet = CDOUtil.createXATransaction();
+
+ transSet.add(CDOUtil.getViewSet(resourceSet));
+
+ transactionA1.commit();
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ resD.save(outputStream, null);
+ dataOfresD = outputStream.toByteArray();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ CDOSession session2 = openSession(REPOSITORY_B_NAME);
+ CDOTransaction transaction2 = session2.openTransaction(resourceSet);
+
+ CDOViewSet set = CDOUtil.getViewSet(resourceSet);
+ assertNotNull(set);
+
+ resourceSet.getPackageRegistry().put(getModel1Package().getNsURI(), getModel1Package());
+ resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
+
+ Resource resD = resourceSet.createResource(URI.createURI("test://1"));
+ resD.load(new ByteArrayInputStream(dataOfresD), null);
+
+ CDOResource resA = transaction.getResource(getResourcePath("/resA"));
+ CDOResource resB = transaction2.getResource(getResourcePath("/resB"));
+ Company companyA = (Company)resA.getContents().get(0);
+ Company companyB = (Company)resB.getContents().get(0);
+ Company companyD = (Company)resD.getContents().get(0);
+
+ assertNotSame(resA.getURI(), resB.getURI());
+ assertNotSame(resA.getPath(), "/resA");
+ assertNotSame(resB.getPath(), "/resB");
+ assertNotSame(resA.cdoView(), transaction2);
+ assertNotSame(resB.cdoView(), transaction);
+
+ assertEquals("VALUEA", companyA.getName());
+ assertEquals("VALUEB", companyB.getName());
+ assertEquals("VALUED", companyD.getName());
+
+ Supplier supplierD = (Supplier)resD.getContents().get(1);
+ PurchaseOrder pO = supplierD.getPurchaseOrders().get(0);
+ assertEquals(transaction, CDOUtil.getCDOObject(pO).cdoView());
+ assertEquals(supplierD, pO.getSupplier());
+ }
+ }
+
+ // Skip this test until the problems with XATransactions are solved.
+ // XXX disabled because of Bug 290097
+ @Skips({ IModelConfig.CAPABILITY_LEGACY, "Postgresql" })
+ public void testManyViewsOnOneResourceSet() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ getRepository(REPOSITORY_B_NAME);
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOSession sessionB = openSession(REPOSITORY_B_NAME);
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+ CDOTransaction transactionB = sessionB.openTransaction(resourceSet);
+
+ CDOResource res = transaction.createResource(getResourcePath("/resA"));
+ CDOResource resB = transactionB.createResource(getResourcePath("/resB"));
+
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.getPurchaseOrders().add(purchaseOrder);
+
+ resB.getContents().add(supplier);
+ res.getContents().add(purchaseOrder);
+
+ CDOXATransaction transSet = CDOUtil.createXATransaction();
+ transSet.add(CDOUtil.getViewSet(resourceSet));
+
+ transaction.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOSession sessionA = openSession();
+ CDOTransaction transactionA = sessionA.openTransaction(resourceSet);
+
+ CDOSession sessionB = openSession(REPOSITORY_B_NAME);
+ CDOTransaction transactionB = sessionB.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA.getResource(getResourcePath("/resA"));
+ assertNotNull(resA);
+
+ CDOResource resB = transactionB.getResource(getResourcePath("/resB"));
+ assertNotNull(resB);
+
+ Supplier supplierB = (Supplier)resB.getContents().get(0);
+ PurchaseOrder pO = supplierB.getPurchaseOrders().get(0);
+
+ assertEquals(transactionA, CDOUtil.getCDOObject(pO).cdoView());
+
+ assertEquals(transactionB, CDOUtil.getCDOObject(supplierB).cdoView());
+
+ assertEquals(supplierB, pO.getSupplier());
+ assertEquals(supplierB.getPurchaseOrders().get(0), pO);
+ }
+ }
+
+ public void testObjectNotAttached() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ supplier.getPurchaseOrders().add(purchaseOrder);
+
+ resource1.getContents().add(supplier);
+
+ try
+ {
+ msg("Committing");
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException success)
+ {
+ assertEquals(true, success.getCause() instanceof DanglingReferenceException);
+ assertSame(purchaseOrder, ((DanglingReferenceException)success.getCause()).getTarget());
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testUsingObjectsBetweenSameTransaction() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ CDOTransaction transaction2 = session.openTransaction();
+
+ CDOResource resource1 = transaction1.createResource("/test1");
+ CDOResource resource2 = transaction2.createResource("/test2");
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ supplier.getPurchaseOrders().add(purchaseOrder);
+
+ resource1.getContents().add(supplier);
+ resource2.getContents().add(purchaseOrder);
+
+ transaction1.commit();
+ }
+
+ public void testWithXML() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
+ map.put("xml", new XMLResourceFactoryImpl());
+
+ PurchaseOrder externalObject = getModel1Factory().createPurchaseOrder();
+ Resource externalResource = resourceSet.createResource(URI.createFileURI("/com/foo/bar.xml"));
+ externalResource.getContents().add(externalObject);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.getPurchaseOrders().add(externalObject);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/internal"));
+ resource.getContents().add(supplier);
+ transaction.commit();
+
+ CDORevision salesOrderRevision = CDOUtil.getCDOObject(supplier).cdoRevision();
+ Object externalReference = salesOrderRevision.data().get(getModel1Package().getSupplier_PurchaseOrders(), 0);
+ assertInstanceOf(CDOIDExternal.class, externalReference);
+ }
+
+ public void testWithXMLAndPrefetching() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
+ map.put("xml", new XMLResourceFactoryImpl());
+
+ Resource externalResource = resourceSet.createResource(URI.createFileURI("/com/foo/bar.xml"));
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ for (int i = 0; i < 200; i++)
+ {
+ PurchaseOrder externalObject = getModel1Factory().createPurchaseOrder();
+ externalResource.getContents().add(externalObject);
+
+ supplier.getPurchaseOrders().add(externalObject);
+ }
+
+ CDOResource resource = transaction.createResource(getResourcePath("/internal"));
+ resource.getContents().add(supplier);
+ transaction.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
+ map.put("xml", new XMLResourceFactoryImpl());
+
+ Resource externalResource = resourceSet.createResource(URI.createFileURI("/com/foo/bar.xml"));
+ for (int i = 0; i < 200; i++)
+ {
+ PurchaseOrder externalObject = getModel1Factory().createPurchaseOrder();
+ externalResource.getContents().add(externalObject);
+ }
+
+ SignalCounter signalCounter = new SignalCounter();
+
+ CDOSession session = openSession();
+ ISignalProtocol<?> protocol = ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol();
+ protocol.addListener(signalCounter);
+
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+ transaction.options().setRevisionPrefetchingPolicy(CDOUtil.createRevisionPrefetchingPolicy(10));
+
+ CDOResource resource = transaction.getResource(getResourcePath("/internal"));
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+
+ for (int i = 0; i < 200; i++)
+ {
+ PurchaseOrder externalObject = supplier.getPurchaseOrders().get(i);
+ System.out.println(externalObject);
+ }
+
+ int count = signalCounter.getCountFor(LoadRevisionsRequest.class);
+ assertEquals(3, count); // Resource + top folder + top object (supplier)
+
+ CDORevisionData data = CDOUtil.getCDOObject(supplier).cdoRevision().data();
+ EReference reference = getModel1Package().getSupplier_PurchaseOrders();
+ for (int i = 0; i < 200; i++)
+ {
+ Object value = data.get(reference, i);
+ assertInstanceOf(CDOIDExternal.class, value);
+ }
+ }
+ }
+
+ private EPackage createDynamicEPackage()
+ {
+ final EcoreFactory eFactory = EcoreFactory.eINSTANCE;
+ final EcorePackage ePackage = EcorePackage.eINSTANCE;
+
+ EClass schoolBookEClass = eFactory.createEClass();
+ schoolBookEClass.setName("SchoolBook");
+
+ // create a new attribute for this EClass
+ EAttribute level = eFactory.createEAttribute();
+ level.setName("level");
+ level.setEType(ePackage.getEInt());
+ schoolBookEClass.getEStructuralFeatures().add(level);
+
+ // Create a new EPackage and add the new EClasses
+ EPackage schoolPackage = eFactory.createEPackage();
+ schoolPackage.setName("elv");
+ schoolPackage.setNsPrefix("elv");
+ schoolPackage.setNsURI("http:///www.elver.org/School");
+ schoolPackage.getEClassifiers().add(schoolBookEClass);
+ return schoolPackage;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FeatureMapTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FeatureMapTest.java
index a8977baa7b..7ce06b455f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FeatureMapTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FeatureMapTest.java
@@ -1,248 +1,248 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- * Stefan Winkler - enhanced test cases
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model5.Doctor;
-import org.eclipse.emf.cdo.tests.model5.TestFeatureMap;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.util.ExtendedMetaData;
-import org.eclipse.emf.ecore.util.FeatureMap;
-
-import java.util.List;
-
-/**
- * @author Simon McDuff
- */
-public class FeatureMapTest extends AbstractCDOTest
-{
- private EPackage pkg;
-
- private EClass dummy;
-
- private EAttribute name;
-
- private EClass fmapContainer;
-
- private EAttribute string1;
-
- private EAttribute integer;
-
- private EAttribute fMap;
-
- private EAttribute string2;
-
- private EAttribute longObj;
-
- private EAttribute bool;
-
- private EReference ref1;
-
- private EReference ref2;
-
- private CDOSession session;
-
- private CDOTransaction tx;
-
- private CDOResource resource;
-
- private EObject dummyObj;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
-
- final EcorePackage epackage = EcorePackage.eINSTANCE;
- pkg = EMFUtil.createEPackage("fmaps", "fmaps", "http://cdo.emf.eclipse.org/fmaps");
- dummy = EMFUtil.createEClass(pkg, "Dummy", false, false);
- name = EMFUtil.createEAttribute(dummy, "name", epackage.getEString());
- fmapContainer = EMFUtil.createEClass(pkg, "FMapContainer", false, false);
-
- string1 = EMFUtil.createEAttribute(fmapContainer, "string1", epackage.getEString());
- string1.setUpperBound(-1);
-
- integer = EMFUtil.createEAttribute(fmapContainer, "integer", epackage.getEInt());
- integer.setUpperBound(-1);
-
- fMap = EMFUtil.createEAttribute(fmapContainer, "fmap", epackage.getEFeatureMapEntry());
- fMap.setUpperBound(-1);
-
- string2 = EMFUtil.createEAttribute(fmapContainer, "string2", epackage.getEString());
- string2.setUpperBound(-1);
-
- longObj = EMFUtil.createEAttribute(fmapContainer, "longObj", epackage.getELongObject());
- longObj.setUpperBound(-1);
-
- bool = EMFUtil.createEAttribute(fmapContainer, "bool", epackage.getEBoolean());
-
- ref1 = EMFUtil.createEReference(fmapContainer, "ref1", dummy, true, true);
- ref1.setUpperBound(-1);
-
- ref2 = EMFUtil.createEReference(fmapContainer, "ref2", dummy, true, false);
-
- ExtendedMetaData.INSTANCE.setFeatureKind(fMap, ExtendedMetaData.GROUP_FEATURE);
-
- ExtendedMetaData.INSTANCE.setGroup(string1, fMap);
- ExtendedMetaData.INSTANCE.setGroup(string2, fMap);
- ExtendedMetaData.INSTANCE.setGroup(integer, fMap);
- ExtendedMetaData.INSTANCE.setGroup(longObj, fMap);
- ExtendedMetaData.INSTANCE.setGroup(bool, fMap);
- ExtendedMetaData.INSTANCE.setGroup(ref1, fMap);
- ExtendedMetaData.INSTANCE.setGroup(ref2, fMap);
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- dummyObj = pkg.getEFactoryInstance().create(dummy);
- dummyObj.eSet(name, "DummyName");
-
- session = openSession();
- tx = session.openTransaction();
- resource = tx.getOrCreateResource(getResourcePath("/test/" + System.currentTimeMillis()));
- session.getPackageRegistry().putEPackage(pkg);
- resource.getContents().add(dummyObj);
- tx.commit();
- }
-
- public void _testAddDifferentTypes() throws CommitException
- {
- EObject fMapObj = EcoreUtil.create(fmapContainer);
-
- FeatureMap fm = (FeatureMap)fMapObj.eGet(fMap);
- fm.add(string1, "Hello");
- fm.add(string2, "lorem ipsum dolor sit amet");
- fm.add(string1, "World");
- fm.add(integer, 5);
- fm.add(bool, true);
- fm.add(ref1, dummyObj);
- fm.add(longObj, 12345678901234567L);
- fm.add(ref2, dummyObj);
- fm.add(bool, false); // Overwrites bool=true
- fm.add(ref2, null); // Overwrites ref2=dummyObj
-
- assertEquals(8, fm.size());
-
- resource.getContents().add(fMapObj);
- tx.commit();
-
- purgeCaches();
-
- EObject fMapObjDb = resource.getContents().get(1);
- FeatureMap fmDb = (FeatureMap)fMapObjDb.eGet(fMap);
- EObject dummyDb = resource.getContents().get(0);
-
- assertEquals(8, fmDb.size());
- assertEquals("Hello", fmDb.getValue(0));
- assertEquals(string1, fmDb.getEStructuralFeature(0));
-
- assertEquals("lorem ipsum dolor sit amet", fmDb.getValue(1));
- assertEquals(string2, fmDb.getEStructuralFeature(1));
-
- assertEquals("World", fmDb.getValue(2));
- assertEquals(string1, fmDb.getEStructuralFeature(2));
-
- assertEquals(5, fmDb.getValue(3));
- assertEquals(integer, fmDb.getEStructuralFeature(3));
-
- assertEquals(false, (boolean)(Boolean)fmDb.getValue(4));
- assertEquals(bool, fmDb.getEStructuralFeature(4));
-
- assertEquals(dummyDb, fmDb.getValue(5));
- assertEquals(ref1, fmDb.getEStructuralFeature(5));
-
- assertEquals(12345678901234567L, fmDb.getValue(6));
- assertEquals(longObj, fmDb.getEStructuralFeature(6));
-
- assertNull(fmDb.getValue(7));
- assertEquals(ref2, fmDb.getEStructuralFeature(7));
- }
-
- @Skips("Postgresql")
- public void testFeatureMaps() throws Exception
- {
- skipStoreWithoutFeatureMaps();
-
- EReference feature = getModel5Package().getTestFeatureMap_Doctors();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- TestFeatureMap featureMap = getModel5Factory().createTestFeatureMap();
- FeatureMap people = featureMap.getPeople();
-
- Doctor doctor1 = getModel5Factory().createDoctor();
- Doctor doctor2 = getModel5Factory().createDoctor();
-
- resource.getContents().add(doctor1);
- resource.getContents().add(doctor2);
-
- people.add(feature, doctor1);
- people.add(feature, doctor2);
-
- int featureMapIndex = resource.getContents().size();
- resource.getContents().add(featureMap);
-
- assertEquals(doctor1, people.get(0).getValue());
- List<?> doctors = (List<?>)people.get(feature, true);
- assertEquals(doctor1, doctors.get(0));
- assertEquals(doctor2, doctors.get(1));
- transaction.commit();
-
- clearCache(getRepository().getRevisionManager());
-
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/res1"));
-
- featureMap = (TestFeatureMap)resource.getContents().get(featureMapIndex);
- doctors = (List<?>)featureMap.getPeople().get(feature, true);
- assertInstanceOf(Doctor.class, doctors.get(0));
- assertInstanceOf(Doctor.class, doctors.get(1));
- }
-
- private void purgeCaches()
- {
- // according to Eike's comment at Bug 249681, client caches are
- // ignored, if a new session is opened.
- // server caches are wiped by the clearCache call.
-
- String path = resource.getPath();
-
- tx.close();
- session.close();
-
- clearCache(getRepository().getRevisionManager());
-
- session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
-
- tx = session.openTransaction();
-
- resource = tx.getResource(getResourcePath(path));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ * Stefan Winkler - enhanced test cases
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model5.Doctor;
+import org.eclipse.emf.cdo.tests.model5.TestFeatureMap;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+import org.eclipse.emf.ecore.util.FeatureMap;
+
+import java.util.List;
+
+/**
+ * @author Simon McDuff
+ */
+public class FeatureMapTest extends AbstractCDOTest
+{
+ private EPackage pkg;
+
+ private EClass dummy;
+
+ private EAttribute name;
+
+ private EClass fmapContainer;
+
+ private EAttribute string1;
+
+ private EAttribute integer;
+
+ private EAttribute fMap;
+
+ private EAttribute string2;
+
+ private EAttribute longObj;
+
+ private EAttribute bool;
+
+ private EReference ref1;
+
+ private EReference ref2;
+
+ private CDOSession session;
+
+ private CDOTransaction tx;
+
+ private CDOResource resource;
+
+ private EObject dummyObj;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+
+ final EcorePackage epackage = EcorePackage.eINSTANCE;
+ pkg = EMFUtil.createEPackage("fmaps", "fmaps", "http://cdo.emf.eclipse.org/fmaps");
+ dummy = EMFUtil.createEClass(pkg, "Dummy", false, false);
+ name = EMFUtil.createEAttribute(dummy, "name", epackage.getEString());
+ fmapContainer = EMFUtil.createEClass(pkg, "FMapContainer", false, false);
+
+ string1 = EMFUtil.createEAttribute(fmapContainer, "string1", epackage.getEString());
+ string1.setUpperBound(-1);
+
+ integer = EMFUtil.createEAttribute(fmapContainer, "integer", epackage.getEInt());
+ integer.setUpperBound(-1);
+
+ fMap = EMFUtil.createEAttribute(fmapContainer, "fmap", epackage.getEFeatureMapEntry());
+ fMap.setUpperBound(-1);
+
+ string2 = EMFUtil.createEAttribute(fmapContainer, "string2", epackage.getEString());
+ string2.setUpperBound(-1);
+
+ longObj = EMFUtil.createEAttribute(fmapContainer, "longObj", epackage.getELongObject());
+ longObj.setUpperBound(-1);
+
+ bool = EMFUtil.createEAttribute(fmapContainer, "bool", epackage.getEBoolean());
+
+ ref1 = EMFUtil.createEReference(fmapContainer, "ref1", dummy, true, true);
+ ref1.setUpperBound(-1);
+
+ ref2 = EMFUtil.createEReference(fmapContainer, "ref2", dummy, true, false);
+
+ ExtendedMetaData.INSTANCE.setFeatureKind(fMap, ExtendedMetaData.GROUP_FEATURE);
+
+ ExtendedMetaData.INSTANCE.setGroup(string1, fMap);
+ ExtendedMetaData.INSTANCE.setGroup(string2, fMap);
+ ExtendedMetaData.INSTANCE.setGroup(integer, fMap);
+ ExtendedMetaData.INSTANCE.setGroup(longObj, fMap);
+ ExtendedMetaData.INSTANCE.setGroup(bool, fMap);
+ ExtendedMetaData.INSTANCE.setGroup(ref1, fMap);
+ ExtendedMetaData.INSTANCE.setGroup(ref2, fMap);
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ dummyObj = pkg.getEFactoryInstance().create(dummy);
+ dummyObj.eSet(name, "DummyName");
+
+ session = openSession();
+ tx = session.openTransaction();
+ resource = tx.getOrCreateResource(getResourcePath("/test/" + System.currentTimeMillis()));
+ session.getPackageRegistry().putEPackage(pkg);
+ resource.getContents().add(dummyObj);
+ tx.commit();
+ }
+
+ public void _testAddDifferentTypes() throws CommitException
+ {
+ EObject fMapObj = EcoreUtil.create(fmapContainer);
+
+ FeatureMap fm = (FeatureMap)fMapObj.eGet(fMap);
+ fm.add(string1, "Hello");
+ fm.add(string2, "lorem ipsum dolor sit amet");
+ fm.add(string1, "World");
+ fm.add(integer, 5);
+ fm.add(bool, true);
+ fm.add(ref1, dummyObj);
+ fm.add(longObj, 12345678901234567L);
+ fm.add(ref2, dummyObj);
+ fm.add(bool, false); // Overwrites bool=true
+ fm.add(ref2, null); // Overwrites ref2=dummyObj
+
+ assertEquals(8, fm.size());
+
+ resource.getContents().add(fMapObj);
+ tx.commit();
+
+ purgeCaches();
+
+ EObject fMapObjDb = resource.getContents().get(1);
+ FeatureMap fmDb = (FeatureMap)fMapObjDb.eGet(fMap);
+ EObject dummyDb = resource.getContents().get(0);
+
+ assertEquals(8, fmDb.size());
+ assertEquals("Hello", fmDb.getValue(0));
+ assertEquals(string1, fmDb.getEStructuralFeature(0));
+
+ assertEquals("lorem ipsum dolor sit amet", fmDb.getValue(1));
+ assertEquals(string2, fmDb.getEStructuralFeature(1));
+
+ assertEquals("World", fmDb.getValue(2));
+ assertEquals(string1, fmDb.getEStructuralFeature(2));
+
+ assertEquals(5, fmDb.getValue(3));
+ assertEquals(integer, fmDb.getEStructuralFeature(3));
+
+ assertEquals(false, (boolean)(Boolean)fmDb.getValue(4));
+ assertEquals(bool, fmDb.getEStructuralFeature(4));
+
+ assertEquals(dummyDb, fmDb.getValue(5));
+ assertEquals(ref1, fmDb.getEStructuralFeature(5));
+
+ assertEquals(12345678901234567L, fmDb.getValue(6));
+ assertEquals(longObj, fmDb.getEStructuralFeature(6));
+
+ assertNull(fmDb.getValue(7));
+ assertEquals(ref2, fmDb.getEStructuralFeature(7));
+ }
+
+ @Skips("Postgresql")
+ public void testFeatureMaps() throws Exception
+ {
+ skipStoreWithoutFeatureMaps();
+
+ EReference feature = getModel5Package().getTestFeatureMap_Doctors();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ TestFeatureMap featureMap = getModel5Factory().createTestFeatureMap();
+ FeatureMap people = featureMap.getPeople();
+
+ Doctor doctor1 = getModel5Factory().createDoctor();
+ Doctor doctor2 = getModel5Factory().createDoctor();
+
+ resource.getContents().add(doctor1);
+ resource.getContents().add(doctor2);
+
+ people.add(feature, doctor1);
+ people.add(feature, doctor2);
+
+ int featureMapIndex = resource.getContents().size();
+ resource.getContents().add(featureMap);
+
+ assertEquals(doctor1, people.get(0).getValue());
+ List<?> doctors = (List<?>)people.get(feature, true);
+ assertEquals(doctor1, doctors.get(0));
+ assertEquals(doctor2, doctors.get(1));
+ transaction.commit();
+
+ clearCache(getRepository().getRevisionManager());
+
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/res1"));
+
+ featureMap = (TestFeatureMap)resource.getContents().get(featureMapIndex);
+ doctors = (List<?>)featureMap.getPeople().get(feature, true);
+ assertInstanceOf(Doctor.class, doctors.get(0));
+ assertInstanceOf(Doctor.class, doctors.get(1));
+ }
+
+ private void purgeCaches()
+ {
+ // according to Eike's comment at Bug 249681, client caches are
+ // ignored, if a new session is opened.
+ // server caches are wiped by the clearCache call.
+
+ String path = resource.getPath();
+
+ tx.close();
+ session.close();
+
+ clearCache(getRepository().getRevisionManager());
+
+ session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+
+ tx = session.openTransaction();
+
+ resource = tx.getResource(getResourcePath(path));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/GeneratedEcoreTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/GeneratedEcoreTest.java
index edc6ef52b0..c797675d6c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/GeneratedEcoreTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/GeneratedEcoreTest.java
@@ -1,61 +1,61 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.util.TestEMFUtil;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcorePackage;
-
-/**
- * @author Eike Stepper
- */
-public class GeneratedEcoreTest extends AbstractCDOTest
-{
- /**
- * TODO Fix me
- */
- public void testGeneratedEcore() throws Exception
- {
- // Obtain model
- EPackage ecore = EcorePackage.eINSTANCE;
-
- // Create resource in session 1
- CDOSession session1 = openSession();
- session1.getPackageRegistry().putEPackage(ecore);
- CDOTransaction transaction1 = session1.openTransaction();
- CDOResource res1 = transaction1.createResource("/res");
-
- EPackage root1 = TestEMFUtil.loadEcore("model1.ecore", session1.getPackageRegistry());
- res1.getContents().add(root1);
- transaction1.commit();
-
- // Load resource in session 2
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- CDOResource res2 = transaction2.getResource(getResourcePath("/res"));
-
- EList<EObject> contents = res2.getContents();
- EPackage root2 = (EPackage)contents.get(0);
- assertEquals("Unresolved proxy", false, root2.eIsProxy());
- assertEquals(res2, root2.eResource());
-
- CDOUtil.load(root2, transaction2);
- TestEMFUtil.saveEcore("model1X.ecore", root2);
- // assertEquals(true, "Models differ", EcoreUtil.equals(root1, root2));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.util.TestEMFUtil;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcorePackage;
+
+/**
+ * @author Eike Stepper
+ */
+public class GeneratedEcoreTest extends AbstractCDOTest
+{
+ /**
+ * TODO Fix me
+ */
+ public void testGeneratedEcore() throws Exception
+ {
+ // Obtain model
+ EPackage ecore = EcorePackage.eINSTANCE;
+
+ // Create resource in session 1
+ CDOSession session1 = openSession();
+ session1.getPackageRegistry().putEPackage(ecore);
+ CDOTransaction transaction1 = session1.openTransaction();
+ CDOResource res1 = transaction1.createResource("/res");
+
+ EPackage root1 = TestEMFUtil.loadEcore("model1.ecore", session1.getPackageRegistry());
+ res1.getContents().add(root1);
+ transaction1.commit();
+
+ // Load resource in session 2
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource res2 = transaction2.getResource(getResourcePath("/res"));
+
+ EList<EObject> contents = res2.getContents();
+ EPackage root2 = (EPackage)contents.get(0);
+ assertEquals("Unresolved proxy", false, root2.eIsProxy());
+ assertEquals(res2, root2.eResource());
+
+ CDOUtil.load(root2, transaction2);
+ TestEMFUtil.saveEcore("model1X.ecore", root2);
+ // assertEquals(true, "Models differ", EcoreUtil.equals(root1, root2));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java
index e47bc81d35..24e1e152a0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java
@@ -1,541 +1,541 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOListFeatureDeltaImpl;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.net4j.util.om.OMPlatform;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class IndexReconstructionTest extends AbstractCDOTest
-{
- private CDOTransaction transaction;
-
- private CDOResource resource;
-
- private Set<ReconstructedIndex> expectedIndices;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- OMPlatform.INSTANCE.setDebugging(false);
- CDOSession session = openSession();
- transaction = session.openTransaction();
- resource = transaction.createResource(getResourcePath("/test1"));
- expectedIndices = new HashSet<ReconstructedIndex>();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- CDOSession session = transaction.getSession();
- expectedIndices = null;
- transaction.close();
- transaction = null;
- session.close();
- session = null;
- super.doTearDown();
- }
-
- public void testAddBefore1() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(0, createSalesOrder());
- customer.getSalesOrders().add(0, createSalesOrder());
- customer.getSalesOrders().add(0, createSalesOrder());
- customer.getSalesOrders().add(0, createSalesOrder());
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 0);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 1);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 2);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 3);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 4);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- checkReconstructedIndices();
- }
-
- public void testAddBefore4() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(0, createSalesOrder());
- customer.getSalesOrders().add(0, createSalesOrder());
- customer.getSalesOrders().add(0, createSalesOrder());
- customer.getSalesOrders().add(0, createSalesOrder());
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 0);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 1);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- checkReconstructedIndices();
- }
-
- public void testAddAfter1() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 1);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 2);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 3);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 4);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- checkReconstructedIndices();
- }
-
- public void testAddAfter4() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 5);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 6);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- checkReconstructedIndices();
- }
-
- public void testRemove1() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().remove(0);
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 5);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- checkReconstructedIndices();
- }
-
- public void testRemove4() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().remove(0);
- customer.getSalesOrders().remove(0);
- customer.getSalesOrders().remove(0);
- customer.getSalesOrders().remove(0);
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 0);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 1);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- checkReconstructedIndices();
- }
-
- public void testRemoveAdded() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- checkReconstructedIndices();
- }
-
- public void testRemoveLastAdded() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
-
- dumpReconstructedIndices();
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- checkReconstructedIndices();
- }
-
- public void testReAdded() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().remove(2);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 9);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 10);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 11);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 12);
- checkReconstructedIndices();
- }
-
- public void testMoveBehindEnd() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().move(7, 2);
- customer.getSalesOrders().move(7, 2);
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- checkReconstructedIndices();
- }
-
- public void testMoveBackward() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().move(5, 0);
- customer.getSalesOrders().move(5, 0);
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 6);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- checkReconstructedIndices();
- }
-
- public void testMoveForward() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- transaction.commit();
-
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().add(createSalesOrder());
- customer.getSalesOrders().move(2, 7);
- customer.getSalesOrders().move(2, 7);
-
- dumpReconstructedIndices();
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 6);
- expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
- expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
- checkReconstructedIndices();
- }
-
- private SalesOrder createSalesOrder()
- {
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- resource.getContents().add(salesOrder);
- return salesOrder;
- }
-
- private void dumpReconstructedIndices()
- {
- Collection<CDORevisionDelta> revisionDeltas = transaction.getRevisionDeltas().values();
- for (CDORevisionDelta revisionDelta : revisionDeltas)
- {
- for (CDOFeatureDelta featureDelta : revisionDelta.getFeatureDeltas())
- {
- if (featureDelta instanceof CDOListFeatureDeltaImpl)
- {
- int[] indices = ((CDOListFeatureDeltaImpl)featureDelta).reconstructAddedIndices().getElement2();
- if (indices[0] != 0)
- {
- System.out.print(revisionDelta.getID());
- System.out.print(": ");
- System.out.print(featureDelta.getFeature().getEContainingClass().getName());
- System.out.print(".");
- System.out.print(featureDelta.getFeature().getName());
- System.out.print("=");
- for (int i = 1; i <= indices[0]; i++)
- {
- System.out.print(indices[i] + " ");
- }
-
- System.out.println();
- }
- }
- }
- }
- }
-
- private void expectIndex(CDOID id, EStructuralFeature eFeature, int index)
- {
- ReconstructedIndex expectedIndex = new ReconstructedIndex(id, eFeature, index);
- if (!expectedIndices.add(expectedIndex))
- {
- fail("Duplicate expected ids: " + expectedIndex);
- }
- }
-
- private void checkReconstructedIndices()
- {
- boolean fail = false;
- Collection<CDORevisionDelta> revisionDeltas = transaction.getRevisionDeltas().values();
- for (CDORevisionDelta revisionDelta : revisionDeltas)
- {
- for (CDOFeatureDelta featureDelta : revisionDelta.getFeatureDeltas())
- {
- if (featureDelta instanceof CDOListFeatureDeltaImpl)
- {
- int[] indices = ((CDOListFeatureDeltaImpl)featureDelta).reconstructAddedIndices().getElement2();
- for (int i = 1; i <= indices[0]; i++)
- {
- ReconstructedIndex expectedIndex = new ReconstructedIndex(revisionDelta.getID(), featureDelta.getFeature(),
- indices[i]);
- if (!expectedIndices.remove(expectedIndex))
- {
- System.out.println("Reconstructed but not expected ids: " + expectedIndex);
- fail = true;
- }
- }
- }
- }
- }
-
- if (!expectedIndices.isEmpty())
- {
- System.out.println("Expected but not reconstructed indices: " + expectedIndices);
- fail = true;
- }
-
- if (fail)
- {
- fail("Detailed cause has been written to the console");
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class ReconstructedIndex
- {
- private CDOID id;
-
- private EStructuralFeature feature;
-
- private int index;
-
- public ReconstructedIndex(CDOID id, EStructuralFeature feature, int index)
- {
- this.feature = feature;
- this.id = id;
- this.index = index;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof ReconstructedIndex)
- {
- ReconstructedIndex that = (ReconstructedIndex)obj;
- return id.equals(that.id) && feature.equals(that.feature) && index == that.index;
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return id.hashCode() ^ feature.hashCode() ^ index;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}: {1}.{2}={3}", id, feature.getEContainingClass().getName(), feature.getName(),
- index);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.EresourcePackage;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOListFeatureDeltaImpl;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.net4j.util.om.OMPlatform;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class IndexReconstructionTest extends AbstractCDOTest
+{
+ private CDOTransaction transaction;
+
+ private CDOResource resource;
+
+ private Set<ReconstructedIndex> expectedIndices;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ OMPlatform.INSTANCE.setDebugging(false);
+ CDOSession session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.createResource(getResourcePath("/test1"));
+ expectedIndices = new HashSet<ReconstructedIndex>();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ CDOSession session = transaction.getSession();
+ expectedIndices = null;
+ transaction.close();
+ transaction = null;
+ session.close();
+ session = null;
+ super.doTearDown();
+ }
+
+ public void testAddBefore1() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(0, createSalesOrder());
+ customer.getSalesOrders().add(0, createSalesOrder());
+ customer.getSalesOrders().add(0, createSalesOrder());
+ customer.getSalesOrders().add(0, createSalesOrder());
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 0);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 1);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 2);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 3);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 4);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ checkReconstructedIndices();
+ }
+
+ public void testAddBefore4() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(0, createSalesOrder());
+ customer.getSalesOrders().add(0, createSalesOrder());
+ customer.getSalesOrders().add(0, createSalesOrder());
+ customer.getSalesOrders().add(0, createSalesOrder());
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 0);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 1);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ checkReconstructedIndices();
+ }
+
+ public void testAddAfter1() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 1);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 2);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 3);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 4);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ checkReconstructedIndices();
+ }
+
+ public void testAddAfter4() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 5);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 6);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ checkReconstructedIndices();
+ }
+
+ public void testRemove1() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().remove(0);
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 5);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ checkReconstructedIndices();
+ }
+
+ public void testRemove4() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().remove(0);
+ customer.getSalesOrders().remove(0);
+ customer.getSalesOrders().remove(0);
+ customer.getSalesOrders().remove(0);
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 0);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 1);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ checkReconstructedIndices();
+ }
+
+ public void testRemoveAdded() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ checkReconstructedIndices();
+ }
+
+ public void testRemoveLastAdded() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+
+ dumpReconstructedIndices();
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ checkReconstructedIndices();
+ }
+
+ public void testReAdded() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().remove(2);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 9);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 10);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 11);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 12);
+ checkReconstructedIndices();
+ }
+
+ public void testMoveBehindEnd() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().move(7, 2);
+ customer.getSalesOrders().move(7, 2);
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 4);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ checkReconstructedIndices();
+ }
+
+ public void testMoveBackward() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().move(5, 0);
+ customer.getSalesOrders().move(5, 0);
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 6);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ checkReconstructedIndices();
+ }
+
+ public void testMoveForward() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ transaction.commit();
+
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().add(createSalesOrder());
+ customer.getSalesOrders().move(2, 7);
+ customer.getSalesOrders().move(2, 7);
+
+ dumpReconstructedIndices();
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 2);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 3);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 6);
+ expectIndex(CDOUtil.getCDOObject(customer).cdoID(), getModel1Package().getCustomer_SalesOrders(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 5);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 6);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 7);
+ expectIndex(resource.cdoID(), EresourcePackage.eINSTANCE.getCDOResource_Contents(), 8);
+ checkReconstructedIndices();
+ }
+
+ private SalesOrder createSalesOrder()
+ {
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ resource.getContents().add(salesOrder);
+ return salesOrder;
+ }
+
+ private void dumpReconstructedIndices()
+ {
+ Collection<CDORevisionDelta> revisionDeltas = transaction.getRevisionDeltas().values();
+ for (CDORevisionDelta revisionDelta : revisionDeltas)
+ {
+ for (CDOFeatureDelta featureDelta : revisionDelta.getFeatureDeltas())
+ {
+ if (featureDelta instanceof CDOListFeatureDeltaImpl)
+ {
+ int[] indices = ((CDOListFeatureDeltaImpl)featureDelta).reconstructAddedIndices().getElement2();
+ if (indices[0] != 0)
+ {
+ System.out.print(revisionDelta.getID());
+ System.out.print(": ");
+ System.out.print(featureDelta.getFeature().getEContainingClass().getName());
+ System.out.print(".");
+ System.out.print(featureDelta.getFeature().getName());
+ System.out.print("=");
+ for (int i = 1; i <= indices[0]; i++)
+ {
+ System.out.print(indices[i] + " ");
+ }
+
+ System.out.println();
+ }
+ }
+ }
+ }
+ }
+
+ private void expectIndex(CDOID id, EStructuralFeature eFeature, int index)
+ {
+ ReconstructedIndex expectedIndex = new ReconstructedIndex(id, eFeature, index);
+ if (!expectedIndices.add(expectedIndex))
+ {
+ fail("Duplicate expected ids: " + expectedIndex);
+ }
+ }
+
+ private void checkReconstructedIndices()
+ {
+ boolean fail = false;
+ Collection<CDORevisionDelta> revisionDeltas = transaction.getRevisionDeltas().values();
+ for (CDORevisionDelta revisionDelta : revisionDeltas)
+ {
+ for (CDOFeatureDelta featureDelta : revisionDelta.getFeatureDeltas())
+ {
+ if (featureDelta instanceof CDOListFeatureDeltaImpl)
+ {
+ int[] indices = ((CDOListFeatureDeltaImpl)featureDelta).reconstructAddedIndices().getElement2();
+ for (int i = 1; i <= indices[0]; i++)
+ {
+ ReconstructedIndex expectedIndex = new ReconstructedIndex(revisionDelta.getID(), featureDelta.getFeature(),
+ indices[i]);
+ if (!expectedIndices.remove(expectedIndex))
+ {
+ System.out.println("Reconstructed but not expected ids: " + expectedIndex);
+ fail = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (!expectedIndices.isEmpty())
+ {
+ System.out.println("Expected but not reconstructed indices: " + expectedIndices);
+ fail = true;
+ }
+
+ if (fail)
+ {
+ fail("Detailed cause has been written to the console");
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class ReconstructedIndex
+ {
+ private CDOID id;
+
+ private EStructuralFeature feature;
+
+ private int index;
+
+ public ReconstructedIndex(CDOID id, EStructuralFeature feature, int index)
+ {
+ this.feature = feature;
+ this.id = id;
+ this.index = index;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ReconstructedIndex)
+ {
+ ReconstructedIndex that = (ReconstructedIndex)obj;
+ return id.equals(that.id) && feature.equals(that.feature) && index == that.index;
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return id.hashCode() ^ feature.hashCode() ^ index;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}: {1}.{2}={3}", id, feature.getEContainingClass().getName(), feature.getName(),
+ index);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
index 90a0ac27d5..9755bf598e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
@@ -1,835 +1,835 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.OrderAddress;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.session.SessionUtil;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
-
-import java.util.Date;
-
-/**
- * @author Eike Stepper
- */
-public class InitialTest extends AbstractCDOTest
-{
- public void testTransientObject() throws Exception
- {
- final Date date = new Date();
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
- assertTransient(supplier);
-
- msg("Setting name");
- supplier.setName("Stepper");
- assertTransient(supplier);
-
- msg("Verifying name");
- assertEquals("Stepper", supplier.getName());
- assertTransient(supplier);
-
- msg("Creating purchaseOrder");
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- assertTransient(purchaseOrder);
-
- msg("Setting date");
- purchaseOrder.setDate(date);
- assertTransient(purchaseOrder);
-
- msg("Verifying date");
- assertEquals(date, purchaseOrder.getDate());
- assertTransient(purchaseOrder);
-
- msg("Setting supplier");
- purchaseOrder.setSupplier(supplier);
- assertTransient(supplier);
- assertTransient(purchaseOrder);
-
- msg("Verifying supplier");
- assertEquals(supplier, purchaseOrder.getSupplier());
- assertTransient(supplier);
- assertTransient(purchaseOrder);
- }
-
- public void testTransientResource() throws Exception
- {
- final URI uri = URI.createURI("cdo:/test1");
-
- msg("Creating resourceSet");
- ResourceSet resourceSet = new ResourceSetImpl();
- SessionUtil.prepareResourceSet(resourceSet);
-
- msg("Creating resource");
- CDOResource resource = (CDOResource)resourceSet.createResource(uri);
- assertTransient(resource);
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
- assertTransient(supplier);
- assertEquals(null, supplier.eContainer());
-
- msg("Verifying contents");
- EList<EObject> contents = resource.getContents();
- assertNotNull(contents);
- assertEquals(true, contents.isEmpty());
- assertEquals(0, contents.size());
- assertTransient(resource);
-
- msg("Adding supplier");
- contents.add(supplier);
- assertTransient(resource);
- assertTransient(supplier);
- assertContent(resource, supplier);
-
- assertEquals(true, resourceSet.getResources().contains(resource));
- resource.delete(null);
- assertEquals(false, resourceSet.getResources().contains(resource));
- assertTransient(supplier);
- }
-
- public void testOpenSession() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
- assertNotNull(session);
- assertEquals(false, session.isClosed());
- assertEquals(RepositoryConfig.REPOSITORY_NAME, session.getRepositoryInfo().getName());
- assertEquals(RepositoryConfig.REPOSITORY_NAME, session.getRepositoryInfo().getUUID());
- }
-
- public void testStartTransaction() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
- assertNotNull(transaction);
- assertEquals(session, transaction.getSession());
- }
-
- public void testAttachResource() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- assertNew(resource, transaction);
- assertEquals(URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
- resource.getURI());
- ResourceSet expected = transaction.getResourceSet();
- ResourceSet actual = resource.getResourceSet();
- assertEquals(expected, actual);
- }
-
- public void testAttachObject() throws Exception
- {
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Getting contents");
- EList<EObject> contents = resource.getContents();
-
- msg("Adding supplier");
- contents.add(supplier);
- assertNew(supplier, transaction);
- assertEquals(transaction, CDOUtil.getCDOObject(supplier).cdoView());
- assertEquals(resource, CDOUtil.getCDOObject(supplier).cdoDirectResource());
- assertEquals(0, CDOUtil.getCDOObject(supplier).cdoRevision().getVersion());
- assertEquals(resource, supplier.eResource());
- assertEquals(null, supplier.eContainer());
- }
-
- public void testCommitNew() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- msg("Committing");
- CDOCommitInfo commit = transaction.commit();
- assertEquals(CDOState.CLEAN, resource.cdoState());
- assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(supplier).cdoState());
- assertEquals(1, CDOUtil.getCDOObject(supplier).cdoRevision().getVersion());
- assertCreatedTime(resource, commit.getTimeStamp());
- assertCreatedTime(supplier, commit.getTimeStamp());
- }
-
- public void testReadResourceClean() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- msg("Committing");
- long commitTime = transaction.commit().getTimeStamp();
-
- msg("Getting supplier");
- EList<EObject> contents = resource.getContents();
- Supplier s = (Supplier)contents.get(0);
- assertEquals(1, CDOUtil.getCDOObject(s).cdoRevision().getVersion());
- assertEquals(supplier, s);
- assertCreatedTime(s, commitTime);
- }
-
- public void testReadObjectClean() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- msg("Committing");
- transaction.commit();
-
- msg("Getting supplier");
- Supplier s = (Supplier)resource.getContents().get(0);
- assertEquals(1, CDOUtil.getCDOObject(s).cdoRevision().getVersion());
-
- msg("Verifying name");
- assertEquals("Stepper", s.getName());
- }
-
- public void testWriteClean() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- msg("Committing");
- transaction.commit();
-
- msg("Getting supplier");
- Supplier s = (Supplier)resource.getContents().get(0);
-
- msg("Setting name");
- s.setName("Eike");
- assertEquals("Eike", s.getName());
- assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(supplier).cdoState());
- assertEquals(CDOState.CLEAN, resource.cdoState());
- }
-
- public void testCommitDirty() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
-
- resource.getContents().add(supplier);
-
- CDOCommitInfo commit = transaction.commit();
- long commitTime1 = commit.getTimeStamp();
- assertCreatedTime(supplier, commitTime1);
-
- supplier.setName("Eike");
-
- long commitTime2 = transaction.commit().getTimeStamp();
- assertEquals(true, commitTime1 < commitTime2);
- assertEquals(CDOState.CLEAN, resource.cdoState());
- assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(supplier).cdoState());
- assertCreatedTime(supplier, commitTime2);
- }
-
- public void testGetResource() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- {
- disableConsole();
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- msg("Committing");
- transaction.commit();
- enableConsole();
- }
-
- {
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Getting resource");
- CDOResource resource = transaction.getResource(getResourcePath("/test1"), true);
- assertNotNull(resource);
- assertEquals(URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
- resource.getURI());
- assertEquals(transaction.getResourceSet(), resource.getResourceSet());
- assertEquals(1, transaction.getResourceSet().getResources().size());
- assertEquals(CDOState.CLEAN, resource.cdoState());
- assertEquals(transaction, resource.cdoView());
- assertNotNull(resource.cdoRevision());
- }
-
- {
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Getting resource");
- CDOResource resource = (CDOResource)transaction.getResourceSet().getResource(
- CDOURIUtil.createResourceURI(transaction, getResourcePath("/test1")), true);
- assertNotNull(resource);
- assertEquals(URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
- resource.getURI());
- assertEquals(transaction.getResourceSet(), resource.getResourceSet());
- assertEquals(1, transaction.getResourceSet().getResources().size());
- assertEquals(CDOState.CLEAN, resource.cdoState());
- assertEquals(transaction, resource.cdoView());
- assertNotNull(resource.cdoRevision());
- }
- }
-
- public void testGetContents() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- {
- disableConsole();
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- msg("Committing");
- transaction.commit();
- enableConsole();
- }
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Getting resource");
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- msg("Getting contents");
- EList<EObject> contents = resource.getContents();
- assertNotNull(contents);
-
- Supplier supplier = (Supplier)contents.get(0);
- assertEquals("Stepper", supplier.getName());
- }
-
- public void testReadObjectProxy() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- {
- disableConsole();
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- msg("Committing");
- transaction.commit();
- enableConsole();
- }
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Getting resource");
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- msg("Getting contents");
- EList<EObject> contents = resource.getContents();
-
- msg("Getting supplier");
- Supplier s = (Supplier)contents.get(0);
- assertNotNull(s);
-
- msg("Verifying name");
- assertEquals("Stepper", s.getName());
- }
-
- public void testReadTransientValue() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- {
- disableConsole();
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Product1 product = getModel1Factory().createProduct1();
-
- msg("Setting name");
- product.setDescription("DESCRIPTION");
- product.setName("McDuff");
-
- msg("Adding supplier");
- resource.getContents().add(product);
-
- assertEquals("DESCRIPTION", product.getDescription());
-
- msg("Committing");
- transaction.commit();
- enableConsole();
- }
-
- msg("Opening transaction");
- CDOView view = session.openView();
-
- msg("Getting resource");
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- msg("Getting contents");
- EList<EObject> contents = resource.getContents();
-
- msg("Getting supplier");
- Product1 s = (Product1)contents.get(0);
- assertNotNull(s);
-
- msg("Verifying name");
- assertEquals("McDuff", s.getName());
-
- assertNull(s.getDescription());
-
- s.setDescription("HELLO");
-
- assertEquals("HELLO", s.getDescription());
- }
-
- public void testLoadResource() throws Exception
- {
- {
- // disableConsole();
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- msg("Committing");
- transaction.commit();
- // XXX session.close();
- // enableConsole();
- }
-
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Getting resource");
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
- assertNotNull(resource);
-
- URI uri = URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1"));
- URI resourceURI = resource.getURI();
- assertEquals(uri, resourceURI);
- assertEquals(transaction.getResourceSet(), resource.getResourceSet());
- assertEquals(CDOState.CLEAN, resource.cdoState());
- assertEquals(transaction, resource.cdoView());
- assertNotNull(resource.cdoRevision());
- }
-
- public void testLoadObject() throws Exception
- {
- {
- // disableConsole();
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- msg("Committing");
- transaction.commit();
- // XXX session.close();
- enableConsole();
- }
-
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Getting resource");
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- msg("Getting contents");
- EList<EObject> contents = resource.getContents();
-
- msg("Getting supplier");
- Supplier s = (Supplier)contents.get(0);
- assertNotNull(s);
-
- msg("Verifying name");
- assertEquals("Stepper", s.getName());
- }
-
- /**
- * bug 226317
- */
- public void testMultipleInheritence() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- OrderAddress orderAddress = getModel1Factory().createOrderAddress();
- resource.getContents().add(orderAddress);
-
- assertEquals(getModel1Package().getAddress_City().getFeatureID(), getModel1Package().getOrderDetail_Price()
- .getFeatureID());
-
- orderAddress.setCity("ALLO");
- orderAddress.setPrice(2.8f);
- orderAddress.setTestAttribute(true);
-
- assertEquals(2.8f, orderAddress.getPrice());
- assertEquals("ALLO", orderAddress.getCity());
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- resource.getContents().add(orderDetail);
- orderDetail.setPrice(3f);
-
- transaction.commit();
-
- orderAddress.setCity("ALLO");
-
- transaction.commit();
- session.close();
-
- session = openSession();
-
- msg("Opening transaction");
- transaction = session.openTransaction();
- orderAddress = (OrderAddress)CDOUtil.getEObject(transaction.getObject(CDOUtil.getCDOObject(orderAddress).cdoID(),
- true));
-
- assertEquals(2.8f, orderAddress.getPrice());
- assertEquals("ALLO", orderAddress.getCity());
-
- orderAddress.setPrice(2.8f);
- transaction.commit();
- session.close();
-
- session = openSession();
-
- transaction = session.openTransaction();
- orderAddress = (OrderAddress)CDOUtil.getEObject(transaction.getObject(CDOUtil.getCDOObject(orderAddress).cdoID(),
- true));
-
- assertEquals(2.8f, orderAddress.getPrice());
- assertEquals("ALLO", orderAddress.getCity());
-
- orderAddress.setPrice(2.8f);
-
- session.close();
- }
-
- public void testNullReference() throws Exception
- {
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating orderDetail");
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
-
- msg("Setting price");
- orderDetail.setPrice(4.75f);
-
- msg("Adding orderDetail");
- resource.getContents().add(orderDetail);
-
- msg("Committing");
- transaction.commit();
- session.close();
- }
-
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Getting resource");
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- msg("Getting contents");
- EList<EObject> contents = resource.getContents();
-
- msg("Getting supplier");
- OrderDetail orderDetail = (OrderDetail)contents.get(0);
- assertNotNull(orderDetail);
-
- msg("Verifying price");
- assertEquals(4.75f, orderDetail.getPrice());
-
- msg("Verifying product");
- assertEquals(null, orderDetail.getProduct());
- }
-
- public void testDirectResourceEMF() throws Exception
- {
- Resource resource1 = new XMLResourceImpl();
-
- EPackage p = EcoreFactory.eINSTANCE.createEPackage();
- EClass c = EcoreFactory.eINSTANCE.createEClass();
-
- resource1.getContents().add(p);
- p.getEClassifiers().add(c);
-
- assertEquals(null, ((InternalEObject)c).eDirectResource());
- assertEquals(resource1, ((InternalEObject)p).eDirectResource());
- }
-
- public void testDirectResource() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
- // Resource resource1 = new XMIResourceImpl();
-
- Category cat1 = getModel1Factory().createCategory();
- assertTransient(cat1);
-
- Category cat2 = getModel1Factory().createCategory();
- assertTransient(cat2);
-
- // resource1.getContents().add(cat2);
- resource1.getContents().add(cat1);
- cat1.getCategories().add(cat2);
-
- assertEquals(null, CDOUtil.getCDOObject(cat2).cdoDirectResource());
- assertEquals(resource1, CDOUtil.getCDOObject(cat1).cdoDirectResource());
- assertEquals(null, ((InternalEObject)cat2).eDirectResource());
- assertEquals(resource1, ((InternalEObject)cat1).eDirectResource());
-
- transaction.close();
- session.close();
- }
-
- public void testResourceAccessor() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Creating supplier");
- Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
- supplier.setName("Stepper");
-
- msg("Adding supplier");
- resource.getContents().add(supplier);
-
- URI supplierTempURI = EcoreUtil.getURI(supplier);
-
- msg("Retrieving supplier from URI before commit");
- EObject supplier1 = transaction.getResourceSet().getEObject(supplierTempURI, true);
-
- assertEquals(supplier, CDOUtil.getEObject(supplier1));
-
- msg("Committing");
- transaction.commit();
-
- URI supplierURI = EcoreUtil.getURI(supplier);
-
- msg("Retrieving supplier from URI after commit");
- EObject supplierFromURI = transaction.getResourceSet().getEObject(supplierURI, true);
-
- assertEquals(supplier, CDOUtil.getEObject(supplierFromURI));
-
- EObject supplierAfterCommit2 = transaction.getResourceSet().getEObject(supplierTempURI, true);
- if (session.getRepositoryInfo().getIDGenerationLocation() == IDGenerationLocation.STORE)
- {
- assertEquals(null, supplierAfterCommit2);
- }
- else
- {
- assertEquals(supplier, supplierAfterCommit2);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.OrderAddress;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.internal.cdo.session.SessionUtil;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
+
+import java.util.Date;
+
+/**
+ * @author Eike Stepper
+ */
+public class InitialTest extends AbstractCDOTest
+{
+ public void testTransientObject() throws Exception
+ {
+ final Date date = new Date();
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+ assertTransient(supplier);
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+ assertTransient(supplier);
+
+ msg("Verifying name");
+ assertEquals("Stepper", supplier.getName());
+ assertTransient(supplier);
+
+ msg("Creating purchaseOrder");
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ assertTransient(purchaseOrder);
+
+ msg("Setting date");
+ purchaseOrder.setDate(date);
+ assertTransient(purchaseOrder);
+
+ msg("Verifying date");
+ assertEquals(date, purchaseOrder.getDate());
+ assertTransient(purchaseOrder);
+
+ msg("Setting supplier");
+ purchaseOrder.setSupplier(supplier);
+ assertTransient(supplier);
+ assertTransient(purchaseOrder);
+
+ msg("Verifying supplier");
+ assertEquals(supplier, purchaseOrder.getSupplier());
+ assertTransient(supplier);
+ assertTransient(purchaseOrder);
+ }
+
+ public void testTransientResource() throws Exception
+ {
+ final URI uri = URI.createURI("cdo:/test1");
+
+ msg("Creating resourceSet");
+ ResourceSet resourceSet = new ResourceSetImpl();
+ SessionUtil.prepareResourceSet(resourceSet);
+
+ msg("Creating resource");
+ CDOResource resource = (CDOResource)resourceSet.createResource(uri);
+ assertTransient(resource);
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+ assertTransient(supplier);
+ assertEquals(null, supplier.eContainer());
+
+ msg("Verifying contents");
+ EList<EObject> contents = resource.getContents();
+ assertNotNull(contents);
+ assertEquals(true, contents.isEmpty());
+ assertEquals(0, contents.size());
+ assertTransient(resource);
+
+ msg("Adding supplier");
+ contents.add(supplier);
+ assertTransient(resource);
+ assertTransient(supplier);
+ assertContent(resource, supplier);
+
+ assertEquals(true, resourceSet.getResources().contains(resource));
+ resource.delete(null);
+ assertEquals(false, resourceSet.getResources().contains(resource));
+ assertTransient(supplier);
+ }
+
+ public void testOpenSession() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+ assertNotNull(session);
+ assertEquals(false, session.isClosed());
+ assertEquals(RepositoryConfig.REPOSITORY_NAME, session.getRepositoryInfo().getName());
+ assertEquals(RepositoryConfig.REPOSITORY_NAME, session.getRepositoryInfo().getUUID());
+ }
+
+ public void testStartTransaction() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+ assertNotNull(transaction);
+ assertEquals(session, transaction.getSession());
+ }
+
+ public void testAttachResource() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ assertNew(resource, transaction);
+ assertEquals(URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
+ resource.getURI());
+ ResourceSet expected = transaction.getResourceSet();
+ ResourceSet actual = resource.getResourceSet();
+ assertEquals(expected, actual);
+ }
+
+ public void testAttachObject() throws Exception
+ {
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Getting contents");
+ EList<EObject> contents = resource.getContents();
+
+ msg("Adding supplier");
+ contents.add(supplier);
+ assertNew(supplier, transaction);
+ assertEquals(transaction, CDOUtil.getCDOObject(supplier).cdoView());
+ assertEquals(resource, CDOUtil.getCDOObject(supplier).cdoDirectResource());
+ assertEquals(0, CDOUtil.getCDOObject(supplier).cdoRevision().getVersion());
+ assertEquals(resource, supplier.eResource());
+ assertEquals(null, supplier.eContainer());
+ }
+
+ public void testCommitNew() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ msg("Committing");
+ CDOCommitInfo commit = transaction.commit();
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(supplier).cdoState());
+ assertEquals(1, CDOUtil.getCDOObject(supplier).cdoRevision().getVersion());
+ assertCreatedTime(resource, commit.getTimeStamp());
+ assertCreatedTime(supplier, commit.getTimeStamp());
+ }
+
+ public void testReadResourceClean() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ msg("Committing");
+ long commitTime = transaction.commit().getTimeStamp();
+
+ msg("Getting supplier");
+ EList<EObject> contents = resource.getContents();
+ Supplier s = (Supplier)contents.get(0);
+ assertEquals(1, CDOUtil.getCDOObject(s).cdoRevision().getVersion());
+ assertEquals(supplier, s);
+ assertCreatedTime(s, commitTime);
+ }
+
+ public void testReadObjectClean() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ msg("Committing");
+ transaction.commit();
+
+ msg("Getting supplier");
+ Supplier s = (Supplier)resource.getContents().get(0);
+ assertEquals(1, CDOUtil.getCDOObject(s).cdoRevision().getVersion());
+
+ msg("Verifying name");
+ assertEquals("Stepper", s.getName());
+ }
+
+ public void testWriteClean() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ msg("Committing");
+ transaction.commit();
+
+ msg("Getting supplier");
+ Supplier s = (Supplier)resource.getContents().get(0);
+
+ msg("Setting name");
+ s.setName("Eike");
+ assertEquals("Eike", s.getName());
+ assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(supplier).cdoState());
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ }
+
+ public void testCommitDirty() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+
+ resource.getContents().add(supplier);
+
+ CDOCommitInfo commit = transaction.commit();
+ long commitTime1 = commit.getTimeStamp();
+ assertCreatedTime(supplier, commitTime1);
+
+ supplier.setName("Eike");
+
+ long commitTime2 = transaction.commit().getTimeStamp();
+ assertEquals(true, commitTime1 < commitTime2);
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(supplier).cdoState());
+ assertCreatedTime(supplier, commitTime2);
+ }
+
+ public void testGetResource() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ {
+ disableConsole();
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ msg("Committing");
+ transaction.commit();
+ enableConsole();
+ }
+
+ {
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Getting resource");
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"), true);
+ assertNotNull(resource);
+ assertEquals(URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
+ resource.getURI());
+ assertEquals(transaction.getResourceSet(), resource.getResourceSet());
+ assertEquals(1, transaction.getResourceSet().getResources().size());
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ assertEquals(transaction, resource.cdoView());
+ assertNotNull(resource.cdoRevision());
+ }
+
+ {
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Getting resource");
+ CDOResource resource = (CDOResource)transaction.getResourceSet().getResource(
+ CDOURIUtil.createResourceURI(transaction, getResourcePath("/test1")), true);
+ assertNotNull(resource);
+ assertEquals(URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
+ resource.getURI());
+ assertEquals(transaction.getResourceSet(), resource.getResourceSet());
+ assertEquals(1, transaction.getResourceSet().getResources().size());
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ assertEquals(transaction, resource.cdoView());
+ assertNotNull(resource.cdoRevision());
+ }
+ }
+
+ public void testGetContents() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ {
+ disableConsole();
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ msg("Committing");
+ transaction.commit();
+ enableConsole();
+ }
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Getting resource");
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ msg("Getting contents");
+ EList<EObject> contents = resource.getContents();
+ assertNotNull(contents);
+
+ Supplier supplier = (Supplier)contents.get(0);
+ assertEquals("Stepper", supplier.getName());
+ }
+
+ public void testReadObjectProxy() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ {
+ disableConsole();
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ msg("Committing");
+ transaction.commit();
+ enableConsole();
+ }
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Getting resource");
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ msg("Getting contents");
+ EList<EObject> contents = resource.getContents();
+
+ msg("Getting supplier");
+ Supplier s = (Supplier)contents.get(0);
+ assertNotNull(s);
+
+ msg("Verifying name");
+ assertEquals("Stepper", s.getName());
+ }
+
+ public void testReadTransientValue() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ {
+ disableConsole();
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Product1 product = getModel1Factory().createProduct1();
+
+ msg("Setting name");
+ product.setDescription("DESCRIPTION");
+ product.setName("McDuff");
+
+ msg("Adding supplier");
+ resource.getContents().add(product);
+
+ assertEquals("DESCRIPTION", product.getDescription());
+
+ msg("Committing");
+ transaction.commit();
+ enableConsole();
+ }
+
+ msg("Opening transaction");
+ CDOView view = session.openView();
+
+ msg("Getting resource");
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ msg("Getting contents");
+ EList<EObject> contents = resource.getContents();
+
+ msg("Getting supplier");
+ Product1 s = (Product1)contents.get(0);
+ assertNotNull(s);
+
+ msg("Verifying name");
+ assertEquals("McDuff", s.getName());
+
+ assertNull(s.getDescription());
+
+ s.setDescription("HELLO");
+
+ assertEquals("HELLO", s.getDescription());
+ }
+
+ public void testLoadResource() throws Exception
+ {
+ {
+ // disableConsole();
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ msg("Committing");
+ transaction.commit();
+ // XXX session.close();
+ // enableConsole();
+ }
+
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Getting resource");
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+ assertNotNull(resource);
+
+ URI uri = URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1"));
+ URI resourceURI = resource.getURI();
+ assertEquals(uri, resourceURI);
+ assertEquals(transaction.getResourceSet(), resource.getResourceSet());
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ assertEquals(transaction, resource.cdoView());
+ assertNotNull(resource.cdoRevision());
+ }
+
+ public void testLoadObject() throws Exception
+ {
+ {
+ // disableConsole();
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ msg("Committing");
+ transaction.commit();
+ // XXX session.close();
+ enableConsole();
+ }
+
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Getting resource");
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ msg("Getting contents");
+ EList<EObject> contents = resource.getContents();
+
+ msg("Getting supplier");
+ Supplier s = (Supplier)contents.get(0);
+ assertNotNull(s);
+
+ msg("Verifying name");
+ assertEquals("Stepper", s.getName());
+ }
+
+ /**
+ * bug 226317
+ */
+ public void testMultipleInheritence() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ OrderAddress orderAddress = getModel1Factory().createOrderAddress();
+ resource.getContents().add(orderAddress);
+
+ assertEquals(getModel1Package().getAddress_City().getFeatureID(), getModel1Package().getOrderDetail_Price()
+ .getFeatureID());
+
+ orderAddress.setCity("ALLO");
+ orderAddress.setPrice(2.8f);
+ orderAddress.setTestAttribute(true);
+
+ assertEquals(2.8f, orderAddress.getPrice());
+ assertEquals("ALLO", orderAddress.getCity());
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ resource.getContents().add(orderDetail);
+ orderDetail.setPrice(3f);
+
+ transaction.commit();
+
+ orderAddress.setCity("ALLO");
+
+ transaction.commit();
+ session.close();
+
+ session = openSession();
+
+ msg("Opening transaction");
+ transaction = session.openTransaction();
+ orderAddress = (OrderAddress)CDOUtil.getEObject(transaction.getObject(CDOUtil.getCDOObject(orderAddress).cdoID(),
+ true));
+
+ assertEquals(2.8f, orderAddress.getPrice());
+ assertEquals("ALLO", orderAddress.getCity());
+
+ orderAddress.setPrice(2.8f);
+ transaction.commit();
+ session.close();
+
+ session = openSession();
+
+ transaction = session.openTransaction();
+ orderAddress = (OrderAddress)CDOUtil.getEObject(transaction.getObject(CDOUtil.getCDOObject(orderAddress).cdoID(),
+ true));
+
+ assertEquals(2.8f, orderAddress.getPrice());
+ assertEquals("ALLO", orderAddress.getCity());
+
+ orderAddress.setPrice(2.8f);
+
+ session.close();
+ }
+
+ public void testNullReference() throws Exception
+ {
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating orderDetail");
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+
+ msg("Setting price");
+ orderDetail.setPrice(4.75f);
+
+ msg("Adding orderDetail");
+ resource.getContents().add(orderDetail);
+
+ msg("Committing");
+ transaction.commit();
+ session.close();
+ }
+
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Getting resource");
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ msg("Getting contents");
+ EList<EObject> contents = resource.getContents();
+
+ msg("Getting supplier");
+ OrderDetail orderDetail = (OrderDetail)contents.get(0);
+ assertNotNull(orderDetail);
+
+ msg("Verifying price");
+ assertEquals(4.75f, orderDetail.getPrice());
+
+ msg("Verifying product");
+ assertEquals(null, orderDetail.getProduct());
+ }
+
+ public void testDirectResourceEMF() throws Exception
+ {
+ Resource resource1 = new XMLResourceImpl();
+
+ EPackage p = EcoreFactory.eINSTANCE.createEPackage();
+ EClass c = EcoreFactory.eINSTANCE.createEClass();
+
+ resource1.getContents().add(p);
+ p.getEClassifiers().add(c);
+
+ assertEquals(null, ((InternalEObject)c).eDirectResource());
+ assertEquals(resource1, ((InternalEObject)p).eDirectResource());
+ }
+
+ public void testDirectResource() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
+ // Resource resource1 = new XMIResourceImpl();
+
+ Category cat1 = getModel1Factory().createCategory();
+ assertTransient(cat1);
+
+ Category cat2 = getModel1Factory().createCategory();
+ assertTransient(cat2);
+
+ // resource1.getContents().add(cat2);
+ resource1.getContents().add(cat1);
+ cat1.getCategories().add(cat2);
+
+ assertEquals(null, CDOUtil.getCDOObject(cat2).cdoDirectResource());
+ assertEquals(resource1, CDOUtil.getCDOObject(cat1).cdoDirectResource());
+ assertEquals(null, ((InternalEObject)cat2).eDirectResource());
+ assertEquals(resource1, ((InternalEObject)cat1).eDirectResource());
+
+ transaction.close();
+ session.close();
+ }
+
+ public void testResourceAccessor() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Creating supplier");
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ msg("Setting name");
+ supplier.setName("Stepper");
+
+ msg("Adding supplier");
+ resource.getContents().add(supplier);
+
+ URI supplierTempURI = EcoreUtil.getURI(supplier);
+
+ msg("Retrieving supplier from URI before commit");
+ EObject supplier1 = transaction.getResourceSet().getEObject(supplierTempURI, true);
+
+ assertEquals(supplier, CDOUtil.getEObject(supplier1));
+
+ msg("Committing");
+ transaction.commit();
+
+ URI supplierURI = EcoreUtil.getURI(supplier);
+
+ msg("Retrieving supplier from URI after commit");
+ EObject supplierFromURI = transaction.getResourceSet().getEObject(supplierURI, true);
+
+ assertEquals(supplier, CDOUtil.getEObject(supplierFromURI));
+
+ EObject supplierAfterCommit2 = transaction.getResourceSet().getEObject(supplierTempURI, true);
+ if (session.getRepositoryInfo().getIDGenerationLocation() == IDGenerationLocation.STORE)
+ {
+ assertEquals(null, supplierAfterCommit2);
+ }
+ else
+ {
+ assertEquals(supplier, supplierAfterCommit2);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java
index 65235ef1e7..05987c36bc 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java
@@ -1,822 +1,822 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.InvalidObjectException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.view.CDOViewImpl;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.spi.cdo.FSMUtil;
-
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Eike Stepper
- */
-public class InvalidationTest extends AbstractCDOTest
-{
- public void testSeparateView() throws Exception
- {
- final CDOSession session = openSession();
-
- // ************************************************************* //
-
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- final Category category2A = getModel1Factory().createCategory();
- category2A.setName("category2");
-
- final Category category3A = getModel1Factory().createCategory();
- category3A.setName("category3");
-
- final Company companyA = getModel1Factory().createCompany();
-
- companyA.getCategories().add(category1A);
- category1A.getCategories().add(category2A);
- category2A.getCategories().add(category3A);
-
- final CDOTransaction transaction = session.openTransaction();
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(companyA);
- transaction.commit();
-
- // ************************************************************* //
-
- final CDOView view = session.openTransaction();
-
- final CDOResource resourceB = view.getResource(getResourcePath("/test1"));
- assertProxy(resourceB);
-
- EList<EObject> contents = resourceB.getContents();
- final Company companyB = (Company)contents.get(0);
- assertClean(companyB, view);
- assertClean(resourceB, view);
- assertContent(resourceB, companyB);
-
- final Category category1B = companyB.getCategories().get(0);
- assertClean(category1B, view);
- assertClean(companyB, view);
- assertContent(companyB, category1B);
-
- final Category category2B = category1B.getCategories().get(0);
- assertClean(category2B, view);
- assertClean(category1B, view);
- assertContent(category1B, category2B);
-
- final Category category3B = category2B.getCategories().get(0);
- assertClean(category3B, view);
- assertClean(category2B, view);
- assertContent(category2B, category3B);
- assertClean(category3B, view);
-
- // ************************************************************* //
-
- category1A.setName("CHANGED NAME");
- assertEquals("category1", category1B.getName());
- transaction.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- String name = category1B.getName();
- return "CHANGED NAME".equals(name);
- }
- }.assertNoTimeOut();
- }
-
- public void testSeparateViewNotification() throws Exception
- {
- final CDOSession session = openSession();
-
- // ************************************************************* //
-
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- final Category category2A = getModel1Factory().createCategory();
- category2A.setName("category2");
-
- final Category category3A = getModel1Factory().createCategory();
- category3A.setName("category3");
-
- final Company companyA = getModel1Factory().createCompany();
-
- companyA.getCategories().add(category1A);
- category1A.getCategories().add(category2A);
- category2A.getCategories().add(category3A);
-
- final CDOTransaction transaction = session.openTransaction();
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(companyA);
- transaction.commit();
-
- // ************************************************************* //
-
- final CDOView viewB = session.openTransaction();
- final CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
- assertProxy(resourceB);
-
- EList<EObject> contents = resourceB.getContents();
- final Company companyB = (Company)contents.get(0);
- assertClean(companyB, viewB);
- assertClean(resourceB, viewB);
- assertContent(resourceB, companyB);
-
- final Category category1B = companyB.getCategories().get(0);
- assertClean(category1B, viewB);
- assertClean(companyB, viewB);
- assertContent(companyB, category1B);
-
- final Category category2B = category1B.getCategories().get(0);
- assertClean(category2B, viewB);
- assertClean(category1B, viewB);
- assertContent(category1B, category2B);
-
- final Category category3B = category2B.getCategories().get(0);
- assertClean(category3B, viewB);
- assertClean(category2B, viewB);
- assertContent(category2B, category3B);
- assertClean(category3B, viewB);
-
- // ************************************************************* //
-
- final CountDownLatch latch = new CountDownLatch(1);
- viewB.getSession().addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOSessionInvalidationEvent)
- {
- CDOSessionInvalidationEvent e = (CDOSessionInvalidationEvent)event;
- if (e.getLocalTransaction() == transaction)
- {
- msg("CDOSessionInvalidationEvent: " + e);
- latch.countDown();
- }
- }
- }
- });
-
- category1A.setName("CHANGED NAME");
- transaction.commit();
-
- boolean notified = latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- assertEquals(true, notified);
- }
-
- public void testConflictSameSession() throws Exception, IOException
- {
- CDOSession session = openSession();
- CDOTransaction trans1 = session.openTransaction();
- CDOTransaction trans2 = session.openTransaction();
- testConflict(trans1, trans2);
- }
-
- public void testConflictDifferentSession() throws Exception, IOException
- {
- CDOSession session1 = openSession();
- CDOTransaction trans1 = session1.openTransaction();
-
- CDOSession session2 = openSession();
- CDOTransaction trans2 = session2.openTransaction();
-
- testConflict(trans1, trans2);
- }
-
- private void testConflict(CDOTransaction trans1, CDOTransaction trans2) throws Exception
- {
- final CDOResource res1 = trans1.getOrCreateResource(getResourcePath("/test"));
- trans1.commit();
-
- final CDOResource res2 = trans2.getOrCreateResource(getResourcePath("/test"));
-
- final Customer customerA1 = getModel1Factory().createCustomer();
- res1.getContents().add(customerA1);
-
- final Customer customerB2 = getModel1Factory().createCustomer();
- res2.getContents().add(customerB2);
-
- trans1.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return CDOUtil.getCDOObject(res2).cdoState() == CDOState.CONFLICT;
- }
- }.assertNoTimeOut();
-
- final Customer customerA2 = getModel1Factory().createCustomer();
- res1.getContents().add(customerA2);
- trans1.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return CDOUtil.getCDOObject(res2).cdoState() == CDOState.CONFLICT;
- }
- }.assertNoTimeOut();
-
- trans2.rollback();
- assertEquals(2, res1.getContents().size());
- }
-
- public void testDetachedConflictSameSession() throws Exception, IOException
- {
- CDOSession session = openSession();
- CDOTransaction trans1 = session.openTransaction();
- CDOTransaction trans2 = session.openTransaction();
- testDetachedConflict(trans1, trans2);
- }
-
- public void testDetachedConflictDifferentSession() throws Exception, IOException
- {
- CDOSession session1 = openSession();
- CDOTransaction trans1 = session1.openTransaction();
-
- CDOSession session2 = openSession();
- CDOTransaction trans2 = session2.openTransaction();
-
- testDetachedConflict(trans1, trans2);
- }
-
- private void testDetachedConflict(CDOTransaction trans1, CDOTransaction trans2) throws Exception
- {
- final CDOResource res1 = trans1.getOrCreateResource(getResourcePath("/test"));
- trans1.commit();
-
- final CDOResource res2 = trans2.getResource(getResourcePath("/test"));
-
- res1.delete(null);
-
- res2.getContents().add(getModel1Factory().createCustomer());
- assertEquals(true, res2.isExisting());
-
- commitAndSync(trans1, trans2);
- assertEquals(CDOState.INVALID_CONFLICT, CDOUtil.getCDOObject(res2).cdoState());
-
- trans2.rollback();
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(res2).cdoState());
- assertEquals(false, res2.isExisting());
-
- try
- {
- res2.getContents().get(0);
- fail("InvalidObjectException expected");
- }
- catch (InvalidObjectException expected)
- {
- // SUCCESS
- }
- }
-
- public void testSeparateSession() throws Exception
- {
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- final Category category2A = getModel1Factory().createCategory();
- category2A.setName("category2");
-
- final Category category3A = getModel1Factory().createCategory();
- category3A.setName("category3");
-
- final Company companyA = getModel1Factory().createCompany();
- companyA.getCategories().add(category1A);
- category1A.getCategories().add(category2A);
- category2A.getCategories().add(category3A);
-
- final CDOSession sessionA = openSession();
- final CDOTransaction transaction = sessionA.openTransaction();
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(companyA);
- transaction.commit();
-
- // ************************************************************* //
-
- final CDOSession sessionB = openSession();
- final CDOView viewB = sessionB.openTransaction();
- final CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
- assertProxy(resourceB);
-
- EList<EObject> contents = resourceB.getContents();
- final Company companyB = (Company)contents.get(0);
- assertClean(companyB, viewB);
- assertClean(resourceB, viewB);
- assertContent(resourceB, companyB);
-
- final Category category1B = companyB.getCategories().get(0);
- assertClean(category1B, viewB);
- assertClean(companyB, viewB);
- assertContent(companyB, category1B);
-
- final Category category2B = category1B.getCategories().get(0);
- assertClean(category2B, viewB);
- assertClean(category1B, viewB);
- assertContent(category1B, category2B);
-
- final Category category3B = category2B.getCategories().get(0);
- assertClean(category3B, viewB);
- assertClean(category2B, viewB);
- assertContent(category2B, category3B);
- assertClean(category3B, viewB);
-
- // ************************************************************* //
-
- category1A.setName("CHANGED NAME");
- transaction.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return "CHANGED NAME".equals(category1B.getName());
- }
- }.assertNoTimeOut();
- }
-
- /**
- * See bug 236784
- */
- public void testInvalidateAndCache() throws Exception
- {
- msg("Opening sessionA");
- CDOSession sessionA = openSession();
-
- msg("Opening transactionA");
- final CDOTransaction transactionA = sessionA.openTransaction();
- final CDOID cdoidA;
-
- // *************************************************************
- {
- msg("Creating categoryA");
- Category categoryA = getModel1Factory().createCategory();
- categoryA.setName("categoryA");
-
- msg("Creating companyA");
- Company companyA = getModel1Factory().createCompany();
-
- msg("Adding categories");
- companyA.getCategories().add(categoryA);
-
- msg("Creating resource");
- CDOResource resourceA = transactionA.createResource(getResourcePath("/test1"));
-
- msg("Adding companyA");
- resourceA.getContents().add(companyA);
-
- msg("Committing");
- transactionA.commit();
-
- cdoidA = CDOUtil.getCDOObject(categoryA).cdoID();
- ((CDOViewImpl)transactionA).removeObject(cdoidA);
- }
-
- // *************************************************************
- msg("Opening sessionB");
- CDOSession sessionB = openSession();
-
- msg("Opening transactionB");
- CDOTransaction transactionB = sessionB.openTransaction();
- Category categoryB;
-
- categoryB = (Category)CDOUtil.getEObject(transactionB.getObject(cdoidA, true));
- msg("Changing name");
- categoryB.setName("CHANGED NAME");
-
- msg("\n\n\n\n\n\n\n\n\n\n\nCommitting");
- transactionB.commit();
-
- msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- Category categoryA = (Category)CDOUtil.getEObject(transactionA.getObject(cdoidA, true));
- String name = categoryA.getName();
- return "CHANGED NAME".equals(name);
- }
- }.assertNoTimeOut();
- }
-
- public void testRefreshEmptyRepository() throws Exception
- {
- CDOSession session = openSession();
- assertEquals(0, session.refresh());
- session.close();
- }
-
- public void testSeparateSession_PassiveUpdateDisable() throws Exception
- {
- Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- Category category2A = getModel1Factory().createCategory();
- category2A.setName("category2");
-
- Category category3A = getModel1Factory().createCategory();
- category3A.setName("category3");
-
- Company companyA = getModel1Factory().createCompany();
- companyA.getCategories().add(category1A);
-
- category1A.getCategories().add(category2A);
- category2A.getCategories().add(category3A);
-
- CDOSession sessionA = openSession();
- CDOTransaction transaction = sessionA.openTransaction();
- CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(companyA);
-
- transaction.commit();
- URI uriCategory1 = EcoreUtil.getURI(category1A);
-
- // ************************************************************* //
-
- CDOSession sessionB = openSession();
- sessionB.options().setPassiveUpdateEnabled(false);
-
- CDOView viewB = sessionB.openTransaction();
- final Category category1B = (Category)viewB.getResourceSet().getEObject(uriCategory1, true);
-
- // ************************************************************* //
-
- category1A.setName("CHANGED NAME");
- transaction.commit();
-
- sessionB.refresh();
-
- // TODO Why poll? refresh is synchonous...
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return "CHANGED NAME".equals(category1B.getName());
- }
- }.assertNoTimeOut();
- }
-
- public void testPassiveUpdateOnAndOff() throws Exception
- {
- msg("Creating category1");
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- msg("Creating category2");
- final Category category2A = getModel1Factory().createCategory();
- category2A.setName("category2");
-
- msg("Creating category3");
- final Category category3A = getModel1Factory().createCategory();
- category3A.setName("category3");
-
- msg("Creating company");
- final Company companyA = getModel1Factory().createCompany();
-
- msg("Adding categories");
- companyA.getCategories().add(category1A);
- category1A.getCategories().add(category2A);
- category2A.getCategories().add(category3A);
-
- msg("Opening sessionA");
- final CDOSession sessionA = openSession();
-
- msg("Attaching transaction");
- final CDOTransaction transaction = sessionA.openTransaction();
-
- msg("Creating resource");
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resourceA.getContents().add(companyA);
-
- msg("Committing");
- transaction.commit();
-
- URI uriCategory1 = EcoreUtil.getURI(category1A);
- // ************************************************************* //
-
- msg("Opening sessionB");
- final CDOSession sessionB = openSession();
-
- sessionB.options().setPassiveUpdateEnabled(false);
-
- msg("Attaching viewB");
- final CDOView viewB = sessionB.openTransaction();
-
- final Category category1B = (Category)viewB.getResourceSet().getEObject(uriCategory1, true);
-
- // ************************************************************* //
- msg("Opening sessionB");
- final CDOSession sessionC = openSession();
-
- assertEquals(true, sessionC.options().isPassiveUpdateEnabled());
-
- msg("Attaching viewB");
- final CDOView viewC = sessionC.openTransaction();
-
- final Category category1C = (Category)viewC.getResourceSet().getEObject(uriCategory1, true);
-
- msg("Changing name");
- category1A.setName("CHANGED NAME");
-
- class TimeOuterB extends PollingTimeOuter
- {
- @Override
- protected boolean successful()
- {
- return "CHANGED NAME".equals(category1B.getName());
- }
- }
-
- class TimeOuterC extends PollingTimeOuter
- {
- @Override
- protected boolean successful()
- {
- return "CHANGED NAME".equals(category1C.getName());
- }
- }
-
- transaction.commit();
-
- new TimeOuterC().assertNoTimeOut();
-
- // It should refresh the session
- sessionB.options().setPassiveUpdateEnabled(true);
-
- msg("Checking after sync");
- new TimeOuterB().assertNoTimeOut();
- new TimeOuterC().assertNoTimeOut();
-
- category1A.setName("CHANGED NAME-VERSION2");
-
- class TimeOuterB_2 extends PollingTimeOuter
- {
- @Override
- protected boolean successful()
- {
- return "CHANGED NAME-VERSION2".equals(category1B.getName());
- }
- }
-
- class TimeOuterC_2 extends PollingTimeOuter
- {
- @Override
- protected boolean successful()
- {
- return "CHANGED NAME-VERSION2".equals(category1C.getName());
- }
- }
-
- transaction.commit();
-
- new TimeOuterB_2().assertNoTimeOut();
- new TimeOuterC_2().assertNoTimeOut();
- }
-
- public void testDetach() throws Exception
- {
- final Category categoryA = getModel1Factory().createCategory();
- categoryA.setName("category1");
-
- final CDOSession sessionA = openSession();
- final CDOTransaction transaction = sessionA.openTransaction();
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- resourceA.getContents().add(categoryA);
- transaction.commit();
-
- // ************************************************************* //
-
- final CDOSession sessionB = openSession();
- final CDOView viewB = sessionB.openTransaction();
- viewB.options().setInvalidationNotificationEnabled(true);
-
- final CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
- assertProxy(resourceB);
-
- EList<EObject> contents = resourceB.getContents();
- final Category categoryB = (Category)contents.get(0);
- final TestAdapter testAdapter = new TestAdapter();
- categoryB.eAdapters().add(testAdapter);
-
- // ************************************************************* //
-
- resourceA.getContents().remove(categoryA);
- assertEquals(0, testAdapter.getNotifications().length);
-
- transaction.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return FSMUtil.isInvalid(CDOUtil.getCDOObject(categoryB));
- }
- }.assertNoTimeOut();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
- }
-
- public void testDetachAndPassiveUpdate() throws Exception
- {
- detachAndPassiveUpdate(false);
- }
-
- public void testDetachAndPassiveUpdateWithoutRevisionTimestamp() throws Exception
- {
- detachAndPassiveUpdate(true);
- }
-
- private void detachAndPassiveUpdate(boolean isRemoveRevision) throws Exception
- {
- msg("Creating category1");
- final Category categoryA = getModel1Factory().createCategory();
- categoryA.setName("category1");
-
- msg("Opening sessionA");
- final CDOSession sessionA = openSession();
-
- msg("Attaching transaction");
- final CDOTransaction transaction = sessionA.openTransaction();
-
- msg("Creating resource");
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- msg("Adding company");
- resourceA.getContents().add(categoryA);
-
- msg("Committing");
- transaction.commit();
-
- // ************************************************************* //
-
- msg("Opening sessionB");
- final CDOSession sessionB = openSession();
- sessionB.options().setPassiveUpdateEnabled(false);
-
- msg("Attaching viewB");
- final CDOView viewB = sessionB.openTransaction();
- viewB.options().setInvalidationNotificationEnabled(true);
-
- msg("Loading resource");
- final CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
- assertProxy(resourceB);
-
- EList<EObject> contents = resourceB.getContents();
- final Category categoryB = (Category)contents.get(0);
-
- final TestAdapter testAdapter = new TestAdapter();
- categoryB.eAdapters().add(testAdapter);
-
- // ************************************************************* //
-
- resourceA.getContents().remove(categoryA);
- assertEquals(0, testAdapter.getNotifications().length);
-
- transaction.commit();
-
- final Category categoryA2 = getModel1Factory().createCategory();
- categoryA2.setName("categoryA2");
- resourceA.getContents().add(categoryA2);
- transaction.commit();
-
- if (isRemoveRevision)
- {
- clearCache(getRepository().getRevisionManager());
- getRepository().getRevisionManager().getCache()
- .removeRevision(resourceA.cdoID(), resourceA.cdoRevision().getBranch().getVersion(1));
- getRepository().getRevisionManager().getCache()
- .removeRevision(resourceA.cdoID(), resourceA.cdoRevision().getBranch().getVersion(2));
- }
-
- assertEquals(0, testAdapter.getNotifications().length);
- sessionB.refresh();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return FSMUtil.isInvalid(CDOUtil.getCDOObject(categoryB));
- }
- }.assertNoTimeOut();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
- }
-
- public void testPassiveUpdateMode_CHANGES() throws Exception
- {
- Category categoryA = getModel1Factory().createCategory();
- categoryA.setName("category1");
-
- CDOSession sessionA = openSession();
- CDOTransaction transaction = sessionA.openTransaction();
- CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- resourceA.getContents().add(categoryA);
- transaction.commit();
-
- // ************************************************************* //
-
- CDOSession sessionB = openSession();
- sessionB.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
-
- CDOView viewB = sessionB.openTransaction();
- CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
-
- Category categoryB = (Category)resourceB.getContents().get(0);
-
- final TestAdapter testAdapter = new TestAdapter();
- categoryB.eAdapters().add(testAdapter);
-
- // ************************************************************* //
-
- categoryA.setName("CHANGED");
- assertEquals(0, testAdapter.getNotifications().length);
- transaction.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- Notification[] notifications = testAdapter.getNotifications();
- if (notifications.length != 0)
- {
- if (!ObjectUtil.equals(notifications[0].getOldStringValue(), "category1"))
- {
- fail("No old value");
- }
-
- if (!ObjectUtil.equals(notifications[0].getNewStringValue(), "CHANGED"))
- {
- fail("No new value");
- }
-
- return true;
- }
-
- return false;
- }
- }.assertNoTimeOut();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.InvalidObjectException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.internal.cdo.view.CDOViewImpl;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.spi.cdo.FSMUtil;
+
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Eike Stepper
+ */
+public class InvalidationTest extends AbstractCDOTest
+{
+ public void testSeparateView() throws Exception
+ {
+ final CDOSession session = openSession();
+
+ // ************************************************************* //
+
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ final Category category2A = getModel1Factory().createCategory();
+ category2A.setName("category2");
+
+ final Category category3A = getModel1Factory().createCategory();
+ category3A.setName("category3");
+
+ final Company companyA = getModel1Factory().createCompany();
+
+ companyA.getCategories().add(category1A);
+ category1A.getCategories().add(category2A);
+ category2A.getCategories().add(category3A);
+
+ final CDOTransaction transaction = session.openTransaction();
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(companyA);
+ transaction.commit();
+
+ // ************************************************************* //
+
+ final CDOView view = session.openTransaction();
+
+ final CDOResource resourceB = view.getResource(getResourcePath("/test1"));
+ assertProxy(resourceB);
+
+ EList<EObject> contents = resourceB.getContents();
+ final Company companyB = (Company)contents.get(0);
+ assertClean(companyB, view);
+ assertClean(resourceB, view);
+ assertContent(resourceB, companyB);
+
+ final Category category1B = companyB.getCategories().get(0);
+ assertClean(category1B, view);
+ assertClean(companyB, view);
+ assertContent(companyB, category1B);
+
+ final Category category2B = category1B.getCategories().get(0);
+ assertClean(category2B, view);
+ assertClean(category1B, view);
+ assertContent(category1B, category2B);
+
+ final Category category3B = category2B.getCategories().get(0);
+ assertClean(category3B, view);
+ assertClean(category2B, view);
+ assertContent(category2B, category3B);
+ assertClean(category3B, view);
+
+ // ************************************************************* //
+
+ category1A.setName("CHANGED NAME");
+ assertEquals("category1", category1B.getName());
+ transaction.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ String name = category1B.getName();
+ return "CHANGED NAME".equals(name);
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testSeparateViewNotification() throws Exception
+ {
+ final CDOSession session = openSession();
+
+ // ************************************************************* //
+
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ final Category category2A = getModel1Factory().createCategory();
+ category2A.setName("category2");
+
+ final Category category3A = getModel1Factory().createCategory();
+ category3A.setName("category3");
+
+ final Company companyA = getModel1Factory().createCompany();
+
+ companyA.getCategories().add(category1A);
+ category1A.getCategories().add(category2A);
+ category2A.getCategories().add(category3A);
+
+ final CDOTransaction transaction = session.openTransaction();
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(companyA);
+ transaction.commit();
+
+ // ************************************************************* //
+
+ final CDOView viewB = session.openTransaction();
+ final CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
+ assertProxy(resourceB);
+
+ EList<EObject> contents = resourceB.getContents();
+ final Company companyB = (Company)contents.get(0);
+ assertClean(companyB, viewB);
+ assertClean(resourceB, viewB);
+ assertContent(resourceB, companyB);
+
+ final Category category1B = companyB.getCategories().get(0);
+ assertClean(category1B, viewB);
+ assertClean(companyB, viewB);
+ assertContent(companyB, category1B);
+
+ final Category category2B = category1B.getCategories().get(0);
+ assertClean(category2B, viewB);
+ assertClean(category1B, viewB);
+ assertContent(category1B, category2B);
+
+ final Category category3B = category2B.getCategories().get(0);
+ assertClean(category3B, viewB);
+ assertClean(category2B, viewB);
+ assertContent(category2B, category3B);
+ assertClean(category3B, viewB);
+
+ // ************************************************************* //
+
+ final CountDownLatch latch = new CountDownLatch(1);
+ viewB.getSession().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOSessionInvalidationEvent)
+ {
+ CDOSessionInvalidationEvent e = (CDOSessionInvalidationEvent)event;
+ if (e.getLocalTransaction() == transaction)
+ {
+ msg("CDOSessionInvalidationEvent: " + e);
+ latch.countDown();
+ }
+ }
+ }
+ });
+
+ category1A.setName("CHANGED NAME");
+ transaction.commit();
+
+ boolean notified = latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ assertEquals(true, notified);
+ }
+
+ public void testConflictSameSession() throws Exception, IOException
+ {
+ CDOSession session = openSession();
+ CDOTransaction trans1 = session.openTransaction();
+ CDOTransaction trans2 = session.openTransaction();
+ testConflict(trans1, trans2);
+ }
+
+ public void testConflictDifferentSession() throws Exception, IOException
+ {
+ CDOSession session1 = openSession();
+ CDOTransaction trans1 = session1.openTransaction();
+
+ CDOSession session2 = openSession();
+ CDOTransaction trans2 = session2.openTransaction();
+
+ testConflict(trans1, trans2);
+ }
+
+ private void testConflict(CDOTransaction trans1, CDOTransaction trans2) throws Exception
+ {
+ final CDOResource res1 = trans1.getOrCreateResource(getResourcePath("/test"));
+ trans1.commit();
+
+ final CDOResource res2 = trans2.getOrCreateResource(getResourcePath("/test"));
+
+ final Customer customerA1 = getModel1Factory().createCustomer();
+ res1.getContents().add(customerA1);
+
+ final Customer customerB2 = getModel1Factory().createCustomer();
+ res2.getContents().add(customerB2);
+
+ trans1.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return CDOUtil.getCDOObject(res2).cdoState() == CDOState.CONFLICT;
+ }
+ }.assertNoTimeOut();
+
+ final Customer customerA2 = getModel1Factory().createCustomer();
+ res1.getContents().add(customerA2);
+ trans1.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return CDOUtil.getCDOObject(res2).cdoState() == CDOState.CONFLICT;
+ }
+ }.assertNoTimeOut();
+
+ trans2.rollback();
+ assertEquals(2, res1.getContents().size());
+ }
+
+ public void testDetachedConflictSameSession() throws Exception, IOException
+ {
+ CDOSession session = openSession();
+ CDOTransaction trans1 = session.openTransaction();
+ CDOTransaction trans2 = session.openTransaction();
+ testDetachedConflict(trans1, trans2);
+ }
+
+ public void testDetachedConflictDifferentSession() throws Exception, IOException
+ {
+ CDOSession session1 = openSession();
+ CDOTransaction trans1 = session1.openTransaction();
+
+ CDOSession session2 = openSession();
+ CDOTransaction trans2 = session2.openTransaction();
+
+ testDetachedConflict(trans1, trans2);
+ }
+
+ private void testDetachedConflict(CDOTransaction trans1, CDOTransaction trans2) throws Exception
+ {
+ final CDOResource res1 = trans1.getOrCreateResource(getResourcePath("/test"));
+ trans1.commit();
+
+ final CDOResource res2 = trans2.getResource(getResourcePath("/test"));
+
+ res1.delete(null);
+
+ res2.getContents().add(getModel1Factory().createCustomer());
+ assertEquals(true, res2.isExisting());
+
+ commitAndSync(trans1, trans2);
+ assertEquals(CDOState.INVALID_CONFLICT, CDOUtil.getCDOObject(res2).cdoState());
+
+ trans2.rollback();
+ assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(res2).cdoState());
+ assertEquals(false, res2.isExisting());
+
+ try
+ {
+ res2.getContents().get(0);
+ fail("InvalidObjectException expected");
+ }
+ catch (InvalidObjectException expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ public void testSeparateSession() throws Exception
+ {
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ final Category category2A = getModel1Factory().createCategory();
+ category2A.setName("category2");
+
+ final Category category3A = getModel1Factory().createCategory();
+ category3A.setName("category3");
+
+ final Company companyA = getModel1Factory().createCompany();
+ companyA.getCategories().add(category1A);
+ category1A.getCategories().add(category2A);
+ category2A.getCategories().add(category3A);
+
+ final CDOSession sessionA = openSession();
+ final CDOTransaction transaction = sessionA.openTransaction();
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(companyA);
+ transaction.commit();
+
+ // ************************************************************* //
+
+ final CDOSession sessionB = openSession();
+ final CDOView viewB = sessionB.openTransaction();
+ final CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
+ assertProxy(resourceB);
+
+ EList<EObject> contents = resourceB.getContents();
+ final Company companyB = (Company)contents.get(0);
+ assertClean(companyB, viewB);
+ assertClean(resourceB, viewB);
+ assertContent(resourceB, companyB);
+
+ final Category category1B = companyB.getCategories().get(0);
+ assertClean(category1B, viewB);
+ assertClean(companyB, viewB);
+ assertContent(companyB, category1B);
+
+ final Category category2B = category1B.getCategories().get(0);
+ assertClean(category2B, viewB);
+ assertClean(category1B, viewB);
+ assertContent(category1B, category2B);
+
+ final Category category3B = category2B.getCategories().get(0);
+ assertClean(category3B, viewB);
+ assertClean(category2B, viewB);
+ assertContent(category2B, category3B);
+ assertClean(category3B, viewB);
+
+ // ************************************************************* //
+
+ category1A.setName("CHANGED NAME");
+ transaction.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return "CHANGED NAME".equals(category1B.getName());
+ }
+ }.assertNoTimeOut();
+ }
+
+ /**
+ * See bug 236784
+ */
+ public void testInvalidateAndCache() throws Exception
+ {
+ msg("Opening sessionA");
+ CDOSession sessionA = openSession();
+
+ msg("Opening transactionA");
+ final CDOTransaction transactionA = sessionA.openTransaction();
+ final CDOID cdoidA;
+
+ // *************************************************************
+ {
+ msg("Creating categoryA");
+ Category categoryA = getModel1Factory().createCategory();
+ categoryA.setName("categoryA");
+
+ msg("Creating companyA");
+ Company companyA = getModel1Factory().createCompany();
+
+ msg("Adding categories");
+ companyA.getCategories().add(categoryA);
+
+ msg("Creating resource");
+ CDOResource resourceA = transactionA.createResource(getResourcePath("/test1"));
+
+ msg("Adding companyA");
+ resourceA.getContents().add(companyA);
+
+ msg("Committing");
+ transactionA.commit();
+
+ cdoidA = CDOUtil.getCDOObject(categoryA).cdoID();
+ ((CDOViewImpl)transactionA).removeObject(cdoidA);
+ }
+
+ // *************************************************************
+ msg("Opening sessionB");
+ CDOSession sessionB = openSession();
+
+ msg("Opening transactionB");
+ CDOTransaction transactionB = sessionB.openTransaction();
+ Category categoryB;
+
+ categoryB = (Category)CDOUtil.getEObject(transactionB.getObject(cdoidA, true));
+ msg("Changing name");
+ categoryB.setName("CHANGED NAME");
+
+ msg("\n\n\n\n\n\n\n\n\n\n\nCommitting");
+ transactionB.commit();
+
+ msg("Checking after commit");
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ Category categoryA = (Category)CDOUtil.getEObject(transactionA.getObject(cdoidA, true));
+ String name = categoryA.getName();
+ return "CHANGED NAME".equals(name);
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testRefreshEmptyRepository() throws Exception
+ {
+ CDOSession session = openSession();
+ assertEquals(0, session.refresh());
+ session.close();
+ }
+
+ public void testSeparateSession_PassiveUpdateDisable() throws Exception
+ {
+ Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ Category category2A = getModel1Factory().createCategory();
+ category2A.setName("category2");
+
+ Category category3A = getModel1Factory().createCategory();
+ category3A.setName("category3");
+
+ Company companyA = getModel1Factory().createCompany();
+ companyA.getCategories().add(category1A);
+
+ category1A.getCategories().add(category2A);
+ category2A.getCategories().add(category3A);
+
+ CDOSession sessionA = openSession();
+ CDOTransaction transaction = sessionA.openTransaction();
+ CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(companyA);
+
+ transaction.commit();
+ URI uriCategory1 = EcoreUtil.getURI(category1A);
+
+ // ************************************************************* //
+
+ CDOSession sessionB = openSession();
+ sessionB.options().setPassiveUpdateEnabled(false);
+
+ CDOView viewB = sessionB.openTransaction();
+ final Category category1B = (Category)viewB.getResourceSet().getEObject(uriCategory1, true);
+
+ // ************************************************************* //
+
+ category1A.setName("CHANGED NAME");
+ transaction.commit();
+
+ sessionB.refresh();
+
+ // TODO Why poll? refresh is synchonous...
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return "CHANGED NAME".equals(category1B.getName());
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testPassiveUpdateOnAndOff() throws Exception
+ {
+ msg("Creating category1");
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ msg("Creating category2");
+ final Category category2A = getModel1Factory().createCategory();
+ category2A.setName("category2");
+
+ msg("Creating category3");
+ final Category category3A = getModel1Factory().createCategory();
+ category3A.setName("category3");
+
+ msg("Creating company");
+ final Company companyA = getModel1Factory().createCompany();
+
+ msg("Adding categories");
+ companyA.getCategories().add(category1A);
+ category1A.getCategories().add(category2A);
+ category2A.getCategories().add(category3A);
+
+ msg("Opening sessionA");
+ final CDOSession sessionA = openSession();
+
+ msg("Attaching transaction");
+ final CDOTransaction transaction = sessionA.openTransaction();
+
+ msg("Creating resource");
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resourceA.getContents().add(companyA);
+
+ msg("Committing");
+ transaction.commit();
+
+ URI uriCategory1 = EcoreUtil.getURI(category1A);
+ // ************************************************************* //
+
+ msg("Opening sessionB");
+ final CDOSession sessionB = openSession();
+
+ sessionB.options().setPassiveUpdateEnabled(false);
+
+ msg("Attaching viewB");
+ final CDOView viewB = sessionB.openTransaction();
+
+ final Category category1B = (Category)viewB.getResourceSet().getEObject(uriCategory1, true);
+
+ // ************************************************************* //
+ msg("Opening sessionB");
+ final CDOSession sessionC = openSession();
+
+ assertEquals(true, sessionC.options().isPassiveUpdateEnabled());
+
+ msg("Attaching viewB");
+ final CDOView viewC = sessionC.openTransaction();
+
+ final Category category1C = (Category)viewC.getResourceSet().getEObject(uriCategory1, true);
+
+ msg("Changing name");
+ category1A.setName("CHANGED NAME");
+
+ class TimeOuterB extends PollingTimeOuter
+ {
+ @Override
+ protected boolean successful()
+ {
+ return "CHANGED NAME".equals(category1B.getName());
+ }
+ }
+
+ class TimeOuterC extends PollingTimeOuter
+ {
+ @Override
+ protected boolean successful()
+ {
+ return "CHANGED NAME".equals(category1C.getName());
+ }
+ }
+
+ transaction.commit();
+
+ new TimeOuterC().assertNoTimeOut();
+
+ // It should refresh the session
+ sessionB.options().setPassiveUpdateEnabled(true);
+
+ msg("Checking after sync");
+ new TimeOuterB().assertNoTimeOut();
+ new TimeOuterC().assertNoTimeOut();
+
+ category1A.setName("CHANGED NAME-VERSION2");
+
+ class TimeOuterB_2 extends PollingTimeOuter
+ {
+ @Override
+ protected boolean successful()
+ {
+ return "CHANGED NAME-VERSION2".equals(category1B.getName());
+ }
+ }
+
+ class TimeOuterC_2 extends PollingTimeOuter
+ {
+ @Override
+ protected boolean successful()
+ {
+ return "CHANGED NAME-VERSION2".equals(category1C.getName());
+ }
+ }
+
+ transaction.commit();
+
+ new TimeOuterB_2().assertNoTimeOut();
+ new TimeOuterC_2().assertNoTimeOut();
+ }
+
+ public void testDetach() throws Exception
+ {
+ final Category categoryA = getModel1Factory().createCategory();
+ categoryA.setName("category1");
+
+ final CDOSession sessionA = openSession();
+ final CDOTransaction transaction = sessionA.openTransaction();
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ resourceA.getContents().add(categoryA);
+ transaction.commit();
+
+ // ************************************************************* //
+
+ final CDOSession sessionB = openSession();
+ final CDOView viewB = sessionB.openTransaction();
+ viewB.options().setInvalidationNotificationEnabled(true);
+
+ final CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
+ assertProxy(resourceB);
+
+ EList<EObject> contents = resourceB.getContents();
+ final Category categoryB = (Category)contents.get(0);
+ final TestAdapter testAdapter = new TestAdapter();
+ categoryB.eAdapters().add(testAdapter);
+
+ // ************************************************************* //
+
+ resourceA.getContents().remove(categoryA);
+ assertEquals(0, testAdapter.getNotifications().length);
+
+ transaction.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return FSMUtil.isInvalid(CDOUtil.getCDOObject(categoryB));
+ }
+ }.assertNoTimeOut();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testDetachAndPassiveUpdate() throws Exception
+ {
+ detachAndPassiveUpdate(false);
+ }
+
+ public void testDetachAndPassiveUpdateWithoutRevisionTimestamp() throws Exception
+ {
+ detachAndPassiveUpdate(true);
+ }
+
+ private void detachAndPassiveUpdate(boolean isRemoveRevision) throws Exception
+ {
+ msg("Creating category1");
+ final Category categoryA = getModel1Factory().createCategory();
+ categoryA.setName("category1");
+
+ msg("Opening sessionA");
+ final CDOSession sessionA = openSession();
+
+ msg("Attaching transaction");
+ final CDOTransaction transaction = sessionA.openTransaction();
+
+ msg("Creating resource");
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Adding company");
+ resourceA.getContents().add(categoryA);
+
+ msg("Committing");
+ transaction.commit();
+
+ // ************************************************************* //
+
+ msg("Opening sessionB");
+ final CDOSession sessionB = openSession();
+ sessionB.options().setPassiveUpdateEnabled(false);
+
+ msg("Attaching viewB");
+ final CDOView viewB = sessionB.openTransaction();
+ viewB.options().setInvalidationNotificationEnabled(true);
+
+ msg("Loading resource");
+ final CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
+ assertProxy(resourceB);
+
+ EList<EObject> contents = resourceB.getContents();
+ final Category categoryB = (Category)contents.get(0);
+
+ final TestAdapter testAdapter = new TestAdapter();
+ categoryB.eAdapters().add(testAdapter);
+
+ // ************************************************************* //
+
+ resourceA.getContents().remove(categoryA);
+ assertEquals(0, testAdapter.getNotifications().length);
+
+ transaction.commit();
+
+ final Category categoryA2 = getModel1Factory().createCategory();
+ categoryA2.setName("categoryA2");
+ resourceA.getContents().add(categoryA2);
+ transaction.commit();
+
+ if (isRemoveRevision)
+ {
+ clearCache(getRepository().getRevisionManager());
+ getRepository().getRevisionManager().getCache()
+ .removeRevision(resourceA.cdoID(), resourceA.cdoRevision().getBranch().getVersion(1));
+ getRepository().getRevisionManager().getCache()
+ .removeRevision(resourceA.cdoID(), resourceA.cdoRevision().getBranch().getVersion(2));
+ }
+
+ assertEquals(0, testAdapter.getNotifications().length);
+ sessionB.refresh();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return FSMUtil.isInvalid(CDOUtil.getCDOObject(categoryB));
+ }
+ }.assertNoTimeOut();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testPassiveUpdateMode_CHANGES() throws Exception
+ {
+ Category categoryA = getModel1Factory().createCategory();
+ categoryA.setName("category1");
+
+ CDOSession sessionA = openSession();
+ CDOTransaction transaction = sessionA.openTransaction();
+ CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ resourceA.getContents().add(categoryA);
+ transaction.commit();
+
+ // ************************************************************* //
+
+ CDOSession sessionB = openSession();
+ sessionB.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+
+ CDOView viewB = sessionB.openTransaction();
+ CDOResource resourceB = viewB.getResource(getResourcePath("/test1"));
+
+ Category categoryB = (Category)resourceB.getContents().get(0);
+
+ final TestAdapter testAdapter = new TestAdapter();
+ categoryB.eAdapters().add(testAdapter);
+
+ // ************************************************************* //
+
+ categoryA.setName("CHANGED");
+ assertEquals(0, testAdapter.getNotifications().length);
+ transaction.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ Notification[] notifications = testAdapter.getNotifications();
+ if (notifications.length != 0)
+ {
+ if (!ObjectUtil.equals(notifications[0].getOldStringValue(), "category1"))
+ {
+ fail("No old value");
+ }
+
+ if (!ObjectUtil.equals(notifications[0].getNewStringValue(), "CHANGED"))
+ {
+ fail("No new value");
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+ }.assertNoTimeOut();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LegacyTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LegacyTest.java
index f4190c7998..b803f01455 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LegacyTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LegacyTest.java
@@ -1,56 +1,56 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Martin Fluegge - recreation of the test case
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
-
-/**
- * @author Eike Stepper
- */
-public class LegacyTest extends AbstractCDOTest
-{
- public void testLegacyModeEnabled() throws Exception
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("Martin Fluegge");
- customer.setStreet("ABC Street 7");
- customer.setCity("Berlin");
-
- CDOSession session = openSession();
- CDOUtil.setLegacyModeDefault(false);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- try
- {
- resource.getContents().add(customer);
- transaction.commit();
-
- if (isConfig(LEGACY))
- {
- fail("LegacyModeNotEnabledException expected");
- }
- }
- catch (LegacyModeNotEnabledException ex)
- {
- if (!isConfig(LEGACY))
- {
- fail("Native mode should not throw an exception here (" + ex.getMessage() + ")");
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Martin Fluegge - recreation of the test case
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
+
+/**
+ * @author Eike Stepper
+ */
+public class LegacyTest extends AbstractCDOTest
+{
+ public void testLegacyModeEnabled() throws Exception
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("Martin Fluegge");
+ customer.setStreet("ABC Street 7");
+ customer.setCity("Berlin");
+
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(false);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ try
+ {
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ if (isConfig(LEGACY))
+ {
+ fail("LegacyModeNotEnabledException expected");
+ }
+ }
+ catch (LegacyModeNotEnabledException ex)
+ {
+ if (!isConfig(LEGACY))
+ {
+ fail("Native mode should not throw an exception here (" + ex.getMessage() + ")");
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LobTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LobTest.java
index 40fbd793d9..5dd368daed 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LobTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LobTest.java
@@ -1,156 +1,156 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.lob.CDOBlob;
-import org.eclipse.emf.cdo.common.lob.CDOClob;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.CDOLobStoreImpl;
-import org.eclipse.emf.cdo.tests.bundle.OM;
-import org.eclipse.emf.cdo.tests.model3.File;
-import org.eclipse.emf.cdo.tests.model3.Image;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.HexUtil;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-
-/**
- * @author Eike Stepper
- */
-public class LobTest extends AbstractCDOTest
-{
- private byte[] lobID;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- skipStoreWithoutLargeObjects();
- lobID = null;
- }
-
- public void testCommitBlob() throws Exception
- {
- InputStream inputStream = null;
-
- try
- {
- inputStream = OM.BUNDLE.getInputStream("copyright.txt");
- CDOBlob blob = new CDOBlob(inputStream);
-
- Image image = getModel3Factory().createImage();
- image.setWidth(320);
- image.setHeight(200);
- image.setData(blob);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("res"));
- resource.getContents().add(image);
-
- transaction.commit();
-
- lobID = blob.getID();
- }
- finally
- {
- IOUtil.close(inputStream);
- }
- }
-
- @CleanRepositoriesBefore
- public void testReadBlob() throws Exception
- {
- testCommitBlob();
- new java.io.File(CDOLobStoreImpl.INSTANCE.getFolder(), HexUtil.bytesToHex(lobID) + ".blob").delete();
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("res"));
-
- Image image = (Image)resource.getContents().get(0);
- assertEquals(320, image.getWidth());
- assertEquals(200, image.getHeight());
-
- CDOBlob blob = image.getData();
- InputStream inputStream = blob.getContents();
-
- try
- {
- IOUtil.copyBinary(inputStream, System.out);
- }
- finally
- {
- IOUtil.close(inputStream);
- }
- }
-
- public void testCommitClob() throws Exception
- {
- InputStream inputStream = null;
-
- try
- {
- inputStream = OM.BUNDLE.getInputStream("copyright.txt");
- CDOClob clob = new CDOClob(new InputStreamReader(inputStream));
-
- File file = getModel3Factory().createFile();
- file.setName("copyright.txt");
- file.setData(clob);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("res"));
- resource.getContents().add(file);
-
- transaction.commit();
-
- lobID = clob.getID();
- }
- finally
- {
- IOUtil.close(inputStream);
- }
- }
-
- @CleanRepositoriesBefore
- public void testReadClob() throws Exception
- {
- testCommitClob();
- new java.io.File(CDOLobStoreImpl.INSTANCE.getFolder(), HexUtil.bytesToHex(lobID) + ".clob").delete();
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("res"));
-
- File file = (File)resource.getContents().get(0);
- assertEquals("copyright.txt", file.getName());
-
- CDOClob clob = file.getData();
- Reader reader = clob.getContents();
-
- try
- {
- IOUtil.copyCharacter(reader, new OutputStreamWriter(System.out));
- }
- finally
- {
- IOUtil.close(reader);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.lob.CDOBlob;
+import org.eclipse.emf.cdo.common.lob.CDOClob;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.CDOLobStoreImpl;
+import org.eclipse.emf.cdo.tests.bundle.OM;
+import org.eclipse.emf.cdo.tests.model3.File;
+import org.eclipse.emf.cdo.tests.model3.Image;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.HexUtil;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+
+/**
+ * @author Eike Stepper
+ */
+public class LobTest extends AbstractCDOTest
+{
+ private byte[] lobID;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ skipStoreWithoutLargeObjects();
+ lobID = null;
+ }
+
+ public void testCommitBlob() throws Exception
+ {
+ InputStream inputStream = null;
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOBlob blob = new CDOBlob(inputStream);
+
+ Image image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+ image.setData(blob);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+ resource.getContents().add(image);
+
+ transaction.commit();
+
+ lobID = blob.getID();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testReadBlob() throws Exception
+ {
+ testCommitBlob();
+ new java.io.File(CDOLobStoreImpl.INSTANCE.getFolder(), HexUtil.bytesToHex(lobID) + ".blob").delete();
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("res"));
+
+ Image image = (Image)resource.getContents().get(0);
+ assertEquals(320, image.getWidth());
+ assertEquals(200, image.getHeight());
+
+ CDOBlob blob = image.getData();
+ InputStream inputStream = blob.getContents();
+
+ try
+ {
+ IOUtil.copyBinary(inputStream, System.out);
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+
+ public void testCommitClob() throws Exception
+ {
+ InputStream inputStream = null;
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOClob clob = new CDOClob(new InputStreamReader(inputStream));
+
+ File file = getModel3Factory().createFile();
+ file.setName("copyright.txt");
+ file.setData(clob);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+ resource.getContents().add(file);
+
+ transaction.commit();
+
+ lobID = clob.getID();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testReadClob() throws Exception
+ {
+ testCommitClob();
+ new java.io.File(CDOLobStoreImpl.INSTANCE.getFolder(), HexUtil.bytesToHex(lobID) + ".clob").delete();
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("res"));
+
+ File file = (File)resource.getContents().get(0);
+ assertEquals("copyright.txt", file.getName());
+
+ CDOClob clob = file.getData();
+ Reader reader = clob.getContents();
+
+ try
+ {
+ IOUtil.copyCharacter(reader, new OutputStreamWriter(System.out));
+ }
+ finally
+ {
+ IOUtil.close(reader);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartRepositoryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartRepositoryTest.java
index 0e1a911c35..96676ec43b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartRepositoryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartRepositoryTest.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.server.ILockingManager.DurableViewHandler;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-
-/**
- * @author Eike Stepper
- */
-@Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
-public class LockingManagerRestartRepositoryTest extends LockingManagerRestartSessionTest
-{
- @Override
- protected void doBetweenSessionCloseAndOpen()
- {
- DurableViewHandler[] handlers = getRepository().getLockingManager().getDurableViewHandlers();
- restartRepository();
-
- for (DurableViewHandler handler : handlers)
- {
- getRepository().getLockingManager().addDurableViewHandler(handler);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.server.ILockingManager.DurableViewHandler;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+
+/**
+ * @author Eike Stepper
+ */
+@Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
+public class LockingManagerRestartRepositoryTest extends LockingManagerRestartSessionTest
+{
+ @Override
+ protected void doBetweenSessionCloseAndOpen()
+ {
+ DurableViewHandler[] handlers = getRepository().getLockingManager().getDurableViewHandlers();
+ restartRepository();
+
+ for (DurableViewHandler handler : handlers)
+ {
+ getRepository().getLockingManager().addDurableViewHandler(handler);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartSessionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartSessionTest.java
index 40e86866dc..d544808e50 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartSessionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartSessionTest.java
@@ -1,30 +1,30 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-/**
- * @author Eike Stepper
- */
-public class LockingManagerRestartSessionTest extends LockingManagerRestartTransactionTest
-{
- @Override
- protected void restart(String durableLockingID)
- {
- session.close();
- doBetweenSessionCloseAndOpen();
- session = openSession();
- super.restart(durableLockingID);
- }
-
- protected void doBetweenSessionCloseAndOpen()
- {
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+/**
+ * @author Eike Stepper
+ */
+public class LockingManagerRestartSessionTest extends LockingManagerRestartTransactionTest
+{
+ @Override
+ protected void restart(String durableLockingID)
+ {
+ session.close();
+ doBetweenSessionCloseAndOpen();
+ session = openSession();
+ super.restart(durableLockingID);
+ }
+
+ protected void doBetweenSessionCloseAndOpen()
+ {
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartTransactionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartTransactionTest.java
index 93db7380bf..cade1e3437 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartTransactionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerRestartTransactionTest.java
@@ -1,403 +1,403 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockAreaNotFoundException;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.ILockingManager;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-/**
- * @author Eike Stepper
- */
-public class LockingManagerRestartTransactionTest extends AbstractLockingTest
-{
- protected CDOSession session;
-
- protected CDOTransaction transaction;
-
- protected CDOResource resource;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
-
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.createResource(getResourcePath("/res1"));
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- LifecycleUtil.deactivate(session);
- super.doTearDown();
- }
-
- protected void restart(String durableLockingID)
- {
- transaction.close();
- transaction = session.openTransaction(durableLockingID);
- resource = transaction.getOrCreateResource(getResourcePath("/res1"));
- }
-
- public void testWrongDurableLockingID() throws Exception
- {
- try
- {
- restart("ABC");
- fail("LockAreaNotFoundException expected");
- }
- catch (LockAreaNotFoundException expected)
- {
- assertEquals("ABC", expected.getDurableLockingID());
- }
- }
-
- public void testGetDurableLockingID() throws Exception
- {
- String durableLockingID = transaction.enableDurableLocking();
- String actual = transaction.getDurableLockingID();
- assertEquals(durableLockingID, actual);
-
- restart(durableLockingID);
-
- actual = transaction.getDurableLockingID();
- assertEquals(durableLockingID, actual);
- }
-
- public void testKeepDurableLockingID() throws Exception
- {
- String durableLockingID = transaction.enableDurableLocking();
- String actual = transaction.enableDurableLocking();
- assertEquals(durableLockingID, actual);
-
- restart(durableLockingID);
-
- actual = transaction.enableDurableLocking();
- assertEquals(durableLockingID, actual);
- }
-
- public void testDisableDurableLocking() throws Exception
- {
- String durableLockingID = transaction.enableDurableLocking();
- transaction.disableDurableLocking(false);
- assertEquals(null, transaction.getDurableLockingID());
-
- try
- {
- restart(durableLockingID);
- fail("LockAreaNotFoundException expected");
- }
- catch (LockAreaNotFoundException expected)
- {
- assertEquals(durableLockingID, expected.getDurableLockingID());
- }
- }
-
- public void testDisableDurableLockingAfterRestart() throws Exception
- {
- String durableLockingID = transaction.enableDurableLocking();
- restart(durableLockingID);
-
- transaction.disableDurableLocking(false);
- assertEquals(null, transaction.getDurableLockingID());
-
- try
- {
- restart(durableLockingID);
- fail("LockAreaNotFoundException expected");
- }
- catch (LockAreaNotFoundException expected)
- {
- }
- }
-
- public void testDisableDurableLockingAndReleaseLocks() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
- readLock(company);
-
- transaction.enableDurableLocking();
- assertReadLock(true, company);
-
- transaction.disableDurableLocking(true);
- assertReadLock(false, company);
- }
-
- public void testWrongReadOnly() throws Exception
- {
- String durableLockingID = transaction.enableDurableLocking();
- transaction.close();
-
- try
- {
- session.openView(durableLockingID);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- }
- }
-
- public void testWrongReadOnlyAfterRestart() throws Exception
- {
- String durableLockingID = transaction.enableDurableLocking();
- restart(durableLockingID);
- transaction.close();
-
- try
- {
- session.openView(durableLockingID);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- }
- }
-
- public void testDuplicateOpenView() throws Exception
- {
- String durableLockingID = transaction.enableDurableLocking();
-
- try
- {
- session.openTransaction(durableLockingID);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- }
- }
-
- public void testDuplicateOpenViewAfterRestart() throws Exception
- {
- String durableLockingID = transaction.enableDurableLocking();
- restart(durableLockingID);
-
- try
- {
- session.openTransaction(durableLockingID);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- }
- }
-
- public void testReadLockAfterEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- String durableLockingID = transaction.enableDurableLocking();
- readLock(company);
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertReadLock(true, company);
- }
-
- public void testReadLockBeforeEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- readLock(company);
- String durableLockingID = transaction.enableDurableLocking();
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertReadLock(true, company);
- }
-
- public void testWriteLockAfterEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- String durableLockingID = transaction.enableDurableLocking();
- writeLock(company);
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertWriteLock(true, company);
- }
-
- public void testWriteLockBeforeEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- writeLock(company);
- String durableLockingID = transaction.enableDurableLocking();
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertWriteLock(true, company);
- }
-
- public void testWriteOptionAfterEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- String durableLockingID = transaction.enableDurableLocking();
- writeOption(company);
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertWriteOption(true, company);
- }
-
- public void testWriteOptionBeforeEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- writeOption(company);
- String durableLockingID = transaction.enableDurableLocking();
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertWriteOption(true, company);
- }
-
- public void testLockUpgradeAfterEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- String durableLockingID = transaction.enableDurableLocking();
- readLock(company);
- writeLock(company);
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertWriteLock(true, company);
- }
-
- public void testLockUpgradeBeforeEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- readLock(company);
- writeLock(company);
- String durableLockingID = transaction.enableDurableLocking();
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertWriteLock(true, company);
- }
-
- public void testLockDowngradeAfterEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- String durableLockingID = transaction.enableDurableLocking();
-
- readLock(company);
- assertReadLock(true, company);
- assertWriteLock(false, company);
-
- writeLock(company);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- writeUnlock(company);
- assertReadLock(true, company);
- assertWriteLock(false, company);
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertReadLock(true, company);
- assertWriteLock(false, company);
- }
-
- public void testLockDowngradeBeforeEnable() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- readLock(company);
- assertReadLock(true, company);
- assertWriteLock(false, company);
-
- writeLock(company);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- writeUnlock(company);
- assertReadLock(true, company);
- assertWriteLock(false, company);
- String durableLockingID = transaction.enableDurableLocking();
-
- restart(durableLockingID);
-
- company = (Company)resource.getContents().get(0);
- assertReadLock(true, company);
- assertWriteLock(false, company);
- }
-
- public void testDurableViewHandler() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- writeLock(company);
-
- String durableLockingID = transaction.enableDurableLocking();
-
- final boolean[] gotCalled = { false };
- getRepository().getLockingManager().addDurableViewHandler(new ILockingManager.DurableViewHandler()
- {
- public void openingView(CDOCommonSession session, int viewID, boolean readOnly, LockArea area)
- {
- gotCalled[0] = true;
- }
- });
-
- restart(durableLockingID);
-
- assertEquals(true, gotCalled[0]);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockAreaNotFoundException;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.ILockingManager;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class LockingManagerRestartTransactionTest extends AbstractLockingTest
+{
+ protected CDOSession session;
+
+ protected CDOTransaction transaction;
+
+ protected CDOResource resource;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.createResource(getResourcePath("/res1"));
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ LifecycleUtil.deactivate(session);
+ super.doTearDown();
+ }
+
+ protected void restart(String durableLockingID)
+ {
+ transaction.close();
+ transaction = session.openTransaction(durableLockingID);
+ resource = transaction.getOrCreateResource(getResourcePath("/res1"));
+ }
+
+ public void testWrongDurableLockingID() throws Exception
+ {
+ try
+ {
+ restart("ABC");
+ fail("LockAreaNotFoundException expected");
+ }
+ catch (LockAreaNotFoundException expected)
+ {
+ assertEquals("ABC", expected.getDurableLockingID());
+ }
+ }
+
+ public void testGetDurableLockingID() throws Exception
+ {
+ String durableLockingID = transaction.enableDurableLocking();
+ String actual = transaction.getDurableLockingID();
+ assertEquals(durableLockingID, actual);
+
+ restart(durableLockingID);
+
+ actual = transaction.getDurableLockingID();
+ assertEquals(durableLockingID, actual);
+ }
+
+ public void testKeepDurableLockingID() throws Exception
+ {
+ String durableLockingID = transaction.enableDurableLocking();
+ String actual = transaction.enableDurableLocking();
+ assertEquals(durableLockingID, actual);
+
+ restart(durableLockingID);
+
+ actual = transaction.enableDurableLocking();
+ assertEquals(durableLockingID, actual);
+ }
+
+ public void testDisableDurableLocking() throws Exception
+ {
+ String durableLockingID = transaction.enableDurableLocking();
+ transaction.disableDurableLocking(false);
+ assertEquals(null, transaction.getDurableLockingID());
+
+ try
+ {
+ restart(durableLockingID);
+ fail("LockAreaNotFoundException expected");
+ }
+ catch (LockAreaNotFoundException expected)
+ {
+ assertEquals(durableLockingID, expected.getDurableLockingID());
+ }
+ }
+
+ public void testDisableDurableLockingAfterRestart() throws Exception
+ {
+ String durableLockingID = transaction.enableDurableLocking();
+ restart(durableLockingID);
+
+ transaction.disableDurableLocking(false);
+ assertEquals(null, transaction.getDurableLockingID());
+
+ try
+ {
+ restart(durableLockingID);
+ fail("LockAreaNotFoundException expected");
+ }
+ catch (LockAreaNotFoundException expected)
+ {
+ }
+ }
+
+ public void testDisableDurableLockingAndReleaseLocks() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+ readLock(company);
+
+ transaction.enableDurableLocking();
+ assertReadLock(true, company);
+
+ transaction.disableDurableLocking(true);
+ assertReadLock(false, company);
+ }
+
+ public void testWrongReadOnly() throws Exception
+ {
+ String durableLockingID = transaction.enableDurableLocking();
+ transaction.close();
+
+ try
+ {
+ session.openView(durableLockingID);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ }
+
+ public void testWrongReadOnlyAfterRestart() throws Exception
+ {
+ String durableLockingID = transaction.enableDurableLocking();
+ restart(durableLockingID);
+ transaction.close();
+
+ try
+ {
+ session.openView(durableLockingID);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ }
+
+ public void testDuplicateOpenView() throws Exception
+ {
+ String durableLockingID = transaction.enableDurableLocking();
+
+ try
+ {
+ session.openTransaction(durableLockingID);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ }
+
+ public void testDuplicateOpenViewAfterRestart() throws Exception
+ {
+ String durableLockingID = transaction.enableDurableLocking();
+ restart(durableLockingID);
+
+ try
+ {
+ session.openTransaction(durableLockingID);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ }
+
+ public void testReadLockAfterEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ String durableLockingID = transaction.enableDurableLocking();
+ readLock(company);
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertReadLock(true, company);
+ }
+
+ public void testReadLockBeforeEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ readLock(company);
+ String durableLockingID = transaction.enableDurableLocking();
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertReadLock(true, company);
+ }
+
+ public void testWriteLockAfterEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ String durableLockingID = transaction.enableDurableLocking();
+ writeLock(company);
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertWriteLock(true, company);
+ }
+
+ public void testWriteLockBeforeEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ writeLock(company);
+ String durableLockingID = transaction.enableDurableLocking();
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertWriteLock(true, company);
+ }
+
+ public void testWriteOptionAfterEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ String durableLockingID = transaction.enableDurableLocking();
+ writeOption(company);
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertWriteOption(true, company);
+ }
+
+ public void testWriteOptionBeforeEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ writeOption(company);
+ String durableLockingID = transaction.enableDurableLocking();
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertWriteOption(true, company);
+ }
+
+ public void testLockUpgradeAfterEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ String durableLockingID = transaction.enableDurableLocking();
+ readLock(company);
+ writeLock(company);
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertWriteLock(true, company);
+ }
+
+ public void testLockUpgradeBeforeEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ readLock(company);
+ writeLock(company);
+ String durableLockingID = transaction.enableDurableLocking();
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertWriteLock(true, company);
+ }
+
+ public void testLockDowngradeAfterEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ String durableLockingID = transaction.enableDurableLocking();
+
+ readLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+
+ writeLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ writeUnlock(company);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+ }
+
+ public void testLockDowngradeBeforeEnable() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ readLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+
+ writeLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ writeUnlock(company);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+ String durableLockingID = transaction.enableDurableLocking();
+
+ restart(durableLockingID);
+
+ company = (Company)resource.getContents().get(0);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+ }
+
+ public void testDurableViewHandler() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ writeLock(company);
+
+ String durableLockingID = transaction.enableDurableLocking();
+
+ final boolean[] gotCalled = { false };
+ getRepository().getLockingManager().addDurableViewHandler(new ILockingManager.DurableViewHandler()
+ {
+ public void openingView(CDOCommonSession session, int viewID, boolean readOnly, LockArea area)
+ {
+ gotCalled[0] = true;
+ }
+ });
+
+ restart(durableLockingID);
+
+ assertEquals(true, gotCalled[0]);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
index e46df0c2e1..fa72b65359 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
@@ -1,1194 +1,1194 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- * Caspar De Groot - write options
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOLock;
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalLockManager;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.LockTimeoutException;
-import org.eclipse.emf.cdo.util.ObjectNotFoundException;
-import org.eclipse.emf.cdo.util.StaleRevisionLockException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-import org.eclipse.net4j.util.concurrent.RWOLockManager;
-import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState;
-import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Simon McDuff
- */
-public class LockingManagerTest extends AbstractLockingTest
-{
- public void testUnlockAll() throws Exception
- {
- final RWOLockManager<Integer, Integer> lockingManager = new RWOLockManager<Integer, Integer>();
-
- Set<Integer> keys = new HashSet<Integer>();
- keys.add(1);
- keys.add(2);
- keys.add(3);
-
- lockingManager.lock(LockType.READ, 1, keys, 100);
- lockingManager.unlock(1);
- }
-
- public void testWriteOptions() throws Exception
- {
- final RWOLockManager<Integer, Integer> lockingManager = new RWOLockManager<Integer, Integer>();
-
- Set<Integer> keys = new HashSet<Integer>();
- keys.add(1);
- lockingManager.lock(LockType.OPTION, 1, keys, 100);
-
- // (R=Read, W=Write, WO=WriteOption)
- // Scenario 1: 1 has WO, 2 requests W -> fail
- keys.clear();
- keys.add(1);
-
- try
- {
- lockingManager.lock(LockType.WRITE, 2, keys, 100); // Must fail
- fail("Should have thrown an exception");
- }
- catch (TimeoutRuntimeException e)
- {
- }
-
- // Scenario 2: 1 has WO, 2 requests R -> succeed
- try
- {
- lockingManager.lock(LockType.READ, 2, keys, 100); // Must succeed
- }
- catch (TimeoutRuntimeException e)
- {
- fail("Should not have thrown an exception");
- }
-
- // Scenario 3: 1 has WO, 2 has R, 1 requests W -> fail
- try
- {
- lockingManager.lock(LockType.WRITE, 1, keys, 100); // Must fail
- fail("Should have thrown an exception");
- }
- catch (TimeoutRuntimeException e)
- {
- }
-
- // Scenario 4: 1 has WO, 2 has R, 2 requests WO -> fail
- try
- {
- lockingManager.lock(LockType.OPTION, 2, keys, 100); // Must fail
- fail("Should have thrown an exception");
- }
- catch (TimeoutRuntimeException e)
- {
- }
-
- // Scenario 5: 1 has WO, 2 has nothing, 2 requests WO -> fail
- lockingManager.unlock(LockType.READ, 2, keys);
- try
- {
- lockingManager.lock(LockType.OPTION, 2, keys, 100); // Must fail
- fail("Should have thrown an exception");
- }
- catch (TimeoutRuntimeException e)
- {
- }
-
- // Scenario 6: 1 has W, 2 has nothing, 2 requests WO -> fail
- lockingManager.unlock(LockType.OPTION, 1, keys);
- lockingManager.lock(LockType.WRITE, 1, keys, 100);
- try
- {
- lockingManager.lock(LockType.OPTION, 2, keys, 100); // Must fail
- fail("Should have thrown an exception");
- }
- catch (TimeoutRuntimeException e)
- {
- }
-
- // Scenario 7: 1 has W, 1 request WO -> succeed
- try
- {
- lockingManager.lock(LockType.OPTION, 1, keys, 100); // Must succeed
- }
- catch (TimeoutRuntimeException e)
- {
- fail("Should not have thrown an exception");
- }
-
- // Scenario 8: 1 has W, 2 has R, 1 request WO -> succeed
- lockingManager.unlock(LockType.OPTION, 1, keys);
- lockingManager.lock(LockType.READ, 1, keys, 100);
- try
- {
- lockingManager.lock(LockType.OPTION, 1, keys, 100); // Must succeed
- }
- catch (TimeoutRuntimeException e)
- {
- fail("Should not have thrown an exception");
- }
- }
-
- public void testBasicUpgradeFromReadToWriteLock() throws Exception
- {
- final RWOLockManager<Integer, Integer> lockingManager = new RWOLockManager<Integer, Integer>();
-
- Runnable step1 = new Runnable()
- {
- public void run()
- {
- Set<Integer> keys = new HashSet<Integer>();
- keys.add(1);
- try
- {
- lockingManager.lock(LockType.WRITE, 1, keys, 50000);
- }
- catch (InterruptedException ex)
- {
- fail("Should not have exception");
- }
- }
- };
-
- ExecutorService executors = Executors.newFixedThreadPool(10);
- Set<Integer> keys = new HashSet<Integer>();
- keys.add(1);
- keys.add(2);
- keys.add(3);
- keys.add(4);
-
- msg("Context 1 have readlock 1,2,3,4");
- lockingManager.lock(LockType.READ, 1, keys, 1000);
- assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 1));
- assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 2));
- assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 3));
- assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 4));
-
- keys.clear();
- keys.add(1);
- keys.add(2);
- keys.add(3);
-
- msg("Context 2 have readlock 1,2,3");
- lockingManager.lock(LockType.READ, 2, keys, 1000);
- assertEquals(true, lockingManager.hasLock(LockType.READ, 2, 1));
- assertEquals(true, lockingManager.hasLock(LockType.READ, 2, 2));
- assertEquals(true, lockingManager.hasLock(LockType.READ, 2, 3));
- assertEquals(true, lockingManager.hasLockByOthers(LockType.READ, 2, 1));
- assertEquals(true, lockingManager.hasLockByOthers(LockType.READ, 1, 1));
-
- keys.clear();
- keys.add(4);
-
- msg("Context 1 have readlock 1,2,3,4 and writeLock 4");
- lockingManager.lock(LockType.WRITE, 1, keys, 1000);
- assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 4));
- assertEquals(true, lockingManager.hasLock(LockType.WRITE, 1, 4));
-
- keys.clear();
- keys.add(1);
-
- try
- {
- lockingManager.lock(LockType.WRITE, 1, keys, 1000);
- fail("Should not have exception");
- }
- catch (RuntimeException expected)
- {
- }
-
- executors.execute(step1);
- executors.execute(step1);
-
- sleep(1000);
-
- keys.clear();
- keys.add(1);
- keys.add(2);
- keys.add(3);
- lockingManager.unlock(LockType.READ, 2, keys);
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return lockingManager.hasLock(LockType.WRITE, 1, 1);
- }
- }.assertNoTimeOut();
- }
-
- public void testBasicWrongUnlock() throws Exception
- {
- final RWOLockManager<Integer, Integer> lockingManager = new RWOLockManager<Integer, Integer>();
- Set<Integer> keys = new HashSet<Integer>();
- keys.add(1);
- lockingManager.lock(LockType.READ, 1, keys, 10000);
- lockingManager.unlock(LockType.READ, 1, keys);
-
- try
- {
- lockingManager.unlock(LockType.READ, 1, keys);
- fail("Should have an exception");
- }
- catch (IllegalMonitorStateException exception)
- {
- }
- }
-
- public void testReadTimeout() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- writeLock(company);
-
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = transaction2.getObject(company);
-
- long start = System.currentTimeMillis();
- assertWriteLock(false, company2);
- assertEquals(true, System.currentTimeMillis() - start < 300);
-
- start = System.currentTimeMillis();
- assertEquals(false, CDOUtil.getCDOObject(company2).cdoWriteLock().tryLock(2, TimeUnit.SECONDS));
- assertEquals(true, System.currentTimeMillis() - start >= 2000);
- }
-
- public void testReadLockByOthers() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- readLock(company);
-
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
-
- CDOObject cdoCompany2 = CDOUtil.getCDOObject(company2);
- assertEquals(false, cdoCompany2.cdoWriteLock().isLockedByOthers());
- assertEquals(true, cdoCompany2.cdoReadLock().isLockedByOthers());
- }
-
- public void testDetachedObjects() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
- res.getContents().remove(0);
-
- transaction.commit();
-
- try
- {
- readLock(company2);
- fail("IllegalArgumentException expected");
- }
- catch (IllegalArgumentException expected)
- {
- }
-
- assertReadLock(false, company2);
- assertEquals(false, CDOUtil.getCDOObject(company2).cdoReadLock().isLockedByOthers());
- }
-
- public void testWriteLockByOthers() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- writeLock(company);
-
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
-
- CDOObject cdoCompany2 = CDOUtil.getCDOObject(company2);
- assertEquals(true, cdoCompany2.cdoWriteLock().isLockedByOthers());
- assertEquals(false, cdoCompany2.cdoReadLock().isLockedByOthers());
- }
-
- public void testWriteLock() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
-
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
- CDOObject cdoCompany2 = CDOUtil.getCDOObject(company2);
-
- transaction.lockObjects(Collections.singletonList(cdoCompany), LockType.WRITE, CDOLock.WAIT);
-
- try
- {
- transaction2.lockObjects(Collections.singletonList(cdoCompany2), LockType.WRITE, 1000);
- fail("Should have thrown an exception");
- }
- catch (LockTimeoutException ex)
- {
- }
-
- company2.setCity("Ottawa");
-
- try
- {
- transaction2.commit();
- fail("CommitException expected");
- }
- catch (CommitException exception)
- {
- }
- }
-
- public void testWriteLockViaObject() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
-
- writeLock(company);
- assertWriteLock(false, company2);
-
- company2.setCity("Ottawa");
-
- try
- {
- transaction2.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- }
- }
-
- public void testWriteLockFromDifferenceTransaction() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
-
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
- CDOObject cdoCompany2 = CDOUtil.getCDOObject(company2);
-
- transaction.lockObjects(Collections.singletonList(cdoCompany), LockType.WRITE, DEFAULT_TIMEOUT);
-
- try
- {
- transaction2.lockObjects(Collections.singletonList(cdoCompany2), LockType.WRITE, 1000);
- fail("Should have an exception");
- }
- catch (LockTimeoutException ex)
- {
- }
- }
-
- public void testWriteLockMultiple() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- List<CDOObject> objects = new ArrayList<CDOObject>();
-
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- transaction.lockObjects(objects, LockType.WRITE, DEFAULT_TIMEOUT);
-
- assertWriteLock(false, company);
- assertReadLock(false, company);
- for (CDOObject object : objects)
- {
- assertWriteLock(true, object);
- assertReadLock(false, object);
- }
- }
-
- public void testWriteUnlockMultiple() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- List<CDOObject> objects = new ArrayList<CDOObject>();
-
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- transaction.lockObjects(objects, LockType.WRITE, DEFAULT_TIMEOUT);
-
- assertWriteLock(false, company);
- assertReadLock(false, company);
- for (CDOObject object : objects)
- {
- assertWriteLock(true, object);
- assertReadLock(false, object);
- }
-
- transaction.unlockObjects(objects, LockType.WRITE);
-
- assertWriteLock(false, company);
- assertReadLock(false, company);
- for (CDOObject object : objects)
- {
- assertWriteLock(false, object);
- assertReadLock(false, object);
- }
- }
-
- public void testReadLockMultiple() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- List<CDOObject> objects = new ArrayList<CDOObject>();
-
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- transaction.lockObjects(objects, LockType.READ, DEFAULT_TIMEOUT);
-
- assertReadLock(false, company);
- assertWriteLock(false, company);
- for (CDOObject object : objects)
- {
- assertReadLock(true, object);
- assertWriteLock(false, object);
- }
- }
-
- public void testReadUnlockMultiple() throws Exception
- {
- Company company = getModel1Factory().createCompany();
- List<CDOObject> objects = new ArrayList<CDOObject>();
-
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
- addCategory(company, objects);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- transaction.lockObjects(objects, LockType.READ, DEFAULT_TIMEOUT);
-
- assertReadLock(false, company);
- assertWriteLock(false, company);
- for (CDOObject object : objects)
- {
- assertReadLock(true, object);
- assertWriteLock(false, object);
- }
-
- transaction.unlockObjects(objects, LockType.READ);
-
- assertWriteLock(false, company);
- assertReadLock(false, company);
- for (CDOObject object : objects)
- {
- assertWriteLock(false, object);
- assertReadLock(false, object);
- }
- }
-
- public void testReadLockAndCommitFromDifferentTransaction() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
-
- transaction.lockObjects(Collections.singletonList(cdoCompany), LockType.READ, DEFAULT_TIMEOUT);
- company2.setCity("Ottawa");
-
- try
- {
- transaction2.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- }
- }
-
- public void testWriteLockAndCommitFromDifferentTransaction() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
-
- transaction.lockObjects(Collections.singletonList(cdoCompany), LockType.WRITE, DEFAULT_TIMEOUT);
- company2.setCity("Ottawa");
-
- try
- {
- transaction2.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- IOUtil.print(expected);
- }
- }
-
- public void testReadLockAndCommitSameTransaction() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- readLock(company);
-
- company.setCity("Ottawa");
- transaction.commit();
- }
-
- public void testWriteLockAndCommitSameTransaction() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- writeLock(company);
-
- company.setCity("Ottawa");
- assertWriteLock(true, company);
- assertReadLock(false, company);
-
- transaction.commit();
-
- assertWriteLock(false, company);
- assertReadLock(false, company);
- }
-
- public void testWriteLockAndRollback() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- writeLock(company);
- company.setCity("Ottawa");
-
- transaction.rollback();
- assertWriteLock(false, company);
- }
-
- public void testLockUnlock() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
-
- readLock(company);
- assertReadLock(true, company);
- assertWriteLock(false, company);
-
- writeLock(company);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- readLock(company);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- writeLock(company);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- readUnlock(cdoCompany);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- readUnlock(cdoCompany);
- assertReadLock(false, company);
- assertWriteLock(true, company);
-
- writeUnlock(cdoCompany);
- assertReadLock(false, company);
- assertWriteLock(true, company);
-
- writeUnlock(cdoCompany);
- assertReadLock(false, company);
- assertWriteLock(false, company);
-
- /********************/
-
- readLock(company);
- assertReadLock(true, company);
- assertWriteLock(false, company);
-
- writeLock(company);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- readLock(company);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- writeLock(company);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- writeUnlock(cdoCompany);
- assertReadLock(true, company);
- assertWriteLock(true, company);
-
- writeUnlock(cdoCompany);
- assertReadLock(true, company);
- assertWriteLock(false, company);
-
- readUnlock(cdoCompany);
- assertReadLock(true, company);
- assertWriteLock(false, company);
-
- readUnlock(cdoCompany);
- assertReadLock(false, company);
- assertWriteLock(false, company);
- }
-
- /**
- * Bug 352191.
- */
- public void testLockDetached() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- res.getContents().remove(0);
- assertTransient(company);
-
- CDOObject cdoObject = CDOUtil.getCDOObject(company);
- transaction.lockObjects(Collections.singleton(cdoObject), LockType.WRITE, DEFAULT_TIMEOUT);
-
- // Verify
- CDOTransaction transaction2 = session.openTransaction();
- CDOResource res2 = transaction2.getResource(getResourcePath("/res1"));
- Company company2 = (Company)res2.getContents().get(0);
- company2.setName("NewName");
-
- try
- {
- transaction2.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- // SUCCESS
- }
- }
-
- public void testTransactionClose() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- InternalRepository repo = getRepository();
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
- IView view = repo.getSessionManager().getSession(session.getSessionID()).getView(transaction.getViewID());
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
- readLock(company);
- transaction.close();
- assertEquals(false, repo.getLockingManager().hasLock(LockType.READ, view, cdoCompany.cdoID()));
- }
-
- public void testSessionClose() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- InternalRepository repo = getRepository();
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
- IView view = repo.getSessionManager().getSession(session.getSessionID()).getView(transaction.getViewID());
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
- readLock(company);
- session.close();
-
- sleep(100);
- assertEquals(false, repo.getLockingManager().hasLock(LockType.READ, view, cdoCompany.cdoID()));
- }
-
- public void testBugzilla_270345() throws Exception
- {
- Company company1 = getModel1Factory().createCompany();
- Company company2 = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- CDOTransaction transaction2 = session.openTransaction();
- CDOResource res = transaction1.getOrCreateResource(getResourcePath("/res1"));
- res.getContents().add(company1);
- res.getContents().add(company2);
- transaction1.commit();
-
- writeLock(company1);
- assertWriteLock(true, company1);
-
- Company companyFrom2 = (Company)CDOUtil.getEObject(transaction2.getObject(company2));
- companyFrom2.setCity("sss");
- transaction2.commit();
- assertWriteLock(true, company1);
- }
-
- public void testAutoReleaseLockFalse_commit() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
- transaction.options().setAutoReleaseLocksEnabled(false);
-
- writeLock(company);
- readLock(company);
-
- msg("Test with read/write lock");
- assertWriteLock(true, company);
- assertReadLock(true, company);
-
- company.setCity("Ottawa");
- transaction.commit();
- assertWriteLock(true, company);
- assertReadLock(true, company);
-
- msg("Clean locks");
- transaction.unlockObjects(null, null);
-
- msg("Test with read lock");
- readLock(company);
- assertReadLock(true, company);
-
- company.setCity("Toronto");
- transaction.commit();
- assertReadLock(true, company);
-
- transaction.options().setAutoReleaseLocksEnabled(true);
- transaction.commit();
- assertReadLock(false, company);
- }
-
- public void testAutoReleaseLockFalse_rollback() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
- transaction.options().setAutoReleaseLocksEnabled(false);
-
- writeLock(company);
- readLock(company);
-
- msg("Test with read/write lock");
- assertWriteLock(true, company);
- assertReadLock(true, company);
-
- company.setCity("Ottawa");
- transaction.rollback();
- assertWriteLock(true, company);
- assertReadLock(true, company);
-
- msg("Clean locks");
- transaction.unlockObjects(null, null);
-
- msg("Test with read lock");
- readLock(company);
- assertReadLock(true, company);
-
- company.setCity("Toronto");
- transaction.rollback();
- assertReadLock(true, company);
-
- transaction.options().setAutoReleaseLocksEnabled(true);
- transaction.rollback();
- assertReadLock(false, company);
- }
-
- public void testWriteLockPerformance() throws Exception
- {
- final int ITERATION = 100;
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
- res.getContents().add(company);
- transaction.commit();
-
- long start = System.currentTimeMillis();
-
- // 335-418 locks/sec
- for (int i = 0; i < ITERATION; i++)
- {
- writeLock(company);
- }
-
- msg("Lock " + ITERATION / ((double)(System.currentTimeMillis() - start) / 1000) + " objects/sec");
- }
-
- public void testReadLockStaleRevision() throws Exception
- {
- lockStaleRevision(LockType.READ);
- }
-
- public void testWriteLockStaleRevision() throws Exception
- {
- lockStaleRevision(LockType.WRITE);
- }
-
- private void lockStaleRevision(LockType type) throws Exception
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("AAA");
- res.getContents().add(company);
- transaction.commit();
-
- updateInOtherSession();
-
- try
- {
- if (type == LockType.WRITE)
- {
- writeLock(company);
- }
- else if (type == LockType.READ)
- {
- readLock(company);
- }
-
- fail("StaleRevisionLockException expected");
- }
- catch (StaleRevisionLockException expected)
- {
- }
-
- session.close();
- }
-
- private void updateInOtherSession() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res1"));
-
- Company company = (Company)res.getContents().get(0);
- company.setName("BBB");
- transaction.commit();
-
- session.close();
- }
-
- private void addCategory(Company company, List<CDOObject> objects)
- {
- Category category = getModel1Factory().createCategory();
- company.getCategories().add(category);
- objects.add(CDOUtil.getCDOObject(category));
- }
-
- public void testRecursiveLock() throws Exception
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
-
- Category category1 = getModel1Factory().createCategory();
- Category category2_1 = getModel1Factory().createCategory();
- Category category2_2 = getModel1Factory().createCategory();
- Category category3 = getModel1Factory().createCategory();
- res.getContents().add(category1);
- category1.getCategories().add(category2_1);
- category1.getCategories().add(category2_2);
- category2_1.getCategories().add(category3);
-
- transaction.commit();
-
- CDOObject top = CDOUtil.getCDOObject(category1);
- transaction.lockObjects(Collections.singleton(top), LockType.WRITE, 5000, true);
-
- assertWriteLock(true, category1);
- assertWriteLock(true, category2_1);
- assertWriteLock(true, category2_2);
- assertWriteLock(true, category3);
-
- transaction.unlockObjects(Collections.singleton(top), LockType.WRITE, true);
-
- assertWriteLock(false, category1);
- assertWriteLock(false, category2_1);
- assertWriteLock(false, category2_2);
- assertWriteLock(false, category3);
-
- session.close();
- }
-
- public void testLockOnNewObject() throws Exception
- {
- CDOSession session1 = openSession();
- CDOSession session2 = openSession();
-
- CDOTransaction transaction = session1.openTransaction();
- transaction.options().setAutoReleaseLocksEnabled(false);
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- transaction.commit();
-
- Category category1 = getModel1Factory().createCategory();
- Category category2 = getModel1Factory().createCategory();
- Category category3 = getModel1Factory().createCategory();
- resource.getContents().add(category1);
- resource.getContents().add(category2);
- resource.getContents().add(category3);
-
- readLock(category1);
- writeLock(category2);
- writeOption(category3);
-
- assertReadLock(true, category1);
- assertWriteLock(true, category2);
- assertWriteOption(true, category3);
-
- readUnlock(category1);
- writeUnlock(category2);
- writeUnoption(category3);
-
- assertReadLock(false, category1);
- assertWriteLock(false, category2);
- assertWriteLock(false, category3);
-
- readLock(category1);
- writeLock(category2);
- writeOption(category3);
-
- transaction.commit();
-
- CDOView controlView = session2.openView();
- controlView.options().setLockNotificationEnabled(true);
- CDOResource r = controlView.getResource(getResourcePath("/res1"));
-
- CDOObject category1cv = CDOUtil.getCDOObject(r.getContents().get(0));
- CDOObject category2cv = CDOUtil.getCDOObject(r.getContents().get(1));
- CDOObject category3cv = CDOUtil.getCDOObject(r.getContents().get(2));
-
- assertEquals(true, category1cv.cdoReadLock().isLockedByOthers());
- assertEquals(true, category2cv.cdoWriteLock().isLockedByOthers());
- assertEquals(true, category3cv.cdoWriteOption().isLockedByOthers());
-
- readUnlock(category1);
- writeUnlock(category2);
- writeUnoption(category3);
-
- assertEquals(false, category1cv.cdoReadLock().isLockedByOthers());
- assertEquals(false, category2cv.cdoReadLock().isLockedByOthers());
- assertEquals(false, category3cv.cdoReadLock().isLockedByOthers());
-
- session1.close();
- session2.close();
- }
-
- public void testDeleteLockedObject() throws Exception
- {
- CDOSession session1 = openSession();
- CDOSession session2 = openSession();
-
- CDOTransaction tx = session1.openTransaction();
- tx.options().setAutoReleaseLocksEnabled(false);
- CDOResource resource = tx.createResource(getResourcePath("/res1"));
- Category category1 = getModel1Factory().createCategory();
- resource.getContents().add(category1);
- tx.commit();
-
- CDOID id = CDOUtil.getCDOObject(category1).cdoID();
-
- writeLock(category1);
-
- resource.getContents().remove(category1);
- tx.commit();
-
- CDOView controlView = session2.openView();
-
- try
- {
- controlView.getObject(id);
- fail("Should have thrown " + ObjectNotFoundException.class.getSimpleName());
- }
- catch (ObjectNotFoundException ignore)
- {
- // Do nothing
- }
-
- InternalLockManager mgr = getRepository().getLockingManager();
- boolean branching = getRepository().isSupportingBranches();
- Object key = branching ? CDOIDUtil.createIDAndBranch(id, tx.getBranch()) : id;
- LockState<Object, IView> state = mgr.getLockState(key);
- assertNull(state);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ * Caspar De Groot - write options
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOLock;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalLockManager;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.LockTimeoutException;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+import org.eclipse.emf.cdo.util.StaleRevisionLockException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+import org.eclipse.net4j.util.concurrent.RWOLockManager;
+import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState;
+import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Simon McDuff
+ */
+public class LockingManagerTest extends AbstractLockingTest
+{
+ public void testUnlockAll() throws Exception
+ {
+ final RWOLockManager<Integer, Integer> lockingManager = new RWOLockManager<Integer, Integer>();
+
+ Set<Integer> keys = new HashSet<Integer>();
+ keys.add(1);
+ keys.add(2);
+ keys.add(3);
+
+ lockingManager.lock(LockType.READ, 1, keys, 100);
+ lockingManager.unlock(1);
+ }
+
+ public void testWriteOptions() throws Exception
+ {
+ final RWOLockManager<Integer, Integer> lockingManager = new RWOLockManager<Integer, Integer>();
+
+ Set<Integer> keys = new HashSet<Integer>();
+ keys.add(1);
+ lockingManager.lock(LockType.OPTION, 1, keys, 100);
+
+ // (R=Read, W=Write, WO=WriteOption)
+ // Scenario 1: 1 has WO, 2 requests W -> fail
+ keys.clear();
+ keys.add(1);
+
+ try
+ {
+ lockingManager.lock(LockType.WRITE, 2, keys, 100); // Must fail
+ fail("Should have thrown an exception");
+ }
+ catch (TimeoutRuntimeException e)
+ {
+ }
+
+ // Scenario 2: 1 has WO, 2 requests R -> succeed
+ try
+ {
+ lockingManager.lock(LockType.READ, 2, keys, 100); // Must succeed
+ }
+ catch (TimeoutRuntimeException e)
+ {
+ fail("Should not have thrown an exception");
+ }
+
+ // Scenario 3: 1 has WO, 2 has R, 1 requests W -> fail
+ try
+ {
+ lockingManager.lock(LockType.WRITE, 1, keys, 100); // Must fail
+ fail("Should have thrown an exception");
+ }
+ catch (TimeoutRuntimeException e)
+ {
+ }
+
+ // Scenario 4: 1 has WO, 2 has R, 2 requests WO -> fail
+ try
+ {
+ lockingManager.lock(LockType.OPTION, 2, keys, 100); // Must fail
+ fail("Should have thrown an exception");
+ }
+ catch (TimeoutRuntimeException e)
+ {
+ }
+
+ // Scenario 5: 1 has WO, 2 has nothing, 2 requests WO -> fail
+ lockingManager.unlock(LockType.READ, 2, keys);
+ try
+ {
+ lockingManager.lock(LockType.OPTION, 2, keys, 100); // Must fail
+ fail("Should have thrown an exception");
+ }
+ catch (TimeoutRuntimeException e)
+ {
+ }
+
+ // Scenario 6: 1 has W, 2 has nothing, 2 requests WO -> fail
+ lockingManager.unlock(LockType.OPTION, 1, keys);
+ lockingManager.lock(LockType.WRITE, 1, keys, 100);
+ try
+ {
+ lockingManager.lock(LockType.OPTION, 2, keys, 100); // Must fail
+ fail("Should have thrown an exception");
+ }
+ catch (TimeoutRuntimeException e)
+ {
+ }
+
+ // Scenario 7: 1 has W, 1 request WO -> succeed
+ try
+ {
+ lockingManager.lock(LockType.OPTION, 1, keys, 100); // Must succeed
+ }
+ catch (TimeoutRuntimeException e)
+ {
+ fail("Should not have thrown an exception");
+ }
+
+ // Scenario 8: 1 has W, 2 has R, 1 request WO -> succeed
+ lockingManager.unlock(LockType.OPTION, 1, keys);
+ lockingManager.lock(LockType.READ, 1, keys, 100);
+ try
+ {
+ lockingManager.lock(LockType.OPTION, 1, keys, 100); // Must succeed
+ }
+ catch (TimeoutRuntimeException e)
+ {
+ fail("Should not have thrown an exception");
+ }
+ }
+
+ public void testBasicUpgradeFromReadToWriteLock() throws Exception
+ {
+ final RWOLockManager<Integer, Integer> lockingManager = new RWOLockManager<Integer, Integer>();
+
+ Runnable step1 = new Runnable()
+ {
+ public void run()
+ {
+ Set<Integer> keys = new HashSet<Integer>();
+ keys.add(1);
+ try
+ {
+ lockingManager.lock(LockType.WRITE, 1, keys, 50000);
+ }
+ catch (InterruptedException ex)
+ {
+ fail("Should not have exception");
+ }
+ }
+ };
+
+ ExecutorService executors = Executors.newFixedThreadPool(10);
+ Set<Integer> keys = new HashSet<Integer>();
+ keys.add(1);
+ keys.add(2);
+ keys.add(3);
+ keys.add(4);
+
+ msg("Context 1 have readlock 1,2,3,4");
+ lockingManager.lock(LockType.READ, 1, keys, 1000);
+ assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 1));
+ assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 2));
+ assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 3));
+ assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 4));
+
+ keys.clear();
+ keys.add(1);
+ keys.add(2);
+ keys.add(3);
+
+ msg("Context 2 have readlock 1,2,3");
+ lockingManager.lock(LockType.READ, 2, keys, 1000);
+ assertEquals(true, lockingManager.hasLock(LockType.READ, 2, 1));
+ assertEquals(true, lockingManager.hasLock(LockType.READ, 2, 2));
+ assertEquals(true, lockingManager.hasLock(LockType.READ, 2, 3));
+ assertEquals(true, lockingManager.hasLockByOthers(LockType.READ, 2, 1));
+ assertEquals(true, lockingManager.hasLockByOthers(LockType.READ, 1, 1));
+
+ keys.clear();
+ keys.add(4);
+
+ msg("Context 1 have readlock 1,2,3,4 and writeLock 4");
+ lockingManager.lock(LockType.WRITE, 1, keys, 1000);
+ assertEquals(true, lockingManager.hasLock(LockType.READ, 1, 4));
+ assertEquals(true, lockingManager.hasLock(LockType.WRITE, 1, 4));
+
+ keys.clear();
+ keys.add(1);
+
+ try
+ {
+ lockingManager.lock(LockType.WRITE, 1, keys, 1000);
+ fail("Should not have exception");
+ }
+ catch (RuntimeException expected)
+ {
+ }
+
+ executors.execute(step1);
+ executors.execute(step1);
+
+ sleep(1000);
+
+ keys.clear();
+ keys.add(1);
+ keys.add(2);
+ keys.add(3);
+ lockingManager.unlock(LockType.READ, 2, keys);
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return lockingManager.hasLock(LockType.WRITE, 1, 1);
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testBasicWrongUnlock() throws Exception
+ {
+ final RWOLockManager<Integer, Integer> lockingManager = new RWOLockManager<Integer, Integer>();
+ Set<Integer> keys = new HashSet<Integer>();
+ keys.add(1);
+ lockingManager.lock(LockType.READ, 1, keys, 10000);
+ lockingManager.unlock(LockType.READ, 1, keys);
+
+ try
+ {
+ lockingManager.unlock(LockType.READ, 1, keys);
+ fail("Should have an exception");
+ }
+ catch (IllegalMonitorStateException exception)
+ {
+ }
+ }
+
+ public void testReadTimeout() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ writeLock(company);
+
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = transaction2.getObject(company);
+
+ long start = System.currentTimeMillis();
+ assertWriteLock(false, company2);
+ assertEquals(true, System.currentTimeMillis() - start < 300);
+
+ start = System.currentTimeMillis();
+ assertEquals(false, CDOUtil.getCDOObject(company2).cdoWriteLock().tryLock(2, TimeUnit.SECONDS));
+ assertEquals(true, System.currentTimeMillis() - start >= 2000);
+ }
+
+ public void testReadLockByOthers() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ readLock(company);
+
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
+
+ CDOObject cdoCompany2 = CDOUtil.getCDOObject(company2);
+ assertEquals(false, cdoCompany2.cdoWriteLock().isLockedByOthers());
+ assertEquals(true, cdoCompany2.cdoReadLock().isLockedByOthers());
+ }
+
+ public void testDetachedObjects() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
+ res.getContents().remove(0);
+
+ transaction.commit();
+
+ try
+ {
+ readLock(company2);
+ fail("IllegalArgumentException expected");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ assertReadLock(false, company2);
+ assertEquals(false, CDOUtil.getCDOObject(company2).cdoReadLock().isLockedByOthers());
+ }
+
+ public void testWriteLockByOthers() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ writeLock(company);
+
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
+
+ CDOObject cdoCompany2 = CDOUtil.getCDOObject(company2);
+ assertEquals(true, cdoCompany2.cdoWriteLock().isLockedByOthers());
+ assertEquals(false, cdoCompany2.cdoReadLock().isLockedByOthers());
+ }
+
+ public void testWriteLock() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
+
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+ CDOObject cdoCompany2 = CDOUtil.getCDOObject(company2);
+
+ transaction.lockObjects(Collections.singletonList(cdoCompany), LockType.WRITE, CDOLock.WAIT);
+
+ try
+ {
+ transaction2.lockObjects(Collections.singletonList(cdoCompany2), LockType.WRITE, 1000);
+ fail("Should have thrown an exception");
+ }
+ catch (LockTimeoutException ex)
+ {
+ }
+
+ company2.setCity("Ottawa");
+
+ try
+ {
+ transaction2.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException exception)
+ {
+ }
+ }
+
+ public void testWriteLockViaObject() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
+
+ writeLock(company);
+ assertWriteLock(false, company2);
+
+ company2.setCity("Ottawa");
+
+ try
+ {
+ transaction2.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+ }
+
+ public void testWriteLockFromDifferenceTransaction() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
+
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+ CDOObject cdoCompany2 = CDOUtil.getCDOObject(company2);
+
+ transaction.lockObjects(Collections.singletonList(cdoCompany), LockType.WRITE, DEFAULT_TIMEOUT);
+
+ try
+ {
+ transaction2.lockObjects(Collections.singletonList(cdoCompany2), LockType.WRITE, 1000);
+ fail("Should have an exception");
+ }
+ catch (LockTimeoutException ex)
+ {
+ }
+ }
+
+ public void testWriteLockMultiple() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ List<CDOObject> objects = new ArrayList<CDOObject>();
+
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ transaction.lockObjects(objects, LockType.WRITE, DEFAULT_TIMEOUT);
+
+ assertWriteLock(false, company);
+ assertReadLock(false, company);
+ for (CDOObject object : objects)
+ {
+ assertWriteLock(true, object);
+ assertReadLock(false, object);
+ }
+ }
+
+ public void testWriteUnlockMultiple() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ List<CDOObject> objects = new ArrayList<CDOObject>();
+
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ transaction.lockObjects(objects, LockType.WRITE, DEFAULT_TIMEOUT);
+
+ assertWriteLock(false, company);
+ assertReadLock(false, company);
+ for (CDOObject object : objects)
+ {
+ assertWriteLock(true, object);
+ assertReadLock(false, object);
+ }
+
+ transaction.unlockObjects(objects, LockType.WRITE);
+
+ assertWriteLock(false, company);
+ assertReadLock(false, company);
+ for (CDOObject object : objects)
+ {
+ assertWriteLock(false, object);
+ assertReadLock(false, object);
+ }
+ }
+
+ public void testReadLockMultiple() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ List<CDOObject> objects = new ArrayList<CDOObject>();
+
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ transaction.lockObjects(objects, LockType.READ, DEFAULT_TIMEOUT);
+
+ assertReadLock(false, company);
+ assertWriteLock(false, company);
+ for (CDOObject object : objects)
+ {
+ assertReadLock(true, object);
+ assertWriteLock(false, object);
+ }
+ }
+
+ public void testReadUnlockMultiple() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ List<CDOObject> objects = new ArrayList<CDOObject>();
+
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+ addCategory(company, objects);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ transaction.lockObjects(objects, LockType.READ, DEFAULT_TIMEOUT);
+
+ assertReadLock(false, company);
+ assertWriteLock(false, company);
+ for (CDOObject object : objects)
+ {
+ assertReadLock(true, object);
+ assertWriteLock(false, object);
+ }
+
+ transaction.unlockObjects(objects, LockType.READ);
+
+ assertWriteLock(false, company);
+ assertReadLock(false, company);
+ for (CDOObject object : objects)
+ {
+ assertWriteLock(false, object);
+ assertReadLock(false, object);
+ }
+ }
+
+ public void testReadLockAndCommitFromDifferentTransaction() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+
+ transaction.lockObjects(Collections.singletonList(cdoCompany), LockType.READ, DEFAULT_TIMEOUT);
+ company2.setCity("Ottawa");
+
+ try
+ {
+ transaction2.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+ }
+
+ public void testWriteLockAndCommitFromDifferentTransaction() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = (Company)transaction2.getResource(getResourcePath("/res1")).getContents().get(0);
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+
+ transaction.lockObjects(Collections.singletonList(cdoCompany), LockType.WRITE, DEFAULT_TIMEOUT);
+ company2.setCity("Ottawa");
+
+ try
+ {
+ transaction2.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ IOUtil.print(expected);
+ }
+ }
+
+ public void testReadLockAndCommitSameTransaction() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ readLock(company);
+
+ company.setCity("Ottawa");
+ transaction.commit();
+ }
+
+ public void testWriteLockAndCommitSameTransaction() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ writeLock(company);
+
+ company.setCity("Ottawa");
+ assertWriteLock(true, company);
+ assertReadLock(false, company);
+
+ transaction.commit();
+
+ assertWriteLock(false, company);
+ assertReadLock(false, company);
+ }
+
+ public void testWriteLockAndRollback() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ writeLock(company);
+ company.setCity("Ottawa");
+
+ transaction.rollback();
+ assertWriteLock(false, company);
+ }
+
+ public void testLockUnlock() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+
+ readLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+
+ writeLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ readLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ writeLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ readUnlock(cdoCompany);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ readUnlock(cdoCompany);
+ assertReadLock(false, company);
+ assertWriteLock(true, company);
+
+ writeUnlock(cdoCompany);
+ assertReadLock(false, company);
+ assertWriteLock(true, company);
+
+ writeUnlock(cdoCompany);
+ assertReadLock(false, company);
+ assertWriteLock(false, company);
+
+ /********************/
+
+ readLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+
+ writeLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ readLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ writeLock(company);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ writeUnlock(cdoCompany);
+ assertReadLock(true, company);
+ assertWriteLock(true, company);
+
+ writeUnlock(cdoCompany);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+
+ readUnlock(cdoCompany);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+
+ readUnlock(cdoCompany);
+ assertReadLock(false, company);
+ assertWriteLock(false, company);
+ }
+
+ /**
+ * Bug 352191.
+ */
+ public void testLockDetached() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ res.getContents().remove(0);
+ assertTransient(company);
+
+ CDOObject cdoObject = CDOUtil.getCDOObject(company);
+ transaction.lockObjects(Collections.singleton(cdoObject), LockType.WRITE, DEFAULT_TIMEOUT);
+
+ // Verify
+ CDOTransaction transaction2 = session.openTransaction();
+ CDOResource res2 = transaction2.getResource(getResourcePath("/res1"));
+ Company company2 = (Company)res2.getContents().get(0);
+ company2.setName("NewName");
+
+ try
+ {
+ transaction2.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ public void testTransactionClose() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ InternalRepository repo = getRepository();
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ IView view = repo.getSessionManager().getSession(session.getSessionID()).getView(transaction.getViewID());
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+ readLock(company);
+ transaction.close();
+ assertEquals(false, repo.getLockingManager().hasLock(LockType.READ, view, cdoCompany.cdoID()));
+ }
+
+ public void testSessionClose() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ InternalRepository repo = getRepository();
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ IView view = repo.getSessionManager().getSession(session.getSessionID()).getView(transaction.getViewID());
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+ readLock(company);
+ session.close();
+
+ sleep(100);
+ assertEquals(false, repo.getLockingManager().hasLock(LockType.READ, view, cdoCompany.cdoID()));
+ }
+
+ public void testBugzilla_270345() throws Exception
+ {
+ Company company1 = getModel1Factory().createCompany();
+ Company company2 = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ CDOTransaction transaction2 = session.openTransaction();
+ CDOResource res = transaction1.getOrCreateResource(getResourcePath("/res1"));
+ res.getContents().add(company1);
+ res.getContents().add(company2);
+ transaction1.commit();
+
+ writeLock(company1);
+ assertWriteLock(true, company1);
+
+ Company companyFrom2 = (Company)CDOUtil.getEObject(transaction2.getObject(company2));
+ companyFrom2.setCity("sss");
+ transaction2.commit();
+ assertWriteLock(true, company1);
+ }
+
+ public void testAutoReleaseLockFalse_commit() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+ transaction.options().setAutoReleaseLocksEnabled(false);
+
+ writeLock(company);
+ readLock(company);
+
+ msg("Test with read/write lock");
+ assertWriteLock(true, company);
+ assertReadLock(true, company);
+
+ company.setCity("Ottawa");
+ transaction.commit();
+ assertWriteLock(true, company);
+ assertReadLock(true, company);
+
+ msg("Clean locks");
+ transaction.unlockObjects(null, null);
+
+ msg("Test with read lock");
+ readLock(company);
+ assertReadLock(true, company);
+
+ company.setCity("Toronto");
+ transaction.commit();
+ assertReadLock(true, company);
+
+ transaction.options().setAutoReleaseLocksEnabled(true);
+ transaction.commit();
+ assertReadLock(false, company);
+ }
+
+ public void testAutoReleaseLockFalse_rollback() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+ transaction.options().setAutoReleaseLocksEnabled(false);
+
+ writeLock(company);
+ readLock(company);
+
+ msg("Test with read/write lock");
+ assertWriteLock(true, company);
+ assertReadLock(true, company);
+
+ company.setCity("Ottawa");
+ transaction.rollback();
+ assertWriteLock(true, company);
+ assertReadLock(true, company);
+
+ msg("Clean locks");
+ transaction.unlockObjects(null, null);
+
+ msg("Test with read lock");
+ readLock(company);
+ assertReadLock(true, company);
+
+ company.setCity("Toronto");
+ transaction.rollback();
+ assertReadLock(true, company);
+
+ transaction.options().setAutoReleaseLocksEnabled(true);
+ transaction.rollback();
+ assertReadLock(false, company);
+ }
+
+ public void testWriteLockPerformance() throws Exception
+ {
+ final int ITERATION = 100;
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+
+ long start = System.currentTimeMillis();
+
+ // 335-418 locks/sec
+ for (int i = 0; i < ITERATION; i++)
+ {
+ writeLock(company);
+ }
+
+ msg("Lock " + ITERATION / ((double)(System.currentTimeMillis() - start) / 1000) + " objects/sec");
+ }
+
+ public void testReadLockStaleRevision() throws Exception
+ {
+ lockStaleRevision(LockType.READ);
+ }
+
+ public void testWriteLockStaleRevision() throws Exception
+ {
+ lockStaleRevision(LockType.WRITE);
+ }
+
+ private void lockStaleRevision(LockType type) throws Exception
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("AAA");
+ res.getContents().add(company);
+ transaction.commit();
+
+ updateInOtherSession();
+
+ try
+ {
+ if (type == LockType.WRITE)
+ {
+ writeLock(company);
+ }
+ else if (type == LockType.READ)
+ {
+ readLock(company);
+ }
+
+ fail("StaleRevisionLockException expected");
+ }
+ catch (StaleRevisionLockException expected)
+ {
+ }
+
+ session.close();
+ }
+
+ private void updateInOtherSession() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res1"));
+
+ Company company = (Company)res.getContents().get(0);
+ company.setName("BBB");
+ transaction.commit();
+
+ session.close();
+ }
+
+ private void addCategory(Company company, List<CDOObject> objects)
+ {
+ Category category = getModel1Factory().createCategory();
+ company.getCategories().add(category);
+ objects.add(CDOUtil.getCDOObject(category));
+ }
+
+ public void testRecursiveLock() throws Exception
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+
+ Category category1 = getModel1Factory().createCategory();
+ Category category2_1 = getModel1Factory().createCategory();
+ Category category2_2 = getModel1Factory().createCategory();
+ Category category3 = getModel1Factory().createCategory();
+ res.getContents().add(category1);
+ category1.getCategories().add(category2_1);
+ category1.getCategories().add(category2_2);
+ category2_1.getCategories().add(category3);
+
+ transaction.commit();
+
+ CDOObject top = CDOUtil.getCDOObject(category1);
+ transaction.lockObjects(Collections.singleton(top), LockType.WRITE, 5000, true);
+
+ assertWriteLock(true, category1);
+ assertWriteLock(true, category2_1);
+ assertWriteLock(true, category2_2);
+ assertWriteLock(true, category3);
+
+ transaction.unlockObjects(Collections.singleton(top), LockType.WRITE, true);
+
+ assertWriteLock(false, category1);
+ assertWriteLock(false, category2_1);
+ assertWriteLock(false, category2_2);
+ assertWriteLock(false, category3);
+
+ session.close();
+ }
+
+ public void testLockOnNewObject() throws Exception
+ {
+ CDOSession session1 = openSession();
+ CDOSession session2 = openSession();
+
+ CDOTransaction transaction = session1.openTransaction();
+ transaction.options().setAutoReleaseLocksEnabled(false);
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ transaction.commit();
+
+ Category category1 = getModel1Factory().createCategory();
+ Category category2 = getModel1Factory().createCategory();
+ Category category3 = getModel1Factory().createCategory();
+ resource.getContents().add(category1);
+ resource.getContents().add(category2);
+ resource.getContents().add(category3);
+
+ readLock(category1);
+ writeLock(category2);
+ writeOption(category3);
+
+ assertReadLock(true, category1);
+ assertWriteLock(true, category2);
+ assertWriteOption(true, category3);
+
+ readUnlock(category1);
+ writeUnlock(category2);
+ writeUnoption(category3);
+
+ assertReadLock(false, category1);
+ assertWriteLock(false, category2);
+ assertWriteLock(false, category3);
+
+ readLock(category1);
+ writeLock(category2);
+ writeOption(category3);
+
+ transaction.commit();
+
+ CDOView controlView = session2.openView();
+ controlView.options().setLockNotificationEnabled(true);
+ CDOResource r = controlView.getResource(getResourcePath("/res1"));
+
+ CDOObject category1cv = CDOUtil.getCDOObject(r.getContents().get(0));
+ CDOObject category2cv = CDOUtil.getCDOObject(r.getContents().get(1));
+ CDOObject category3cv = CDOUtil.getCDOObject(r.getContents().get(2));
+
+ assertEquals(true, category1cv.cdoReadLock().isLockedByOthers());
+ assertEquals(true, category2cv.cdoWriteLock().isLockedByOthers());
+ assertEquals(true, category3cv.cdoWriteOption().isLockedByOthers());
+
+ readUnlock(category1);
+ writeUnlock(category2);
+ writeUnoption(category3);
+
+ assertEquals(false, category1cv.cdoReadLock().isLockedByOthers());
+ assertEquals(false, category2cv.cdoReadLock().isLockedByOthers());
+ assertEquals(false, category3cv.cdoReadLock().isLockedByOthers());
+
+ session1.close();
+ session2.close();
+ }
+
+ public void testDeleteLockedObject() throws Exception
+ {
+ CDOSession session1 = openSession();
+ CDOSession session2 = openSession();
+
+ CDOTransaction tx = session1.openTransaction();
+ tx.options().setAutoReleaseLocksEnabled(false);
+ CDOResource resource = tx.createResource(getResourcePath("/res1"));
+ Category category1 = getModel1Factory().createCategory();
+ resource.getContents().add(category1);
+ tx.commit();
+
+ CDOID id = CDOUtil.getCDOObject(category1).cdoID();
+
+ writeLock(category1);
+
+ resource.getContents().remove(category1);
+ tx.commit();
+
+ CDOView controlView = session2.openView();
+
+ try
+ {
+ controlView.getObject(id);
+ fail("Should have thrown " + ObjectNotFoundException.class.getSimpleName());
+ }
+ catch (ObjectNotFoundException ignore)
+ {
+ // Do nothing
+ }
+
+ InternalLockManager mgr = getRepository().getLockingManager();
+ boolean branching = getRepository().isSupportingBranches();
+ Object key = branching ? CDOIDUtil.createIDAndBranch(id, tx.getBranch()) : id;
+ LockState<Object, IView> state = mgr.getLockState(key);
+ assertNull(state);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
index a849cfaef8..df51716e35 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
@@ -1,452 +1,452 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
-import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener2;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-/**
- * @author Caspar De Groot
- */
-public class LockingNotificationsTest extends AbstractLockingTest
-{
- private CDOView openViewWithLockNotifications(CDOSession session, CDOBranch branch)
- {
- CDOView view = branch != null ? session.openView(branch) : session.openView();
- view.options().setLockNotificationEnabled(true);
- return view;
- }
-
- /**
- * FIXME Disabled until bug 358603 is addressed.
- */
- public void _testSameBranchDifferentSession_explicitRelease() throws CommitException
- {
- sameBranchDifferentSession(LockReleaseMode.EXPLICIT);
- }
-
- public void testSameBranchDifferentSession_autoRelease() throws CommitException
- {
- sameBranchDifferentSession(LockReleaseMode.AUTO);
- }
-
- private void sameBranchDifferentSession(LockReleaseMode mode) throws CommitException
- {
- CDOSession session1 = openSession();
- CDOSession session2 = openSession();
- CDOView controlView = openViewWithLockNotifications(session2, null);
- if (mode == LockReleaseMode.EXPLICIT)
- {
- withExplicitRelease(session1, controlView, true);
- }
- else if (mode == LockReleaseMode.AUTO)
- {
- withAutoRelease(session1, controlView, true);
- }
-
- session1.close();
- session2.close();
- }
-
- public void testSameBranchSameSession_explicitRelease() throws CommitException
- {
- sameBranchSameSession(LockReleaseMode.EXPLICIT);
- }
-
- public void testSameBranchSameSession_autoRelease() throws CommitException
- {
- sameBranchSameSession(LockReleaseMode.AUTO);
- }
-
- private void sameBranchSameSession(LockReleaseMode mode) throws CommitException
- {
- CDOSession session1 = openSession();
- CDOView controlView = openViewWithLockNotifications(session1, null);
- if (mode == LockReleaseMode.EXPLICIT)
- {
- withExplicitRelease(session1, controlView, true);
- }
- else if (mode == LockReleaseMode.AUTO)
- {
- withAutoRelease(session1, controlView, true);
- }
-
- session1.close();
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testDifferentBranchDifferentSession() throws CommitException
- {
- differentBranchDifferentSession(LockReleaseMode.EXPLICIT);
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testDifferentBranchDifferentSession_autoRelease() throws CommitException
- {
- differentBranchDifferentSession(LockReleaseMode.AUTO);
- }
-
- private void differentBranchDifferentSession(LockReleaseMode mode) throws CommitException
- {
- CDOSession session1 = openSession();
- CDOBranch subBranch = session1.getBranchManager().getMainBranch().createBranch("sub1");
- CDOSession session2 = openSession();
- CDOView controlView = openViewWithLockNotifications(session2, subBranch);
- if (mode == LockReleaseMode.EXPLICIT)
- {
- withExplicitRelease(session1, controlView, false);
- }
- else if (mode == LockReleaseMode.AUTO)
- {
- withAutoRelease(session1, controlView, false);
- }
-
- session1.close();
- session2.close();
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testDifferentBranchSameSession() throws CommitException
- {
- differentBranchSameSession(LockReleaseMode.EXPLICIT);
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testDifferentBranchSameSession_autoRelease() throws CommitException
- {
- differentBranchSameSession(LockReleaseMode.AUTO);
- }
-
- private void differentBranchSameSession(LockReleaseMode mode) throws CommitException
- {
- CDOSession session1 = openSession();
- CDOBranch subBranch = session1.getBranchManager().getMainBranch().createBranch("sub2");
- CDOView controlView = openViewWithLockNotifications(session1, subBranch);
- if (mode == LockReleaseMode.EXPLICIT)
- {
- withExplicitRelease(session1, controlView, false);
- }
- else if (mode == LockReleaseMode.AUTO)
- {
- withAutoRelease(session1, controlView, false);
- }
-
- session1.close();
- }
-
- private void withExplicitRelease(CDOSession session1, CDOView controlView, boolean mustReceiveNotifications)
- throws CommitException
- {
- TestListener2 controlViewListener = new TestListener2(CDOViewLocksChangedEvent.class);
- controlView.addListener(controlViewListener);
-
- CDOTransaction tx1 = session1.openTransaction();
- CDOResource res1 = tx1.getOrCreateResource(getResourcePath("r1"));
- TestListener2 transactionListener = new TestListener2(CDOViewLocksChangedEvent.class);
- tx1.addListener(transactionListener);
- res1.getContents().clear();
- Company company = getModel1Factory().createCompany();
- res1.getContents().add(company);
- tx1.commit();
-
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
-
- CDOObject cdoCompanyInControlView = null;
- if (mustReceiveNotifications)
- {
- cdoCompanyInControlView = controlView.getObject(cdoCompany.cdoID());
- }
-
- /* Test write lock */
-
- cdoCompany.cdoWriteLock().lock();
- if (mustReceiveNotifications)
- {
- controlViewListener.waitFor(1);
- assertEquals(1, controlViewListener.getEvents().size());
-
- CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(0);
- assertLockOwner(tx1, event.getLockOwner());
-
- CDOLockState[] lockStates = event.getLockStates();
- assertEquals(1, lockStates.length);
- assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
- assertLockOwner(tx1, lockStates[0].getWriteLockOwner());
- assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
- }
-
- cdoCompany.cdoWriteLock().unlock();
- if (mustReceiveNotifications)
- {
- controlViewListener.waitFor(2);
-
- assertEquals(2, controlViewListener.getEvents().size());
-
- CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(1);
- assertLockOwner(tx1, event.getLockOwner());
-
- CDOLockState[] lockStates = event.getLockStates();
- assertEquals(1, lockStates.length);
- assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
- assertNull(lockStates[0].getWriteLockOwner());
- assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
- }
-
- /* Test read lock */
-
- cdoCompany.cdoReadLock().lock();
- if (mustReceiveNotifications)
- {
- controlViewListener.waitFor(3);
- assertEquals(3, controlViewListener.getEvents().size());
-
- CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(2);
- assertLockOwner(tx1, event.getLockOwner());
-
- CDOLockState[] lockStates = event.getLockStates();
- assertEquals(1, lockStates.length);
- assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
- assertEquals(1, lockStates[0].getReadLockOwners().size());
- CDOLockOwner tx1Lo = CDOLockUtil.createLockOwner(tx1);
- assertEquals(true, lockStates[0].getReadLockOwners().contains(tx1Lo));
- assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
- }
-
- cdoCompany.cdoReadLock().unlock();
- if (mustReceiveNotifications)
- {
- controlViewListener.waitFor(4);
-
- assertEquals(4, controlViewListener.getEvents().size());
-
- CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(3);
- assertLockOwner(tx1, event.getLockOwner());
-
- CDOLockState[] lockStates = event.getLockStates();
- assertEquals(1, lockStates.length);
- assertEquals(0, lockStates[0].getReadLockOwners().size());
- assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
- }
-
- /* Test write option */
-
- cdoCompany.cdoWriteOption().lock();
- if (mustReceiveNotifications)
- {
- controlViewListener.waitFor(5);
- assertEquals(5, controlViewListener.getEvents().size());
-
- CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(4);
- assertLockOwner(tx1, event.getLockOwner());
-
- CDOLockState[] lockStates = event.getLockStates();
- assertEquals(1, lockStates.length);
- assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
- assertLockOwner(tx1, lockStates[0].getWriteOptionOwner());
- assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
- }
-
- cdoCompany.cdoWriteOption().unlock();
- if (mustReceiveNotifications)
- {
- controlViewListener.waitFor(6);
-
- assertEquals(6, controlViewListener.getEvents().size());
-
- CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(5);
- assertLockOwner(tx1, event.getLockOwner());
-
- CDOLockState[] lockStates = event.getLockStates();
- assertEquals(1, lockStates.length);
- assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
- assertNull(lockStates[0].getWriteOptionOwner());
- assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
- }
-
- assertEquals(0, transactionListener.getEvents().size());
-
- if (!mustReceiveNotifications)
- {
- assertEquals(0, controlViewListener.getEvents().size());
- }
- }
-
- private void withAutoRelease(CDOSession session1, CDOView controlView, boolean mustReceiveNotifications)
- throws CommitException
- {
- TestListener2 controlViewListener = new TestListener2(CDOViewLocksChangedEvent.class);
- controlView.addListener(controlViewListener);
-
- CDOTransaction tx1 = session1.openTransaction();
- tx1.options().setAutoReleaseLocksEnabled(true);
- CDOResource res1 = tx1.getOrCreateResource(getResourcePath("r1"));
- res1.getContents().clear();
- Company company = getModel1Factory().createCompany();
- res1.getContents().add(company);
- tx1.commit();
-
- implicitRelease(company, LockType.WRITE, tx1, controlViewListener, mustReceiveNotifications);
- implicitRelease(company, LockType.READ, tx1, controlViewListener, mustReceiveNotifications);
- implicitRelease(company, LockType.OPTION, tx1, controlViewListener, mustReceiveNotifications);
- }
-
- private void implicitRelease(Company company, LockType type, CDOTransaction tx, TestListener2 controlViewListener,
- boolean mustReceiveNotifications) throws CommitException
- {
- CDOViewLocksChangedEvent e;
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
-
- company.setName(company.getName() + "x"); // Make name field dirty
- cdoCompany.cdoWriteLock().lock();
-
- if (mustReceiveNotifications)
- {
- controlViewListener.waitFor(1);
- e = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(0);
- assertSame(Operation.LOCK, e.getOperation());
- assertSame(LockType.WRITE, e.getLockType());
- }
-
- tx.commit();
-
- if (mustReceiveNotifications)
- {
- controlViewListener.waitFor(2);
- e = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(1);
- assertSame(Operation.UNLOCK, e.getOperation());
- assertNull(e.getLockType());
- }
-
- if (!mustReceiveNotifications)
- {
- assertEquals(0, controlViewListener.getEvents().size());
- }
- }
-
- private void assertLockedObject(CDOObject obj, Object lockedObject)
- {
- if (lockedObject instanceof CDOIDAndBranch)
- {
- CDOIDAndBranch idAndBranch = CDOIDUtil.createIDAndBranch(obj.cdoID(), obj.cdoView().getBranch());
- assertEquals(idAndBranch, lockedObject);
- }
- else if (lockedObject instanceof CDOID)
- {
- assertEquals(obj.cdoID(), lockedObject);
- }
- }
-
- private void assertLockOwner(CDOView view, CDOLockOwner lockOwner)
- {
- CDOLockOwner lo = CDOLockUtil.createLockOwner(view);
- assertEquals(lo, lockOwner);
- }
-
- public void testEnableDisableNotifications() throws CommitException
- {
- CDOSession session1 = openSession();
- CDOSession session2 = openSession();
- CDOView controlView = session2.openView();
- withExplicitRelease(session1, controlView, false);
-
- controlView.options().setLockNotificationEnabled(true);
- withExplicitRelease(session1, controlView, true);
-
- controlView.options().setLockNotificationEnabled(false);
- withExplicitRelease(session1, controlView, false);
-
- session1.close();
- session2.close();
- }
-
- public void testLockStateHeldByDurableView() throws CommitException
- {
- {
- CDOSession session1 = openSession();
- CDOTransaction tx1 = session1.openTransaction();
- tx1.enableDurableLocking();
- CDOResource res1 = tx1.createResource(getResourcePath("r1"));
- Company company1 = getModel1Factory().createCompany();
- res1.getContents().add(company1);
- tx1.commit();
-
- CDOUtil.getCDOObject(company1).cdoWriteLock().lock();
- tx1.close();
- session1.close();
- }
-
- CDOSession session2 = openSession();
- CDOView controlView = session2.openView();
- CDOResource resource = controlView.getResource(getResourcePath("r1"));
- Company company1 = (Company)resource.getContents().get(0);
- CDOObject cdoObj = CDOUtil.getCDOObject(company1);
- assertEquals(true, cdoObj.cdoWriteLock().isLockedByOthers());
- assertEquals(true, cdoObj.cdoLockState().getWriteLockOwner().isDurableView());
- session2.close();
- }
-
- public void testLockStateNewAndTransient() throws CommitException
- {
- Company company1 = getModel1Factory().createCompany();
- CDOObject cdoObj = CDOUtil.getCDOObject(company1);
- assertTransient(cdoObj);
- assertNull(cdoObj.cdoLockState());
-
- CDOSession session1 = openSession();
- CDOTransaction tx1 = session1.openTransaction();
- CDOResource res1 = tx1.createResource(getResourcePath("r1"));
- res1.getContents().add(company1);
- assertNew(cdoObj, tx1);
- assertNotNull(cdoObj.cdoLockState());
-
- res1.getContents().remove(company1);
- assertTransient(cdoObj);
- assertNull(cdoObj.cdoLockState());
-
- res1.getContents().add(company1);
- tx1.commit();
- assertClean(cdoObj, tx1);
- assertNotNull(cdoObj.cdoLockState());
-
- res1.getContents().remove(company1);
- assertTransient(cdoObj);
- assertNull(cdoObj.cdoLockState());
-
- session1.close();
- }
-
- /**
- * @author Caspar De Groot
- */
- private static enum LockReleaseMode
- {
- EXPLICIT, AUTO
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestListener2;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+
+/**
+ * @author Caspar De Groot
+ */
+public class LockingNotificationsTest extends AbstractLockingTest
+{
+ private CDOView openViewWithLockNotifications(CDOSession session, CDOBranch branch)
+ {
+ CDOView view = branch != null ? session.openView(branch) : session.openView();
+ view.options().setLockNotificationEnabled(true);
+ return view;
+ }
+
+ /**
+ * FIXME Disabled until bug 358603 is addressed.
+ */
+ public void _testSameBranchDifferentSession_explicitRelease() throws CommitException
+ {
+ sameBranchDifferentSession(LockReleaseMode.EXPLICIT);
+ }
+
+ public void testSameBranchDifferentSession_autoRelease() throws CommitException
+ {
+ sameBranchDifferentSession(LockReleaseMode.AUTO);
+ }
+
+ private void sameBranchDifferentSession(LockReleaseMode mode) throws CommitException
+ {
+ CDOSession session1 = openSession();
+ CDOSession session2 = openSession();
+ CDOView controlView = openViewWithLockNotifications(session2, null);
+ if (mode == LockReleaseMode.EXPLICIT)
+ {
+ withExplicitRelease(session1, controlView, true);
+ }
+ else if (mode == LockReleaseMode.AUTO)
+ {
+ withAutoRelease(session1, controlView, true);
+ }
+
+ session1.close();
+ session2.close();
+ }
+
+ public void testSameBranchSameSession_explicitRelease() throws CommitException
+ {
+ sameBranchSameSession(LockReleaseMode.EXPLICIT);
+ }
+
+ public void testSameBranchSameSession_autoRelease() throws CommitException
+ {
+ sameBranchSameSession(LockReleaseMode.AUTO);
+ }
+
+ private void sameBranchSameSession(LockReleaseMode mode) throws CommitException
+ {
+ CDOSession session1 = openSession();
+ CDOView controlView = openViewWithLockNotifications(session1, null);
+ if (mode == LockReleaseMode.EXPLICIT)
+ {
+ withExplicitRelease(session1, controlView, true);
+ }
+ else if (mode == LockReleaseMode.AUTO)
+ {
+ withAutoRelease(session1, controlView, true);
+ }
+
+ session1.close();
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testDifferentBranchDifferentSession() throws CommitException
+ {
+ differentBranchDifferentSession(LockReleaseMode.EXPLICIT);
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testDifferentBranchDifferentSession_autoRelease() throws CommitException
+ {
+ differentBranchDifferentSession(LockReleaseMode.AUTO);
+ }
+
+ private void differentBranchDifferentSession(LockReleaseMode mode) throws CommitException
+ {
+ CDOSession session1 = openSession();
+ CDOBranch subBranch = session1.getBranchManager().getMainBranch().createBranch("sub1");
+ CDOSession session2 = openSession();
+ CDOView controlView = openViewWithLockNotifications(session2, subBranch);
+ if (mode == LockReleaseMode.EXPLICIT)
+ {
+ withExplicitRelease(session1, controlView, false);
+ }
+ else if (mode == LockReleaseMode.AUTO)
+ {
+ withAutoRelease(session1, controlView, false);
+ }
+
+ session1.close();
+ session2.close();
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testDifferentBranchSameSession() throws CommitException
+ {
+ differentBranchSameSession(LockReleaseMode.EXPLICIT);
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testDifferentBranchSameSession_autoRelease() throws CommitException
+ {
+ differentBranchSameSession(LockReleaseMode.AUTO);
+ }
+
+ private void differentBranchSameSession(LockReleaseMode mode) throws CommitException
+ {
+ CDOSession session1 = openSession();
+ CDOBranch subBranch = session1.getBranchManager().getMainBranch().createBranch("sub2");
+ CDOView controlView = openViewWithLockNotifications(session1, subBranch);
+ if (mode == LockReleaseMode.EXPLICIT)
+ {
+ withExplicitRelease(session1, controlView, false);
+ }
+ else if (mode == LockReleaseMode.AUTO)
+ {
+ withAutoRelease(session1, controlView, false);
+ }
+
+ session1.close();
+ }
+
+ private void withExplicitRelease(CDOSession session1, CDOView controlView, boolean mustReceiveNotifications)
+ throws CommitException
+ {
+ TestListener2 controlViewListener = new TestListener2(CDOViewLocksChangedEvent.class);
+ controlView.addListener(controlViewListener);
+
+ CDOTransaction tx1 = session1.openTransaction();
+ CDOResource res1 = tx1.getOrCreateResource(getResourcePath("r1"));
+ TestListener2 transactionListener = new TestListener2(CDOViewLocksChangedEvent.class);
+ tx1.addListener(transactionListener);
+ res1.getContents().clear();
+ Company company = getModel1Factory().createCompany();
+ res1.getContents().add(company);
+ tx1.commit();
+
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+
+ CDOObject cdoCompanyInControlView = null;
+ if (mustReceiveNotifications)
+ {
+ cdoCompanyInControlView = controlView.getObject(cdoCompany.cdoID());
+ }
+
+ /* Test write lock */
+
+ cdoCompany.cdoWriteLock().lock();
+ if (mustReceiveNotifications)
+ {
+ controlViewListener.waitFor(1);
+ assertEquals(1, controlViewListener.getEvents().size());
+
+ CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(0);
+ assertLockOwner(tx1, event.getLockOwner());
+
+ CDOLockState[] lockStates = event.getLockStates();
+ assertEquals(1, lockStates.length);
+ assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
+ assertLockOwner(tx1, lockStates[0].getWriteLockOwner());
+ assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
+ }
+
+ cdoCompany.cdoWriteLock().unlock();
+ if (mustReceiveNotifications)
+ {
+ controlViewListener.waitFor(2);
+
+ assertEquals(2, controlViewListener.getEvents().size());
+
+ CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(1);
+ assertLockOwner(tx1, event.getLockOwner());
+
+ CDOLockState[] lockStates = event.getLockStates();
+ assertEquals(1, lockStates.length);
+ assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
+ assertNull(lockStates[0].getWriteLockOwner());
+ assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
+ }
+
+ /* Test read lock */
+
+ cdoCompany.cdoReadLock().lock();
+ if (mustReceiveNotifications)
+ {
+ controlViewListener.waitFor(3);
+ assertEquals(3, controlViewListener.getEvents().size());
+
+ CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(2);
+ assertLockOwner(tx1, event.getLockOwner());
+
+ CDOLockState[] lockStates = event.getLockStates();
+ assertEquals(1, lockStates.length);
+ assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
+ assertEquals(1, lockStates[0].getReadLockOwners().size());
+ CDOLockOwner tx1Lo = CDOLockUtil.createLockOwner(tx1);
+ assertEquals(true, lockStates[0].getReadLockOwners().contains(tx1Lo));
+ assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
+ }
+
+ cdoCompany.cdoReadLock().unlock();
+ if (mustReceiveNotifications)
+ {
+ controlViewListener.waitFor(4);
+
+ assertEquals(4, controlViewListener.getEvents().size());
+
+ CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(3);
+ assertLockOwner(tx1, event.getLockOwner());
+
+ CDOLockState[] lockStates = event.getLockStates();
+ assertEquals(1, lockStates.length);
+ assertEquals(0, lockStates[0].getReadLockOwners().size());
+ assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
+ }
+
+ /* Test write option */
+
+ cdoCompany.cdoWriteOption().lock();
+ if (mustReceiveNotifications)
+ {
+ controlViewListener.waitFor(5);
+ assertEquals(5, controlViewListener.getEvents().size());
+
+ CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(4);
+ assertLockOwner(tx1, event.getLockOwner());
+
+ CDOLockState[] lockStates = event.getLockStates();
+ assertEquals(1, lockStates.length);
+ assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
+ assertLockOwner(tx1, lockStates[0].getWriteOptionOwner());
+ assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
+ }
+
+ cdoCompany.cdoWriteOption().unlock();
+ if (mustReceiveNotifications)
+ {
+ controlViewListener.waitFor(6);
+
+ assertEquals(6, controlViewListener.getEvents().size());
+
+ CDOViewLocksChangedEvent event = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(5);
+ assertLockOwner(tx1, event.getLockOwner());
+
+ CDOLockState[] lockStates = event.getLockStates();
+ assertEquals(1, lockStates.length);
+ assertLockedObject(cdoCompany, lockStates[0].getLockedObject());
+ assertNull(lockStates[0].getWriteOptionOwner());
+ assertSame(cdoCompanyInControlView.cdoLockState(), lockStates[0]);
+ }
+
+ assertEquals(0, transactionListener.getEvents().size());
+
+ if (!mustReceiveNotifications)
+ {
+ assertEquals(0, controlViewListener.getEvents().size());
+ }
+ }
+
+ private void withAutoRelease(CDOSession session1, CDOView controlView, boolean mustReceiveNotifications)
+ throws CommitException
+ {
+ TestListener2 controlViewListener = new TestListener2(CDOViewLocksChangedEvent.class);
+ controlView.addListener(controlViewListener);
+
+ CDOTransaction tx1 = session1.openTransaction();
+ tx1.options().setAutoReleaseLocksEnabled(true);
+ CDOResource res1 = tx1.getOrCreateResource(getResourcePath("r1"));
+ res1.getContents().clear();
+ Company company = getModel1Factory().createCompany();
+ res1.getContents().add(company);
+ tx1.commit();
+
+ implicitRelease(company, LockType.WRITE, tx1, controlViewListener, mustReceiveNotifications);
+ implicitRelease(company, LockType.READ, tx1, controlViewListener, mustReceiveNotifications);
+ implicitRelease(company, LockType.OPTION, tx1, controlViewListener, mustReceiveNotifications);
+ }
+
+ private void implicitRelease(Company company, LockType type, CDOTransaction tx, TestListener2 controlViewListener,
+ boolean mustReceiveNotifications) throws CommitException
+ {
+ CDOViewLocksChangedEvent e;
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+
+ company.setName(company.getName() + "x"); // Make name field dirty
+ cdoCompany.cdoWriteLock().lock();
+
+ if (mustReceiveNotifications)
+ {
+ controlViewListener.waitFor(1);
+ e = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(0);
+ assertSame(Operation.LOCK, e.getOperation());
+ assertSame(LockType.WRITE, e.getLockType());
+ }
+
+ tx.commit();
+
+ if (mustReceiveNotifications)
+ {
+ controlViewListener.waitFor(2);
+ e = (CDOViewLocksChangedEvent)controlViewListener.getEvents().get(1);
+ assertSame(Operation.UNLOCK, e.getOperation());
+ assertNull(e.getLockType());
+ }
+
+ if (!mustReceiveNotifications)
+ {
+ assertEquals(0, controlViewListener.getEvents().size());
+ }
+ }
+
+ private void assertLockedObject(CDOObject obj, Object lockedObject)
+ {
+ if (lockedObject instanceof CDOIDAndBranch)
+ {
+ CDOIDAndBranch idAndBranch = CDOIDUtil.createIDAndBranch(obj.cdoID(), obj.cdoView().getBranch());
+ assertEquals(idAndBranch, lockedObject);
+ }
+ else if (lockedObject instanceof CDOID)
+ {
+ assertEquals(obj.cdoID(), lockedObject);
+ }
+ }
+
+ private void assertLockOwner(CDOView view, CDOLockOwner lockOwner)
+ {
+ CDOLockOwner lo = CDOLockUtil.createLockOwner(view);
+ assertEquals(lo, lockOwner);
+ }
+
+ public void testEnableDisableNotifications() throws CommitException
+ {
+ CDOSession session1 = openSession();
+ CDOSession session2 = openSession();
+ CDOView controlView = session2.openView();
+ withExplicitRelease(session1, controlView, false);
+
+ controlView.options().setLockNotificationEnabled(true);
+ withExplicitRelease(session1, controlView, true);
+
+ controlView.options().setLockNotificationEnabled(false);
+ withExplicitRelease(session1, controlView, false);
+
+ session1.close();
+ session2.close();
+ }
+
+ public void testLockStateHeldByDurableView() throws CommitException
+ {
+ {
+ CDOSession session1 = openSession();
+ CDOTransaction tx1 = session1.openTransaction();
+ tx1.enableDurableLocking();
+ CDOResource res1 = tx1.createResource(getResourcePath("r1"));
+ Company company1 = getModel1Factory().createCompany();
+ res1.getContents().add(company1);
+ tx1.commit();
+
+ CDOUtil.getCDOObject(company1).cdoWriteLock().lock();
+ tx1.close();
+ session1.close();
+ }
+
+ CDOSession session2 = openSession();
+ CDOView controlView = session2.openView();
+ CDOResource resource = controlView.getResource(getResourcePath("r1"));
+ Company company1 = (Company)resource.getContents().get(0);
+ CDOObject cdoObj = CDOUtil.getCDOObject(company1);
+ assertEquals(true, cdoObj.cdoWriteLock().isLockedByOthers());
+ assertEquals(true, cdoObj.cdoLockState().getWriteLockOwner().isDurableView());
+ session2.close();
+ }
+
+ public void testLockStateNewAndTransient() throws CommitException
+ {
+ Company company1 = getModel1Factory().createCompany();
+ CDOObject cdoObj = CDOUtil.getCDOObject(company1);
+ assertTransient(cdoObj);
+ assertNull(cdoObj.cdoLockState());
+
+ CDOSession session1 = openSession();
+ CDOTransaction tx1 = session1.openTransaction();
+ CDOResource res1 = tx1.createResource(getResourcePath("r1"));
+ res1.getContents().add(company1);
+ assertNew(cdoObj, tx1);
+ assertNotNull(cdoObj.cdoLockState());
+
+ res1.getContents().remove(company1);
+ assertTransient(cdoObj);
+ assertNull(cdoObj.cdoLockState());
+
+ res1.getContents().add(company1);
+ tx1.commit();
+ assertClean(cdoObj, tx1);
+ assertNotNull(cdoObj.cdoLockState());
+
+ res1.getContents().remove(company1);
+ assertTransient(cdoObj);
+ assertNull(cdoObj.cdoLockState());
+
+ session1.close();
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private static enum LockReleaseMode
+ {
+ EXPLICIT, AUTO
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MEMStoreQueryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MEMStoreQueryTest.java
index c47916c4ae..f21aee36ee 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MEMStoreQueryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MEMStoreQueryTest.java
@@ -1,219 +1,219 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOQuery;
-
-import org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.collection.CloseableIterator;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Simon McDuff
- */
-@Requires("MEM")
-public class MEMStoreQueryTest extends AbstractCDOTest
-{
- public void testMEMStoreBasicQuery() throws Exception
- {
- Set<Object> objects = new HashSet<Object>();
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
- objects.add(resource1);
- Company company1 = getModel1Factory().createCompany();
- Category category1 = getModel1Factory().createCategory();
-
- resource1.getContents().add(company1);
- company1.getCategories().add(category1);
-
- objects.add(company1);
- objects.add(category1);
- objects.add(transaction.getRootResource());
- objects.add(transaction.getResourceNode(getResourcePath(null)));
- company1.setName("TEST");
-
- transaction.commit();
-
- CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
- List<Object> result = query.getResult(Object.class);
- assertEquals(5, result.size());
- for (Object object : result)
- {
- assertEquals(true, objects.contains(object));
- }
-
- transaction.close();
- session.close();
- }
-
- public void testMEMStoreBasicQuery_EClassParameter() throws Exception
- {
- Set<Object> objects = new HashSet<Object>();
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
- objects.add(resource1);
- Company company1 = getModel1Factory().createCompany();
- Category category1 = getModel1Factory().createCategory();
-
- resource1.getContents().add(company1);
- company1.getCategories().add(category1);
-
- objects.add(company1);
- objects.add(category1);
-
- company1.setName("TEST");
-
- transaction.commit();
- System.out.println(category1.eClass().getEPackage().getNsURI());
-
- CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
- query.setParameter("context", getModel1Package().getCategory());
-
- List<Category> result = query.getResult(Category.class);
- assertEquals(1, result.size());
- assertEquals(category1, result.get(0));
-
- transaction.close();
- session.close();
- }
-
- public void testMEMStoreQueryCancel_successful() throws Exception
- {
- CDOTransaction transaction = initialize(500);
- CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
- query.setParameter("sleep", 1000L);
- final CloseableIterator<Object> result = query.getResultAsync(Object.class);
- result.close();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return !getRepository().getQueryManager().isRunning(((CDOQueryResultIteratorImpl<?>)result).getQueryID());
- }
- }.assertNoTimeOut();
-
- CDOSession session = transaction.getSession();
- transaction.close();
- session.close();
- }
-
- public void testMEMStoreQueryCancel_ViewClose() throws Exception
- {
- CDOTransaction transaction = initialize(500);
- CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
- query.setParameter("sleep", 1000L);
- final CloseableIterator<Object> result = query.getResultAsync(Object.class);
- CDOSession session = transaction.getSession();
- transaction.close();
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return !getRepository().getQueryManager().isRunning(((CDOQueryResultIteratorImpl<?>)result).getQueryID());
- }
- }.assertNoTimeOut();
-
- session.close();
- }
-
- public void testMEMStoreQueryCancel_SessionClose() throws Exception
- {
- CDOTransaction transaction = initialize(500);
- CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
- query.setParameter("sleep", 1000L);
- final CloseableIterator<Object> result = query.getResultAsync(Object.class);
- transaction.getSession().close();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return !getRepository().getQueryManager().isRunning(((CDOQueryResultIteratorImpl<?>)result).getQueryID());
- }
- }.assertNoTimeOut();
- }
-
- public void testMEMStoreQueryAsync_UnsupportedLanguage() throws Exception
- {
- CDOTransaction transaction = initialize(100);
- CDOQuery query = transaction.createQuery("TESTss", "QUERYSTRING");
-
- try
- {
- CloseableIterator<Object> result = query.getResultAsync(Object.class);
- result.hasNext();
- fail("Should throw an exception");
- }
- catch (Exception expected)
- {
- }
- }
-
- public void testMEMStoreQuerySync_UnsupportedLanguage() throws Exception
- {
- CDOTransaction transaction = initialize(100);
- CDOQuery query = transaction.createQuery("TESTss", "QUERYSTRING");
-
- try
- {
- query.getResult(Object.class);
- fail("Should throw an exception");
- }
- catch (Exception expected)
- {
- }
- }
-
- private CDOTransaction initialize(int number)
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
-
- for (int i = 0; i < number; i++)
- {
- Category category1 = getModel1Factory().createCategory();
- resource1.getContents().add(category1);
- }
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- return transaction;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOQuery;
+
+import org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.collection.CloseableIterator;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Simon McDuff
+ */
+@Requires("MEM")
+public class MEMStoreQueryTest extends AbstractCDOTest
+{
+ public void testMEMStoreBasicQuery() throws Exception
+ {
+ Set<Object> objects = new HashSet<Object>();
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+ objects.add(resource1);
+ Company company1 = getModel1Factory().createCompany();
+ Category category1 = getModel1Factory().createCategory();
+
+ resource1.getContents().add(company1);
+ company1.getCategories().add(category1);
+
+ objects.add(company1);
+ objects.add(category1);
+ objects.add(transaction.getRootResource());
+ objects.add(transaction.getResourceNode(getResourcePath(null)));
+ company1.setName("TEST");
+
+ transaction.commit();
+
+ CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
+ List<Object> result = query.getResult(Object.class);
+ assertEquals(5, result.size());
+ for (Object object : result)
+ {
+ assertEquals(true, objects.contains(object));
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ public void testMEMStoreBasicQuery_EClassParameter() throws Exception
+ {
+ Set<Object> objects = new HashSet<Object>();
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+ objects.add(resource1);
+ Company company1 = getModel1Factory().createCompany();
+ Category category1 = getModel1Factory().createCategory();
+
+ resource1.getContents().add(company1);
+ company1.getCategories().add(category1);
+
+ objects.add(company1);
+ objects.add(category1);
+
+ company1.setName("TEST");
+
+ transaction.commit();
+ System.out.println(category1.eClass().getEPackage().getNsURI());
+
+ CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
+ query.setParameter("context", getModel1Package().getCategory());
+
+ List<Category> result = query.getResult(Category.class);
+ assertEquals(1, result.size());
+ assertEquals(category1, result.get(0));
+
+ transaction.close();
+ session.close();
+ }
+
+ public void testMEMStoreQueryCancel_successful() throws Exception
+ {
+ CDOTransaction transaction = initialize(500);
+ CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
+ query.setParameter("sleep", 1000L);
+ final CloseableIterator<Object> result = query.getResultAsync(Object.class);
+ result.close();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return !getRepository().getQueryManager().isRunning(((CDOQueryResultIteratorImpl<?>)result).getQueryID());
+ }
+ }.assertNoTimeOut();
+
+ CDOSession session = transaction.getSession();
+ transaction.close();
+ session.close();
+ }
+
+ public void testMEMStoreQueryCancel_ViewClose() throws Exception
+ {
+ CDOTransaction transaction = initialize(500);
+ CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
+ query.setParameter("sleep", 1000L);
+ final CloseableIterator<Object> result = query.getResultAsync(Object.class);
+ CDOSession session = transaction.getSession();
+ transaction.close();
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return !getRepository().getQueryManager().isRunning(((CDOQueryResultIteratorImpl<?>)result).getQueryID());
+ }
+ }.assertNoTimeOut();
+
+ session.close();
+ }
+
+ public void testMEMStoreQueryCancel_SessionClose() throws Exception
+ {
+ CDOTransaction transaction = initialize(500);
+ CDOQuery query = transaction.createQuery("TEST", "QUERYSTRING");
+ query.setParameter("sleep", 1000L);
+ final CloseableIterator<Object> result = query.getResultAsync(Object.class);
+ transaction.getSession().close();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return !getRepository().getQueryManager().isRunning(((CDOQueryResultIteratorImpl<?>)result).getQueryID());
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testMEMStoreQueryAsync_UnsupportedLanguage() throws Exception
+ {
+ CDOTransaction transaction = initialize(100);
+ CDOQuery query = transaction.createQuery("TESTss", "QUERYSTRING");
+
+ try
+ {
+ CloseableIterator<Object> result = query.getResultAsync(Object.class);
+ result.hasNext();
+ fail("Should throw an exception");
+ }
+ catch (Exception expected)
+ {
+ }
+ }
+
+ public void testMEMStoreQuerySync_UnsupportedLanguage() throws Exception
+ {
+ CDOTransaction transaction = initialize(100);
+ CDOQuery query = transaction.createQuery("TESTss", "QUERYSTRING");
+
+ try
+ {
+ query.getResult(Object.class);
+ fail("Should throw an exception");
+ }
+ catch (Exception expected)
+ {
+ }
+ }
+
+ private CDOTransaction initialize(int number)
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+
+ for (int i = 0; i < number; i++)
+ {
+ Category category1 = getModel1Factory().createCategory();
+ resource1.getContents().add(category1);
+ }
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ return transaction;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java
index 7f9d5791c4..5147a6b7dd 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java
@@ -1,53 +1,53 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.mango.MangoValue;
-import org.eclipse.emf.cdo.tests.mango.MangoValueList;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * @author Eike Stepper
- */
-public class MangoTest extends AbstractCDOTest
-{
- public void testCommitNew() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- MangoValue v1 = getMangoFactory().createMangoValue();
- v1.setName("v1");
- resource.getContents().add(v1);
-
- MangoValue v2 = getMangoFactory().createMangoValue();
- v2.setName("v2");
- resource.getContents().add(v2);
-
- MangoValueList list = getMangoFactory().createMangoValueList();
- list.setName("List");
- list.getValues().add(v1);
- list.getValues().add(v2);
- resource.getContents().add(list);
-
- transaction.commit();
- assertEquals(CDOState.CLEAN, resource.cdoState());
- assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(list).cdoState());
- assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(v1).cdoState());
- assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(v2).cdoState());
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.mango.MangoValue;
+import org.eclipse.emf.cdo.tests.mango.MangoValueList;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class MangoTest extends AbstractCDOTest
+{
+ public void testCommitNew() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ MangoValue v1 = getMangoFactory().createMangoValue();
+ v1.setName("v1");
+ resource.getContents().add(v1);
+
+ MangoValue v2 = getMangoFactory().createMangoValue();
+ v2.setName("v2");
+ resource.getContents().add(v2);
+
+ MangoValueList list = getMangoFactory().createMangoValueList();
+ list.setName("List");
+ list.getValues().add(v1);
+ list.getValues().add(v2);
+ resource.getContents().add(list);
+
+ transaction.commit();
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(list).cdoState());
+ assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(v1).cdoState());
+ assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(v2).cdoState());
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapDynamicTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapDynamicTest.java
index 3299f5c47c..79f22b67a7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapDynamicTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapDynamicTest.java
@@ -1,610 +1,610 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.common.util.EMap;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.impl.EReferenceImpl;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Note! This class should never be attached to our the suites until this notification is removed. Otherwise the test
- * run will fail because this test cases is not yet integrated into our test framework! Only run this test as local
- * JUnit test case.
- *
- * @author Martin Fluegge
- */
-@SuppressWarnings({ "unchecked", "rawtypes" })
-public class MapDynamicTest extends MapTest
-{
- private EPackage dynamicPackage;
-
- private Map objects;
-
- private EStructuralFeature feature;
-
- private final EObject container;
-
- public MapDynamicTest(EObject mapContainer, EReference mapFeature, Map objects2, EPackage dynamicMapEPackge)
- {
- container = mapContainer;
- feature = mapFeature;
- objects = objects2;
- dynamicPackage = dynamicMapEPackge;
- super.setName(feature.getName() + "Test");
- }
-
- @Override
- protected void runTest() throws Throwable
- {
- testMap(container, (EReference)feature, objects, dynamicPackage);
- }
-
- public static Test suite() throws Exception
- {
- TestSuite suite = new TestSuite(MapDynamicTest.class.getName());
-
- EPackage dynamicMapEPackge = createPackage();
- EFactory dynamicMapEFactoryInstance = dynamicMapEPackge.getEFactoryInstance();
-
- for (EStructuralFeature mapFeature : mapContainerEClass.getEAllStructuralFeatures())
- {
- EObject mapContainer = dynamicMapEFactoryInstance.create(mapContainerEClass);
- System.out.println(mapFeature);
- if (mapFeature.getName().endsWith("Map"))
- {
-
- Map objects = new HashMap();
- List key = dummyData.get(getEDataType(mapFeature, "key"));
- List value = dummyData.get(getEDataType(mapFeature, "value"));
- System.out.println("Testing " + mapFeature.getName() + "key: " + key + " / value: " + value);
- for (int i = 0; i < 3; i++)
- {
- objects.put(key.get(i), value.get(i));
- }
-
- // do the actual test
- suite.addTest(new MapDynamicTest(mapContainer, (EReference)mapFeature, objects, dynamicMapEPackge));
- }
- }
-
- return suite;
- }
-
- private static EDataType getEDataType(EStructuralFeature feature, String type) throws Exception
- {
- EClass eType = (EClass)feature.getEType();
- for (EStructuralFeature f : eType.getEAllStructuralFeatures())
- {
- if (f.getName().equals(type))
- {
- return (EDataType)f.getEType();
- }
- }
-
- throw new Exception("Could not find " + type + " for " + feature);
- }
-
- private void testMap(EObject container, EReference feature, Map objects, EPackage epackage) throws Exception
- {
- boolean keyIsReference = false;
- boolean valueIsReference = false;
- boolean keyNotContained = false;
- boolean valueNotContained = false;
-
- String resourceName = "/test1" + count++;
-
- EClass eType = (EClass)feature.getEType();
- for (EStructuralFeature f : eType.getEAllStructuralFeatures())
- {
- if (f.getName().equals("key"))
- {
- if (f instanceof EReference)
- {
- keyIsReference = true;
- if (!((EReferenceImpl)f).isContainment())
- {
- keyNotContained = true;
- }
- }
- }
- else if (f.getName().equals("value"))
- {
- if (f instanceof EReference)
- {
- valueIsReference = true;
- if (!((EReferenceImpl)f).isContainment())
- {
- valueNotContained = true;
- }
- }
- }
- }
-
- {
- CDOSession session = openSession();
- if (epackage != null)
- {
- session.getPackageRegistry().putEPackage(epackage);
- }
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(resourceName);
-
- EMap map = (EMap)container.eGet(feature);
-
- for (Object key : objects.keySet())
- {
- map.put(key, objects.get(key));
- }
-
- compareSimple(objects, map);
-
- resource.getContents().add(container);
- if (keyNotContained && keyIsReference) // avoid dangling references if needed
- {
- for (Object key : map.keySet())
- {
- if (key instanceof EObject)
- {
- resource.getContents().add((EObject)key);
- }
- }
- }
-
- if (valueNotContained && valueIsReference) // avoid dangling references if needed
- {
- for (Object value : map.values())
- {
- if (value instanceof EObject)
- {
- resource.getContents().add((EObject)value);
- }
- }
- }
-
- compareSimple(objects, map);
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- if (epackage != null)
- {
- session.getPackageRegistry().putEPackage(epackage);
- }
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath(resourceName));
-
- EObject mapHolder = resource.getContents().get(0);
-
- for (EStructuralFeature e : mapHolder.eClass().getEAllStructuralFeatures())
- {
- System.out.println(e);
- }
-
- EMap map = (EMap)mapHolder.eGet(feature);
-
- compare(objects, keyIsReference, valueIsReference, map);
-
- assertEquals(map.size(), objects.size());
-
- map.remove(0);
-
- assertEquals(map.size(), objects.size() - 1);
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- if (epackage != null)
- {
- session.getPackageRegistry().putEPackage(epackage);
- }
-
- CDOResource resource = transaction.getResource(getResourcePath(resourceName));
-
- EObject mapHolder = resource.getContents().get(0);
-
- EMap map = (EMap)mapHolder.eGet(feature);
-
- compare(objects, keyIsReference, valueIsReference, map);
-
- assertEquals(map.size(), objects.size() - 1);
-
- map.clear();
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- if (epackage != null)
- {
- session.getPackageRegistry().putEPackage(epackage);
- }
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath(resourceName));
-
- EObject mapHolder = resource.getContents().get(0);
-
- EMap map = (EMap)mapHolder.eGet(feature);
- assertEquals(map.size(), 0);
-
- transaction.close();
- session.close();
- }
- }
-
- private void compareSimple(Map objects, EMap map)
- {
- for (Object key : objects.keySet())
- {
- assertEquals(true, map.keySet().contains(key));
- assertEquals(true, map.values().contains(objects.get(key)));
- }
- }
-
- /**
- * This one looks a bit complicated but we must make sure the reference objects a compared by CDO IDs. Because the
- * test case is designed to be as generic as possible to allow easy enhancement.
- */
- private void compare(Map objects, boolean keyIsReference, boolean valueIsReference, EMap map)
- {
- for (Object key : map.keySet())
- {
- if (!keyIsReference)
- {
- assertEquals(true, objects.keySet().contains(key));
- }
- else
- {
- boolean foundObjectWithSameID = false;
- for (Object keyMap : objects.keySet())
- {
- CDOID valueID = CDOUtil.getCDOObject((EObject)key).cdoID();
- CDOID valueMapID = CDOUtil.getCDOObject((EObject)keyMap).cdoID();
-
- if (valueID.equals(valueMapID))
- {
- foundObjectWithSameID = true;
- }
- }
-
- if (!foundObjectWithSameID)
- {
- fail("key reference with CDOID could not be found");
- }
- }
-
- if (!valueIsReference)
- {
- assertEquals(true, objects.keySet().contains(key));
- }
- else
- {
- boolean foundObjectWithSameID = false;
- for (Object valueMap : objects.values())
- {
- CDOID valueID = CDOUtil.getCDOObject((EObject)map.get(key)).cdoID();
- CDOID valueMapID = CDOUtil.getCDOObject((EObject)valueMap).cdoID();
-
- if (valueID.equals(valueMapID))
- {
- foundObjectWithSameID = true;
- }
- }
- if (!foundObjectWithSameID)
- {
- fail("value reference with CDOID could not be found");
- }
- }
- }
- }
-
- // private static EPackage createPackage()
- // {
- //
- // EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
- // EcorePackage theCorePackage = EcorePackage.eINSTANCE;
- //
- // mapContainerEClass = theCoreFactory.createEClass();
- // mapContainerEClass.setName("MapContainer");
- //
- // EPackage dynamicMapEPackage = theCoreFactory.createEPackage();
- // dynamicMapEPackage.setName("DynamicMapPackage");
- // dynamicMapEPackage.setNsPrefix("dynamicmap");
- // dynamicMapEPackage.setNsURI("http:///org.mftech.examples.emf.dynamic.map");
- //
- // dynamicMapEPackage.getEClassifiers().add(mapContainerEClass);
- //
- // // ++++++++++++++ create dynamic
- // // TODO provide Reference mapping
- // Map<EDataType, Boolean> dataTypes = new HashMap<EDataType, Boolean>();
- // dataTypes.put(theCorePackage.getEBigDecimal(), true);
- // dataTypes.put(theCorePackage.getEBigInteger(), true);
- // dataTypes.put(theCorePackage.getEBoolean(), true);
- // dataTypes.put(theCorePackage.getEBooleanObject(), true);
- // dataTypes.put(theCorePackage.getEByte(), true);
- // // //dataTypes.put(theCorePackage.getEByteArray(), true);
- // dataTypes.put(theCorePackage.getEByteObject(), true);
- // dataTypes.put(theCorePackage.getEChar(), true);
- // // dataTypes.put(theCorePackage.getECharacterObject(), false);
- // dataTypes.put(theCorePackage.getEDate(), true);
- // // // dataTypes.put(theCorePackage.getEDiagnosticChain(), true);
- // dataTypes.put(theCorePackage.getEDouble(), true);
- // // dataTypes.put(theCorePackage.getEDoubleObject(), false);
- // dataTypes.put(theCorePackage.getEFloat(), true);
- // // dataTypes.put(theCorePackage.getEFloatObject(), false);
- // dataTypes.put(theCorePackage.getEInt(), true);
- // // dataTypes.put(theCorePackage.getEIntegerObject(), false);
- // dataTypes.put(theCorePackage.getEJavaObject(), true);
- // dataTypes.put(theCorePackage.getEJavaClass(), true);
- // dataTypes.put(theCorePackage.getELong(), true);
- // // dataTypes.put(theCorePackage.getELongObject(), false);
- // // dataTypes.put(theCorePackage.getEMap(), false);
- // dataTypes.put(theCorePackage.getEShort(), true);
- // dataTypes.put(theCorePackage.getEShortObject(), true);
- // dataTypes.put(theCorePackage.getEString(), true);
- //
- // System.out.println("Start");
- //
- // int i = 0;
- // for (EDataType keyDataType : dataTypes.keySet())
- // {
- // String keyName = keyDataType.getName();
- // for (EDataType valueDataType : dataTypes.keySet())
- // {
- //
- // String valueName = valueDataType.getName();
- // String mapName = keyName + "To" + valueName + "Map";
- //
- // EClass mapEClass = theCoreFactory.createEClass();
- // mapEClass.setName(mapName);
- // mapEClass.setInstanceTypeName("java.util.Map$Entry");
- //
- // EStructuralFeature key;
- // if (dataTypes.get(keyDataType))
- // {
- // key = theCoreFactory.createEAttribute();
- // }
- // else
- // {
- // key = theCoreFactory.createEReference();
- // }
- //
- // key.setName("key");
- // key.setEType(keyDataType);
- //
- // // EStructuralFeature value = theCoreFactory.createEAttribute();
- // EStructuralFeature value;
- // if (dataTypes.get(valueDataType))
- // {
- // value = theCoreFactory.createEAttribute();
- // }
- // else
- // {
- // value = theCoreFactory.createEReference();
- // }
- // value.setName("value");
- // value.setEType(valueDataType);
- //
- // mapEClass.getEStructuralFeatures().add(key);
- // mapEClass.getEStructuralFeatures().add(value);
- //
- // EReference containerMapFeature = theCoreFactory.createEReference();
- //
- // containerMapFeature.setName(mapName);
- // containerMapFeature.setEType(mapEClass);
- // containerMapFeature.setResolveProxies(false);
- // containerMapFeature.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY);
- // containerMapFeature.setContainment(true);
- //
- // dynamicMapEPackage.getEClassifiers().add(mapEClass);
- // mapContainerEClass.getEStructuralFeatures().add(containerMapFeature);
- //
- // System.out.println("Created " + mapName);
- // i++;
- // }
- // }
- //
- // System.out.println("Created " + i + " maps.");
- //
- // initDummyData(theCorePackage);
- // CDOUtil.prepareDynamicEPackage(dynamicMapEPackage);
- // return dynamicMapEPackage;
- //
- // }
-
- // private static void initDummyData(EcorePackage theCorePackage)
- // {
- // List data = new ArrayList();
- // data.add("A");
- // data.add("B");
- // data.add("C");
- // dummyData.put(theCorePackage.getEString(), data);
- //
- // data = new ArrayList();
- // data.add(new BigInteger("11111111111111"));
- // data.add(new BigInteger("22222222222222"));
- // data.add(new BigInteger("333333333333333"));
- // dummyData.put(theCorePackage.getEBigInteger(), data);
- //
- // data = new ArrayList();
- // data.add(new BigDecimal("44444444444444"));
- // data.add(new BigDecimal("55555555555555"));
- // data.add(new BigDecimal("66666666666666"));
- // dummyData.put(theCorePackage.getEBigDecimal(), data);
- //
- // data = new ArrayList();
- // data.add(true);
- // data.add(false);
- // data.add(true);
- // dummyData.put(theCorePackage.getEBoolean(), data);
- //
- // data = new ArrayList();
- // data.add(new Boolean(true));
- // data.add(new Boolean("false"));
- // data.add(new Boolean(true));
- // dummyData.put(theCorePackage.getEBooleanObject(), data);
- //
- // data = new ArrayList();
- // data.add((byte)1);
- // data.add((byte)2);
- // data.add((byte)3);
- // dummyData.put(theCorePackage.getEByte(), data);
- //
- // // TODO create additional dummy Data
- // // dummyData.put(theCorePackage.getEByteArray(), data);
- //
- // data = new ArrayList();
- // data.add(new Byte((byte)1));
- // data.add(new Byte("2"));
- // data.add(new Byte((byte)3));
- // dummyData.put(theCorePackage.getEByteObject(), data);
- //
- // data = new ArrayList();
- // data.add('a');
- // data.add((char)99);
- // data.add('c');
- // dummyData.put(theCorePackage.getEChar(), data);
- //
- // data = new ArrayList();
- // data.add(new Character('a'));
- // data.add(new Character((char)99));
- // data.add(new Character('c'));
- // dummyData.put(theCorePackage.getECharacterObject(), data);
- //
- // data = new ArrayList();
- // data.add(new Date());
- // data.add(new Date());
- // data.add(new Date());
- // dummyData.put(theCorePackage.getEDate(), data);
- //
- // // TODO create additional dummy Data
- // // dummyData.put(theCorePackage.getEDiagnosticChain(), data);
- //
- // data = new ArrayList();
- // data.add(111.111D);
- // data.add(222.222D);
- // data.add(333.333D);
- // dummyData.put(theCorePackage.getEDouble(), data);
- //
- // data = new ArrayList();
- // data.add(new Double(444.444));
- // data.add(new Double("555.555"));
- // data.add(new Double(666.666));
- // dummyData.put(theCorePackage.getEDoubleObject(), data);
- //
- // data = new ArrayList();
- // data.add(111.0001f);
- // data.add(222.0002f);
- // data.add(333.0003f);
- // dummyData.put(theCorePackage.getEFloat(), data);
- //
- // data = new ArrayList();
- // data.add(new Float(444.0004f));
- // data.add(new Float(555.0005d));
- // data.add(new Float("666.0006"));
- // dummyData.put(theCorePackage.getEFloatObject(), data);
- //
- // data = new ArrayList();
- // data.add(11);
- // data.add(22);
- // data.add(33);
- // dummyData.put(theCorePackage.getEInt(), data);
- //
- // data = new ArrayList();
- // data.add(new Integer(44));
- // data.add(new Integer("55"));
- // data.add(new Integer(66));
- // dummyData.put(theCorePackage.getEIntegerObject(), data);
- //
- // data = new ArrayList();
- // data.add(new Long(1));
- // data.add(new Date());
- // data.add(new Integer(2));
- // dummyData.put(theCorePackage.getEJavaObject(), data);
- //
- // data = new ArrayList();
- // data.add(Object.class);
- // data.add(Date.class);
- // data.add(Long.class);
- // dummyData.put(theCorePackage.getEJavaClass(), data);
- //
- // data = new ArrayList();
- // data.add(10101010101L);
- // data.add(20202020202L);
- // data.add(30303030303L);
- // dummyData.put(theCorePackage.getELong(), data);
- //
- // data = new ArrayList();
- // data.add(new Long(40404040404L));
- // data.add(new Long("5050505050505"));
- // data.add(new Long(6060606060606L));
- // dummyData.put(theCorePackage.getELongObject(), data);
- //
- // data = new ArrayList();
- //
- // Map map = new HashMap();
- // map.put(1, 2);
- // map.put(3, 4);
- // data.add(map);
- // map = new HashMap();
- // map.put("A", "B");
- // map.put("C", "D");
- // data.add(map);
- // map = new HashMap();
- // map.put('a', 'b');
- // map.put('c', 'd');
- // data.add(map);
- // dummyData.put(theCorePackage.getEMap(), data);
- //
- // data = new ArrayList();
- // data.add((short)111);
- // data.add((short)222);
- // data.add((short)333);
- // dummyData.put(theCorePackage.getEShort(), data);
- //
- // data = new ArrayList();
- // data.add(new Short((short)111));
- // data.add(new Short((short)222));
- // data.add(new Short((short)333));
- // dummyData.put(theCorePackage.getEShortObject(), data);
- //
- // }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EReferenceImpl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Note! This class should never be attached to our the suites until this notification is removed. Otherwise the test
+ * run will fail because this test cases is not yet integrated into our test framework! Only run this test as local
+ * JUnit test case.
+ *
+ * @author Martin Fluegge
+ */
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public class MapDynamicTest extends MapTest
+{
+ private EPackage dynamicPackage;
+
+ private Map objects;
+
+ private EStructuralFeature feature;
+
+ private final EObject container;
+
+ public MapDynamicTest(EObject mapContainer, EReference mapFeature, Map objects2, EPackage dynamicMapEPackge)
+ {
+ container = mapContainer;
+ feature = mapFeature;
+ objects = objects2;
+ dynamicPackage = dynamicMapEPackge;
+ super.setName(feature.getName() + "Test");
+ }
+
+ @Override
+ protected void runTest() throws Throwable
+ {
+ testMap(container, (EReference)feature, objects, dynamicPackage);
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite(MapDynamicTest.class.getName());
+
+ EPackage dynamicMapEPackge = createPackage();
+ EFactory dynamicMapEFactoryInstance = dynamicMapEPackge.getEFactoryInstance();
+
+ for (EStructuralFeature mapFeature : mapContainerEClass.getEAllStructuralFeatures())
+ {
+ EObject mapContainer = dynamicMapEFactoryInstance.create(mapContainerEClass);
+ System.out.println(mapFeature);
+ if (mapFeature.getName().endsWith("Map"))
+ {
+
+ Map objects = new HashMap();
+ List key = dummyData.get(getEDataType(mapFeature, "key"));
+ List value = dummyData.get(getEDataType(mapFeature, "value"));
+ System.out.println("Testing " + mapFeature.getName() + "key: " + key + " / value: " + value);
+ for (int i = 0; i < 3; i++)
+ {
+ objects.put(key.get(i), value.get(i));
+ }
+
+ // do the actual test
+ suite.addTest(new MapDynamicTest(mapContainer, (EReference)mapFeature, objects, dynamicMapEPackge));
+ }
+ }
+
+ return suite;
+ }
+
+ private static EDataType getEDataType(EStructuralFeature feature, String type) throws Exception
+ {
+ EClass eType = (EClass)feature.getEType();
+ for (EStructuralFeature f : eType.getEAllStructuralFeatures())
+ {
+ if (f.getName().equals(type))
+ {
+ return (EDataType)f.getEType();
+ }
+ }
+
+ throw new Exception("Could not find " + type + " for " + feature);
+ }
+
+ private void testMap(EObject container, EReference feature, Map objects, EPackage epackage) throws Exception
+ {
+ boolean keyIsReference = false;
+ boolean valueIsReference = false;
+ boolean keyNotContained = false;
+ boolean valueNotContained = false;
+
+ String resourceName = "/test1" + count++;
+
+ EClass eType = (EClass)feature.getEType();
+ for (EStructuralFeature f : eType.getEAllStructuralFeatures())
+ {
+ if (f.getName().equals("key"))
+ {
+ if (f instanceof EReference)
+ {
+ keyIsReference = true;
+ if (!((EReferenceImpl)f).isContainment())
+ {
+ keyNotContained = true;
+ }
+ }
+ }
+ else if (f.getName().equals("value"))
+ {
+ if (f instanceof EReference)
+ {
+ valueIsReference = true;
+ if (!((EReferenceImpl)f).isContainment())
+ {
+ valueNotContained = true;
+ }
+ }
+ }
+ }
+
+ {
+ CDOSession session = openSession();
+ if (epackage != null)
+ {
+ session.getPackageRegistry().putEPackage(epackage);
+ }
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(resourceName);
+
+ EMap map = (EMap)container.eGet(feature);
+
+ for (Object key : objects.keySet())
+ {
+ map.put(key, objects.get(key));
+ }
+
+ compareSimple(objects, map);
+
+ resource.getContents().add(container);
+ if (keyNotContained && keyIsReference) // avoid dangling references if needed
+ {
+ for (Object key : map.keySet())
+ {
+ if (key instanceof EObject)
+ {
+ resource.getContents().add((EObject)key);
+ }
+ }
+ }
+
+ if (valueNotContained && valueIsReference) // avoid dangling references if needed
+ {
+ for (Object value : map.values())
+ {
+ if (value instanceof EObject)
+ {
+ resource.getContents().add((EObject)value);
+ }
+ }
+ }
+
+ compareSimple(objects, map);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ if (epackage != null)
+ {
+ session.getPackageRegistry().putEPackage(epackage);
+ }
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath(resourceName));
+
+ EObject mapHolder = resource.getContents().get(0);
+
+ for (EStructuralFeature e : mapHolder.eClass().getEAllStructuralFeatures())
+ {
+ System.out.println(e);
+ }
+
+ EMap map = (EMap)mapHolder.eGet(feature);
+
+ compare(objects, keyIsReference, valueIsReference, map);
+
+ assertEquals(map.size(), objects.size());
+
+ map.remove(0);
+
+ assertEquals(map.size(), objects.size() - 1);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ if (epackage != null)
+ {
+ session.getPackageRegistry().putEPackage(epackage);
+ }
+
+ CDOResource resource = transaction.getResource(getResourcePath(resourceName));
+
+ EObject mapHolder = resource.getContents().get(0);
+
+ EMap map = (EMap)mapHolder.eGet(feature);
+
+ compare(objects, keyIsReference, valueIsReference, map);
+
+ assertEquals(map.size(), objects.size() - 1);
+
+ map.clear();
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ if (epackage != null)
+ {
+ session.getPackageRegistry().putEPackage(epackage);
+ }
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath(resourceName));
+
+ EObject mapHolder = resource.getContents().get(0);
+
+ EMap map = (EMap)mapHolder.eGet(feature);
+ assertEquals(map.size(), 0);
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ private void compareSimple(Map objects, EMap map)
+ {
+ for (Object key : objects.keySet())
+ {
+ assertEquals(true, map.keySet().contains(key));
+ assertEquals(true, map.values().contains(objects.get(key)));
+ }
+ }
+
+ /**
+ * This one looks a bit complicated but we must make sure the reference objects a compared by CDO IDs. Because the
+ * test case is designed to be as generic as possible to allow easy enhancement.
+ */
+ private void compare(Map objects, boolean keyIsReference, boolean valueIsReference, EMap map)
+ {
+ for (Object key : map.keySet())
+ {
+ if (!keyIsReference)
+ {
+ assertEquals(true, objects.keySet().contains(key));
+ }
+ else
+ {
+ boolean foundObjectWithSameID = false;
+ for (Object keyMap : objects.keySet())
+ {
+ CDOID valueID = CDOUtil.getCDOObject((EObject)key).cdoID();
+ CDOID valueMapID = CDOUtil.getCDOObject((EObject)keyMap).cdoID();
+
+ if (valueID.equals(valueMapID))
+ {
+ foundObjectWithSameID = true;
+ }
+ }
+
+ if (!foundObjectWithSameID)
+ {
+ fail("key reference with CDOID could not be found");
+ }
+ }
+
+ if (!valueIsReference)
+ {
+ assertEquals(true, objects.keySet().contains(key));
+ }
+ else
+ {
+ boolean foundObjectWithSameID = false;
+ for (Object valueMap : objects.values())
+ {
+ CDOID valueID = CDOUtil.getCDOObject((EObject)map.get(key)).cdoID();
+ CDOID valueMapID = CDOUtil.getCDOObject((EObject)valueMap).cdoID();
+
+ if (valueID.equals(valueMapID))
+ {
+ foundObjectWithSameID = true;
+ }
+ }
+ if (!foundObjectWithSameID)
+ {
+ fail("value reference with CDOID could not be found");
+ }
+ }
+ }
+ }
+
+ // private static EPackage createPackage()
+ // {
+ //
+ // EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
+ // EcorePackage theCorePackage = EcorePackage.eINSTANCE;
+ //
+ // mapContainerEClass = theCoreFactory.createEClass();
+ // mapContainerEClass.setName("MapContainer");
+ //
+ // EPackage dynamicMapEPackage = theCoreFactory.createEPackage();
+ // dynamicMapEPackage.setName("DynamicMapPackage");
+ // dynamicMapEPackage.setNsPrefix("dynamicmap");
+ // dynamicMapEPackage.setNsURI("http:///org.mftech.examples.emf.dynamic.map");
+ //
+ // dynamicMapEPackage.getEClassifiers().add(mapContainerEClass);
+ //
+ // // ++++++++++++++ create dynamic
+ // // TODO provide Reference mapping
+ // Map<EDataType, Boolean> dataTypes = new HashMap<EDataType, Boolean>();
+ // dataTypes.put(theCorePackage.getEBigDecimal(), true);
+ // dataTypes.put(theCorePackage.getEBigInteger(), true);
+ // dataTypes.put(theCorePackage.getEBoolean(), true);
+ // dataTypes.put(theCorePackage.getEBooleanObject(), true);
+ // dataTypes.put(theCorePackage.getEByte(), true);
+ // // //dataTypes.put(theCorePackage.getEByteArray(), true);
+ // dataTypes.put(theCorePackage.getEByteObject(), true);
+ // dataTypes.put(theCorePackage.getEChar(), true);
+ // // dataTypes.put(theCorePackage.getECharacterObject(), false);
+ // dataTypes.put(theCorePackage.getEDate(), true);
+ // // // dataTypes.put(theCorePackage.getEDiagnosticChain(), true);
+ // dataTypes.put(theCorePackage.getEDouble(), true);
+ // // dataTypes.put(theCorePackage.getEDoubleObject(), false);
+ // dataTypes.put(theCorePackage.getEFloat(), true);
+ // // dataTypes.put(theCorePackage.getEFloatObject(), false);
+ // dataTypes.put(theCorePackage.getEInt(), true);
+ // // dataTypes.put(theCorePackage.getEIntegerObject(), false);
+ // dataTypes.put(theCorePackage.getEJavaObject(), true);
+ // dataTypes.put(theCorePackage.getEJavaClass(), true);
+ // dataTypes.put(theCorePackage.getELong(), true);
+ // // dataTypes.put(theCorePackage.getELongObject(), false);
+ // // dataTypes.put(theCorePackage.getEMap(), false);
+ // dataTypes.put(theCorePackage.getEShort(), true);
+ // dataTypes.put(theCorePackage.getEShortObject(), true);
+ // dataTypes.put(theCorePackage.getEString(), true);
+ //
+ // System.out.println("Start");
+ //
+ // int i = 0;
+ // for (EDataType keyDataType : dataTypes.keySet())
+ // {
+ // String keyName = keyDataType.getName();
+ // for (EDataType valueDataType : dataTypes.keySet())
+ // {
+ //
+ // String valueName = valueDataType.getName();
+ // String mapName = keyName + "To" + valueName + "Map";
+ //
+ // EClass mapEClass = theCoreFactory.createEClass();
+ // mapEClass.setName(mapName);
+ // mapEClass.setInstanceTypeName("java.util.Map$Entry");
+ //
+ // EStructuralFeature key;
+ // if (dataTypes.get(keyDataType))
+ // {
+ // key = theCoreFactory.createEAttribute();
+ // }
+ // else
+ // {
+ // key = theCoreFactory.createEReference();
+ // }
+ //
+ // key.setName("key");
+ // key.setEType(keyDataType);
+ //
+ // // EStructuralFeature value = theCoreFactory.createEAttribute();
+ // EStructuralFeature value;
+ // if (dataTypes.get(valueDataType))
+ // {
+ // value = theCoreFactory.createEAttribute();
+ // }
+ // else
+ // {
+ // value = theCoreFactory.createEReference();
+ // }
+ // value.setName("value");
+ // value.setEType(valueDataType);
+ //
+ // mapEClass.getEStructuralFeatures().add(key);
+ // mapEClass.getEStructuralFeatures().add(value);
+ //
+ // EReference containerMapFeature = theCoreFactory.createEReference();
+ //
+ // containerMapFeature.setName(mapName);
+ // containerMapFeature.setEType(mapEClass);
+ // containerMapFeature.setResolveProxies(false);
+ // containerMapFeature.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY);
+ // containerMapFeature.setContainment(true);
+ //
+ // dynamicMapEPackage.getEClassifiers().add(mapEClass);
+ // mapContainerEClass.getEStructuralFeatures().add(containerMapFeature);
+ //
+ // System.out.println("Created " + mapName);
+ // i++;
+ // }
+ // }
+ //
+ // System.out.println("Created " + i + " maps.");
+ //
+ // initDummyData(theCorePackage);
+ // CDOUtil.prepareDynamicEPackage(dynamicMapEPackage);
+ // return dynamicMapEPackage;
+ //
+ // }
+
+ // private static void initDummyData(EcorePackage theCorePackage)
+ // {
+ // List data = new ArrayList();
+ // data.add("A");
+ // data.add("B");
+ // data.add("C");
+ // dummyData.put(theCorePackage.getEString(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new BigInteger("11111111111111"));
+ // data.add(new BigInteger("22222222222222"));
+ // data.add(new BigInteger("333333333333333"));
+ // dummyData.put(theCorePackage.getEBigInteger(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new BigDecimal("44444444444444"));
+ // data.add(new BigDecimal("55555555555555"));
+ // data.add(new BigDecimal("66666666666666"));
+ // dummyData.put(theCorePackage.getEBigDecimal(), data);
+ //
+ // data = new ArrayList();
+ // data.add(true);
+ // data.add(false);
+ // data.add(true);
+ // dummyData.put(theCorePackage.getEBoolean(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Boolean(true));
+ // data.add(new Boolean("false"));
+ // data.add(new Boolean(true));
+ // dummyData.put(theCorePackage.getEBooleanObject(), data);
+ //
+ // data = new ArrayList();
+ // data.add((byte)1);
+ // data.add((byte)2);
+ // data.add((byte)3);
+ // dummyData.put(theCorePackage.getEByte(), data);
+ //
+ // // TODO create additional dummy Data
+ // // dummyData.put(theCorePackage.getEByteArray(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Byte((byte)1));
+ // data.add(new Byte("2"));
+ // data.add(new Byte((byte)3));
+ // dummyData.put(theCorePackage.getEByteObject(), data);
+ //
+ // data = new ArrayList();
+ // data.add('a');
+ // data.add((char)99);
+ // data.add('c');
+ // dummyData.put(theCorePackage.getEChar(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Character('a'));
+ // data.add(new Character((char)99));
+ // data.add(new Character('c'));
+ // dummyData.put(theCorePackage.getECharacterObject(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Date());
+ // data.add(new Date());
+ // data.add(new Date());
+ // dummyData.put(theCorePackage.getEDate(), data);
+ //
+ // // TODO create additional dummy Data
+ // // dummyData.put(theCorePackage.getEDiagnosticChain(), data);
+ //
+ // data = new ArrayList();
+ // data.add(111.111D);
+ // data.add(222.222D);
+ // data.add(333.333D);
+ // dummyData.put(theCorePackage.getEDouble(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Double(444.444));
+ // data.add(new Double("555.555"));
+ // data.add(new Double(666.666));
+ // dummyData.put(theCorePackage.getEDoubleObject(), data);
+ //
+ // data = new ArrayList();
+ // data.add(111.0001f);
+ // data.add(222.0002f);
+ // data.add(333.0003f);
+ // dummyData.put(theCorePackage.getEFloat(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Float(444.0004f));
+ // data.add(new Float(555.0005d));
+ // data.add(new Float("666.0006"));
+ // dummyData.put(theCorePackage.getEFloatObject(), data);
+ //
+ // data = new ArrayList();
+ // data.add(11);
+ // data.add(22);
+ // data.add(33);
+ // dummyData.put(theCorePackage.getEInt(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Integer(44));
+ // data.add(new Integer("55"));
+ // data.add(new Integer(66));
+ // dummyData.put(theCorePackage.getEIntegerObject(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Long(1));
+ // data.add(new Date());
+ // data.add(new Integer(2));
+ // dummyData.put(theCorePackage.getEJavaObject(), data);
+ //
+ // data = new ArrayList();
+ // data.add(Object.class);
+ // data.add(Date.class);
+ // data.add(Long.class);
+ // dummyData.put(theCorePackage.getEJavaClass(), data);
+ //
+ // data = new ArrayList();
+ // data.add(10101010101L);
+ // data.add(20202020202L);
+ // data.add(30303030303L);
+ // dummyData.put(theCorePackage.getELong(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Long(40404040404L));
+ // data.add(new Long("5050505050505"));
+ // data.add(new Long(6060606060606L));
+ // dummyData.put(theCorePackage.getELongObject(), data);
+ //
+ // data = new ArrayList();
+ //
+ // Map map = new HashMap();
+ // map.put(1, 2);
+ // map.put(3, 4);
+ // data.add(map);
+ // map = new HashMap();
+ // map.put("A", "B");
+ // map.put("C", "D");
+ // data.add(map);
+ // map = new HashMap();
+ // map.put('a', 'b');
+ // map.put('c', 'd');
+ // data.add(map);
+ // dummyData.put(theCorePackage.getEMap(), data);
+ //
+ // data = new ArrayList();
+ // data.add((short)111);
+ // data.add((short)222);
+ // data.add((short)333);
+ // dummyData.put(theCorePackage.getEShort(), data);
+ //
+ // data = new ArrayList();
+ // data.add(new Short((short)111));
+ // data.add(new Short((short)222));
+ // data.add(new Short((short)333));
+ // dummyData.put(theCorePackage.getEShortObject(), data);
+ //
+ // }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MemoryLeakTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MemoryLeakTest.java
index db5da37529..b3fac0a813 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MemoryLeakTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MemoryLeakTest.java
@@ -1,145 +1,145 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author Eike Stepper
- */
-public class MemoryLeakTest extends AbstractCDOTest
-{
- private static final int LEVELS = 5;
-
- private static final int CATEGORIES = 5;
-
- private static final int PRODUCTS = 10;
-
- protected Company company;
-
- @Override
- protected void doSetUp() throws Exception
- {
- // disableConsole();
- super.doSetUp();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- Resource resource = transaction.createResource(getResourcePath("res1"));
-
- company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- commit();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- // enableConsole();
- super.doTearDown();
- }
-
- protected void commit()
- {
- try
- {
- CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView();
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- public void testLargeModel() throws Exception
- {
- Category category = getModel1Factory().createCategory();
- category.setName("ROOT");
- company.getCategories().add(category);
- commit();
-
- try
- {
- createModel(category, LEVELS);
- }
- catch (OutOfMemoryError error)
- {
- error.printStackTrace();
- }
- }
-
- private void createModel(Category parent, int levels)
- {
- IOUtil.OUT().println(parent + ": " + (LEVELS - levels));
-
- EList<Category> categories = parent.getCategories();
- for (int i = 0; i < CATEGORIES; i++)
- {
- Category category = getModel1Factory().createCategory();
- category.setName("Category" + levels + "-" + i);
- categories.add(category);
- }
-
- EList<Product1> products = parent.getProducts();
- for (int i = 0; i < PRODUCTS; i++)
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Product" + levels + "-" + i);
- products.add(product);
- }
-
- commit();
-
- if (levels > 0)
- {
- for (Category category : categories)
- {
- createModel(category, levels - 1);
- }
- }
- }
-
- @SuppressWarnings("unused")
- private Category selectCategory(EList<Category> categories)
- {
- int size = categories.size();
- if (size == 0)
- {
- return null;
- }
-
- int index = (int)(Math.random() * size);
- Category category = categories.get(index);
- if (Math.random() >= .5d)
- {
- Category recurse = selectCategory(category.getCategories());
- if (recurse != null)
- {
- return recurse;
- }
- }
-
- return category;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * @author Eike Stepper
+ */
+public class MemoryLeakTest extends AbstractCDOTest
+{
+ private static final int LEVELS = 5;
+
+ private static final int CATEGORIES = 5;
+
+ private static final int PRODUCTS = 10;
+
+ protected Company company;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ // disableConsole();
+ super.doSetUp();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ Resource resource = transaction.createResource(getResourcePath("res1"));
+
+ company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ commit();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ // enableConsole();
+ super.doTearDown();
+ }
+
+ protected void commit()
+ {
+ try
+ {
+ CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView();
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ public void testLargeModel() throws Exception
+ {
+ Category category = getModel1Factory().createCategory();
+ category.setName("ROOT");
+ company.getCategories().add(category);
+ commit();
+
+ try
+ {
+ createModel(category, LEVELS);
+ }
+ catch (OutOfMemoryError error)
+ {
+ error.printStackTrace();
+ }
+ }
+
+ private void createModel(Category parent, int levels)
+ {
+ IOUtil.OUT().println(parent + ": " + (LEVELS - levels));
+
+ EList<Category> categories = parent.getCategories();
+ for (int i = 0; i < CATEGORIES; i++)
+ {
+ Category category = getModel1Factory().createCategory();
+ category.setName("Category" + levels + "-" + i);
+ categories.add(category);
+ }
+
+ EList<Product1> products = parent.getProducts();
+ for (int i = 0; i < PRODUCTS; i++)
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Product" + levels + "-" + i);
+ products.add(product);
+ }
+
+ commit();
+
+ if (levels > 0)
+ {
+ for (Category category : categories)
+ {
+ createModel(category, levels - 1);
+ }
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private Category selectCategory(EList<Category> categories)
+ {
+ int size = categories.size();
+ if (size == 0)
+ {
+ return null;
+ }
+
+ int index = (int)(Math.random() * size);
+ Category category = categories.get(index);
+ if (Math.random() >= .5d)
+ {
+ Category recurse = selectCategory(category.getCategories());
+ if (recurse != null)
+ {
+ return recurse;
+ }
+ }
+
+ return category;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java
index 8ea59ef7a8..33e846d956 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java
@@ -1,696 +1,696 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-/**
- * @author Eike Stepper
- */
-@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
-public class MergingTest extends AbstractCDOTest
-{
- public void testFromEmptyBranches() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time2 = transaction.commit().getTimeStamp();
- CDOBranch source2 = mainBranch.createBranch("source2", time2);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time3 = transaction.commit().getTimeStamp();
- CDOBranch source3 = mainBranch.createBranch("source3", time3);
-
- CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- result = transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- result = transaction.merge(source3.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- public void testFromBranchWithAdditions() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- transaction.commit();
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- transaction.commit();
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- addCompany(contents1);
- addCompany(contents1);
- commitAndSync(tx1, transaction);
- tx1.close();
-
- CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(false, result.isEmpty());
- assertEquals(2, result.getNewObjects().size());
- assertEquals(1, result.getChangedObjects().size());
- assertEquals(0, result.getDetachedObjects().size());
- assertEquals(true, transaction.isDirty());
-
- CDOCommitInfo commitInfo1 = transaction.commit();
- assertEquals(2, commitInfo1.getNewObjects().size());
- assertEquals(1, commitInfo1.getChangedObjects().size());
- assertEquals(0, commitInfo1.getDetachedObjects().size());
- assertEquals(false, transaction.isDirty());
- assertEquals(mainBranch, ((CDORevision)commitInfo1.getNewObjects().get(0)).getBranch());
- assertEquals(mainBranch, ((CDORevision)commitInfo1.getNewObjects().get(1)).getBranch());
- assertEquals(1, ((CDORevision)commitInfo1.getNewObjects().get(0)).getVersion());
- assertEquals(1, ((CDORevision)commitInfo1.getNewObjects().get(1)).getVersion());
-
- session.close();
- }
-
- @SuppressWarnings("unused")
- public void testRemergeAfterAdditionsInSource() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- Company company0 = addCompany(contents);
- Company company1 = addCompany(contents);
- Company company2 = addCompany(contents);
- Company company3 = addCompany(contents);
- Company company4 = addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- sleep(10);
- Company company5 = addCompany(contents);
- Company company6 = addCompany(contents);
- Company company7 = addCompany(contents);
- Company company8 = addCompany(contents);
- transaction.commit();
-
- sleep(10);
- Company company9 = addCompany(contents);
- Company company10 = addCompany(contents);
- Company company11 = addCompany(contents);
- transaction.commit();
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- addCompany(contents1);
- addCompany(contents1);
- commitAndSync(tx1, transaction);
- tx1.close();
-
- transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- transaction.commit();
-
- CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- @SuppressWarnings("unused")
- public void testRemergeAfterAdditionsInSource2() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- Company company0 = addCompany(contents);
- Company company1 = addCompany(contents);
- Company company2 = addCompany(contents);
- Company company3 = addCompany(contents);
- Company company4 = addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- sleep(10);
- Company company5 = addCompany(contents);
- Company company6 = addCompany(contents);
- Company company7 = addCompany(contents);
- Company company8 = addCompany(contents);
- transaction.commit();
-
- sleep(10);
- Company company9 = addCompany(contents);
- Company company10 = addCompany(contents);
- Company company11 = addCompany(contents);
- transaction.commit();
-
- {
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- addCompany(contents1);
- addCompany(contents1);
- commitAndSync(tx1, transaction);
- tx1.close();
- }
-
- transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- transaction.commit();
-
- {
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- addCompany(contents1);
- commitAndSync(tx1, transaction);
- tx1.close();
- }
-
- CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(false, result.isEmpty());
- assertEquals(1, result.getNewObjects().size());
- assertEquals(1, result.getChangedObjects().size());
- assertEquals(0, result.getDetachedObjects().size());
- assertEquals(true, transaction.isDirty());
-
- CDOCommitInfo commitInfo1 = transaction.commit();
- assertEquals(1, commitInfo1.getNewObjects().size());
- assertEquals(1, commitInfo1.getChangedObjects().size());
- assertEquals(0, commitInfo1.getDetachedObjects().size());
- assertEquals(false, transaction.isDirty());
- assertEquals(mainBranch, ((CDORevision)commitInfo1.getNewObjects().get(0)).getBranch());
- assertEquals(1, ((CDORevision)commitInfo1.getNewObjects().get(0)).getVersion());
-
- result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- public void testAdditionsInSourceAndTarget() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time2 = transaction.commit().getTimeStamp();
- CDOBranch source2 = mainBranch.createBranch("source2", time2);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- transaction.commit();
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- addCompany(contents1);
- addCompany(contents1);
- commitAndSync(tx1, transaction);
- tx1.close();
-
- transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- transaction.commit();
-
- sleep(10);
- CDOTransaction tx2 = session.openTransaction(source2);
- CDOResource res2 = tx2.getResource(getResourcePath("/res"));
- EList<EObject> contents2 = res2.getContents();
- addCompany(contents2);
- commitAndSync(tx2, transaction);
- tx2.close();
-
- CDOChangeSetData result = transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(false, result.isEmpty());
- assertEquals(1, result.getNewObjects().size());
- assertEquals(1, result.getChangedObjects().size());
- assertEquals(0, result.getDetachedObjects().size());
- assertEquals(true, transaction.isDirty());
-
- CDOCommitInfo commitInfo2 = transaction.commit();
- assertEquals(1, commitInfo2.getNewObjects().size());
- assertEquals(1, commitInfo2.getChangedObjects().size());
- assertEquals(0, commitInfo2.getDetachedObjects().size());
- assertEquals(false, transaction.isDirty());
- assertEquals(mainBranch, ((CDORevision)commitInfo2.getNewObjects().get(0)).getBranch());
- assertEquals(1, ((CDORevision)commitInfo2.getNewObjects().get(0)).getVersion());
-
- result = transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- public void testRemergeAfterAdditionsInSourceAndTarget() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time2 = transaction.commit().getTimeStamp();
- CDOBranch source2 = mainBranch.createBranch("source2", time2);
-
- sleep(10);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- transaction.commit();
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- addCompany(contents1);
- addCompany(contents1);
- commitAndSync(tx1, transaction);
- tx1.close();
-
- transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- transaction.commit();
-
- sleep(10);
- CDOTransaction tx2 = session.openTransaction(source2);
- CDOResource res2 = tx2.getResource(getResourcePath("/res"));
- EList<EObject> contents2 = res2.getContents();
- addCompany(contents2);
- commitAndSync(tx2, transaction);
- tx2.close();
-
- transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- transaction.commit();
-
- CDOChangeSetData result = transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- public void testFromBranchWithChangesInSource_100() throws Exception
- {
- disableConsole();
- for (int i = 0; i < 100; i++)
- {
- System.out.println("run: " + i);
- mergeFromBranchWithChangesInSource(i);
- }
-
- enableConsole();
- }
-
- public void testFromBranchWithChangesInSource() throws Exception
- {
- mergeFromBranchWithChangesInSource(0);
- }
-
- private void mergeFromBranchWithChangesInSource(int run) throws CommitException
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res" + run));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time = transaction.commit().getTimeStamp();
- CDOBranch source = mainBranch.createBranch("source" + run, time);
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source);
- CDOResource res1 = tx1.getResource(getResourcePath("/res" + run));
- EList<EObject> contents1 = res1.getContents();
- ((Company)contents1.get(0)).setName("Company0");
- ((Company)contents1.get(1)).setName("Company1");
- ((Company)contents1.get(2)).setName("Company2");
- commitAndSync(tx1, transaction);
- tx1.close();
-
- CDOChangeSetData result = transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(false, result.isEmpty());
- assertEquals(0, result.getNewObjects().size());
- assertEquals(3, result.getChangedObjects().size());
- assertEquals(0, result.getDetachedObjects().size());
- assertEquals(true, transaction.isDirty());
-
- CDOCommitInfo commitInfo1 = transaction.commit();
- assertEquals(0, commitInfo1.getNewObjects().size());
- assertEquals(3, commitInfo1.getChangedObjects().size());
- assertEquals(0, commitInfo1.getDetachedObjects().size());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- @SuppressWarnings("unused")
- public void testRemergeAfterChangesInSource() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- Company company0 = addCompany(contents);
- Company company1 = addCompany(contents);
- Company company2 = addCompany(contents);
- Company company3 = addCompany(contents);
- Company company4 = addCompany(contents);
- long time = transaction.commit().getTimeStamp();
- CDOBranch source = mainBranch.createBranch("source", time);
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- ((Company)contents1.get(0)).setName("Company0");
- ((Company)contents1.get(1)).setName("Company1");
- ((Company)contents1.get(2)).setName("Company2");
- commitAndSync(tx1, transaction);
- tx1.close();
-
- long updateTime1 = session.getLastUpdateTime();
-
- transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- transaction.commit();
- assertEquals(5, contents.size());
-
- long updateTime2 = session.getLastUpdateTime();
- assertEquals(false, updateTime1 == updateTime2);
- assertEquals("Company0", ((Company)contents.get(0)).getName());
- assertEquals("Company1", ((Company)contents.get(1)).getName());
- assertEquals("Company2", ((Company)contents.get(2)).getName());
-
- CDOChangeSetData result = transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- public void testFromBranchWithRemovalsInSource() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- Company company0 = addCompany(contents);
- Company company1 = addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time = transaction.commit().getTimeStamp();
- CDOBranch source = mainBranch.createBranch("source", time);
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- ((Company)contents1.get(0)).setName("Company0");
- contents1.remove(1);
-
- // dumpAllRevisions(getRepository().getStore());
- commitAndSync(tx1, transaction);
- dumpAllRevisions(getRepository().getStore());
- tx1.close();
-
- CDOChangeSetData result = transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(false, result.isEmpty());
- assertEquals(0, result.getNewObjects().size());
- assertEquals(2, result.getChangedObjects().size());
- assertEquals(1, result.getDetachedObjects().size());
- assertEquals(true, transaction.isDirty());
- assertEquals(CDOState.DIRTY, resource.cdoState());
- assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(company0).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(company1).cdoState());
-
- CDOCommitInfo commitInfo1 = transaction.commit();
- assertEquals(0, commitInfo1.getNewObjects().size());
- assertEquals(2, commitInfo1.getChangedObjects().size());
- assertEquals(1, commitInfo1.getDetachedObjects().size());
- assertEquals(false, transaction.isDirty());
- assertEquals(CDOState.CLEAN, resource.cdoState());
- assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(company0).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(company1).cdoState());
-
- session.close();
- }
-
- public void _testRemergeAfterRemovalsInSource() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time = transaction.commit().getTimeStamp();
- CDOBranch source = mainBranch.createBranch("source", time);
-
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- ((Company)contents1.get(0)).setName("Company0");
- contents1.remove(1);
- commitAndSync(tx1, transaction);
- tx1.close();
-
- transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- transaction.commit();
-
- CDOChangeSetData result = transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- /**
- * Bug 309467.
- */
- @SuppressWarnings("unused")
- public void test_Bugzilla_309467() throws Exception
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- Company company0 = addCompany(contents);
- Company company1 = addCompany(contents);
- Company company2 = addCompany(contents);
- Company company3 = addCompany(contents);
- Company company4 = addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- {
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- ((Company)contents1.get(0)).setName("C0");
- ((Company)contents1.get(1)).setName("C1");
- ((Company)contents1.get(2)).setName("C2");
- ((Company)contents1.get(3)).setName("C3");
- ((Company)contents1.get(4)).setName("C4");
- commitAndSync(tx1, transaction);
- tx1.close();
- }
-
- CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(false, result.isEmpty());
- assertEquals(true, transaction.isDirty());
- transaction.commit();
-
- result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- /**
- * Bug 309467.
- */
- @Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
- public void test_Bugzilla_309467_ServerRestart() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
-
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- EList<EObject> contents = resource.getContents();
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- addCompany(contents);
- long time1 = transaction.commit().getTimeStamp();
- CDOBranch source1 = mainBranch.createBranch("source1", time1);
-
- {
- sleep(10);
- CDOTransaction tx1 = session.openTransaction(source1);
- CDOResource res1 = tx1.getResource(getResourcePath("/res"));
- EList<EObject> contents1 = res1.getContents();
- ((Company)contents1.get(0)).setName("C0");
- ((Company)contents1.get(1)).setName("C1");
- ((Company)contents1.get(2)).setName("C2");
- ((Company)contents1.get(3)).setName("C3");
- ((Company)contents1.get(4)).setName("C4");
- commitAndSync(tx1, transaction);
- tx1.close();
- }
-
- CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(false, result.isEmpty());
- assertEquals(true, transaction.isDirty());
- transaction.commit();
- session.close();
- }
-
- restartRepository();
-
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOBranch source1 = mainBranch.getBranch("source1");
-
- CDOTransaction transaction = session.openTransaction(mainBranch);
- CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- assertEquals(true, result.isEmpty());
- assertEquals(false, transaction.isDirty());
-
- session.close();
- }
-
- private Company addCompany(EList<EObject> contents)
- {
- Company company = getModel1Factory().createCompany();
- contents.add(company);
- return company;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+/**
+ * @author Eike Stepper
+ */
+@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+public class MergingTest extends AbstractCDOTest
+{
+ public void testFromEmptyBranches() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time2 = transaction.commit().getTimeStamp();
+ CDOBranch source2 = mainBranch.createBranch("source2", time2);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time3 = transaction.commit().getTimeStamp();
+ CDOBranch source3 = mainBranch.createBranch("source3", time3);
+
+ CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ result = transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ result = transaction.merge(source3.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ public void testFromBranchWithAdditions() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ addCompany(contents1);
+ addCompany(contents1);
+ commitAndSync(tx1, transaction);
+ tx1.close();
+
+ CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(false, result.isEmpty());
+ assertEquals(2, result.getNewObjects().size());
+ assertEquals(1, result.getChangedObjects().size());
+ assertEquals(0, result.getDetachedObjects().size());
+ assertEquals(true, transaction.isDirty());
+
+ CDOCommitInfo commitInfo1 = transaction.commit();
+ assertEquals(2, commitInfo1.getNewObjects().size());
+ assertEquals(1, commitInfo1.getChangedObjects().size());
+ assertEquals(0, commitInfo1.getDetachedObjects().size());
+ assertEquals(false, transaction.isDirty());
+ assertEquals(mainBranch, ((CDORevision)commitInfo1.getNewObjects().get(0)).getBranch());
+ assertEquals(mainBranch, ((CDORevision)commitInfo1.getNewObjects().get(1)).getBranch());
+ assertEquals(1, ((CDORevision)commitInfo1.getNewObjects().get(0)).getVersion());
+ assertEquals(1, ((CDORevision)commitInfo1.getNewObjects().get(1)).getVersion());
+
+ session.close();
+ }
+
+ @SuppressWarnings("unused")
+ public void testRemergeAfterAdditionsInSource() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ Company company0 = addCompany(contents);
+ Company company1 = addCompany(contents);
+ Company company2 = addCompany(contents);
+ Company company3 = addCompany(contents);
+ Company company4 = addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ sleep(10);
+ Company company5 = addCompany(contents);
+ Company company6 = addCompany(contents);
+ Company company7 = addCompany(contents);
+ Company company8 = addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ Company company9 = addCompany(contents);
+ Company company10 = addCompany(contents);
+ Company company11 = addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ addCompany(contents1);
+ addCompany(contents1);
+ commitAndSync(tx1, transaction);
+ tx1.close();
+
+ transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ transaction.commit();
+
+ CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ @SuppressWarnings("unused")
+ public void testRemergeAfterAdditionsInSource2() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ Company company0 = addCompany(contents);
+ Company company1 = addCompany(contents);
+ Company company2 = addCompany(contents);
+ Company company3 = addCompany(contents);
+ Company company4 = addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ sleep(10);
+ Company company5 = addCompany(contents);
+ Company company6 = addCompany(contents);
+ Company company7 = addCompany(contents);
+ Company company8 = addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ Company company9 = addCompany(contents);
+ Company company10 = addCompany(contents);
+ Company company11 = addCompany(contents);
+ transaction.commit();
+
+ {
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ addCompany(contents1);
+ addCompany(contents1);
+ commitAndSync(tx1, transaction);
+ tx1.close();
+ }
+
+ transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ transaction.commit();
+
+ {
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ addCompany(contents1);
+ commitAndSync(tx1, transaction);
+ tx1.close();
+ }
+
+ CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(false, result.isEmpty());
+ assertEquals(1, result.getNewObjects().size());
+ assertEquals(1, result.getChangedObjects().size());
+ assertEquals(0, result.getDetachedObjects().size());
+ assertEquals(true, transaction.isDirty());
+
+ CDOCommitInfo commitInfo1 = transaction.commit();
+ assertEquals(1, commitInfo1.getNewObjects().size());
+ assertEquals(1, commitInfo1.getChangedObjects().size());
+ assertEquals(0, commitInfo1.getDetachedObjects().size());
+ assertEquals(false, transaction.isDirty());
+ assertEquals(mainBranch, ((CDORevision)commitInfo1.getNewObjects().get(0)).getBranch());
+ assertEquals(1, ((CDORevision)commitInfo1.getNewObjects().get(0)).getVersion());
+
+ result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ public void testAdditionsInSourceAndTarget() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time2 = transaction.commit().getTimeStamp();
+ CDOBranch source2 = mainBranch.createBranch("source2", time2);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ addCompany(contents1);
+ addCompany(contents1);
+ commitAndSync(tx1, transaction);
+ tx1.close();
+
+ transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ transaction.commit();
+
+ sleep(10);
+ CDOTransaction tx2 = session.openTransaction(source2);
+ CDOResource res2 = tx2.getResource(getResourcePath("/res"));
+ EList<EObject> contents2 = res2.getContents();
+ addCompany(contents2);
+ commitAndSync(tx2, transaction);
+ tx2.close();
+
+ CDOChangeSetData result = transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(false, result.isEmpty());
+ assertEquals(1, result.getNewObjects().size());
+ assertEquals(1, result.getChangedObjects().size());
+ assertEquals(0, result.getDetachedObjects().size());
+ assertEquals(true, transaction.isDirty());
+
+ CDOCommitInfo commitInfo2 = transaction.commit();
+ assertEquals(1, commitInfo2.getNewObjects().size());
+ assertEquals(1, commitInfo2.getChangedObjects().size());
+ assertEquals(0, commitInfo2.getDetachedObjects().size());
+ assertEquals(false, transaction.isDirty());
+ assertEquals(mainBranch, ((CDORevision)commitInfo2.getNewObjects().get(0)).getBranch());
+ assertEquals(1, ((CDORevision)commitInfo2.getNewObjects().get(0)).getVersion());
+
+ result = transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ public void testRemergeAfterAdditionsInSourceAndTarget() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time2 = transaction.commit().getTimeStamp();
+ CDOBranch source2 = mainBranch.createBranch("source2", time2);
+
+ sleep(10);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ transaction.commit();
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ addCompany(contents1);
+ addCompany(contents1);
+ commitAndSync(tx1, transaction);
+ tx1.close();
+
+ transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ transaction.commit();
+
+ sleep(10);
+ CDOTransaction tx2 = session.openTransaction(source2);
+ CDOResource res2 = tx2.getResource(getResourcePath("/res"));
+ EList<EObject> contents2 = res2.getContents();
+ addCompany(contents2);
+ commitAndSync(tx2, transaction);
+ tx2.close();
+
+ transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ transaction.commit();
+
+ CDOChangeSetData result = transaction.merge(source2.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ public void testFromBranchWithChangesInSource_100() throws Exception
+ {
+ disableConsole();
+ for (int i = 0; i < 100; i++)
+ {
+ System.out.println("run: " + i);
+ mergeFromBranchWithChangesInSource(i);
+ }
+
+ enableConsole();
+ }
+
+ public void testFromBranchWithChangesInSource() throws Exception
+ {
+ mergeFromBranchWithChangesInSource(0);
+ }
+
+ private void mergeFromBranchWithChangesInSource(int run) throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res" + run));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time = transaction.commit().getTimeStamp();
+ CDOBranch source = mainBranch.createBranch("source" + run, time);
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res" + run));
+ EList<EObject> contents1 = res1.getContents();
+ ((Company)contents1.get(0)).setName("Company0");
+ ((Company)contents1.get(1)).setName("Company1");
+ ((Company)contents1.get(2)).setName("Company2");
+ commitAndSync(tx1, transaction);
+ tx1.close();
+
+ CDOChangeSetData result = transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(false, result.isEmpty());
+ assertEquals(0, result.getNewObjects().size());
+ assertEquals(3, result.getChangedObjects().size());
+ assertEquals(0, result.getDetachedObjects().size());
+ assertEquals(true, transaction.isDirty());
+
+ CDOCommitInfo commitInfo1 = transaction.commit();
+ assertEquals(0, commitInfo1.getNewObjects().size());
+ assertEquals(3, commitInfo1.getChangedObjects().size());
+ assertEquals(0, commitInfo1.getDetachedObjects().size());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ @SuppressWarnings("unused")
+ public void testRemergeAfterChangesInSource() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ Company company0 = addCompany(contents);
+ Company company1 = addCompany(contents);
+ Company company2 = addCompany(contents);
+ Company company3 = addCompany(contents);
+ Company company4 = addCompany(contents);
+ long time = transaction.commit().getTimeStamp();
+ CDOBranch source = mainBranch.createBranch("source", time);
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ ((Company)contents1.get(0)).setName("Company0");
+ ((Company)contents1.get(1)).setName("Company1");
+ ((Company)contents1.get(2)).setName("Company2");
+ commitAndSync(tx1, transaction);
+ tx1.close();
+
+ long updateTime1 = session.getLastUpdateTime();
+
+ transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ transaction.commit();
+ assertEquals(5, contents.size());
+
+ long updateTime2 = session.getLastUpdateTime();
+ assertEquals(false, updateTime1 == updateTime2);
+ assertEquals("Company0", ((Company)contents.get(0)).getName());
+ assertEquals("Company1", ((Company)contents.get(1)).getName());
+ assertEquals("Company2", ((Company)contents.get(2)).getName());
+
+ CDOChangeSetData result = transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ public void testFromBranchWithRemovalsInSource() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ Company company0 = addCompany(contents);
+ Company company1 = addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time = transaction.commit().getTimeStamp();
+ CDOBranch source = mainBranch.createBranch("source", time);
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ ((Company)contents1.get(0)).setName("Company0");
+ contents1.remove(1);
+
+ // dumpAllRevisions(getRepository().getStore());
+ commitAndSync(tx1, transaction);
+ dumpAllRevisions(getRepository().getStore());
+ tx1.close();
+
+ CDOChangeSetData result = transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(false, result.isEmpty());
+ assertEquals(0, result.getNewObjects().size());
+ assertEquals(2, result.getChangedObjects().size());
+ assertEquals(1, result.getDetachedObjects().size());
+ assertEquals(true, transaction.isDirty());
+ assertEquals(CDOState.DIRTY, resource.cdoState());
+ assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(company0).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(company1).cdoState());
+
+ CDOCommitInfo commitInfo1 = transaction.commit();
+ assertEquals(0, commitInfo1.getNewObjects().size());
+ assertEquals(2, commitInfo1.getChangedObjects().size());
+ assertEquals(1, commitInfo1.getDetachedObjects().size());
+ assertEquals(false, transaction.isDirty());
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(company0).cdoState());
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(company1).cdoState());
+
+ session.close();
+ }
+
+ public void _testRemergeAfterRemovalsInSource() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time = transaction.commit().getTimeStamp();
+ CDOBranch source = mainBranch.createBranch("source", time);
+
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ ((Company)contents1.get(0)).setName("Company0");
+ contents1.remove(1);
+ commitAndSync(tx1, transaction);
+ tx1.close();
+
+ transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ transaction.commit();
+
+ CDOChangeSetData result = transaction.merge(source.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ /**
+ * Bug 309467.
+ */
+ @SuppressWarnings("unused")
+ public void test_Bugzilla_309467() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ Company company0 = addCompany(contents);
+ Company company1 = addCompany(contents);
+ Company company2 = addCompany(contents);
+ Company company3 = addCompany(contents);
+ Company company4 = addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ {
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ ((Company)contents1.get(0)).setName("C0");
+ ((Company)contents1.get(1)).setName("C1");
+ ((Company)contents1.get(2)).setName("C2");
+ ((Company)contents1.get(3)).setName("C3");
+ ((Company)contents1.get(4)).setName("C4");
+ commitAndSync(tx1, transaction);
+ tx1.close();
+ }
+
+ CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(false, result.isEmpty());
+ assertEquals(true, transaction.isDirty());
+ transaction.commit();
+
+ result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ /**
+ * Bug 309467.
+ */
+ @Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
+ public void test_Bugzilla_309467_ServerRestart() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ EList<EObject> contents = resource.getContents();
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ addCompany(contents);
+ long time1 = transaction.commit().getTimeStamp();
+ CDOBranch source1 = mainBranch.createBranch("source1", time1);
+
+ {
+ sleep(10);
+ CDOTransaction tx1 = session.openTransaction(source1);
+ CDOResource res1 = tx1.getResource(getResourcePath("/res"));
+ EList<EObject> contents1 = res1.getContents();
+ ((Company)contents1.get(0)).setName("C0");
+ ((Company)contents1.get(1)).setName("C1");
+ ((Company)contents1.get(2)).setName("C2");
+ ((Company)contents1.get(3)).setName("C3");
+ ((Company)contents1.get(4)).setName("C4");
+ commitAndSync(tx1, transaction);
+ tx1.close();
+ }
+
+ CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(false, result.isEmpty());
+ assertEquals(true, transaction.isDirty());
+ transaction.commit();
+ session.close();
+ }
+
+ restartRepository();
+
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOBranch source1 = mainBranch.getBranch("source1");
+
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ CDOChangeSetData result = transaction.merge(source1.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ assertEquals(true, result.isEmpty());
+ assertEquals(false, transaction.isDirty());
+
+ session.close();
+ }
+
+ private Company addCompany(EList<EObject> contents)
+ {
+ Company company = getModel1Factory().createCompany();
+ contents.add(company);
+ return company;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MetaTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MetaTest.java
index 9daf4752ce..ca6c6318b2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MetaTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MetaTest.java
@@ -1,105 +1,105 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model3.MetaRef;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.ecore.EReference;
-
-/**
- * @author Eike Stepper
- */
-public class MetaTest extends AbstractCDOTest
-{
- public void testMetaReference() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- MetaRef metaRef = getModel3Factory().createMetaRef();
- metaRef.setEPackageRef(getModel3Package());
- res.getContents().add(metaRef);
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- MetaRef metaRef = (MetaRef)res.getContents().get(0);
- assertEquals(getModel3Package(), metaRef.getEPackageRef());
- }
-
- public void testMetaReferenceAttachFirst() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- MetaRef metaRef = getModel3Factory().createMetaRef();
- res.getContents().add(metaRef);
- metaRef.setEPackageRef(getModel3Package());
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- MetaRef metaRef = (MetaRef)res.getContents().get(0);
- assertEquals(getModel3Package(), metaRef.getEPackageRef());
- }
-
- public void testMetaReference2() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- EReference targetRef = getModel3SubpackagePackage().getClass2_Class1();
-
- {
- MetaRef metaRef = getModel3Factory().createMetaRef();
- metaRef.setEReferenceRef(targetRef);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(metaRef);
-
- transaction.commit();
-
- // EReference sourceRef = getModel3Package().getMetaRef_EReferenceRef();
- // CDORevisionData data = CDOUtil.getCDOObject(metaRef).cdoRevision().data();
- // Object id = data.get(sourceRef, -1);
- // assertInstanceOf(CDOIDMeta.class, id);
-
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- MetaRef metaRef = (MetaRef)resource.getContents().get(0);
- assertEquals(targetRef, metaRef.getEReferenceRef());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model3.MetaRef;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * @author Eike Stepper
+ */
+public class MetaTest extends AbstractCDOTest
+{
+ public void testMetaReference() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ MetaRef metaRef = getModel3Factory().createMetaRef();
+ metaRef.setEPackageRef(getModel3Package());
+ res.getContents().add(metaRef);
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ MetaRef metaRef = (MetaRef)res.getContents().get(0);
+ assertEquals(getModel3Package(), metaRef.getEPackageRef());
+ }
+
+ public void testMetaReferenceAttachFirst() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ MetaRef metaRef = getModel3Factory().createMetaRef();
+ res.getContents().add(metaRef);
+ metaRef.setEPackageRef(getModel3Package());
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ MetaRef metaRef = (MetaRef)res.getContents().get(0);
+ assertEquals(getModel3Package(), metaRef.getEPackageRef());
+ }
+
+ public void testMetaReference2() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ EReference targetRef = getModel3SubpackagePackage().getClass2_Class1();
+
+ {
+ MetaRef metaRef = getModel3Factory().createMetaRef();
+ metaRef.setEReferenceRef(targetRef);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(metaRef);
+
+ transaction.commit();
+
+ // EReference sourceRef = getModel3Package().getMetaRef_EReferenceRef();
+ // CDORevisionData data = CDOUtil.getCDOObject(metaRef).cdoRevision().data();
+ // Object id = data.get(sourceRef, -1);
+ // assertInstanceOf(CDOIDMeta.class, id);
+
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ MetaRef metaRef = (MetaRef)resource.getContents().get(0);
+ assertEquals(targetRef, metaRef.getEReferenceRef());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java
index 9d879ead42..e14c7f33f6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java
@@ -1,191 +1,191 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author Simon McDuff
- */
-public class MultiValuedOfAttributeTest extends AbstractCDOTest
-{
- public void testListOfString() throws Exception
- {
- List<String> list = new ArrayList<String>();
- list.add("Ottawa");
- list.add("Toronto");
- list.add("Berlin");
- testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfString(), getModel5Package()
- .getGenListOfString_Elements());
- }
-
- public void testListOfDate() throws Exception
- {
- List<Date> list = new ArrayList<Date>();
- list.add(new Date(1000));
- list.add(new Date());
- list.add(new Date(new Date().getTime() - 100));
- testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfDate(), getModel5Package()
- .getGenListOfDate_Elements());
- }
-
- public void testListOfInt() throws Exception
- {
- List<Integer> list = new ArrayList<Integer>();
- list.add(10);
- list.add(11);
- list.add(20);
- testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfInt(), getModel5Package()
- .getGenListOfInt_Elements());
- }
-
- public void testListOfShort() throws Exception
- {
- List<Short> list = new ArrayList<Short>();
- list.add((short)10);
- list.add((short)11);
- list.add((short)20);
- testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfShort(), getModel5Package()
- .getGenListOfShort_Elements());
- }
-
- public void testListOfFloat() throws Exception
- {
- List<Float> list = new ArrayList<Float>();
- list.add((float)10);
- list.add((float)11);
- list.add((float)20);
- testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfFloat(), getModel5Package()
- .getGenListOfFloat_Elements());
- }
-
- public void testListOfChar() throws Exception
- {
- List<Character> list = new ArrayList<Character>();
- list.add('c');
- list.add('d');
- list.add('z');
- testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfChar(), getModel5Package()
- .getGenListOfChar_Elements());
- }
-
- public void testListOfBoolean() throws Exception
- {
- List<Boolean> list = new ArrayList<Boolean>();
- list.add(true);
- list.add(false);
- testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfBoolean(), getModel5Package()
- .getGenListOfBoolean_Elements());
- }
-
- public void testListOfDouble() throws Exception
- {
- List<Double> list = new ArrayList<Double>();
- list.add(10.1928);
- list.add(11.12);
- list.add(20.99991);
- testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfDouble(), getModel5Package()
- .getGenListOfDouble_Elements());
- }
-
- public void testListOfInteger() throws Exception
- {
- List<Integer> list = new ArrayList<Integer>();
- list.add(10);
- list.add(null);
- list.add(20);
-
- EAttribute elements = getModel5Package().getGenListOfInteger_Elements();
- EClass containerClass = getModel5Package().getGenListOfInteger();
- testMultiValuedIOfAttribute(list, containerClass, elements);
- }
-
- protected <T> void testMultiValuedIOfAttribute(List<T> list, EClass containerClass, EStructuralFeature feature)
- throws CommitException
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- EObject eGenObject = EcoreUtil.create(containerClass);
-
- @SuppressWarnings("unchecked")
- EList<T> elements = (EList<T>)eGenObject.eGet(feature);
-
- for (int i = 0; i < list.size() - 1; i++)
- {
- elements.add(list.get(i));
- }
-
- resource.getContents().add(eGenObject);
- transaction.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/res1"));
-
- EObject eGenObject = resource.getContents().get(0);
-
- @SuppressWarnings("unchecked")
- EList<T> elements = (EList<T>)eGenObject.eGet(feature);
-
- for (int i = 0; i < list.size() - 1; i++)
- {
- assertEquals(elements.get(i), list.get(i));
- }
-
- elements.add(list.get(list.size() - 1));
- transaction.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(0, 100));
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/res1"));
-
- EObject eGenObject = resource.getContents().get(0);
-
- @SuppressWarnings("unchecked")
- EList<T> elements = (EList<T>)eGenObject.eGet(feature);
-
- for (int i = 0; i < list.size() - 1; i++)
- {
- assertEquals(elements.get(i), list.get(i));
- }
-
- transaction.commit();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author Simon McDuff
+ */
+public class MultiValuedOfAttributeTest extends AbstractCDOTest
+{
+ public void testListOfString() throws Exception
+ {
+ List<String> list = new ArrayList<String>();
+ list.add("Ottawa");
+ list.add("Toronto");
+ list.add("Berlin");
+ testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfString(), getModel5Package()
+ .getGenListOfString_Elements());
+ }
+
+ public void testListOfDate() throws Exception
+ {
+ List<Date> list = new ArrayList<Date>();
+ list.add(new Date(1000));
+ list.add(new Date());
+ list.add(new Date(new Date().getTime() - 100));
+ testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfDate(), getModel5Package()
+ .getGenListOfDate_Elements());
+ }
+
+ public void testListOfInt() throws Exception
+ {
+ List<Integer> list = new ArrayList<Integer>();
+ list.add(10);
+ list.add(11);
+ list.add(20);
+ testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfInt(), getModel5Package()
+ .getGenListOfInt_Elements());
+ }
+
+ public void testListOfShort() throws Exception
+ {
+ List<Short> list = new ArrayList<Short>();
+ list.add((short)10);
+ list.add((short)11);
+ list.add((short)20);
+ testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfShort(), getModel5Package()
+ .getGenListOfShort_Elements());
+ }
+
+ public void testListOfFloat() throws Exception
+ {
+ List<Float> list = new ArrayList<Float>();
+ list.add((float)10);
+ list.add((float)11);
+ list.add((float)20);
+ testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfFloat(), getModel5Package()
+ .getGenListOfFloat_Elements());
+ }
+
+ public void testListOfChar() throws Exception
+ {
+ List<Character> list = new ArrayList<Character>();
+ list.add('c');
+ list.add('d');
+ list.add('z');
+ testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfChar(), getModel5Package()
+ .getGenListOfChar_Elements());
+ }
+
+ public void testListOfBoolean() throws Exception
+ {
+ List<Boolean> list = new ArrayList<Boolean>();
+ list.add(true);
+ list.add(false);
+ testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfBoolean(), getModel5Package()
+ .getGenListOfBoolean_Elements());
+ }
+
+ public void testListOfDouble() throws Exception
+ {
+ List<Double> list = new ArrayList<Double>();
+ list.add(10.1928);
+ list.add(11.12);
+ list.add(20.99991);
+ testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfDouble(), getModel5Package()
+ .getGenListOfDouble_Elements());
+ }
+
+ public void testListOfInteger() throws Exception
+ {
+ List<Integer> list = new ArrayList<Integer>();
+ list.add(10);
+ list.add(null);
+ list.add(20);
+
+ EAttribute elements = getModel5Package().getGenListOfInteger_Elements();
+ EClass containerClass = getModel5Package().getGenListOfInteger();
+ testMultiValuedIOfAttribute(list, containerClass, elements);
+ }
+
+ protected <T> void testMultiValuedIOfAttribute(List<T> list, EClass containerClass, EStructuralFeature feature)
+ throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ EObject eGenObject = EcoreUtil.create(containerClass);
+
+ @SuppressWarnings("unchecked")
+ EList<T> elements = (EList<T>)eGenObject.eGet(feature);
+
+ for (int i = 0; i < list.size() - 1; i++)
+ {
+ elements.add(list.get(i));
+ }
+
+ resource.getContents().add(eGenObject);
+ transaction.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/res1"));
+
+ EObject eGenObject = resource.getContents().get(0);
+
+ @SuppressWarnings("unchecked")
+ EList<T> elements = (EList<T>)eGenObject.eGet(feature);
+
+ for (int i = 0; i < list.size() - 1; i++)
+ {
+ assertEquals(elements.get(i), list.get(i));
+ }
+
+ elements.add(list.get(list.size() - 1));
+ transaction.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(0, 100));
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/res1"));
+
+ EObject eGenObject = resource.getContents().get(0);
+
+ @SuppressWarnings("unchecked")
+ EList<T> elements = (EList<T>)eGenObject.eGet(feature);
+
+ for (int i = 0; i < list.size() - 1; i++)
+ {
+ assertEquals(elements.get(i), list.get(i));
+ }
+
+ transaction.commit();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NonCDOResourceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NonCDOResourceTest.java
index 350dab3acc..a73a5a8c81 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NonCDOResourceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NonCDOResourceTest.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
-
-import junit.framework.TestCase;
-
-/**
- * See bug 201593
- *
- * @author Simon McDuff
- */
-public class NonCDOResourceTest extends TestCase
-{
- public void testNonCDOResource() throws Exception
- {
- Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
-
- Resource resource = new ResourceImpl();
- resource.setURI(URI.createFileURI("/res1"));
- resource.getContents().add(supplier);
-
- assertEquals(resource, supplier.eResource());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
+
+import junit.framework.TestCase;
+
+/**
+ * See bug 201593
+ *
+ * @author Simon McDuff
+ */
+public class NonCDOResourceTest extends TestCase
+{
+ public void testNonCDOResource() throws Exception
+ {
+ Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
+
+ Resource resource = new ResourceImpl();
+ resource.setURI(URI.createFileURI("/res1"));
+ resource.getContents().add(supplier);
+
+ assertEquals(resource, supplier.eResource());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java
index 3688af1a39..d9b12b3d6f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java
@@ -1,88 +1,88 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Address;
-import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import java.util.Date;
-
-/**
- *
- */
-public class OldValueNotificationTest extends AbstractCDOTest
-{
- public void testSameSession() throws Exception
- {
- final CDOSession session = openSession();
- final CDOTransaction transaction = session.openTransaction();
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- Address address1 = getModel1Factory().createAddress();
- address1.setCity("Basel");
- address1.setStreet("Turnerstrasse 39");
- address1.setName("Michael Szediwy");
-
- SpecialPurchaseOrder order = getModel2Factory().createSpecialPurchaseOrder();
- order.setDate(new Date());
- order.setShippingAddress(address1);
-
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(order);
- transaction.commit();
-
- final TestAdapter adapter = new TestAdapter()
- {
- @Override
- public void notifyChanged(Notification notification)
- {
- super.notifyChanged(notification);
- }
- };
-
- final CDOView view = session.openView();
- SpecialPurchaseOrder roOrder = view.getObject(order);
- System.out.println(CDOUtil.getCDOObject(roOrder).cdoState());
- roOrder.eAdapters().add(adapter);
-
- Address address2 = getModel1Factory().createAddress();
- address2.setCity("Basel2");
- address2.setStreet("Turnerstrasse 392");
- address2.setName("Michael Szediwy2");
-
- order.setShippingAddress(address2);
-
- transaction.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // Commit notifications from the same session always have full deltas
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1;
- }
- }.assertNoTimeOut();
-
- Notification[] notifications = adapter.getNotifications();
- notifications[0].getOldValue();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Address;
+import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import java.util.Date;
+
+/**
+ *
+ */
+public class OldValueNotificationTest extends AbstractCDOTest
+{
+ public void testSameSession() throws Exception
+ {
+ final CDOSession session = openSession();
+ final CDOTransaction transaction = session.openTransaction();
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ Address address1 = getModel1Factory().createAddress();
+ address1.setCity("Basel");
+ address1.setStreet("Turnerstrasse 39");
+ address1.setName("Michael Szediwy");
+
+ SpecialPurchaseOrder order = getModel2Factory().createSpecialPurchaseOrder();
+ order.setDate(new Date());
+ order.setShippingAddress(address1);
+
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(order);
+ transaction.commit();
+
+ final TestAdapter adapter = new TestAdapter()
+ {
+ @Override
+ public void notifyChanged(Notification notification)
+ {
+ super.notifyChanged(notification);
+ }
+ };
+
+ final CDOView view = session.openView();
+ SpecialPurchaseOrder roOrder = view.getObject(order);
+ System.out.println(CDOUtil.getCDOObject(roOrder).cdoState());
+ roOrder.eAdapters().add(adapter);
+
+ Address address2 = getModel1Factory().createAddress();
+ address2.setCity("Basel2");
+ address2.setStreet("Turnerstrasse 392");
+ address2.setName("Michael Szediwy2");
+
+ order.setShippingAddress(address2);
+
+ transaction.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // Commit notifications from the same session always have full deltas
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length == 1;
+ }
+ }.assertNoTimeOut();
+
+ Notification[] notifications = adapter.getNotifications();
+ notifications[0].getOldValue();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
index 9150514c7a..75b8ae1600 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
@@ -1,808 +1,808 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Stefan Winkler - Bug 332912 - Caching subtype-relationships in the CDOPackageRegistry
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistryPopulator;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.bundle.OM;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.mango.MangoValue;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
-import org.eclipse.emf.cdo.tests.model3.Class1;
-import org.eclipse.emf.cdo.tests.model3.Model3Package;
-import org.eclipse.emf.cdo.tests.model3.subpackage.Class2;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class PackageRegistryTest extends AbstractCDOTest
-{
- public void testGeneratedPackage() throws Exception
- {
- {
- // Create resource in session 1
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Eike");
- res.getContents().add(company);
- transaction.commit();
- }
-
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- Company company = (Company)res.getContents().get(0);
- assertEquals("Eike", company.getName());
- }
-
- public void testCommitTwoPackages() throws Exception
- {
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(getModel1Package());
- session.getPackageRegistry().putEPackage(getModel2Package());
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- SpecialPurchaseOrder specialPurchaseOrder = getModel2Factory().createSpecialPurchaseOrder();
- specialPurchaseOrder.setDiscountCode("12345");
- res.getContents().add(specialPurchaseOrder);
- transaction.commit();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- SpecialPurchaseOrder specialPurchaseOrder = (SpecialPurchaseOrder)res.getContents().get(0);
- assertEquals("12345", specialPurchaseOrder.getDiscountCode());
- }
-
- public void testCommitUnrelatedPackage() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- res.getContents().add(purchaseOrder);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- MangoValue value = getMangoFactory().createMangoValue();
- value.setName("V0");
- res.getContents().add(value);
-
- transaction.commit();
- session.close();
- }
-
- @CleanRepositoriesBefore
- public void testCommitNestedPackages() throws Exception
- {
- CDOSession session = openSession();
- assertEquals(3, session.getPackageRegistry().size());
-
- session.getPackageRegistry().putEPackage(getModel3SubpackagePackage());
- assertEquals(5, session.getPackageRegistry().size());
-
- session.close();
- }
-
- @CleanRepositoriesBefore
- public void testCommitTopLevelPackages() throws Exception
- {
- CDOSession session = openSession();
- assertEquals(3, session.getPackageRegistry().size());
-
- session.getPackageRegistry().putEPackage(getModel3Package());
- assertEquals(5, session.getPackageRegistry().size());
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- Class1 class1 = getModel3Factory().createClass1();
- res.getContents().add(class1);
- transaction.commit();
-
- EPackage model3Package = session.getPackageRegistry().getEPackage(getModel3Package().getNsURI());
- assertNotNull(model3Package);
- session.close();
- }
-
- public void testLoadNestedPackages() throws Exception
- {
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(getModel3Package());
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- Class1 class1 = getModel3Factory().createClass1();
- res.getContents().add(class1);
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- EPackage model3Package = session.getPackageRegistry().getEPackage(getModel3Package().getNsURI());
- assertNotNull(model3Package);
-
- EPackage subPackage = session.getPackageRegistry().getEPackage(getModel3SubpackagePackage().getNsURI());
- assertNotNull(subPackage);
- session.close();
- }
-
- public void testCommitCircularPackages() throws Exception
- {
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(Model3Package.eINSTANCE);
- CDOTransaction transaction = session.openTransaction();
- CDOResource res1 = transaction.createResource(getResourcePath("/res1"));
- CDOResource res2 = transaction.createResource(getResourcePath("/res2"));
-
- Class1 class1 = getModel3Factory().createClass1();
- Class2 class2 = getModel3SubpackageFactory().createClass2();
- class1.getClass2().add(class2);
-
- res1.getContents().add(class1);
- res2.getContents().add(class2);
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res1 = transaction.getResource(getResourcePath("/res1"));
-
- Class1 class1 = (Class1)res1.getContents().get(0);
- assertNotNull(class1);
- EList<Class2> class22 = class1.getClass2();
- Class2 class2 = class22.get(0);
- assertNotNull(class2);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res2 = transaction.getResource(getResourcePath("/res2"));
-
- Class2 class2 = (Class2)res2.getContents().get(0);
- assertNotNull(class2);
- Class1 class1 = class2.getClass1().get(0);
- assertNotNull(class1);
- }
-
- public void testPackageRegistry() throws Exception
- {
- {
- // Create resource in session 1
- CDOSession session = openSession(IRepositoryConfig.REPOSITORY_NAME);
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Eike");
- res.getContents().add(company);
- transaction.commit();
- }
-
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- Company company = (Company)res.getContents().get(0);
- assertEquals("Eike", company.getName());
- }
-
- /**
- * Bug 249383: Dynamic models in the global EPackage.Registry are not committed bug 249383
- */
- public void testGlobalDynamicPackageEager() throws Exception
- {
- String nsURI = "http://dynamic";
-
- try
- {
- EPackage p = EcoreFactory.eINSTANCE.createEPackage();
- p.setName("dynamic");
- p.setNsPrefix("dynamic");
- p.setNsURI(nsURI);
-
- EClass c = EcoreFactory.eINSTANCE.createEClass();
- c.setName("DClass");
-
- p.getEClassifiers().add(c);
- EPackage.Registry.INSTANCE.put(nsURI, p);
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(p);
- p = session.getPackageRegistry().getEPackage(nsURI);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- EFactory factory = p.getEFactoryInstance();
- EObject object = factory.create(c);
-
- res.getContents().add(object);
- transaction.commit();
- session.close();
- }
- finally
- {
- EPackage.Registry.INSTANCE.remove(nsURI);
- }
- }
-
- /**
- * Bug 249383: Dynamic models in the global EPackage.Registry are not committed bug 249383
- */
- public void testGlobalDynamicPackage() throws Exception
- {
- String nsURI = "http://dynamic";
-
- try
- {
- EPackage p = EcoreFactory.eINSTANCE.createEPackage();
- p.setName("dynamic");
- p.setNsPrefix("dynamic");
- p.setNsURI(nsURI);
-
- EClass c = EcoreFactory.eINSTANCE.createEClass();
- c.setName("DClass");
-
- p.getEClassifiers().add(c);
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(p);
- }
-
- EPackage.Registry.INSTANCE.put(nsURI, p);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- EFactory factory = p.getEFactoryInstance();
- EObject object = factory.create(c);
-
- res.getContents().add(object);
- transaction.commit();
- session.close();
- }
- catch (Exception ex)
- {
- EPackage.Registry.INSTANCE.remove(nsURI);
- }
- }
-
- public void testGlobalDynamicPackageUnprepared() throws Exception
- {
- String nsURI = "http://dynamic";
-
- try
- {
- EPackage p = EcoreFactory.eINSTANCE.createEPackage();
- p.setName("dynamic");
- p.setNsPrefix("dynamic");
- p.setNsURI(nsURI);
-
- EClass c = EcoreFactory.eINSTANCE.createEClass();
- c.setName("DClass");
-
- p.getEClassifiers().add(c);
- EPackage.Registry.INSTANCE.put(nsURI, p);
-
- CDOSession session = openSession();
-
- // The default case is that legacy is disabled. For our test bed it is always enabled.
- // To test the default case we must switch of legacy here.
- CDOUtil.setLegacyModeDefault(false);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- EFactory factory = p.getEFactoryInstance();
- EObject object = factory.create(c);
-
- res.getContents().add(object);
- transaction.commit();
- session.close();
-
- fail("LegacyModeNotEnabledException expected");
- }
- catch (LegacyModeNotEnabledException expected)
- {
- // SUCCESS
- }
- finally
- {
- EPackage.Registry.INSTANCE.remove(nsURI);
- }
- }
-
- @CleanRepositoriesBefore
- public void testDynamicPackageFactory() throws Exception
- {
- // -Dorg.eclipse.emf.ecore.EPackage.Registry.INSTANCE=org.eclipse.emf.ecore.impl.CDOPackageRegistryImpl
-
- {
- EPackage model1 = loadModel("model1.ecore");
- EClass companyClass = (EClass)model1.getEClassifier("Company");
- EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
- Resource model1Resource = model1.eResource();
-
- // Create resource in session 1
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
- assertEquals(model1Resource, model1.eResource());
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- EFactory factory = model1.getEFactoryInstance();
- EObject company = factory.create(companyClass);
- company.eSet(nameAttribute, "Eike");
- res.getContents().add(company);
- transaction.commit();
- session.close();
- }
-
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- CDOObject company = CDOUtil.getCDOObject(res.getContents().get(0));
- EClass companyClass = company.eClass();
- EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
- String name = (String)company.eGet(nameAttribute);
- assertEquals("Eike", name);
- session.close();
- }
-
- @CleanRepositoriesBefore
- public void testDynamicPackageNewInstance() throws Exception
- {
- {
- EPackage model1 = loadModel("model1.ecore");
- EClass companyClass = (EClass)model1.getEClassifier("Company");
- EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
-
- // Create resource in session 1
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- CDOObject company = CDOUtil.getCDOObject(EcoreUtil.create(companyClass));
- company.eSet(nameAttribute, "Eike");
- res.getContents().add(company);
- transaction.commit();
- session.close();
- }
-
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- CDOObject company = CDOUtil.getCDOObject(res.getContents().get(0));
- EClass companyClass = company.eClass();
- EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
- String name = (String)company.eGet(nameAttribute);
- assertEquals("Eike", name);
- session.close();
- }
-
- @CleanRepositoriesBefore
- public void testDuplicatePackageRegistration() throws Exception
- {
- CDOSession session1 = openSession();
- CDOSession session2 = openSession();
-
- try
- {
- {
- CDOTransaction transaction = session1.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Company1");
- res.getContents().add(company);
- transaction.commit();
- sleep(1000); // Give session2 a chance to react
- }
-
- CDOPackageRegistry packageRegistry = session2.getPackageRegistry();
- Model1Package model1Package = getModel1Package();
- packageRegistry.putEPackage(model1Package);
-
- CDOPackageUnit packageUnit = packageRegistry.getPackageUnit(model1Package);
- assertEquals(CDOPackageUnit.State.LOADED, packageUnit.getState());
-
- {
- CDOTransaction transaction = session2.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res2"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Company2");
- res.getContents().add(company);
- transaction.commit();
- }
- }
- finally
- {
- session1.close();
- session2.close();
- }
- }
-
- @CleanRepositoriesBefore
- public void testReuseCommittedPackage() throws Exception
- {
- final long timeStamp;
- final CDOSession session1 = openSession();
- final CDOSession session2 = openSession();
-
- try
- {
- {
- CDOTransaction transaction = session1.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Company1");
- res.getContents().add(company);
- timeStamp = transaction.commit().getTimeStamp();
- }
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return session2.getLastUpdateTime() >= timeStamp;
- }
- }.assertNoTimeOut();
-
- {
- CDOTransaction transaction = session2.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res2"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Company2");
- res.getContents().add(company);
- transaction.commit();
- }
- }
- finally
- {
- session1.close();
- session2.close();
- }
- }
-
- @CleanRepositoriesBefore
- public void testConcurrentPackageRegistration() throws Exception
- {
- CDOSession session1 = openSession();
- session1.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOSession session2 = openSession();
- session2.getPackageRegistry().putEPackage(getModel1Package());
-
- try
- {
- {
- CDOTransaction transaction = session1.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Company1");
- res.getContents().add(company);
- transaction.commit();
- sleep(1000); // Give session2 a chance to react
- }
-
- CDOPackageRegistry packageRegistry = session2.getPackageRegistry();
- Model1Package model1Package = getModel1Package();
-
- CDOPackageUnit packageUnit = packageRegistry.getPackageUnit(model1Package);
- assertEquals(CDOPackageUnit.State.LOADED, packageUnit.getState());
-
- {
- CDOTransaction transaction = session2.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res2"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Company2");
- res.getContents().add(company);
- transaction.commit();
- }
- }
- finally
- {
- session1.close();
- session2.close();
- }
- }
-
- /**
- * Bug 353246.
- * <p>
- * Cannot reproduce the problem with MEMStore because MEMStoreAccessor.writePackageUnits() is empty.
- */
- @CleanRepositoriesBefore
- public void testConcurrentPackageRegistration2() throws Exception
- {
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
- CDOResource resource1 = transaction1.createResource(getResourcePath("/res1"));
- transaction1.commit();
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- CDOResource resource2 = transaction2.createResource(getResourcePath("/res2"));
- transaction2.commit();
-
- session2.options().setPassiveUpdateEnabled(false);
-
- resource1.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- resource2.getContents().add(getModel1Factory().createCompany());
- transaction2.commit();
- }
-
- @CleanRepositoriesBefore
- public void testPopulator() throws Exception
- {
- String nsURI = "http://dynamic";
- EPackage.Registry registry = new EPackageRegistryImpl();
-
- {
- EPackage p = EcoreFactory.eINSTANCE.createEPackage();
- p.setName("dynamic");
- p.setNsPrefix("dynamic");
- p.setNsURI(nsURI);
-
- EClass c = EcoreFactory.eINSTANCE.createEClass();
- c.setName("DClass");
-
- p.getEClassifiers().add(c);
- registry.put(nsURI, p);
-
- CDOSession session = openSession();
- CDOPackageRegistryPopulator.populate(registry, session.getPackageRegistry());
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Eike");
- res.getContents().add(company);
- transaction.commit();
- }
-
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- Company company = (Company)res.getContents().get(0);
- assertEquals("Eike", company.getName());
- }
-
- @CleanRepositoriesBefore
- public void testPopulatorGlobal() throws Exception
- {
- String nsURI = "http://dynamic";
- EPackage.Registry registry = EPackage.Registry.INSTANCE;
-
- try
- {
- {
- EPackage p = EcoreFactory.eINSTANCE.createEPackage();
- p.setName("dynamic");
- p.setNsPrefix("dynamic");
- p.setNsURI(nsURI);
-
- EClass c = EcoreFactory.eINSTANCE.createEClass();
- c.setName("DClass");
-
- p.getEClassifiers().add(c);
- registry.put(nsURI, p);
-
- CDOSession session = openSession();
- CDOPackageRegistryPopulator.populate(registry, session.getPackageRegistry());
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Eike");
- res.getContents().add(company);
- transaction.commit();
- }
-
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- Company company = (Company)res.getContents().get(0);
- assertEquals("Eike", company.getName());
- }
- finally
- {
- EPackage.Registry.INSTANCE.remove(nsURI);
- }
- }
-
- @CleanRepositoriesBefore
- public void testLaziness() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/res"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Eike");
- res.getContents().add(company);
- transaction.commit();
- }
-
- // Load resource in session 2
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/res"));
-
- Company company = (Company)res.getContents().get(0);
- assertEquals("Eike", company.getName());
- }
-
- public void testSubclassCacheInvalidation() throws IOException
- {
- ResourceSet rs = new ResourceSetImpl();
- rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
- Resource r1 = rs.createResource(URI.createURI("SubclassTest1.ecore"));
- r1.load(OM.BUNDLE.getInputStream("SubclassTest1.ecore"), null);
- EPackage p1 = (EPackage)r1.getContents().get(0);
- Resource r2 = rs.createResource(URI.createURI("SubclassTest2.ecore"));
- r2.load(OM.BUNDLE.getInputStream("SubclassTest2.ecore"), null);
- EPackage p2 = (EPackage)r2.getContents().get(0);
-
- CDOSession session = openSession();
- CDOPackageRegistry registry = session.getPackageRegistry();
- registry.putEPackage(p1);
- registry.putEPackage(p2);
-
- Map<EClass, List<EClass>> subTypes = registry.getSubTypes();
-
- assertSubtypes((EClass)p1.getEClassifier("RootClass"), subTypes,
- Arrays.asList("Child1", "Child4", "SubChild", "SubChild3", "Child5", "Child6", "SubChild2", "Child7", "Child8"));
- assertSubtypes((EClass)p1.getEClassifier("RootAbstractClass"), subTypes,
- Arrays.asList("Child2", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2", "Child8"));
- assertSubtypes((EClass)p1.getEClassifier("RootInterface"), subTypes,
- Arrays.asList("Child3", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2", "Child8"));
- }
-
- public void testSubclassCache() throws IOException
- {
- ResourceSet rs = new ResourceSetImpl();
- rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
- Resource r1 = rs.createResource(URI.createURI("SubclassTest1.ecore"));
- r1.load(OM.BUNDLE.getInputStream("SubclassTest1.ecore"), null);
- EPackage p1 = (EPackage)r1.getContents().get(0);
- Resource r2 = rs.createResource(URI.createURI("SubclassTest2.ecore"));
- r2.load(OM.BUNDLE.getInputStream("SubclassTest2.ecore"), null);
- EPackage p2 = (EPackage)r2.getContents().get(0);
-
- CDOSession session = openSession();
- CDOPackageRegistry registry = session.getPackageRegistry();
- registry.putEPackage(p1);
- Map<EClass, List<EClass>> subTypes = registry.getSubTypes();
-
- assertSubtypes((EClass)p1.getEClassifier("RootClass"), subTypes,
- Arrays.asList("Child1", "Child4", "SubChild", "SubChild3", "Child5", "Child6", "SubChild2"));
- assertSubtypes((EClass)p1.getEClassifier("RootAbstractClass"), subTypes,
- Arrays.asList("Child2", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2"));
- assertSubtypes((EClass)p1.getEClassifier("RootInterface"), subTypes,
- Arrays.asList("Child3", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2"));
-
- registry.putEPackage(p2);
- subTypes = registry.getSubTypes();
-
- assertSubtypes((EClass)p1.getEClassifier("RootClass"), subTypes,
- Arrays.asList("Child1", "Child4", "SubChild", "SubChild3", "Child5", "Child6", "SubChild2", "Child7", "Child8"));
- assertSubtypes((EClass)p1.getEClassifier("RootAbstractClass"), subTypes,
- Arrays.asList("Child2", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2", "Child8"));
- assertSubtypes((EClass)p1.getEClassifier("RootInterface"), subTypes,
- Arrays.asList("Child3", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2", "Child8"));
- }
-
- private void assertSubtypes(EClass eClass, Map<EClass, List<EClass>> subTypes, List<String> expected)
- {
- List<EClass> actual = subTypes.get(eClass);
- String[] actualArray = new String[actual.size()];
- for (int i = 0; i < actualArray.length; i++)
- {
- actualArray[i] = actual.get(i).getName();
- }
-
- String[] expectedArray = expected.toArray(new String[expected.size()]);
-
- Arrays.sort(actualArray);
- Arrays.sort(expectedArray);
-
- assertEquals(expectedArray, actualArray);
- }
-
- public static EPackage loadModel(String fileName) throws IOException
- {
- URI uri = URI.createURI(fileName);
- XMIResource resource = new XMIResourceImpl(uri);
- resource.setEncoding("UTF-8");
- resource.load(OM.BUNDLE.getInputStream(fileName), null);
- return (EPackage)resource.getContents().get(0);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Stefan Winkler - Bug 332912 - Caching subtype-relationships in the CDOPackageRegistry
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistryPopulator;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.bundle.OM;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.mango.MangoValue;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
+import org.eclipse.emf.cdo.tests.model3.Class1;
+import org.eclipse.emf.cdo.tests.model3.Model3Package;
+import org.eclipse.emf.cdo.tests.model3.subpackage.Class2;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class PackageRegistryTest extends AbstractCDOTest
+{
+ public void testGeneratedPackage() throws Exception
+ {
+ {
+ // Create resource in session 1
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ Company company = (Company)res.getContents().get(0);
+ assertEquals("Eike", company.getName());
+ }
+
+ public void testCommitTwoPackages() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(getModel1Package());
+ session.getPackageRegistry().putEPackage(getModel2Package());
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ SpecialPurchaseOrder specialPurchaseOrder = getModel2Factory().createSpecialPurchaseOrder();
+ specialPurchaseOrder.setDiscountCode("12345");
+ res.getContents().add(specialPurchaseOrder);
+ transaction.commit();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ SpecialPurchaseOrder specialPurchaseOrder = (SpecialPurchaseOrder)res.getContents().get(0);
+ assertEquals("12345", specialPurchaseOrder.getDiscountCode());
+ }
+
+ public void testCommitUnrelatedPackage() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ res.getContents().add(purchaseOrder);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ MangoValue value = getMangoFactory().createMangoValue();
+ value.setName("V0");
+ res.getContents().add(value);
+
+ transaction.commit();
+ session.close();
+ }
+
+ @CleanRepositoriesBefore
+ public void testCommitNestedPackages() throws Exception
+ {
+ CDOSession session = openSession();
+ assertEquals(3, session.getPackageRegistry().size());
+
+ session.getPackageRegistry().putEPackage(getModel3SubpackagePackage());
+ assertEquals(5, session.getPackageRegistry().size());
+
+ session.close();
+ }
+
+ @CleanRepositoriesBefore
+ public void testCommitTopLevelPackages() throws Exception
+ {
+ CDOSession session = openSession();
+ assertEquals(3, session.getPackageRegistry().size());
+
+ session.getPackageRegistry().putEPackage(getModel3Package());
+ assertEquals(5, session.getPackageRegistry().size());
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ Class1 class1 = getModel3Factory().createClass1();
+ res.getContents().add(class1);
+ transaction.commit();
+
+ EPackage model3Package = session.getPackageRegistry().getEPackage(getModel3Package().getNsURI());
+ assertNotNull(model3Package);
+ session.close();
+ }
+
+ public void testLoadNestedPackages() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(getModel3Package());
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ Class1 class1 = getModel3Factory().createClass1();
+ res.getContents().add(class1);
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ EPackage model3Package = session.getPackageRegistry().getEPackage(getModel3Package().getNsURI());
+ assertNotNull(model3Package);
+
+ EPackage subPackage = session.getPackageRegistry().getEPackage(getModel3SubpackagePackage().getNsURI());
+ assertNotNull(subPackage);
+ session.close();
+ }
+
+ public void testCommitCircularPackages() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(Model3Package.eINSTANCE);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res1 = transaction.createResource(getResourcePath("/res1"));
+ CDOResource res2 = transaction.createResource(getResourcePath("/res2"));
+
+ Class1 class1 = getModel3Factory().createClass1();
+ Class2 class2 = getModel3SubpackageFactory().createClass2();
+ class1.getClass2().add(class2);
+
+ res1.getContents().add(class1);
+ res2.getContents().add(class2);
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res1 = transaction.getResource(getResourcePath("/res1"));
+
+ Class1 class1 = (Class1)res1.getContents().get(0);
+ assertNotNull(class1);
+ EList<Class2> class22 = class1.getClass2();
+ Class2 class2 = class22.get(0);
+ assertNotNull(class2);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res2 = transaction.getResource(getResourcePath("/res2"));
+
+ Class2 class2 = (Class2)res2.getContents().get(0);
+ assertNotNull(class2);
+ Class1 class1 = class2.getClass1().get(0);
+ assertNotNull(class1);
+ }
+
+ public void testPackageRegistry() throws Exception
+ {
+ {
+ // Create resource in session 1
+ CDOSession session = openSession(IRepositoryConfig.REPOSITORY_NAME);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ Company company = (Company)res.getContents().get(0);
+ assertEquals("Eike", company.getName());
+ }
+
+ /**
+ * Bug 249383: Dynamic models in the global EPackage.Registry are not committed bug 249383
+ */
+ public void testGlobalDynamicPackageEager() throws Exception
+ {
+ String nsURI = "http://dynamic";
+
+ try
+ {
+ EPackage p = EcoreFactory.eINSTANCE.createEPackage();
+ p.setName("dynamic");
+ p.setNsPrefix("dynamic");
+ p.setNsURI(nsURI);
+
+ EClass c = EcoreFactory.eINSTANCE.createEClass();
+ c.setName("DClass");
+
+ p.getEClassifiers().add(c);
+ EPackage.Registry.INSTANCE.put(nsURI, p);
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(p);
+ p = session.getPackageRegistry().getEPackage(nsURI);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ EFactory factory = p.getEFactoryInstance();
+ EObject object = factory.create(c);
+
+ res.getContents().add(object);
+ transaction.commit();
+ session.close();
+ }
+ finally
+ {
+ EPackage.Registry.INSTANCE.remove(nsURI);
+ }
+ }
+
+ /**
+ * Bug 249383: Dynamic models in the global EPackage.Registry are not committed bug 249383
+ */
+ public void testGlobalDynamicPackage() throws Exception
+ {
+ String nsURI = "http://dynamic";
+
+ try
+ {
+ EPackage p = EcoreFactory.eINSTANCE.createEPackage();
+ p.setName("dynamic");
+ p.setNsPrefix("dynamic");
+ p.setNsURI(nsURI);
+
+ EClass c = EcoreFactory.eINSTANCE.createEClass();
+ c.setName("DClass");
+
+ p.getEClassifiers().add(c);
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(p);
+ }
+
+ EPackage.Registry.INSTANCE.put(nsURI, p);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ EFactory factory = p.getEFactoryInstance();
+ EObject object = factory.create(c);
+
+ res.getContents().add(object);
+ transaction.commit();
+ session.close();
+ }
+ catch (Exception ex)
+ {
+ EPackage.Registry.INSTANCE.remove(nsURI);
+ }
+ }
+
+ public void testGlobalDynamicPackageUnprepared() throws Exception
+ {
+ String nsURI = "http://dynamic";
+
+ try
+ {
+ EPackage p = EcoreFactory.eINSTANCE.createEPackage();
+ p.setName("dynamic");
+ p.setNsPrefix("dynamic");
+ p.setNsURI(nsURI);
+
+ EClass c = EcoreFactory.eINSTANCE.createEClass();
+ c.setName("DClass");
+
+ p.getEClassifiers().add(c);
+ EPackage.Registry.INSTANCE.put(nsURI, p);
+
+ CDOSession session = openSession();
+
+ // The default case is that legacy is disabled. For our test bed it is always enabled.
+ // To test the default case we must switch of legacy here.
+ CDOUtil.setLegacyModeDefault(false);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ EFactory factory = p.getEFactoryInstance();
+ EObject object = factory.create(c);
+
+ res.getContents().add(object);
+ transaction.commit();
+ session.close();
+
+ fail("LegacyModeNotEnabledException expected");
+ }
+ catch (LegacyModeNotEnabledException expected)
+ {
+ // SUCCESS
+ }
+ finally
+ {
+ EPackage.Registry.INSTANCE.remove(nsURI);
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testDynamicPackageFactory() throws Exception
+ {
+ // -Dorg.eclipse.emf.ecore.EPackage.Registry.INSTANCE=org.eclipse.emf.ecore.impl.CDOPackageRegistryImpl
+
+ {
+ EPackage model1 = loadModel("model1.ecore");
+ EClass companyClass = (EClass)model1.getEClassifier("Company");
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+ Resource model1Resource = model1.eResource();
+
+ // Create resource in session 1
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+ assertEquals(model1Resource, model1.eResource());
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ EFactory factory = model1.getEFactoryInstance();
+ EObject company = factory.create(companyClass);
+ company.eSet(nameAttribute, "Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ session.close();
+ }
+
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ CDOObject company = CDOUtil.getCDOObject(res.getContents().get(0));
+ EClass companyClass = company.eClass();
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+ String name = (String)company.eGet(nameAttribute);
+ assertEquals("Eike", name);
+ session.close();
+ }
+
+ @CleanRepositoriesBefore
+ public void testDynamicPackageNewInstance() throws Exception
+ {
+ {
+ EPackage model1 = loadModel("model1.ecore");
+ EClass companyClass = (EClass)model1.getEClassifier("Company");
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+
+ // Create resource in session 1
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ CDOObject company = CDOUtil.getCDOObject(EcoreUtil.create(companyClass));
+ company.eSet(nameAttribute, "Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ session.close();
+ }
+
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ CDOObject company = CDOUtil.getCDOObject(res.getContents().get(0));
+ EClass companyClass = company.eClass();
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+ String name = (String)company.eGet(nameAttribute);
+ assertEquals("Eike", name);
+ session.close();
+ }
+
+ @CleanRepositoriesBefore
+ public void testDuplicatePackageRegistration() throws Exception
+ {
+ CDOSession session1 = openSession();
+ CDOSession session2 = openSession();
+
+ try
+ {
+ {
+ CDOTransaction transaction = session1.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company1");
+ res.getContents().add(company);
+ transaction.commit();
+ sleep(1000); // Give session2 a chance to react
+ }
+
+ CDOPackageRegistry packageRegistry = session2.getPackageRegistry();
+ Model1Package model1Package = getModel1Package();
+ packageRegistry.putEPackage(model1Package);
+
+ CDOPackageUnit packageUnit = packageRegistry.getPackageUnit(model1Package);
+ assertEquals(CDOPackageUnit.State.LOADED, packageUnit.getState());
+
+ {
+ CDOTransaction transaction = session2.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res2"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company2");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+ }
+ finally
+ {
+ session1.close();
+ session2.close();
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testReuseCommittedPackage() throws Exception
+ {
+ final long timeStamp;
+ final CDOSession session1 = openSession();
+ final CDOSession session2 = openSession();
+
+ try
+ {
+ {
+ CDOTransaction transaction = session1.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company1");
+ res.getContents().add(company);
+ timeStamp = transaction.commit().getTimeStamp();
+ }
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return session2.getLastUpdateTime() >= timeStamp;
+ }
+ }.assertNoTimeOut();
+
+ {
+ CDOTransaction transaction = session2.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res2"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company2");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+ }
+ finally
+ {
+ session1.close();
+ session2.close();
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testConcurrentPackageRegistration() throws Exception
+ {
+ CDOSession session1 = openSession();
+ session1.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOSession session2 = openSession();
+ session2.getPackageRegistry().putEPackage(getModel1Package());
+
+ try
+ {
+ {
+ CDOTransaction transaction = session1.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company1");
+ res.getContents().add(company);
+ transaction.commit();
+ sleep(1000); // Give session2 a chance to react
+ }
+
+ CDOPackageRegistry packageRegistry = session2.getPackageRegistry();
+ Model1Package model1Package = getModel1Package();
+
+ CDOPackageUnit packageUnit = packageRegistry.getPackageUnit(model1Package);
+ assertEquals(CDOPackageUnit.State.LOADED, packageUnit.getState());
+
+ {
+ CDOTransaction transaction = session2.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res2"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company2");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+ }
+ finally
+ {
+ session1.close();
+ session2.close();
+ }
+ }
+
+ /**
+ * Bug 353246.
+ * <p>
+ * Cannot reproduce the problem with MEMStore because MEMStoreAccessor.writePackageUnits() is empty.
+ */
+ @CleanRepositoriesBefore
+ public void testConcurrentPackageRegistration2() throws Exception
+ {
+ CDOSession session1 = openSession();
+ CDOTransaction transaction1 = session1.openTransaction();
+ CDOResource resource1 = transaction1.createResource(getResourcePath("/res1"));
+ transaction1.commit();
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource resource2 = transaction2.createResource(getResourcePath("/res2"));
+ transaction2.commit();
+
+ session2.options().setPassiveUpdateEnabled(false);
+
+ resource1.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ resource2.getContents().add(getModel1Factory().createCompany());
+ transaction2.commit();
+ }
+
+ @CleanRepositoriesBefore
+ public void testPopulator() throws Exception
+ {
+ String nsURI = "http://dynamic";
+ EPackage.Registry registry = new EPackageRegistryImpl();
+
+ {
+ EPackage p = EcoreFactory.eINSTANCE.createEPackage();
+ p.setName("dynamic");
+ p.setNsPrefix("dynamic");
+ p.setNsURI(nsURI);
+
+ EClass c = EcoreFactory.eINSTANCE.createEClass();
+ c.setName("DClass");
+
+ p.getEClassifiers().add(c);
+ registry.put(nsURI, p);
+
+ CDOSession session = openSession();
+ CDOPackageRegistryPopulator.populate(registry, session.getPackageRegistry());
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ Company company = (Company)res.getContents().get(0);
+ assertEquals("Eike", company.getName());
+ }
+
+ @CleanRepositoriesBefore
+ public void testPopulatorGlobal() throws Exception
+ {
+ String nsURI = "http://dynamic";
+ EPackage.Registry registry = EPackage.Registry.INSTANCE;
+
+ try
+ {
+ {
+ EPackage p = EcoreFactory.eINSTANCE.createEPackage();
+ p.setName("dynamic");
+ p.setNsPrefix("dynamic");
+ p.setNsURI(nsURI);
+
+ EClass c = EcoreFactory.eINSTANCE.createEClass();
+ c.setName("DClass");
+
+ p.getEClassifiers().add(c);
+ registry.put(nsURI, p);
+
+ CDOSession session = openSession();
+ CDOPackageRegistryPopulator.populate(registry, session.getPackageRegistry());
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ Company company = (Company)res.getContents().get(0);
+ assertEquals("Eike", company.getName());
+ }
+ finally
+ {
+ EPackage.Registry.INSTANCE.remove(nsURI);
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testLaziness() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/res"));
+
+ Company company = (Company)res.getContents().get(0);
+ assertEquals("Eike", company.getName());
+ }
+
+ public void testSubclassCacheInvalidation() throws IOException
+ {
+ ResourceSet rs = new ResourceSetImpl();
+ rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
+ Resource r1 = rs.createResource(URI.createURI("SubclassTest1.ecore"));
+ r1.load(OM.BUNDLE.getInputStream("SubclassTest1.ecore"), null);
+ EPackage p1 = (EPackage)r1.getContents().get(0);
+ Resource r2 = rs.createResource(URI.createURI("SubclassTest2.ecore"));
+ r2.load(OM.BUNDLE.getInputStream("SubclassTest2.ecore"), null);
+ EPackage p2 = (EPackage)r2.getContents().get(0);
+
+ CDOSession session = openSession();
+ CDOPackageRegistry registry = session.getPackageRegistry();
+ registry.putEPackage(p1);
+ registry.putEPackage(p2);
+
+ Map<EClass, List<EClass>> subTypes = registry.getSubTypes();
+
+ assertSubtypes((EClass)p1.getEClassifier("RootClass"), subTypes,
+ Arrays.asList("Child1", "Child4", "SubChild", "SubChild3", "Child5", "Child6", "SubChild2", "Child7", "Child8"));
+ assertSubtypes((EClass)p1.getEClassifier("RootAbstractClass"), subTypes,
+ Arrays.asList("Child2", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2", "Child8"));
+ assertSubtypes((EClass)p1.getEClassifier("RootInterface"), subTypes,
+ Arrays.asList("Child3", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2", "Child8"));
+ }
+
+ public void testSubclassCache() throws IOException
+ {
+ ResourceSet rs = new ResourceSetImpl();
+ rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
+ Resource r1 = rs.createResource(URI.createURI("SubclassTest1.ecore"));
+ r1.load(OM.BUNDLE.getInputStream("SubclassTest1.ecore"), null);
+ EPackage p1 = (EPackage)r1.getContents().get(0);
+ Resource r2 = rs.createResource(URI.createURI("SubclassTest2.ecore"));
+ r2.load(OM.BUNDLE.getInputStream("SubclassTest2.ecore"), null);
+ EPackage p2 = (EPackage)r2.getContents().get(0);
+
+ CDOSession session = openSession();
+ CDOPackageRegistry registry = session.getPackageRegistry();
+ registry.putEPackage(p1);
+ Map<EClass, List<EClass>> subTypes = registry.getSubTypes();
+
+ assertSubtypes((EClass)p1.getEClassifier("RootClass"), subTypes,
+ Arrays.asList("Child1", "Child4", "SubChild", "SubChild3", "Child5", "Child6", "SubChild2"));
+ assertSubtypes((EClass)p1.getEClassifier("RootAbstractClass"), subTypes,
+ Arrays.asList("Child2", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2"));
+ assertSubtypes((EClass)p1.getEClassifier("RootInterface"), subTypes,
+ Arrays.asList("Child3", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2"));
+
+ registry.putEPackage(p2);
+ subTypes = registry.getSubTypes();
+
+ assertSubtypes((EClass)p1.getEClassifier("RootClass"), subTypes,
+ Arrays.asList("Child1", "Child4", "SubChild", "SubChild3", "Child5", "Child6", "SubChild2", "Child7", "Child8"));
+ assertSubtypes((EClass)p1.getEClassifier("RootAbstractClass"), subTypes,
+ Arrays.asList("Child2", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2", "Child8"));
+ assertSubtypes((EClass)p1.getEClassifier("RootInterface"), subTypes,
+ Arrays.asList("Child3", "Child4", "SubChild", "SubChild3", "Child6", "SubChild2", "Child8"));
+ }
+
+ private void assertSubtypes(EClass eClass, Map<EClass, List<EClass>> subTypes, List<String> expected)
+ {
+ List<EClass> actual = subTypes.get(eClass);
+ String[] actualArray = new String[actual.size()];
+ for (int i = 0; i < actualArray.length; i++)
+ {
+ actualArray[i] = actual.get(i).getName();
+ }
+
+ String[] expectedArray = expected.toArray(new String[expected.size()]);
+
+ Arrays.sort(actualArray);
+ Arrays.sort(expectedArray);
+
+ assertEquals(expectedArray, actualArray);
+ }
+
+ public static EPackage loadModel(String fileName) throws IOException
+ {
+ URI uri = URI.createURI(fileName);
+ XMIResource resource = new XMIResourceImpl(uri);
+ resource.setEncoding("UTF-8");
+ resource.load(OM.BUNDLE.getInputStream(fileName), null);
+ return (EPackage)resource.getContents().get(0);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PartialCommitTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PartialCommitTest.java
index b04270bdbd..63af76927d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PartialCommitTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PartialCommitTest.java
@@ -1,1413 +1,1413 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.legacy.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.legacy.model4.model4Package;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.MultiNonContainedElement;
-import org.eclipse.emf.cdo.tests.model4.RefMultiNonContained;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefSingleNonContained;
-import org.eclipse.emf.cdo.tests.model4.SingleNonContainedElement;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.CommitIntegrityException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.util.CommitIntegrityCheck;
-import org.eclipse.emf.internal.cdo.util.CommitIntegrityCheck.Style;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class PartialCommitTest extends AbstractCDOTest
-{
- private static String RESOURCENAME = "/r1";
-
- private CDOSession session;
-
- private InternalCDOTransaction tx;
-
- private CDOResource resource1;
-
- /* ---- Model 1 stuff ---- */
-
- private Company company1, company2, company3, company99;
-
- private PurchaseOrder purchaseOrder;
-
- private Supplier supplier1;
-
- /* ---- Model 4 stuff ---- */
-
- private RefSingleContainedNPL refSingleContained1, refSingleContained2;
-
- private ContainedElementNoOpposite singleContainedElement1;
-
- private RefSingleNonContained refSingleNonContained1, refSingleNonContained2;
-
- private SingleNonContainedElement singleNonContainedElement1, singleNonContainedElement2;
-
- private RefMultiNonContained refMultiNonContained1, refMultiNonContained2;
-
- private MultiNonContainedElement multiNonContainedElement1, multiNonContainedElement2;
-
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
- return map;
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
-
- session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- tx = (InternalCDOTransaction)session.openTransaction();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- tx.close();
- session.close();
- super.doTearDown();
- }
-
- @CleanRepositoriesBefore
- public void testNewTopLevelResource() throws CommitException
- {
- CDOResource topResource1 = tx.createResource("/top1");
- tx.commit();
-
- topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
- CDOResource topResource2 = tx.createResource("/top2");
- tx.setCommittables(createSet(topResource2, tx.getRootResource()));
- goodAll();
- }
-
- @CleanRepositoriesBefore
- public void testNewTopLevelResource_rootResourceNotIncluded() throws CommitException
- {
- CDOResource topResource1 = tx.createResource("/top1");
- tx.commit();
-
- topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
- CDOResource topResource2 = tx.createResource("/top2");
- tx.setCommittables(createSet(topResource2));
- badAll(createSet(tx.getRootResource()));
- }
-
- @CleanRepositoriesBefore
- public void testNewNestedResource() throws CommitException
- {
- CDOResource topResource1 = tx.createResource("/top1");
- tx.commit();
-
- topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
- CDOResource nestedResource = tx.createResource("/folder/nested");
- tx.setCommittables(createSet(nestedResource, nestedResource.getFolder(), tx.getRootResource()));
- goodAll();
- }
-
- @CleanRepositoriesBefore
- public void testNewNestedResource_rootResourceNotIncluded() throws CommitException
- {
- CDOResource topResource1 = tx.createResource("/top1");
- tx.commit();
-
- topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
- CDOResource nestedResource = tx.createResource("/folder/nested");
- tx.setCommittables(createSet(nestedResource, nestedResource.getFolder()));
- badAll(createSet(tx.getRootResource()));
- }
-
- @CleanRepositoriesBefore
- public void testNewNestedResource_resourceFolderNotIncluded() throws CommitException
- {
- CDOResource topResource1 = tx.createResource("/top1");
- tx.commit();
-
- topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
- CDOResource nestedResource = tx.createResource("/folder/nested");
- tx.setCommittables(createSet(nestedResource, tx.getRootResource()));
- badAll(createSet(nestedResource.getFolder()));
- }
-
- public void testPartialCleanUp_dirtyObjects() throws CommitException
- {
- simpleModel1Setup();
-
- company1.setName("Company1");
- company2.setName("Company2");
- company3.setName("Company3");
-
- tx.setCommittables(createSet(company1));
- tx.commit();
-
- assertClean(company1, tx);
- assertDirty(company2, tx);
- assertDirty(company3, tx);
- assertEquals(true, tx.isDirty());
-
- tx.setCommittables(createSet(company2));
- tx.commit();
-
- assertClean(company1, tx);
- assertClean(company2, tx);
- assertDirty(company3, tx);
- assertEquals(true, tx.isDirty());
-
- tx.setCommittables(createSet(company3));
- tx.commit();
-
- assertClean(company1, tx);
- assertClean(company2, tx);
- assertClean(company3, tx);
- assertEquals(false, tx.isDirty());
- }
-
- public void testPartialCleanUp_newObjects() throws CommitException
- {
- simpleModel1Setup();
- Category cat = Model1Factory.eINSTANCE.createCategory();
- resource1.getContents().add(cat);
- tx.commit();
-
- company1.setName("Zzz"); // Make dirty but don't include; so as to force partial commit
-
- // Make some new objects; but with different containers
- Company company4 = Model1Factory.eINSTANCE.createCompany();
- resource1.getContents().add(company4);
- PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
- company2.getPurchaseOrders().add(po);
- Product1 product = Model1Factory.eINSTANCE.createProduct1();
- product.setName("product1");
- cat.getProducts().add(product);
-
- tx.setCommittables(createSet(company4, resource1));
- tx.commit();
-
- assertClean(company4, tx);
- assertNew(po, tx);
- assertNew(product, tx);
- assertEquals(true, tx.isDirty());
-
- tx.setCommittables(createSet(po, company2));
- tx.commit();
-
- assertClean(company4, tx);
- assertClean(po, tx);
- assertNew(product, tx);
- assertEquals(true, tx.isDirty());
-
- tx.setCommittables(createSet(product, cat));
- tx.commit();
-
- assertClean(company4, tx);
- assertClean(po, tx);
- assertClean(product, tx);
- assertEquals(true, tx.isDirty());
-
- tx.setCommittables(createSet(company1));
- tx.commit();
- assertEquals(false, tx.isDirty());
- }
-
- public void testPartialCleanUp_detachedObjects() throws CommitException
- {
- skipStoreWithoutQueryXRefs();
-
- simpleModel1Setup();
- Category cat = Model1Factory.eINSTANCE.createCategory();
- resource1.getContents().add(cat);
-
- // Make some new objects; but with different containers
- Company company4 = Model1Factory.eINSTANCE.createCompany();
- resource1.getContents().add(company4);
- PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
- company2.getPurchaseOrders().add(po);
- Product1 product = Model1Factory.eINSTANCE.createProduct1();
- product.setName("product1");
- cat.getProducts().add(product);
- tx.commit();
-
- company1.setName("Zzz"); // Make dirty but don't include; so as to force partial commit
-
- resource1.getContents().remove(company4);
- company2.getPurchaseOrders().remove(po);
- cat.getProducts().remove(product);
-
- assertEquals(true, tx.getDetachedObjects().containsValue(company4));
- assertEquals(true, tx.getCleanRevisions().containsKey(company4));
- assertEquals(true, tx.getDetachedObjects().containsValue(po));
- assertEquals(true, tx.getCleanRevisions().containsKey(company4));
- assertEquals(true, tx.getDetachedObjects().containsValue(product));
- assertEquals(true, tx.getCleanRevisions().containsKey(company4));
- assertEquals(true, tx.isDirty());
-
- tx.setCommittables(createSet(company4, resource1));
- tx.commit();
-
- assertEquals(false, tx.getDetachedObjects().containsValue(company4));
- assertEquals(false, tx.getCleanRevisions().containsKey(company4));
- assertEquals(true, tx.getDetachedObjects().containsValue(po));
- assertEquals(true, tx.getCleanRevisions().containsKey(po));
- assertEquals(true, tx.getDetachedObjects().containsValue(product));
- assertEquals(true, tx.getCleanRevisions().containsKey(product));
- assertEquals(true, tx.isDirty());
-
- tx.setCommittables(createSet(po, company2));
- tx.commit();
-
- assertEquals(false, tx.getDetachedObjects().containsValue(company4));
- assertEquals(false, tx.getCleanRevisions().containsKey(company4));
- assertEquals(false, tx.getDetachedObjects().containsValue(po));
- assertEquals(false, tx.getCleanRevisions().containsKey(po));
- assertEquals(true, tx.getDetachedObjects().containsValue(product));
- assertEquals(true, tx.getCleanRevisions().containsKey(product));
- assertEquals(true, tx.isDirty());
-
- tx.setCommittables(createSet(product, cat));
- tx.commit();
-
- assertEquals(false, tx.getDetachedObjects().containsValue(company4));
- assertEquals(false, tx.getCleanRevisions().containsKey(company4));
- assertEquals(false, tx.getDetachedObjects().containsValue(po));
- assertEquals(false, tx.getCleanRevisions().containsKey(po));
- assertEquals(false, tx.getDetachedObjects().containsValue(product));
- assertEquals(false, tx.getCleanRevisions().containsKey(product));
- assertEquals(true, tx.isDirty());
-
- tx.setCommittables(createSet(company1));
- tx.commit();
- assertEquals(false, tx.isDirty());
- }
-
- public void testDirty() throws CommitException
- {
- simpleModel1Setup();
- supplier1.setName("Supplier");
- company1.setName("Company");
-
- tx.setCommittables(createSet(supplier1));
- tx.commit();
-
- assertDirty(company1, tx);
- assertEquals(company1.getName(), "Company");
-
- assertClean(supplier1, tx);
- assertEquals(supplier1.getName(), "Supplier");
- }
-
- public void testNew() throws CommitException
- {
- simpleModel1Setup();
- PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
- company2.getPurchaseOrders().add(po);
-
- // Include both the new object and its container
- tx.setCommittables(createSet(company2, po));
- goodAll();
- }
-
- public void testNew_containerOfNewObjectNotIncluded() throws CommitException
- {
- simpleModel1Setup();
- PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
- company2.getPurchaseOrders().add(po);
-
- // Include only the new object
- tx.setCommittables(createSet(po));
- badAll(createSet(company2));
- }
-
- public void testNew_newObjectNotIncluded() throws CommitException
- {
- simpleModel1Setup();
- PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
- company2.getPurchaseOrders().add(po);
-
- // Include only the new object's container
- tx.setCommittables(createSet(company2));
- badAll(createSet(po));
- }
-
- @CleanRepositoriesBefore
- public void testDetach() throws CommitException
- {
- skipStoreWithoutQueryXRefs();
-
- simpleModel1Setup();
- EcoreUtil.delete(purchaseOrder);
-
- // Include the detached object and its old container
- tx.setCommittables(createSet(company1, purchaseOrder));
- goodAll();
- }
-
- public void testDetach_containerOfDetachedObjectNotIncluded() throws CommitException
- {
- simpleModel1Setup();
- EcoreUtil.delete(purchaseOrder);
-
- // Include only the detached object
- tx.setCommittables(createSet(purchaseOrder));
- badAll(createSet(company1));
- }
-
- public void testDetach_detachedObjectNotIncluded() throws CommitException
- {
- simpleModel1Setup();
- EcoreUtil.delete(purchaseOrder);
-
- // Include only the detached object's old container
- tx.setCommittables(createSet(company1));
- badAll(createSet(purchaseOrder));
- }
-
- public void testMove() throws CommitException
- {
- simpleModel1Setup();
- company2.getPurchaseOrders().add(purchaseOrder);
- supplier1.setName("Supplier");
-
- // Include the old and new containers as well as the object that was moved
- tx.setCommittables(createSet(purchaseOrder, company1, company2));
- goodAll();
-
- assertClean(company1, tx);
- assertClean(company2, tx);
- assertClean(purchaseOrder, tx);
- assertDirty(supplier1, tx);
-
- assertEquals(false, company1.getPurchaseOrders().contains(purchaseOrder));
- assertEquals(true, company2.getPurchaseOrders().contains(purchaseOrder));
- assertEquals("Supplier", supplier1.getName());
- assertSame(company2, purchaseOrder.eContainer());
- }
-
- public void testMove_newContainerNotIncluded() throws CommitException
- {
- simpleModel1Setup();
- company2.getPurchaseOrders().add(purchaseOrder);
-
- // Include only the object that was moved and its old container
- tx.setCommittables(createSet(purchaseOrder, company1));
- badAll(createSet(company2));
- }
-
- public void testMove_oldContainerNotIncluded() throws CommitException
- {
- simpleModel1Setup();
- company2.getPurchaseOrders().add(purchaseOrder);
-
- // Include only the object that was moved and its new container
- tx.setCommittables(createSet(purchaseOrder, company2));
- badAll(createSet(company1));
- }
-
- public void testMove_movedObjectNotIncluded() throws CommitException
- {
- simpleModel1Setup();
- company2.getPurchaseOrders().add(purchaseOrder);
-
- // Include only the old and new containers
- tx.setCommittables(createSet(company1, company2));
- badAll(createSet(purchaseOrder));
- }
-
- public void testMove_onlyOldContainerIncluded() throws CommitException
- {
- simpleModel1Setup();
- company2.getPurchaseOrders().add(purchaseOrder);
-
- // Include only the old container
- tx.setCommittables(createSet(company1));
- badAll(createSet(company2, purchaseOrder));
- }
-
- public void testMove_onlyNewContainerIncluded() throws CommitException
- {
- simpleModel1Setup();
- company2.getPurchaseOrders().add(purchaseOrder);
-
- // Include only the new container
- tx.setCommittables(createSet(company2));
- badAll(createSet(company1, purchaseOrder));
- }
-
- public void testMove_onlyMovedObjectIncluded() throws CommitException
- {
- simpleModel1Setup();
- company2.getPurchaseOrders().add(purchaseOrder);
-
- // Include only the moved object
- tx.setCommittables(createSet(purchaseOrder));
- badAll(createSet(company1, company2));
- }
-
- public void testDoubleMove() throws CommitException
- {
- simpleModel1Setup();
- company2.getPurchaseOrders().add(purchaseOrder);
- company3.getPurchaseOrders().add(purchaseOrder);
-
- // Include the old and new containers as well as the object that was moved
- // (The point here is that company2 does NOT have to be included.)
- tx.setCommittables(createSet(purchaseOrder, company1, company3));
- System.out.printf("---> purchaseOrder=%s company1=%s company2=%s company3=%s\n", purchaseOrder, company1, company2,
- company3);
- goodAll();
- }
-
- public void test_noCommittablesAfterCommit() throws CommitException
- {
- simpleModel1Setup();
- company1.setName("zzz");
- tx.setCommittables(createSet(company1));
- tx.commit();
-
- assertNull(tx.getCommittables());
- }
-
- public void testNewSingle() throws CommitException
- {
- simpleModel4ContainmentSetup();
- ContainedElementNoOpposite singleContainedElement = model4Factory.eINSTANCE.createContainedElementNoOpposite();
- refSingleContained2.setElement(singleContainedElement);
-
- // Include both the new object and its container
- tx.setCommittables(createSet(refSingleContained2, singleContainedElement));
- goodAll();
- }
-
- public void testNewSingle_containerOfNewObjectNotIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- ContainedElementNoOpposite singleContainedElement = model4Factory.eINSTANCE.createContainedElementNoOpposite();
- refSingleContained2.setElement(singleContainedElement);
-
- // Include only the new object
- tx.setCommittables(createSet(singleContainedElement));
- badAll(createSet(refSingleContained2));
- }
-
- public void testNewSingle_newObjectNotIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- ContainedElementNoOpposite singleContainedElement = model4Factory.eINSTANCE.createContainedElementNoOpposite();
- refSingleContained2.setElement(singleContainedElement);
-
- // Include only the new object's container
- tx.setCommittables(createSet(refSingleContained2));
- badAll(createSet(singleContainedElement));
- }
-
- public void testDetachSingleRef() throws CommitException
- {
- skipStoreWithoutQueryXRefs();
-
- simpleModel4ContainmentSetup();
- refSingleContained1.setElement(null);
-
- // Include the detached object and its old container
- tx.setCommittables(createSet(refSingleContained1, singleContainedElement1));
- goodAll();
- }
-
- public void testDetachSingleRef_containerOfDetachedObjectNotIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- refSingleContained1.setElement(null);
-
- // Include only the detached object
- tx.setCommittables(createSet(singleContainedElement1));
- badAll(createSet(refSingleContained1));
- }
-
- public void testDetachSingleRef_detachedObjectNotIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- refSingleContained1.setElement(null);
-
- // Include only the detached object's old container
- tx.setCommittables(createSet(refSingleContained1));
- badAll(createSet(singleContainedElement1));
- }
-
- public void testMoveSingleRef() throws CommitException
- {
- simpleModel4ContainmentSetup();
- refSingleContained2.setElement(singleContainedElement1);
-
- // Include the old and new containers as well as the object that was moved
- tx.setCommittables(createSet(refSingleContained1, refSingleContained2, singleContainedElement1));
- goodAll();
- }
-
- public void testMoveSingleRef_newContainerNotIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- refSingleContained2.setElement(singleContainedElement1);
-
- // Include only the object that was moved and its old container
- tx.setCommittables(createSet(refSingleContained1, singleContainedElement1));
- badAll(createSet(refSingleContained2));
- }
-
- public void testMoveSingleRef_oldContainerNotIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- refSingleContained2.setElement(singleContainedElement1);
-
- // Include only the object that was moved and its new container
- tx.setCommittables(createSet(refSingleContained2, singleContainedElement1));
- badAll(createSet(refSingleContained1));
- }
-
- public void testMoveSingleRef_movedObjectNotIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- refSingleContained2.setElement(singleContainedElement1);
-
- // Include only the old and new containers
- tx.setCommittables(createSet(refSingleContained1, refSingleContained2));
- badAll(createSet(singleContainedElement1));
- }
-
- public void testMoveSingleRef_onlyOldContainerIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- refSingleContained2.setElement(singleContainedElement1);
-
- // Include only the old container
- tx.setCommittables(createSet(refSingleContained1));
- badAll(createSet(singleContainedElement1, refSingleContained2));
- }
-
- public void testMoveSingleRef_onlyNewContainerIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- refSingleContained2.setElement(singleContainedElement1);
-
- // Include only the new container
- tx.setCommittables(createSet(refSingleContained2));
- badAll(createSet(singleContainedElement1, refSingleContained1));
- }
-
- public void testMoveSingleRef_onlyMovedObjectIncluded() throws CommitException
- {
- simpleModel4ContainmentSetup();
- refSingleContained2.setElement(singleContainedElement1);
-
- // Include only the moved object
- tx.setCommittables(createSet(singleContainedElement1));
- badAll(createSet(refSingleContained1, refSingleContained2));
- }
-
- public void testNewTopLevel() throws CommitException
- {
- simpleModel1Setup();
- Company company = Model1Factory.eINSTANCE.createCompany();
- resource1.getContents().add(company);
-
- // Include both the resource and the new object
- tx.setCommittables(createSet(resource1, company));
- goodAll();
- }
-
- public void testNewTopLevel_newObjectNotIncluded() throws CommitException
- {
- simpleModel1Setup();
- Company company = Model1Factory.eINSTANCE.createCompany();
- resource1.getContents().add(company);
-
- // Include only the resource
- tx.setCommittables(createSet(resource1));
- badAll(createSet(company));
- }
-
- public void testNewTopLevel_resourceNotIncluded() throws CommitException
- {
- simpleModel1Setup();
- Company company = Model1Factory.eINSTANCE.createCompany();
- resource1.getContents().add(company);
-
- // Include only the new object
- tx.setCommittables(createSet(company));
- badAll(createSet(resource1));
- }
-
- public void _testNewTopLevel_resourceNotIncluded() throws CommitException
- {
- simpleModel1Setup();
-
- CDOID companyID = null;
- {
- Company company = Model1Factory.eINSTANCE.createCompany();
- resource1.getContents().add(company);
-
- // Include only the new object
- tx.setCommittables(createSet(company));
- tx.commit();
-
- companyID = CDOUtil.getCDOObject(company).cdoID();
- }
-
- System.out.println("---> companyID = " + companyID);
- System.out.println("---> " + CDOUtil.getCDOObject(resource1).cdoState());
-
- {
- CDOSession session2 = openSession();
- CDOView view = session2.openView();
- CDOResource resource = view.getResource(getResourcePath(resource1.getPath()));
-
- // We want to know if the new company that was committed, is an element
- // in the getContents() collection of the Resource. We cannot just call
- // getContents().contains(), because of the odd implementation of
- // CDOResourceImpl.contains: it actually asks the element, rather than
- // checking its own collection. So, we have to do this the hard way:
- //
- boolean found = false;
- Iterator<EObject> iter = resource.getContents().iterator();
- while (!found && iter.hasNext())
- {
- CDOObject o = CDOUtil.getCDOObject(iter.next());
- if (o.cdoID().equals(companyID))
- {
- found = true;
- }
- }
- assertEquals(true, found);
-
- view.close();
- session2.close();
- }
- }
-
- // -------- Tests concerning bi-di references ----------
- //
- // Cases to test:
- // Bi-di refs are analogous to containment, the only difference being that
- // bi-di refs are symmetrical, whereas containment/container is not.
- //
- // So:
- //
- // For DIRTY objects, the cases are:
- // 1. Setting a bidi ref to null where it was previously non-null
- // Must check that object owning opposite feature is included
- // 2. Setting a bidi ref to non-null where it was previously null
- // Must check that object owning opposite feature is included
- // 3. Changing a bidi ref from one non-null value to another
- // Must check that both the object owning the NEW opposite feature,
- // as well as the OLD one, are included
- //
- // For NEW objects, the
- // If the detached object had any non-null bidi refs, we must check
- // whether the bidi target is included.
- //
- // For DETACHED objects:
- // If the detached object had any non-null bidi refs, we must check
- // whether the bidi target is included.
-
- public void testDirtySingleBidiNew() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- singleNonContainedElement2.setParent(refSingleNonContained2);
-
- tx.setCommittables(createSet(singleNonContainedElement2, refSingleNonContained2));
- goodAll();
- }
-
- public void testDirtySingleBidiNew_newtargetNotIncluded() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- singleNonContainedElement2.setParent(refSingleNonContained2);
-
- tx.setCommittables(createSet(singleNonContainedElement2));
- badAll(createSet(refSingleNonContained2));
- }
-
- public void testDirtySingleBidiChanged() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- // We "reparent" the singleNonContainedElement1
- singleNonContainedElement1.setParent(refSingleNonContained2);
-
- tx.setCommittables(createSet(singleNonContainedElement1, refSingleNonContained1, refSingleNonContained2));
- goodAll();
- }
-
- public void testDirtySingleBidiChanged_newTargetNotIncluded() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- // We "reparent" the singleNonContainedElement1
- singleNonContainedElement1.setParent(refSingleNonContained2);
-
- tx.setCommittables(createSet(singleNonContainedElement1, refSingleNonContained1));
- badAll(createSet(refSingleNonContained2));
- }
-
- public void testDirtySingleBidiChanged_oldTargetNotIncluded() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- // We "reparent" the singleNonContainedElement1
- singleNonContainedElement1.setParent(refSingleNonContained2);
-
- tx.setCommittables(createSet(singleNonContainedElement1, refSingleNonContained2));
- badAll(createSet(refSingleNonContained1));
- }
-
- public void testDirtySingleBidiRemoved() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- singleNonContainedElement1.setParent(null);
-
- tx.setCommittables(createSet(singleNonContainedElement1, refSingleNonContained1));
- goodAll();
- }
-
- public void testDirtySingleBidiRemoved_oldTargetNotIncluded() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- singleNonContainedElement1.setParent(null);
-
- tx.setCommittables(createSet(singleNonContainedElement1));
- badAll(createSet(refSingleNonContained1));
- }
-
- public void testSingleBidiOnNewObject() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- SingleNonContainedElement newNonContainedElement = model4Factory.eINSTANCE.createSingleNonContainedElement();
- resource1.getContents().add(newNonContainedElement);
- newNonContainedElement.setParent(refSingleNonContained2);
-
- tx.setCommittables(createSet(newNonContainedElement, resource1, refSingleNonContained2));
- goodAll();
- }
-
- public void testSingleBidiOnNewObject_targetNotIncluded() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- SingleNonContainedElement newNonContainedElement = model4Factory.eINSTANCE.createSingleNonContainedElement();
- resource1.getContents().add(newNonContainedElement);
- newNonContainedElement.setParent(refSingleNonContained2);
-
- tx.setCommittables(createSet(newNonContainedElement, resource1));
- badAll(createSet(refSingleNonContained2));
- }
-
- public void testSingleBidiOnRemovedObject() throws CommitException
- {
- skipStoreWithoutQueryXRefs();
-
- simpleModel4SingleBidiSetup();
- EcoreUtil.delete(singleNonContainedElement1);
-
- tx.setCommittables(createSet(singleNonContainedElement1, resource1, refSingleNonContained1));
- goodAll();
- }
-
- public void testSingleBidiOnRemovedObject_targetNotIncluded() throws CommitException
- {
- simpleModel4SingleBidiSetup();
- EcoreUtil.delete(singleNonContainedElement1);
-
- tx.setCommittables(createSet(singleNonContainedElement1, resource1));
- badAll(createSet(refSingleNonContained1));
- }
-
- public void testDirtyMultiBidiNew() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- multiNonContainedElement2.setParent(refMultiNonContained2);
-
- tx.setCommittables(createSet(multiNonContainedElement2, refMultiNonContained2));
- goodAll();
- }
-
- public void testDirtyMultiBidiNew_newtargetNotIncluded() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- multiNonContainedElement2.setParent(refMultiNonContained2);
-
- tx.setCommittables(createSet(multiNonContainedElement2));
- badAll(createSet(refMultiNonContained2));
- }
-
- public void testDirtyMultiBidiChanged() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- // We "reparent" the multiNonContainedElement1
- multiNonContainedElement1.setParent(refMultiNonContained2);
-
- tx.setCommittables(createSet(multiNonContainedElement1, refMultiNonContained1, refMultiNonContained2));
- goodAll();
- }
-
- public void testDirtyMultiBidiChanged_newTargetNotIncluded() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- // We "reparent" the multiNonContainedElement1
- multiNonContainedElement1.setParent(refMultiNonContained2);
-
- tx.setCommittables(createSet(multiNonContainedElement1, refMultiNonContained1));
- badAll(createSet(refMultiNonContained2));
- }
-
- public void testDirtyMultiBidiChanged_oldTargetNotIncluded() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- // We "reparent" the multiNonContainedElement1
- multiNonContainedElement1.setParent(refMultiNonContained2);
-
- tx.setCommittables(createSet(multiNonContainedElement1, refMultiNonContained2));
- badAll(createSet(refMultiNonContained1));
- }
-
- public void testDirtyMultiBidiRemoved() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- multiNonContainedElement1.setParent(null);
-
- tx.setCommittables(createSet(multiNonContainedElement1, refMultiNonContained1));
- goodAll();
- }
-
- public void testDirtyMultiBidiRemoved_oldTargetNotIncluded() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- multiNonContainedElement1.setParent(null);
-
- tx.setCommittables(createSet(multiNonContainedElement1));
- badAll(createSet(refMultiNonContained1));
- }
-
- public void testMultiBidiOnNewObject() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- MultiNonContainedElement newNonContainedElement = model4Factory.eINSTANCE.createMultiNonContainedElement();
- resource1.getContents().add(newNonContainedElement);
- newNonContainedElement.setParent(refMultiNonContained2);
-
- tx.setCommittables(createSet(newNonContainedElement, resource1, refMultiNonContained2));
- goodAll();
- }
-
- public void testMultiBidiOnNewObject_targetNotIncluded() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- MultiNonContainedElement newNonContainedElement = model4Factory.eINSTANCE.createMultiNonContainedElement();
- resource1.getContents().add(newNonContainedElement);
- newNonContainedElement.setParent(refMultiNonContained2);
-
- tx.setCommittables(createSet(newNonContainedElement, resource1));
- badAll(createSet(refMultiNonContained2));
- }
-
- public void testMultiBidiOnRemovedObject() throws CommitException
- {
- skipStoreWithoutQueryXRefs();
-
- simpleModel4MultiBidiSetup();
- EcoreUtil.delete(multiNonContainedElement1);
-
- tx.setCommittables(createSet(multiNonContainedElement1, resource1, refMultiNonContained1));
- goodAll();
- }
-
- public void testMultiBidiOnRemovedObject_targetNotIncluded() throws CommitException
- {
- simpleModel4MultiBidiSetup();
- EcoreUtil.delete(multiNonContainedElement1);
-
- tx.setCommittables(createSet(multiNonContainedElement1, resource1));
- badAll(createSet(refMultiNonContained1));
- }
-
- /* --------- DANGLING REFERENCE PROBLEMS: Single refs ---------- */
-
- public void testIgnoreDanglingSingleRef_newToDetached() throws CommitException
- {
- simpleModel4SingleBidiSetup();
-
- RefSingleNonContained refSingleNonContained3 = model4Factory.eINSTANCE.createRefSingleNonContained();
- resource1.getContents().add(refSingleNonContained3);
-
- EcoreUtil.delete(singleNonContainedElement2);
- refSingleNonContained3.setElement(singleNonContainedElement2);
-
- tx.setCommittables(createSet(refSingleNonContained3, singleNonContainedElement2, resource1));
- good(Style.EXCEPTION);
- }
-
- public void testIgnoreDanglingSingleRef_newToTransient() throws CommitException
- {
- simpleModel4SingleBidiSetup();
-
- RefSingleNonContained refSingleNonContained3 = model4Factory.eINSTANCE.createRefSingleNonContained();
- resource1.getContents().add(refSingleNonContained3);
-
- SingleNonContainedElement singleNonContainedElement3 = model4Factory.eINSTANCE.createSingleNonContainedElement();
- refSingleNonContained3.setElement(singleNonContainedElement3);
-
- tx.setCommittables(createSet(refSingleNonContained3, singleNonContainedElement3, resource1));
- good(Style.EXCEPTION);
- }
-
- public void testIgnoreDanglingSingleRef_dirtyToDetached() throws CommitException
- {
- simpleModel4SingleBidiSetup();
-
- EcoreUtil.delete(singleNonContainedElement2);
- refSingleNonContained2.setElement(singleNonContainedElement2);
-
- tx.setCommittables(createSet(refSingleNonContained2, singleNonContainedElement2, resource1));
- good(Style.EXCEPTION);
- }
-
- public void testIgnoreDanglingSingleRef_dirtyToTransient() throws CommitException
- {
- simpleModel4SingleBidiSetup();
-
- SingleNonContainedElement singleNonContainedElement3 = model4Factory.eINSTANCE.createSingleNonContainedElement();
- refSingleNonContained2.setElement(singleNonContainedElement3);
-
- tx.setCommittables(createSet(refSingleNonContained2));
- good(Style.EXCEPTION);
- }
-
- public void testIgnoreDanglingSingleRef_dirtyToTransient2() throws CommitException
- {
- simpleModel4SingleBidiSetup();
-
- SingleNonContainedElement singleNonContainedElement3 = model4Factory.eINSTANCE.createSingleNonContainedElement();
- refSingleNonContained1.setElement(singleNonContainedElement3);
-
- tx.setCommittables(createSet(refSingleNonContained1, singleNonContainedElement1));
- good(Style.EXCEPTION);
- }
-
- /* --------- DANGLING REFERENCE PROBLEMS: Multi refs ---------- */
-
- public void testIgnoreDanglingMultiRef_newToDetached() throws CommitException
- {
- simpleModel4MultiBidiSetup();
-
- RefMultiNonContained refMultiNonContained3 = model4Factory.eINSTANCE.createRefMultiNonContained();
- resource1.getContents().add(refMultiNonContained3);
-
- EcoreUtil.delete(multiNonContainedElement2);
- refMultiNonContained3.getElements().add(multiNonContainedElement2);
-
- tx.setCommittables(createSet(refMultiNonContained3, multiNonContainedElement2, resource1));
- good(Style.EXCEPTION);
- }
-
- public void testIgnoreDanglingMultiRef_newToTransient() throws CommitException
- {
- simpleModel4SingleBidiSetup();
-
- RefMultiNonContained refMultiNonContained3 = model4Factory.eINSTANCE.createRefMultiNonContained();
- resource1.getContents().add(refMultiNonContained3);
-
- MultiNonContainedElement multiNonContainedElement3 = model4Factory.eINSTANCE.createMultiNonContainedElement();
- refMultiNonContained3.getElements().add(multiNonContainedElement3);
-
- tx.setCommittables(createSet(refMultiNonContained3, multiNonContainedElement3, resource1));
- good(Style.EXCEPTION);
- }
-
- public void testIgnoreDanglingMultiRef_dirtyToDetached() throws CommitException
- {
- simpleModel4MultiBidiSetup();
-
- EcoreUtil.delete(multiNonContainedElement2);
- refMultiNonContained2.getElements().add(multiNonContainedElement2);
-
- tx.setCommittables(createSet(refMultiNonContained2, multiNonContainedElement2, resource1));
- good(Style.EXCEPTION);
- }
-
- public void testIgnoreDanglingMultiRef_dirtyToTransient() throws CommitException
- {
- simpleModel4MultiBidiSetup();
-
- MultiNonContainedElement multiNonContainedElement3 = model4Factory.eINSTANCE.createMultiNonContainedElement();
- refMultiNonContained2.getElements().add(multiNonContainedElement3);
-
- tx.setCommittables(createSet(refMultiNonContained2, resource1));
- good(Style.EXCEPTION);
- }
-
- public void testIgnoreDanglingMultiRef_dirtyToTransient2() throws CommitException
- {
- simpleModel4MultiBidiSetup();
-
- MultiNonContainedElement multiNonContainedElement3 = model4Factory.eINSTANCE.createMultiNonContainedElement();
- refMultiNonContained1.getElements().add(multiNonContainedElement3);
-
- tx.setCommittables(createSet(refMultiNonContained1, multiNonContainedElement1));
- good(Style.EXCEPTION);
- }
-
- /* --------- END OF DANGLING REFERENCE PROBLEMS ---------- */
-
- public void testCheckWithoutCommit_exceptionFast() throws CommitException
- {
- simpleModel1Setup();
- PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
- company2.getPurchaseOrders().add(po);
-
- // Include only the new object
- tx.setCommittables(createSet(po));
- InternalCDOCommitContext ctx = tx.createCommitContext();
- try
- {
- new CommitIntegrityCheck(ctx, CommitIntegrityCheck.Style.EXCEPTION_FAST).check();
- }
- catch (CommitIntegrityException e)
- {
- // Good
- }
- }
-
- public void testCheckWithoutCommit_exception() throws CommitException
- {
- simpleModel1Setup();
- PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
- company2.getPurchaseOrders().add(po);
-
- // Include only the new object
- tx.setCommittables(createSet(po));
- InternalCDOCommitContext ctx = tx.createCommitContext();
- try
- {
- new CommitIntegrityCheck(ctx, CommitIntegrityCheck.Style.EXCEPTION_FAST).check();
- }
- catch (CommitIntegrityException e)
- {
- // Good
- }
- }
-
- public void testCommittablesContainUncommittableObjects()
- {
- // Idea here is to include some objects in the committables, that exist, but
- // are neither dirty nor detached nor new.
- //
- // Actually, one could wonder what the desirable behavior is in this case.
- // Should there be a failure? Or should the "committables" be considered more like
- // a filter; i.e. it's ok for the filter to cover more than what can actually be committed.
- // Hmm... *ponder* *ponder*.
- //
- }
-
- /**
- * Test the commit integrity, assuming that it is good, using all possible checking styles.
- */
- private void goodAll() throws CommitException
- {
- good(Style.NO_EXCEPTION);
- good(Style.EXCEPTION_FAST);
- good(Style.EXCEPTION);
- good(null);
- }
-
- /**
- * Test the commit integrity, assuming that it is good.
- *
- * @param style
- * - the checking style to be used; if null, just commit. In that case, the commit logic will choose the
- * checking style.
- */
- private void good(Style style) throws CommitException
- {
- if (style != null)
- {
- InternalCDOCommitContext ctx = tx.createCommitContext();
- CommitIntegrityCheck check = new CommitIntegrityCheck(ctx, style);
-
- try
- {
- check.check();
- assertEquals("check.getMissingObjects() should have been empty", true, check.getMissingObjects().isEmpty());
- }
- catch (CommitIntegrityException e)
- {
- fail("Should not have thrown " + CommitIntegrityException.class.getName());
- }
- }
- else
- {
- // We always make company99 dirty if it's present
- // (This is just a control object to verify that some stuff does NOT get
- // committed.)
- if (company99 != null)
- {
- company99.setName("000");
- }
-
- tx.commit();
-
- // And we verify that it didn't get included in the commit
- if (company99 != null)
- {
- assertDirty(company99, tx);
- assertEquals("Transaction should still have been dirty", true, tx.isDirty());
- }
- }
- }
-
- /**
- * Test the commit integrity, assuming that it is bad, using all possible checking styles.
- */
- private void badAll(Set<EObject> expectedMissingObjects) throws CommitException
- {
- bad(Style.NO_EXCEPTION, expectedMissingObjects);
- bad(Style.EXCEPTION_FAST, expectedMissingObjects);
- bad(Style.EXCEPTION, expectedMissingObjects);
- bad(null, expectedMissingObjects);
- }
-
- /**
- * Test the commit integrity, assuming that it is bad.
- *
- * @param style
- * - the checking style to be used; if null, just commit. In that case, the commit logic will choose the
- * checking style.
- */
- private void bad(Style style, Set<EObject> expectedMissingObjects) throws CommitException
- {
- CommitIntegrityException commitIntegrityEx = null;
- Set<? extends EObject> missingObjects = null;
-
- CommitIntegrityCheck check = null;
- if (style != null)
- {
- InternalCDOCommitContext ctx = tx.createCommitContext();
- check = new CommitIntegrityCheck(ctx, style);
- }
-
- if (style == Style.NO_EXCEPTION)
- {
- try
- {
- check.check();
- }
- catch (CommitIntegrityException e)
- {
- fail("Should not have thrown " + CommitIntegrityException.class.getName());
- }
- }
- else if (style == CommitIntegrityCheck.Style.EXCEPTION || style == CommitIntegrityCheck.Style.EXCEPTION_FAST)
- {
- try
- {
- check.check();
- fail("Should have thrown " + CommitIntegrityException.class.getName());
- }
- catch (CommitIntegrityException e)
- {
- commitIntegrityEx = e;
- }
- }
- else if (style == null)
- {
- try
- {
- tx.commit();
- fail("Should have thrown " + CommitException.class.getName());
- }
- catch (CommitException e)
- {
- Throwable cause = e.getCause().getCause();
- if (cause instanceof CommitIntegrityException)
- {
- // Good
- commitIntegrityEx = (CommitIntegrityException)cause;
- System.out.println("---> Failed properly: " + e.getCause().getMessage());
- }
- else
- {
- throw e;
- }
- }
- }
- else
- {
- fail("Unknown style");
- }
-
- if (commitIntegrityEx != null)
- {
- missingObjects = commitIntegrityEx.getMissingObjects();
- }
- else
- {
- missingObjects = check.getMissingObjects();
- }
-
- if (style == Style.EXCEPTION_FAST)
- {
- assertEquals(1, missingObjects.size());
- }
- else
- {
- // We cannot use == here, because it isn't (always) possible for the logic to
- // find all missing objects
- assertEquals(true, missingObjects.size() <= expectedMissingObjects.size());
- }
-
- for (EObject missingObject : missingObjects)
- {
- assertEquals(true, expectedMissingObjects.contains(missingObject));
- }
- }
-
- private void simpleModel1Setup() throws CommitException
- {
- EReference ref = Model1Package.eINSTANCE.getCompany_PurchaseOrders();
- boolean preconditions = ref.isContainment() && ref.getEOpposite() == null && ref.isMany();
- if (!preconditions)
- {
- throw new RuntimeException("Model1 does not meet prerequirements for this test");
- }
-
- resource1 = tx.createResource(getResourcePath(RESOURCENAME));
- company1 = Model1Factory.eINSTANCE.createCompany();
- company2 = Model1Factory.eINSTANCE.createCompany();
- company3 = Model1Factory.eINSTANCE.createCompany();
- company99 = Model1Factory.eINSTANCE.createCompany();
- supplier1 = Model1Factory.eINSTANCE.createSupplier();
- purchaseOrder = Model1Factory.eINSTANCE.createPurchaseOrder();
- company1.getPurchaseOrders().add(purchaseOrder);
- resource1.getContents().add(company1);
- resource1.getContents().add(company2);
- resource1.getContents().add(company3);
- resource1.getContents().add(company99);
- resource1.getContents().add(supplier1);
- tx.commit();
- }
-
- private void simpleModel4ContainmentSetup() throws CommitException
- {
- EReference ref = model4Package.eINSTANCE.getRefSingleContainedNPL_Element();
- boolean preconditions = ref.isContainment() && ref.getEOpposite() == null && !ref.isMany();
- if (!preconditions)
- {
- throw new RuntimeException("Model4 does not meet prerequirements for this test");
- }
-
- resource1 = tx.createResource(getResourcePath(RESOURCENAME));
-
- refSingleContained1 = model4Factory.eINSTANCE.createRefSingleContainedNPL();
- refSingleContained2 = model4Factory.eINSTANCE.createRefSingleContainedNPL();
- singleContainedElement1 = model4Factory.eINSTANCE.createContainedElementNoOpposite();
- refSingleContained1.setElement(singleContainedElement1);
- resource1.getContents().add(refSingleContained1);
- resource1.getContents().add(refSingleContained2);
-
- tx.commit();
- }
-
- private void simpleModel4SingleBidiSetup() throws CommitException
- {
- EReference ref = model4Package.eINSTANCE.getRefSingleNonContained_Element();
- boolean preconditions = !ref.isContainment() && ref.getEOpposite() != null && !ref.isMany();
- if (!preconditions)
- {
- throw new RuntimeException("Model4 does not meet prerequirements for this test");
- }
-
- resource1 = tx.createResource(getResourcePath(RESOURCENAME));
-
- refSingleNonContained1 = model4Factory.eINSTANCE.createRefSingleNonContained();
- refSingleNonContained2 = model4Factory.eINSTANCE.createRefSingleNonContained();
- singleNonContainedElement1 = model4Factory.eINSTANCE.createSingleNonContainedElement();
- singleNonContainedElement2 = model4Factory.eINSTANCE.createSingleNonContainedElement();
- refSingleNonContained1.setElement(singleNonContainedElement1);
- resource1.getContents().add(refSingleNonContained1);
- resource1.getContents().add(refSingleNonContained2);
- resource1.getContents().add(singleNonContainedElement1);
- resource1.getContents().add(singleNonContainedElement2);
-
- tx.commit();
- }
-
- private void simpleModel4MultiBidiSetup() throws CommitException
- {
- EReference ref = model4Package.eINSTANCE.getRefMultiNonContained_Elements();
- boolean preconditions = !ref.isContainment() && ref.getEOpposite() != null && ref.isMany();
- if (!preconditions)
- {
- throw new RuntimeException("Model4 does not meet prerequirements for this test");
- }
-
- resource1 = tx.createResource(getResourcePath(RESOURCENAME));
-
- refMultiNonContained1 = model4Factory.eINSTANCE.createRefMultiNonContained();
- refMultiNonContained2 = model4Factory.eINSTANCE.createRefMultiNonContained();
- multiNonContainedElement1 = model4Factory.eINSTANCE.createMultiNonContainedElement();
- multiNonContainedElement2 = model4Factory.eINSTANCE.createMultiNonContainedElement();
- refMultiNonContained1.getElements().add(multiNonContainedElement1);
- resource1.getContents().add(refMultiNonContained1);
- resource1.getContents().add(refMultiNonContained2);
- resource1.getContents().add(multiNonContainedElement1);
- resource1.getContents().add(multiNonContainedElement2);
-
- tx.commit();
- }
-
- private Set<EObject> createSet(EObject... objects)
- {
- Set<EObject> committables = new HashSet<EObject>();
- for (EObject o : objects)
- {
- if (o == null)
- {
- throw new NullPointerException();
- }
- committables.add(o);
- }
- return committables;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.legacy.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.legacy.model4.model4Package;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.MultiNonContainedElement;
+import org.eclipse.emf.cdo.tests.model4.RefMultiNonContained;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefSingleNonContained;
+import org.eclipse.emf.cdo.tests.model4.SingleNonContainedElement;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.CommitIntegrityException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.internal.cdo.util.CommitIntegrityCheck;
+import org.eclipse.emf.internal.cdo.util.CommitIntegrityCheck.Style;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class PartialCommitTest extends AbstractCDOTest
+{
+ private static String RESOURCENAME = "/r1";
+
+ private CDOSession session;
+
+ private InternalCDOTransaction tx;
+
+ private CDOResource resource1;
+
+ /* ---- Model 1 stuff ---- */
+
+ private Company company1, company2, company3, company99;
+
+ private PurchaseOrder purchaseOrder;
+
+ private Supplier supplier1;
+
+ /* ---- Model 4 stuff ---- */
+
+ private RefSingleContainedNPL refSingleContained1, refSingleContained2;
+
+ private ContainedElementNoOpposite singleContainedElement1;
+
+ private RefSingleNonContained refSingleNonContained1, refSingleNonContained2;
+
+ private SingleNonContainedElement singleNonContainedElement1, singleNonContainedElement2;
+
+ private RefMultiNonContained refMultiNonContained1, refMultiNonContained2;
+
+ private MultiNonContainedElement multiNonContainedElement1, multiNonContainedElement2;
+
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+
+ session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ tx = (InternalCDOTransaction)session.openTransaction();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ tx.close();
+ session.close();
+ super.doTearDown();
+ }
+
+ @CleanRepositoriesBefore
+ public void testNewTopLevelResource() throws CommitException
+ {
+ CDOResource topResource1 = tx.createResource("/top1");
+ tx.commit();
+
+ topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
+ CDOResource topResource2 = tx.createResource("/top2");
+ tx.setCommittables(createSet(topResource2, tx.getRootResource()));
+ goodAll();
+ }
+
+ @CleanRepositoriesBefore
+ public void testNewTopLevelResource_rootResourceNotIncluded() throws CommitException
+ {
+ CDOResource topResource1 = tx.createResource("/top1");
+ tx.commit();
+
+ topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
+ CDOResource topResource2 = tx.createResource("/top2");
+ tx.setCommittables(createSet(topResource2));
+ badAll(createSet(tx.getRootResource()));
+ }
+
+ @CleanRepositoriesBefore
+ public void testNewNestedResource() throws CommitException
+ {
+ CDOResource topResource1 = tx.createResource("/top1");
+ tx.commit();
+
+ topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
+ CDOResource nestedResource = tx.createResource("/folder/nested");
+ tx.setCommittables(createSet(nestedResource, nestedResource.getFolder(), tx.getRootResource()));
+ goodAll();
+ }
+
+ @CleanRepositoriesBefore
+ public void testNewNestedResource_rootResourceNotIncluded() throws CommitException
+ {
+ CDOResource topResource1 = tx.createResource("/top1");
+ tx.commit();
+
+ topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
+ CDOResource nestedResource = tx.createResource("/folder/nested");
+ tx.setCommittables(createSet(nestedResource, nestedResource.getFolder()));
+ badAll(createSet(tx.getRootResource()));
+ }
+
+ @CleanRepositoriesBefore
+ public void testNewNestedResource_resourceFolderNotIncluded() throws CommitException
+ {
+ CDOResource topResource1 = tx.createResource("/top1");
+ tx.commit();
+
+ topResource1.setName("top1_newname"); // Make dirty but don't include; this causes partial commit
+ CDOResource nestedResource = tx.createResource("/folder/nested");
+ tx.setCommittables(createSet(nestedResource, tx.getRootResource()));
+ badAll(createSet(nestedResource.getFolder()));
+ }
+
+ public void testPartialCleanUp_dirtyObjects() throws CommitException
+ {
+ simpleModel1Setup();
+
+ company1.setName("Company1");
+ company2.setName("Company2");
+ company3.setName("Company3");
+
+ tx.setCommittables(createSet(company1));
+ tx.commit();
+
+ assertClean(company1, tx);
+ assertDirty(company2, tx);
+ assertDirty(company3, tx);
+ assertEquals(true, tx.isDirty());
+
+ tx.setCommittables(createSet(company2));
+ tx.commit();
+
+ assertClean(company1, tx);
+ assertClean(company2, tx);
+ assertDirty(company3, tx);
+ assertEquals(true, tx.isDirty());
+
+ tx.setCommittables(createSet(company3));
+ tx.commit();
+
+ assertClean(company1, tx);
+ assertClean(company2, tx);
+ assertClean(company3, tx);
+ assertEquals(false, tx.isDirty());
+ }
+
+ public void testPartialCleanUp_newObjects() throws CommitException
+ {
+ simpleModel1Setup();
+ Category cat = Model1Factory.eINSTANCE.createCategory();
+ resource1.getContents().add(cat);
+ tx.commit();
+
+ company1.setName("Zzz"); // Make dirty but don't include; so as to force partial commit
+
+ // Make some new objects; but with different containers
+ Company company4 = Model1Factory.eINSTANCE.createCompany();
+ resource1.getContents().add(company4);
+ PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
+ company2.getPurchaseOrders().add(po);
+ Product1 product = Model1Factory.eINSTANCE.createProduct1();
+ product.setName("product1");
+ cat.getProducts().add(product);
+
+ tx.setCommittables(createSet(company4, resource1));
+ tx.commit();
+
+ assertClean(company4, tx);
+ assertNew(po, tx);
+ assertNew(product, tx);
+ assertEquals(true, tx.isDirty());
+
+ tx.setCommittables(createSet(po, company2));
+ tx.commit();
+
+ assertClean(company4, tx);
+ assertClean(po, tx);
+ assertNew(product, tx);
+ assertEquals(true, tx.isDirty());
+
+ tx.setCommittables(createSet(product, cat));
+ tx.commit();
+
+ assertClean(company4, tx);
+ assertClean(po, tx);
+ assertClean(product, tx);
+ assertEquals(true, tx.isDirty());
+
+ tx.setCommittables(createSet(company1));
+ tx.commit();
+ assertEquals(false, tx.isDirty());
+ }
+
+ public void testPartialCleanUp_detachedObjects() throws CommitException
+ {
+ skipStoreWithoutQueryXRefs();
+
+ simpleModel1Setup();
+ Category cat = Model1Factory.eINSTANCE.createCategory();
+ resource1.getContents().add(cat);
+
+ // Make some new objects; but with different containers
+ Company company4 = Model1Factory.eINSTANCE.createCompany();
+ resource1.getContents().add(company4);
+ PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
+ company2.getPurchaseOrders().add(po);
+ Product1 product = Model1Factory.eINSTANCE.createProduct1();
+ product.setName("product1");
+ cat.getProducts().add(product);
+ tx.commit();
+
+ company1.setName("Zzz"); // Make dirty but don't include; so as to force partial commit
+
+ resource1.getContents().remove(company4);
+ company2.getPurchaseOrders().remove(po);
+ cat.getProducts().remove(product);
+
+ assertEquals(true, tx.getDetachedObjects().containsValue(company4));
+ assertEquals(true, tx.getCleanRevisions().containsKey(company4));
+ assertEquals(true, tx.getDetachedObjects().containsValue(po));
+ assertEquals(true, tx.getCleanRevisions().containsKey(company4));
+ assertEquals(true, tx.getDetachedObjects().containsValue(product));
+ assertEquals(true, tx.getCleanRevisions().containsKey(company4));
+ assertEquals(true, tx.isDirty());
+
+ tx.setCommittables(createSet(company4, resource1));
+ tx.commit();
+
+ assertEquals(false, tx.getDetachedObjects().containsValue(company4));
+ assertEquals(false, tx.getCleanRevisions().containsKey(company4));
+ assertEquals(true, tx.getDetachedObjects().containsValue(po));
+ assertEquals(true, tx.getCleanRevisions().containsKey(po));
+ assertEquals(true, tx.getDetachedObjects().containsValue(product));
+ assertEquals(true, tx.getCleanRevisions().containsKey(product));
+ assertEquals(true, tx.isDirty());
+
+ tx.setCommittables(createSet(po, company2));
+ tx.commit();
+
+ assertEquals(false, tx.getDetachedObjects().containsValue(company4));
+ assertEquals(false, tx.getCleanRevisions().containsKey(company4));
+ assertEquals(false, tx.getDetachedObjects().containsValue(po));
+ assertEquals(false, tx.getCleanRevisions().containsKey(po));
+ assertEquals(true, tx.getDetachedObjects().containsValue(product));
+ assertEquals(true, tx.getCleanRevisions().containsKey(product));
+ assertEquals(true, tx.isDirty());
+
+ tx.setCommittables(createSet(product, cat));
+ tx.commit();
+
+ assertEquals(false, tx.getDetachedObjects().containsValue(company4));
+ assertEquals(false, tx.getCleanRevisions().containsKey(company4));
+ assertEquals(false, tx.getDetachedObjects().containsValue(po));
+ assertEquals(false, tx.getCleanRevisions().containsKey(po));
+ assertEquals(false, tx.getDetachedObjects().containsValue(product));
+ assertEquals(false, tx.getCleanRevisions().containsKey(product));
+ assertEquals(true, tx.isDirty());
+
+ tx.setCommittables(createSet(company1));
+ tx.commit();
+ assertEquals(false, tx.isDirty());
+ }
+
+ public void testDirty() throws CommitException
+ {
+ simpleModel1Setup();
+ supplier1.setName("Supplier");
+ company1.setName("Company");
+
+ tx.setCommittables(createSet(supplier1));
+ tx.commit();
+
+ assertDirty(company1, tx);
+ assertEquals(company1.getName(), "Company");
+
+ assertClean(supplier1, tx);
+ assertEquals(supplier1.getName(), "Supplier");
+ }
+
+ public void testNew() throws CommitException
+ {
+ simpleModel1Setup();
+ PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
+ company2.getPurchaseOrders().add(po);
+
+ // Include both the new object and its container
+ tx.setCommittables(createSet(company2, po));
+ goodAll();
+ }
+
+ public void testNew_containerOfNewObjectNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
+ company2.getPurchaseOrders().add(po);
+
+ // Include only the new object
+ tx.setCommittables(createSet(po));
+ badAll(createSet(company2));
+ }
+
+ public void testNew_newObjectNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
+ company2.getPurchaseOrders().add(po);
+
+ // Include only the new object's container
+ tx.setCommittables(createSet(company2));
+ badAll(createSet(po));
+ }
+
+ @CleanRepositoriesBefore
+ public void testDetach() throws CommitException
+ {
+ skipStoreWithoutQueryXRefs();
+
+ simpleModel1Setup();
+ EcoreUtil.delete(purchaseOrder);
+
+ // Include the detached object and its old container
+ tx.setCommittables(createSet(company1, purchaseOrder));
+ goodAll();
+ }
+
+ public void testDetach_containerOfDetachedObjectNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ EcoreUtil.delete(purchaseOrder);
+
+ // Include only the detached object
+ tx.setCommittables(createSet(purchaseOrder));
+ badAll(createSet(company1));
+ }
+
+ public void testDetach_detachedObjectNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ EcoreUtil.delete(purchaseOrder);
+
+ // Include only the detached object's old container
+ tx.setCommittables(createSet(company1));
+ badAll(createSet(purchaseOrder));
+ }
+
+ public void testMove() throws CommitException
+ {
+ simpleModel1Setup();
+ company2.getPurchaseOrders().add(purchaseOrder);
+ supplier1.setName("Supplier");
+
+ // Include the old and new containers as well as the object that was moved
+ tx.setCommittables(createSet(purchaseOrder, company1, company2));
+ goodAll();
+
+ assertClean(company1, tx);
+ assertClean(company2, tx);
+ assertClean(purchaseOrder, tx);
+ assertDirty(supplier1, tx);
+
+ assertEquals(false, company1.getPurchaseOrders().contains(purchaseOrder));
+ assertEquals(true, company2.getPurchaseOrders().contains(purchaseOrder));
+ assertEquals("Supplier", supplier1.getName());
+ assertSame(company2, purchaseOrder.eContainer());
+ }
+
+ public void testMove_newContainerNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ company2.getPurchaseOrders().add(purchaseOrder);
+
+ // Include only the object that was moved and its old container
+ tx.setCommittables(createSet(purchaseOrder, company1));
+ badAll(createSet(company2));
+ }
+
+ public void testMove_oldContainerNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ company2.getPurchaseOrders().add(purchaseOrder);
+
+ // Include only the object that was moved and its new container
+ tx.setCommittables(createSet(purchaseOrder, company2));
+ badAll(createSet(company1));
+ }
+
+ public void testMove_movedObjectNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ company2.getPurchaseOrders().add(purchaseOrder);
+
+ // Include only the old and new containers
+ tx.setCommittables(createSet(company1, company2));
+ badAll(createSet(purchaseOrder));
+ }
+
+ public void testMove_onlyOldContainerIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ company2.getPurchaseOrders().add(purchaseOrder);
+
+ // Include only the old container
+ tx.setCommittables(createSet(company1));
+ badAll(createSet(company2, purchaseOrder));
+ }
+
+ public void testMove_onlyNewContainerIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ company2.getPurchaseOrders().add(purchaseOrder);
+
+ // Include only the new container
+ tx.setCommittables(createSet(company2));
+ badAll(createSet(company1, purchaseOrder));
+ }
+
+ public void testMove_onlyMovedObjectIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ company2.getPurchaseOrders().add(purchaseOrder);
+
+ // Include only the moved object
+ tx.setCommittables(createSet(purchaseOrder));
+ badAll(createSet(company1, company2));
+ }
+
+ public void testDoubleMove() throws CommitException
+ {
+ simpleModel1Setup();
+ company2.getPurchaseOrders().add(purchaseOrder);
+ company3.getPurchaseOrders().add(purchaseOrder);
+
+ // Include the old and new containers as well as the object that was moved
+ // (The point here is that company2 does NOT have to be included.)
+ tx.setCommittables(createSet(purchaseOrder, company1, company3));
+ System.out.printf("---> purchaseOrder=%s company1=%s company2=%s company3=%s\n", purchaseOrder, company1, company2,
+ company3);
+ goodAll();
+ }
+
+ public void test_noCommittablesAfterCommit() throws CommitException
+ {
+ simpleModel1Setup();
+ company1.setName("zzz");
+ tx.setCommittables(createSet(company1));
+ tx.commit();
+
+ assertNull(tx.getCommittables());
+ }
+
+ public void testNewSingle() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ ContainedElementNoOpposite singleContainedElement = model4Factory.eINSTANCE.createContainedElementNoOpposite();
+ refSingleContained2.setElement(singleContainedElement);
+
+ // Include both the new object and its container
+ tx.setCommittables(createSet(refSingleContained2, singleContainedElement));
+ goodAll();
+ }
+
+ public void testNewSingle_containerOfNewObjectNotIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ ContainedElementNoOpposite singleContainedElement = model4Factory.eINSTANCE.createContainedElementNoOpposite();
+ refSingleContained2.setElement(singleContainedElement);
+
+ // Include only the new object
+ tx.setCommittables(createSet(singleContainedElement));
+ badAll(createSet(refSingleContained2));
+ }
+
+ public void testNewSingle_newObjectNotIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ ContainedElementNoOpposite singleContainedElement = model4Factory.eINSTANCE.createContainedElementNoOpposite();
+ refSingleContained2.setElement(singleContainedElement);
+
+ // Include only the new object's container
+ tx.setCommittables(createSet(refSingleContained2));
+ badAll(createSet(singleContainedElement));
+ }
+
+ public void testDetachSingleRef() throws CommitException
+ {
+ skipStoreWithoutQueryXRefs();
+
+ simpleModel4ContainmentSetup();
+ refSingleContained1.setElement(null);
+
+ // Include the detached object and its old container
+ tx.setCommittables(createSet(refSingleContained1, singleContainedElement1));
+ goodAll();
+ }
+
+ public void testDetachSingleRef_containerOfDetachedObjectNotIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ refSingleContained1.setElement(null);
+
+ // Include only the detached object
+ tx.setCommittables(createSet(singleContainedElement1));
+ badAll(createSet(refSingleContained1));
+ }
+
+ public void testDetachSingleRef_detachedObjectNotIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ refSingleContained1.setElement(null);
+
+ // Include only the detached object's old container
+ tx.setCommittables(createSet(refSingleContained1));
+ badAll(createSet(singleContainedElement1));
+ }
+
+ public void testMoveSingleRef() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ refSingleContained2.setElement(singleContainedElement1);
+
+ // Include the old and new containers as well as the object that was moved
+ tx.setCommittables(createSet(refSingleContained1, refSingleContained2, singleContainedElement1));
+ goodAll();
+ }
+
+ public void testMoveSingleRef_newContainerNotIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ refSingleContained2.setElement(singleContainedElement1);
+
+ // Include only the object that was moved and its old container
+ tx.setCommittables(createSet(refSingleContained1, singleContainedElement1));
+ badAll(createSet(refSingleContained2));
+ }
+
+ public void testMoveSingleRef_oldContainerNotIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ refSingleContained2.setElement(singleContainedElement1);
+
+ // Include only the object that was moved and its new container
+ tx.setCommittables(createSet(refSingleContained2, singleContainedElement1));
+ badAll(createSet(refSingleContained1));
+ }
+
+ public void testMoveSingleRef_movedObjectNotIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ refSingleContained2.setElement(singleContainedElement1);
+
+ // Include only the old and new containers
+ tx.setCommittables(createSet(refSingleContained1, refSingleContained2));
+ badAll(createSet(singleContainedElement1));
+ }
+
+ public void testMoveSingleRef_onlyOldContainerIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ refSingleContained2.setElement(singleContainedElement1);
+
+ // Include only the old container
+ tx.setCommittables(createSet(refSingleContained1));
+ badAll(createSet(singleContainedElement1, refSingleContained2));
+ }
+
+ public void testMoveSingleRef_onlyNewContainerIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ refSingleContained2.setElement(singleContainedElement1);
+
+ // Include only the new container
+ tx.setCommittables(createSet(refSingleContained2));
+ badAll(createSet(singleContainedElement1, refSingleContained1));
+ }
+
+ public void testMoveSingleRef_onlyMovedObjectIncluded() throws CommitException
+ {
+ simpleModel4ContainmentSetup();
+ refSingleContained2.setElement(singleContainedElement1);
+
+ // Include only the moved object
+ tx.setCommittables(createSet(singleContainedElement1));
+ badAll(createSet(refSingleContained1, refSingleContained2));
+ }
+
+ public void testNewTopLevel() throws CommitException
+ {
+ simpleModel1Setup();
+ Company company = Model1Factory.eINSTANCE.createCompany();
+ resource1.getContents().add(company);
+
+ // Include both the resource and the new object
+ tx.setCommittables(createSet(resource1, company));
+ goodAll();
+ }
+
+ public void testNewTopLevel_newObjectNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ Company company = Model1Factory.eINSTANCE.createCompany();
+ resource1.getContents().add(company);
+
+ // Include only the resource
+ tx.setCommittables(createSet(resource1));
+ badAll(createSet(company));
+ }
+
+ public void testNewTopLevel_resourceNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+ Company company = Model1Factory.eINSTANCE.createCompany();
+ resource1.getContents().add(company);
+
+ // Include only the new object
+ tx.setCommittables(createSet(company));
+ badAll(createSet(resource1));
+ }
+
+ public void _testNewTopLevel_resourceNotIncluded() throws CommitException
+ {
+ simpleModel1Setup();
+
+ CDOID companyID = null;
+ {
+ Company company = Model1Factory.eINSTANCE.createCompany();
+ resource1.getContents().add(company);
+
+ // Include only the new object
+ tx.setCommittables(createSet(company));
+ tx.commit();
+
+ companyID = CDOUtil.getCDOObject(company).cdoID();
+ }
+
+ System.out.println("---> companyID = " + companyID);
+ System.out.println("---> " + CDOUtil.getCDOObject(resource1).cdoState());
+
+ {
+ CDOSession session2 = openSession();
+ CDOView view = session2.openView();
+ CDOResource resource = view.getResource(getResourcePath(resource1.getPath()));
+
+ // We want to know if the new company that was committed, is an element
+ // in the getContents() collection of the Resource. We cannot just call
+ // getContents().contains(), because of the odd implementation of
+ // CDOResourceImpl.contains: it actually asks the element, rather than
+ // checking its own collection. So, we have to do this the hard way:
+ //
+ boolean found = false;
+ Iterator<EObject> iter = resource.getContents().iterator();
+ while (!found && iter.hasNext())
+ {
+ CDOObject o = CDOUtil.getCDOObject(iter.next());
+ if (o.cdoID().equals(companyID))
+ {
+ found = true;
+ }
+ }
+ assertEquals(true, found);
+
+ view.close();
+ session2.close();
+ }
+ }
+
+ // -------- Tests concerning bi-di references ----------
+ //
+ // Cases to test:
+ // Bi-di refs are analogous to containment, the only difference being that
+ // bi-di refs are symmetrical, whereas containment/container is not.
+ //
+ // So:
+ //
+ // For DIRTY objects, the cases are:
+ // 1. Setting a bidi ref to null where it was previously non-null
+ // Must check that object owning opposite feature is included
+ // 2. Setting a bidi ref to non-null where it was previously null
+ // Must check that object owning opposite feature is included
+ // 3. Changing a bidi ref from one non-null value to another
+ // Must check that both the object owning the NEW opposite feature,
+ // as well as the OLD one, are included
+ //
+ // For NEW objects, the
+ // If the detached object had any non-null bidi refs, we must check
+ // whether the bidi target is included.
+ //
+ // For DETACHED objects:
+ // If the detached object had any non-null bidi refs, we must check
+ // whether the bidi target is included.
+
+ public void testDirtySingleBidiNew() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ singleNonContainedElement2.setParent(refSingleNonContained2);
+
+ tx.setCommittables(createSet(singleNonContainedElement2, refSingleNonContained2));
+ goodAll();
+ }
+
+ public void testDirtySingleBidiNew_newtargetNotIncluded() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ singleNonContainedElement2.setParent(refSingleNonContained2);
+
+ tx.setCommittables(createSet(singleNonContainedElement2));
+ badAll(createSet(refSingleNonContained2));
+ }
+
+ public void testDirtySingleBidiChanged() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ // We "reparent" the singleNonContainedElement1
+ singleNonContainedElement1.setParent(refSingleNonContained2);
+
+ tx.setCommittables(createSet(singleNonContainedElement1, refSingleNonContained1, refSingleNonContained2));
+ goodAll();
+ }
+
+ public void testDirtySingleBidiChanged_newTargetNotIncluded() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ // We "reparent" the singleNonContainedElement1
+ singleNonContainedElement1.setParent(refSingleNonContained2);
+
+ tx.setCommittables(createSet(singleNonContainedElement1, refSingleNonContained1));
+ badAll(createSet(refSingleNonContained2));
+ }
+
+ public void testDirtySingleBidiChanged_oldTargetNotIncluded() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ // We "reparent" the singleNonContainedElement1
+ singleNonContainedElement1.setParent(refSingleNonContained2);
+
+ tx.setCommittables(createSet(singleNonContainedElement1, refSingleNonContained2));
+ badAll(createSet(refSingleNonContained1));
+ }
+
+ public void testDirtySingleBidiRemoved() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ singleNonContainedElement1.setParent(null);
+
+ tx.setCommittables(createSet(singleNonContainedElement1, refSingleNonContained1));
+ goodAll();
+ }
+
+ public void testDirtySingleBidiRemoved_oldTargetNotIncluded() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ singleNonContainedElement1.setParent(null);
+
+ tx.setCommittables(createSet(singleNonContainedElement1));
+ badAll(createSet(refSingleNonContained1));
+ }
+
+ public void testSingleBidiOnNewObject() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ SingleNonContainedElement newNonContainedElement = model4Factory.eINSTANCE.createSingleNonContainedElement();
+ resource1.getContents().add(newNonContainedElement);
+ newNonContainedElement.setParent(refSingleNonContained2);
+
+ tx.setCommittables(createSet(newNonContainedElement, resource1, refSingleNonContained2));
+ goodAll();
+ }
+
+ public void testSingleBidiOnNewObject_targetNotIncluded() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ SingleNonContainedElement newNonContainedElement = model4Factory.eINSTANCE.createSingleNonContainedElement();
+ resource1.getContents().add(newNonContainedElement);
+ newNonContainedElement.setParent(refSingleNonContained2);
+
+ tx.setCommittables(createSet(newNonContainedElement, resource1));
+ badAll(createSet(refSingleNonContained2));
+ }
+
+ public void testSingleBidiOnRemovedObject() throws CommitException
+ {
+ skipStoreWithoutQueryXRefs();
+
+ simpleModel4SingleBidiSetup();
+ EcoreUtil.delete(singleNonContainedElement1);
+
+ tx.setCommittables(createSet(singleNonContainedElement1, resource1, refSingleNonContained1));
+ goodAll();
+ }
+
+ public void testSingleBidiOnRemovedObject_targetNotIncluded() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+ EcoreUtil.delete(singleNonContainedElement1);
+
+ tx.setCommittables(createSet(singleNonContainedElement1, resource1));
+ badAll(createSet(refSingleNonContained1));
+ }
+
+ public void testDirtyMultiBidiNew() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ multiNonContainedElement2.setParent(refMultiNonContained2);
+
+ tx.setCommittables(createSet(multiNonContainedElement2, refMultiNonContained2));
+ goodAll();
+ }
+
+ public void testDirtyMultiBidiNew_newtargetNotIncluded() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ multiNonContainedElement2.setParent(refMultiNonContained2);
+
+ tx.setCommittables(createSet(multiNonContainedElement2));
+ badAll(createSet(refMultiNonContained2));
+ }
+
+ public void testDirtyMultiBidiChanged() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ // We "reparent" the multiNonContainedElement1
+ multiNonContainedElement1.setParent(refMultiNonContained2);
+
+ tx.setCommittables(createSet(multiNonContainedElement1, refMultiNonContained1, refMultiNonContained2));
+ goodAll();
+ }
+
+ public void testDirtyMultiBidiChanged_newTargetNotIncluded() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ // We "reparent" the multiNonContainedElement1
+ multiNonContainedElement1.setParent(refMultiNonContained2);
+
+ tx.setCommittables(createSet(multiNonContainedElement1, refMultiNonContained1));
+ badAll(createSet(refMultiNonContained2));
+ }
+
+ public void testDirtyMultiBidiChanged_oldTargetNotIncluded() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ // We "reparent" the multiNonContainedElement1
+ multiNonContainedElement1.setParent(refMultiNonContained2);
+
+ tx.setCommittables(createSet(multiNonContainedElement1, refMultiNonContained2));
+ badAll(createSet(refMultiNonContained1));
+ }
+
+ public void testDirtyMultiBidiRemoved() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ multiNonContainedElement1.setParent(null);
+
+ tx.setCommittables(createSet(multiNonContainedElement1, refMultiNonContained1));
+ goodAll();
+ }
+
+ public void testDirtyMultiBidiRemoved_oldTargetNotIncluded() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ multiNonContainedElement1.setParent(null);
+
+ tx.setCommittables(createSet(multiNonContainedElement1));
+ badAll(createSet(refMultiNonContained1));
+ }
+
+ public void testMultiBidiOnNewObject() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ MultiNonContainedElement newNonContainedElement = model4Factory.eINSTANCE.createMultiNonContainedElement();
+ resource1.getContents().add(newNonContainedElement);
+ newNonContainedElement.setParent(refMultiNonContained2);
+
+ tx.setCommittables(createSet(newNonContainedElement, resource1, refMultiNonContained2));
+ goodAll();
+ }
+
+ public void testMultiBidiOnNewObject_targetNotIncluded() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ MultiNonContainedElement newNonContainedElement = model4Factory.eINSTANCE.createMultiNonContainedElement();
+ resource1.getContents().add(newNonContainedElement);
+ newNonContainedElement.setParent(refMultiNonContained2);
+
+ tx.setCommittables(createSet(newNonContainedElement, resource1));
+ badAll(createSet(refMultiNonContained2));
+ }
+
+ public void testMultiBidiOnRemovedObject() throws CommitException
+ {
+ skipStoreWithoutQueryXRefs();
+
+ simpleModel4MultiBidiSetup();
+ EcoreUtil.delete(multiNonContainedElement1);
+
+ tx.setCommittables(createSet(multiNonContainedElement1, resource1, refMultiNonContained1));
+ goodAll();
+ }
+
+ public void testMultiBidiOnRemovedObject_targetNotIncluded() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+ EcoreUtil.delete(multiNonContainedElement1);
+
+ tx.setCommittables(createSet(multiNonContainedElement1, resource1));
+ badAll(createSet(refMultiNonContained1));
+ }
+
+ /* --------- DANGLING REFERENCE PROBLEMS: Single refs ---------- */
+
+ public void testIgnoreDanglingSingleRef_newToDetached() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+
+ RefSingleNonContained refSingleNonContained3 = model4Factory.eINSTANCE.createRefSingleNonContained();
+ resource1.getContents().add(refSingleNonContained3);
+
+ EcoreUtil.delete(singleNonContainedElement2);
+ refSingleNonContained3.setElement(singleNonContainedElement2);
+
+ tx.setCommittables(createSet(refSingleNonContained3, singleNonContainedElement2, resource1));
+ good(Style.EXCEPTION);
+ }
+
+ public void testIgnoreDanglingSingleRef_newToTransient() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+
+ RefSingleNonContained refSingleNonContained3 = model4Factory.eINSTANCE.createRefSingleNonContained();
+ resource1.getContents().add(refSingleNonContained3);
+
+ SingleNonContainedElement singleNonContainedElement3 = model4Factory.eINSTANCE.createSingleNonContainedElement();
+ refSingleNonContained3.setElement(singleNonContainedElement3);
+
+ tx.setCommittables(createSet(refSingleNonContained3, singleNonContainedElement3, resource1));
+ good(Style.EXCEPTION);
+ }
+
+ public void testIgnoreDanglingSingleRef_dirtyToDetached() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+
+ EcoreUtil.delete(singleNonContainedElement2);
+ refSingleNonContained2.setElement(singleNonContainedElement2);
+
+ tx.setCommittables(createSet(refSingleNonContained2, singleNonContainedElement2, resource1));
+ good(Style.EXCEPTION);
+ }
+
+ public void testIgnoreDanglingSingleRef_dirtyToTransient() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+
+ SingleNonContainedElement singleNonContainedElement3 = model4Factory.eINSTANCE.createSingleNonContainedElement();
+ refSingleNonContained2.setElement(singleNonContainedElement3);
+
+ tx.setCommittables(createSet(refSingleNonContained2));
+ good(Style.EXCEPTION);
+ }
+
+ public void testIgnoreDanglingSingleRef_dirtyToTransient2() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+
+ SingleNonContainedElement singleNonContainedElement3 = model4Factory.eINSTANCE.createSingleNonContainedElement();
+ refSingleNonContained1.setElement(singleNonContainedElement3);
+
+ tx.setCommittables(createSet(refSingleNonContained1, singleNonContainedElement1));
+ good(Style.EXCEPTION);
+ }
+
+ /* --------- DANGLING REFERENCE PROBLEMS: Multi refs ---------- */
+
+ public void testIgnoreDanglingMultiRef_newToDetached() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+
+ RefMultiNonContained refMultiNonContained3 = model4Factory.eINSTANCE.createRefMultiNonContained();
+ resource1.getContents().add(refMultiNonContained3);
+
+ EcoreUtil.delete(multiNonContainedElement2);
+ refMultiNonContained3.getElements().add(multiNonContainedElement2);
+
+ tx.setCommittables(createSet(refMultiNonContained3, multiNonContainedElement2, resource1));
+ good(Style.EXCEPTION);
+ }
+
+ public void testIgnoreDanglingMultiRef_newToTransient() throws CommitException
+ {
+ simpleModel4SingleBidiSetup();
+
+ RefMultiNonContained refMultiNonContained3 = model4Factory.eINSTANCE.createRefMultiNonContained();
+ resource1.getContents().add(refMultiNonContained3);
+
+ MultiNonContainedElement multiNonContainedElement3 = model4Factory.eINSTANCE.createMultiNonContainedElement();
+ refMultiNonContained3.getElements().add(multiNonContainedElement3);
+
+ tx.setCommittables(createSet(refMultiNonContained3, multiNonContainedElement3, resource1));
+ good(Style.EXCEPTION);
+ }
+
+ public void testIgnoreDanglingMultiRef_dirtyToDetached() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+
+ EcoreUtil.delete(multiNonContainedElement2);
+ refMultiNonContained2.getElements().add(multiNonContainedElement2);
+
+ tx.setCommittables(createSet(refMultiNonContained2, multiNonContainedElement2, resource1));
+ good(Style.EXCEPTION);
+ }
+
+ public void testIgnoreDanglingMultiRef_dirtyToTransient() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+
+ MultiNonContainedElement multiNonContainedElement3 = model4Factory.eINSTANCE.createMultiNonContainedElement();
+ refMultiNonContained2.getElements().add(multiNonContainedElement3);
+
+ tx.setCommittables(createSet(refMultiNonContained2, resource1));
+ good(Style.EXCEPTION);
+ }
+
+ public void testIgnoreDanglingMultiRef_dirtyToTransient2() throws CommitException
+ {
+ simpleModel4MultiBidiSetup();
+
+ MultiNonContainedElement multiNonContainedElement3 = model4Factory.eINSTANCE.createMultiNonContainedElement();
+ refMultiNonContained1.getElements().add(multiNonContainedElement3);
+
+ tx.setCommittables(createSet(refMultiNonContained1, multiNonContainedElement1));
+ good(Style.EXCEPTION);
+ }
+
+ /* --------- END OF DANGLING REFERENCE PROBLEMS ---------- */
+
+ public void testCheckWithoutCommit_exceptionFast() throws CommitException
+ {
+ simpleModel1Setup();
+ PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
+ company2.getPurchaseOrders().add(po);
+
+ // Include only the new object
+ tx.setCommittables(createSet(po));
+ InternalCDOCommitContext ctx = tx.createCommitContext();
+ try
+ {
+ new CommitIntegrityCheck(ctx, CommitIntegrityCheck.Style.EXCEPTION_FAST).check();
+ }
+ catch (CommitIntegrityException e)
+ {
+ // Good
+ }
+ }
+
+ public void testCheckWithoutCommit_exception() throws CommitException
+ {
+ simpleModel1Setup();
+ PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
+ company2.getPurchaseOrders().add(po);
+
+ // Include only the new object
+ tx.setCommittables(createSet(po));
+ InternalCDOCommitContext ctx = tx.createCommitContext();
+ try
+ {
+ new CommitIntegrityCheck(ctx, CommitIntegrityCheck.Style.EXCEPTION_FAST).check();
+ }
+ catch (CommitIntegrityException e)
+ {
+ // Good
+ }
+ }
+
+ public void testCommittablesContainUncommittableObjects()
+ {
+ // Idea here is to include some objects in the committables, that exist, but
+ // are neither dirty nor detached nor new.
+ //
+ // Actually, one could wonder what the desirable behavior is in this case.
+ // Should there be a failure? Or should the "committables" be considered more like
+ // a filter; i.e. it's ok for the filter to cover more than what can actually be committed.
+ // Hmm... *ponder* *ponder*.
+ //
+ }
+
+ /**
+ * Test the commit integrity, assuming that it is good, using all possible checking styles.
+ */
+ private void goodAll() throws CommitException
+ {
+ good(Style.NO_EXCEPTION);
+ good(Style.EXCEPTION_FAST);
+ good(Style.EXCEPTION);
+ good(null);
+ }
+
+ /**
+ * Test the commit integrity, assuming that it is good.
+ *
+ * @param style
+ * - the checking style to be used; if null, just commit. In that case, the commit logic will choose the
+ * checking style.
+ */
+ private void good(Style style) throws CommitException
+ {
+ if (style != null)
+ {
+ InternalCDOCommitContext ctx = tx.createCommitContext();
+ CommitIntegrityCheck check = new CommitIntegrityCheck(ctx, style);
+
+ try
+ {
+ check.check();
+ assertEquals("check.getMissingObjects() should have been empty", true, check.getMissingObjects().isEmpty());
+ }
+ catch (CommitIntegrityException e)
+ {
+ fail("Should not have thrown " + CommitIntegrityException.class.getName());
+ }
+ }
+ else
+ {
+ // We always make company99 dirty if it's present
+ // (This is just a control object to verify that some stuff does NOT get
+ // committed.)
+ if (company99 != null)
+ {
+ company99.setName("000");
+ }
+
+ tx.commit();
+
+ // And we verify that it didn't get included in the commit
+ if (company99 != null)
+ {
+ assertDirty(company99, tx);
+ assertEquals("Transaction should still have been dirty", true, tx.isDirty());
+ }
+ }
+ }
+
+ /**
+ * Test the commit integrity, assuming that it is bad, using all possible checking styles.
+ */
+ private void badAll(Set<EObject> expectedMissingObjects) throws CommitException
+ {
+ bad(Style.NO_EXCEPTION, expectedMissingObjects);
+ bad(Style.EXCEPTION_FAST, expectedMissingObjects);
+ bad(Style.EXCEPTION, expectedMissingObjects);
+ bad(null, expectedMissingObjects);
+ }
+
+ /**
+ * Test the commit integrity, assuming that it is bad.
+ *
+ * @param style
+ * - the checking style to be used; if null, just commit. In that case, the commit logic will choose the
+ * checking style.
+ */
+ private void bad(Style style, Set<EObject> expectedMissingObjects) throws CommitException
+ {
+ CommitIntegrityException commitIntegrityEx = null;
+ Set<? extends EObject> missingObjects = null;
+
+ CommitIntegrityCheck check = null;
+ if (style != null)
+ {
+ InternalCDOCommitContext ctx = tx.createCommitContext();
+ check = new CommitIntegrityCheck(ctx, style);
+ }
+
+ if (style == Style.NO_EXCEPTION)
+ {
+ try
+ {
+ check.check();
+ }
+ catch (CommitIntegrityException e)
+ {
+ fail("Should not have thrown " + CommitIntegrityException.class.getName());
+ }
+ }
+ else if (style == CommitIntegrityCheck.Style.EXCEPTION || style == CommitIntegrityCheck.Style.EXCEPTION_FAST)
+ {
+ try
+ {
+ check.check();
+ fail("Should have thrown " + CommitIntegrityException.class.getName());
+ }
+ catch (CommitIntegrityException e)
+ {
+ commitIntegrityEx = e;
+ }
+ }
+ else if (style == null)
+ {
+ try
+ {
+ tx.commit();
+ fail("Should have thrown " + CommitException.class.getName());
+ }
+ catch (CommitException e)
+ {
+ Throwable cause = e.getCause().getCause();
+ if (cause instanceof CommitIntegrityException)
+ {
+ // Good
+ commitIntegrityEx = (CommitIntegrityException)cause;
+ System.out.println("---> Failed properly: " + e.getCause().getMessage());
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+ else
+ {
+ fail("Unknown style");
+ }
+
+ if (commitIntegrityEx != null)
+ {
+ missingObjects = commitIntegrityEx.getMissingObjects();
+ }
+ else
+ {
+ missingObjects = check.getMissingObjects();
+ }
+
+ if (style == Style.EXCEPTION_FAST)
+ {
+ assertEquals(1, missingObjects.size());
+ }
+ else
+ {
+ // We cannot use == here, because it isn't (always) possible for the logic to
+ // find all missing objects
+ assertEquals(true, missingObjects.size() <= expectedMissingObjects.size());
+ }
+
+ for (EObject missingObject : missingObjects)
+ {
+ assertEquals(true, expectedMissingObjects.contains(missingObject));
+ }
+ }
+
+ private void simpleModel1Setup() throws CommitException
+ {
+ EReference ref = Model1Package.eINSTANCE.getCompany_PurchaseOrders();
+ boolean preconditions = ref.isContainment() && ref.getEOpposite() == null && ref.isMany();
+ if (!preconditions)
+ {
+ throw new RuntimeException("Model1 does not meet prerequirements for this test");
+ }
+
+ resource1 = tx.createResource(getResourcePath(RESOURCENAME));
+ company1 = Model1Factory.eINSTANCE.createCompany();
+ company2 = Model1Factory.eINSTANCE.createCompany();
+ company3 = Model1Factory.eINSTANCE.createCompany();
+ company99 = Model1Factory.eINSTANCE.createCompany();
+ supplier1 = Model1Factory.eINSTANCE.createSupplier();
+ purchaseOrder = Model1Factory.eINSTANCE.createPurchaseOrder();
+ company1.getPurchaseOrders().add(purchaseOrder);
+ resource1.getContents().add(company1);
+ resource1.getContents().add(company2);
+ resource1.getContents().add(company3);
+ resource1.getContents().add(company99);
+ resource1.getContents().add(supplier1);
+ tx.commit();
+ }
+
+ private void simpleModel4ContainmentSetup() throws CommitException
+ {
+ EReference ref = model4Package.eINSTANCE.getRefSingleContainedNPL_Element();
+ boolean preconditions = ref.isContainment() && ref.getEOpposite() == null && !ref.isMany();
+ if (!preconditions)
+ {
+ throw new RuntimeException("Model4 does not meet prerequirements for this test");
+ }
+
+ resource1 = tx.createResource(getResourcePath(RESOURCENAME));
+
+ refSingleContained1 = model4Factory.eINSTANCE.createRefSingleContainedNPL();
+ refSingleContained2 = model4Factory.eINSTANCE.createRefSingleContainedNPL();
+ singleContainedElement1 = model4Factory.eINSTANCE.createContainedElementNoOpposite();
+ refSingleContained1.setElement(singleContainedElement1);
+ resource1.getContents().add(refSingleContained1);
+ resource1.getContents().add(refSingleContained2);
+
+ tx.commit();
+ }
+
+ private void simpleModel4SingleBidiSetup() throws CommitException
+ {
+ EReference ref = model4Package.eINSTANCE.getRefSingleNonContained_Element();
+ boolean preconditions = !ref.isContainment() && ref.getEOpposite() != null && !ref.isMany();
+ if (!preconditions)
+ {
+ throw new RuntimeException("Model4 does not meet prerequirements for this test");
+ }
+
+ resource1 = tx.createResource(getResourcePath(RESOURCENAME));
+
+ refSingleNonContained1 = model4Factory.eINSTANCE.createRefSingleNonContained();
+ refSingleNonContained2 = model4Factory.eINSTANCE.createRefSingleNonContained();
+ singleNonContainedElement1 = model4Factory.eINSTANCE.createSingleNonContainedElement();
+ singleNonContainedElement2 = model4Factory.eINSTANCE.createSingleNonContainedElement();
+ refSingleNonContained1.setElement(singleNonContainedElement1);
+ resource1.getContents().add(refSingleNonContained1);
+ resource1.getContents().add(refSingleNonContained2);
+ resource1.getContents().add(singleNonContainedElement1);
+ resource1.getContents().add(singleNonContainedElement2);
+
+ tx.commit();
+ }
+
+ private void simpleModel4MultiBidiSetup() throws CommitException
+ {
+ EReference ref = model4Package.eINSTANCE.getRefMultiNonContained_Elements();
+ boolean preconditions = !ref.isContainment() && ref.getEOpposite() != null && ref.isMany();
+ if (!preconditions)
+ {
+ throw new RuntimeException("Model4 does not meet prerequirements for this test");
+ }
+
+ resource1 = tx.createResource(getResourcePath(RESOURCENAME));
+
+ refMultiNonContained1 = model4Factory.eINSTANCE.createRefMultiNonContained();
+ refMultiNonContained2 = model4Factory.eINSTANCE.createRefMultiNonContained();
+ multiNonContainedElement1 = model4Factory.eINSTANCE.createMultiNonContainedElement();
+ multiNonContainedElement2 = model4Factory.eINSTANCE.createMultiNonContainedElement();
+ refMultiNonContained1.getElements().add(multiNonContainedElement1);
+ resource1.getContents().add(refMultiNonContained1);
+ resource1.getContents().add(refMultiNonContained2);
+ resource1.getContents().add(multiNonContainedElement1);
+ resource1.getContents().add(multiNonContainedElement2);
+
+ tx.commit();
+ }
+
+ private Set<EObject> createSet(EObject... objects)
+ {
+ Set<EObject> committables = new HashSet<EObject>();
+ for (EObject o : objects)
+ {
+ if (o == null)
+ {
+ throw new NullPointerException();
+ }
+ committables.add(o);
+ }
+ return committables;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionTest.java
index 57c6fb29a1..a24d049e9b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionTest.java
@@ -1,654 +1,654 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gonzague Reydet - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOPushTransaction;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.ObjectNotFoundException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.om.OMPlatform;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-
-/**
- * @author Gonzague Reydet
- */
-public class PushTransactionTest extends AbstractCDOTest
-{
- private String resourcePath = "res1";
-
- private String supplierName = "supplier0";
-
- private File file;
-
- @Override
- protected void doSetUp() throws Exception
- {
- OMPlatform.INSTANCE.setDebugging(false);
- super.doSetUp();
- populateRepository();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- if (file != null)
- {
- file.delete();
- }
-
- super.doTearDown();
- }
-
- public void testUpdateExistingObject() throws Exception
- {
- String newName = "supplier" + System.currentTimeMillis();
-
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Make a diff in existing element");
- Supplier supplier = (Supplier)resource.getContents().get(0);
- supplier.setName(newName);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- assertEquals(1, transaction.getRevisionDeltas().size());
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- assertEquals(2, resource.getContents().size());
- Supplier supplier = (Supplier)resource.getContents().get(0);
- assertNotNull(supplier);
- assertEquals(newName, supplier.getName());
- }
-
- public void testDeleteExistingObject() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Remove an existing element");
- Supplier supplier = (Supplier)resource.getContents().get(0);
- resource.getContents().remove(supplier);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- assertEquals(1, transaction.getRevisionDeltas().size());
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- assertEquals(1, resource.getContents().size());
- }
-
- public void testAddNewObjectInResource() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Create a new element");
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("supplier" + System.currentTimeMillis());
- resource.getContents().add(supplier);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- assertEquals(1, transaction.getRevisionDeltas().size());
- CDORevisionDelta delta = transaction.getRevisionDeltas().values().iterator().next();
- assertNotNull(delta);
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- assertEquals(3, resource.getContents().size());
- }
-
- public void testAddNewObjectInObject() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Create a new element");
- Category category = getModel1Factory().createCategory();
- Company company = (Company)resource.getContents().get(1);
- company.getCategories().add(category);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- assertEquals(1, transaction.getRevisionDeltas().size());
- CDORevisionDelta delta = transaction.getRevisionDeltas().values().iterator().next();
- assertNotNull(delta);
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- assertEquals(2, resource.getContents().size());
- }
-
- public void testAddNewObjectInObjectBetweenReloadAndPush() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Create a new element");
- Category category = getModel1Factory().createCategory();
- Company company = (Company)resource.getContents().get(1);
- company.getCategories().add(category);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- assertEquals(1, transaction.getRevisionDeltas().size());
- CDORevisionDelta delta = transaction.getRevisionDeltas().values().iterator().next();
- assertNotNull(delta);
-
- msg("Create a new element");
- Category category = getModel1Factory().createCategory();
- CDOResource resource = transaction.getResource(getResourcePath(resourcePath));
- resource.getContents().add(category);
- msg("Commit");
- pushTransaction.commit();
-
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- assertEquals(3, resource.getContents().size());
- }
-
- public void testAddNewObjectInObjectTwiceBetweenReloadAndPush() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Create a new element");
- Category category = getModel1Factory().createCategory();
- Company company = (Company)resource.getContents().get(1);
- company.getCategories().add(category);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- assertEquals(1, transaction.getRevisionDeltas().size());
- CDORevisionDelta delta = transaction.getRevisionDeltas().values().iterator().next();
- assertNotNull(delta);
-
- msg("Create a new element");
- Category category = getModel1Factory().createCategory();
- CDOResource resource = transaction.getResource(getResourcePath(resourcePath));
- resource.getContents().add(category);
- msg("Commit");
- pushTransaction.commit();
-
- msg("Create a new element");
- category = getModel1Factory().createCategory();
- resource.getContents().add(category);
- msg("Commit");
- pushTransaction.commit();
-
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- assertEquals(4, resource.getContents().size());
- }
-
- @CleanRepositoriesBefore
- public void testAddNewResource() throws Exception
- {
- String resourcePath2 = "res2";
-
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Create a new resource");
- CDOResource resource2 = transaction.createResource(resourcePath2);
- resource.getContents().add(resource2);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- CDOResource resource2 = (CDOResource)resource.getContents().get(2);
- assertNotNull(resource2);
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- assertEquals(1, view.getRootResource().getContents().size());
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- CDOResource resource2 = (CDOResource)resource.getContents().get(2);
- assertNotNull(resource2);
- }
-
- public void testAddNewHierarchy() throws Exception
- {
- final String currentSupplierName = "supplier" + System.currentTimeMillis();
- final Date orderDate = new Date();
- final Float orderDetailPrice = 10.5F;
-
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Create a new element");
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName(currentSupplierName);
- resource.getContents().add(supplier);
- msg("Create a new child");
- PurchaseOrder order = getModel1Factory().createPurchaseOrder();
- order.setDate(orderDate);
- supplier.getPurchaseOrders().add(order);
- resource.getContents().add(order);
- OrderDetail detail = getModel1Factory().createOrderDetail();
- detail.setPrice(orderDetailPrice);
- order.getOrderDetails().add(detail);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- assertEquals(1, transaction.getRevisionDeltas().size());
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- assertEquals(4, resource.getContents().size());
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- assertEquals(4, resource.getContents().size());
- Supplier supplier = (Supplier)resource.getContents().get(2);
- assertEquals(currentSupplierName, supplier.getName());
- assertEquals(1, supplier.getPurchaseOrders().size());
- PurchaseOrder order = supplier.getPurchaseOrders().get(0);
- assertNotNull(order);
- assertEquals(orderDate, order.getDate());
- assertEquals(1, order.getOrderDetails().size());
- OrderDetail detail = order.getOrderDetails().get(0);
- assertNotNull(detail);
- assertEquals(orderDetailPrice, detail.getPrice());
- }
-
- @CleanRepositoriesBefore
- public void testMoveObject() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Create a new elements");
- Supplier supplier2 = getModel1Factory().createSupplier();
- supplier2.setName("supplier" + System.currentTimeMillis());
- resource.getContents().add(supplier2);
- msg("Move first supplier");
- Supplier supplier1 = (Supplier)resource.getContents().get(0);
- resource.getContents().move(1, supplier1);
- assertEquals(supplierName, ((Supplier)resource.getContents().get(1)).getName());
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- assertEquals(supplierName, ((Supplier)resource.getContents().get(1)).getName());
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- assertEquals(1, view.getRootResource().getContents().size());
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- assertEquals(supplierName, ((Supplier)resource.getContents().get(1)).getName());
- }
-
- public void testClearObjects() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Create a new elements");
- Supplier supplier2 = getModel1Factory().createSupplier();
- supplier2.setName("supplier" + System.currentTimeMillis());
- resource.getContents().add(supplier2);
- msg("Clear contents");
- resource.getContents().clear();
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- assertEquals(0, resource.getContents().size());
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- assertEquals(0, resource.getContents().size());
- }
-
- public void testUnsetValue() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- Supplier supplier = (Supplier)resource.getContents().get(0);
- supplier.setName(null);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.isDirty());
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- Supplier supplier = (Supplier)resource.getContents().get(0);
- assertNull(supplier.getName());
- push(transaction, pushTransaction);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath(resourcePath));
- Supplier supplier = (Supplier)resource.getContents().get(0);
- assertNull(supplier.getName());
- }
-
- public void testConflictWithRemovedObject() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Make a diff in existing element");
- Supplier supplier = (Supplier)resource.getContents().get(0);
- supplier.setName(null);
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Open transaction & commit changes to repo");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- resource.getContents().remove(0);
- transaction.commit();
- session.close();
- }
-
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- try
- {
- openPushTransaction(transaction, file);
- fail("ObjectNotFoundException expected");
- }
- catch (ObjectNotFoundException expected)
- {
- // SUCCESS
- }
- }
-
- public void testConflictWithModifiedObject() throws Exception
- {
- {
- msg("Open session & local transaction");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction);
- file = pushTransaction.getFile();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- msg("Make a diff in existing element");
- Supplier supplier = (Supplier)resource.getContents().get(0);
- supplier.setName("" + System.currentTimeMillis());
- msg("Commit");
- pushTransaction.commit();
- session.close();
- }
-
- {
- msg("Open transaction & commit changes to repo");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
- Supplier supplier = (Supplier)resource.getContents().get(0);
- supplier.setName("" + System.currentTimeMillis());
- transaction.commit();
- session.close();
- }
-
- msg("Reload previous local session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
- assertEquals(true, transaction.hasConflict());
-
- try
- {
- pushTransaction.push();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- // SUCCESS
- }
- }
-
- protected CDOPushTransaction openPushTransaction(CDOTransaction transaction) throws IOException
- {
- return new CDOPushTransaction(transaction);
- }
-
- protected CDOPushTransaction openPushTransaction(CDOTransaction transaction, File file) throws IOException
- {
- return new CDOPushTransaction(transaction, file);
- }
-
- protected void push(CDOTransaction transaction, CDOPushTransaction pushTransaction) throws CommitException
- {
- msg("Publish previous modifications");
- pushTransaction.push();
- assertEquals(false, transaction.isDirty());
- }
-
- private void populateRepository()
- {
- msg("Populate the repository the classic way");
- msg("Create resource");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(resourcePath));
-
- msg("Populate resource");
- Supplier supplier0 = getModel1Factory().createSupplier();
- supplier0.setName(supplierName);
- resource.getContents().add(supplier0);
- Company company0 = getModel1Factory().createCompany();
- resource.getContents().add(company0);
-
- try
- {
- msg("Commit");
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gonzague Reydet - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOPushTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.om.OMPlatform;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * @author Gonzague Reydet
+ */
+public class PushTransactionTest extends AbstractCDOTest
+{
+ private String resourcePath = "res1";
+
+ private String supplierName = "supplier0";
+
+ private File file;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ OMPlatform.INSTANCE.setDebugging(false);
+ super.doSetUp();
+ populateRepository();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ if (file != null)
+ {
+ file.delete();
+ }
+
+ super.doTearDown();
+ }
+
+ public void testUpdateExistingObject() throws Exception
+ {
+ String newName = "supplier" + System.currentTimeMillis();
+
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Make a diff in existing element");
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ supplier.setName(newName);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ assertEquals(1, transaction.getRevisionDeltas().size());
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ assertEquals(2, resource.getContents().size());
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ assertNotNull(supplier);
+ assertEquals(newName, supplier.getName());
+ }
+
+ public void testDeleteExistingObject() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Remove an existing element");
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ resource.getContents().remove(supplier);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ assertEquals(1, transaction.getRevisionDeltas().size());
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ assertEquals(1, resource.getContents().size());
+ }
+
+ public void testAddNewObjectInResource() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Create a new element");
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("supplier" + System.currentTimeMillis());
+ resource.getContents().add(supplier);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ assertEquals(1, transaction.getRevisionDeltas().size());
+ CDORevisionDelta delta = transaction.getRevisionDeltas().values().iterator().next();
+ assertNotNull(delta);
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ assertEquals(3, resource.getContents().size());
+ }
+
+ public void testAddNewObjectInObject() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Create a new element");
+ Category category = getModel1Factory().createCategory();
+ Company company = (Company)resource.getContents().get(1);
+ company.getCategories().add(category);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ assertEquals(1, transaction.getRevisionDeltas().size());
+ CDORevisionDelta delta = transaction.getRevisionDeltas().values().iterator().next();
+ assertNotNull(delta);
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ assertEquals(2, resource.getContents().size());
+ }
+
+ public void testAddNewObjectInObjectBetweenReloadAndPush() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Create a new element");
+ Category category = getModel1Factory().createCategory();
+ Company company = (Company)resource.getContents().get(1);
+ company.getCategories().add(category);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ assertEquals(1, transaction.getRevisionDeltas().size());
+ CDORevisionDelta delta = transaction.getRevisionDeltas().values().iterator().next();
+ assertNotNull(delta);
+
+ msg("Create a new element");
+ Category category = getModel1Factory().createCategory();
+ CDOResource resource = transaction.getResource(getResourcePath(resourcePath));
+ resource.getContents().add(category);
+ msg("Commit");
+ pushTransaction.commit();
+
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ assertEquals(3, resource.getContents().size());
+ }
+
+ public void testAddNewObjectInObjectTwiceBetweenReloadAndPush() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Create a new element");
+ Category category = getModel1Factory().createCategory();
+ Company company = (Company)resource.getContents().get(1);
+ company.getCategories().add(category);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ assertEquals(1, transaction.getRevisionDeltas().size());
+ CDORevisionDelta delta = transaction.getRevisionDeltas().values().iterator().next();
+ assertNotNull(delta);
+
+ msg("Create a new element");
+ Category category = getModel1Factory().createCategory();
+ CDOResource resource = transaction.getResource(getResourcePath(resourcePath));
+ resource.getContents().add(category);
+ msg("Commit");
+ pushTransaction.commit();
+
+ msg("Create a new element");
+ category = getModel1Factory().createCategory();
+ resource.getContents().add(category);
+ msg("Commit");
+ pushTransaction.commit();
+
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ assertEquals(4, resource.getContents().size());
+ }
+
+ @CleanRepositoriesBefore
+ public void testAddNewResource() throws Exception
+ {
+ String resourcePath2 = "res2";
+
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Create a new resource");
+ CDOResource resource2 = transaction.createResource(resourcePath2);
+ resource.getContents().add(resource2);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ CDOResource resource2 = (CDOResource)resource.getContents().get(2);
+ assertNotNull(resource2);
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ assertEquals(1, view.getRootResource().getContents().size());
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ CDOResource resource2 = (CDOResource)resource.getContents().get(2);
+ assertNotNull(resource2);
+ }
+
+ public void testAddNewHierarchy() throws Exception
+ {
+ final String currentSupplierName = "supplier" + System.currentTimeMillis();
+ final Date orderDate = new Date();
+ final Float orderDetailPrice = 10.5F;
+
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Create a new element");
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName(currentSupplierName);
+ resource.getContents().add(supplier);
+ msg("Create a new child");
+ PurchaseOrder order = getModel1Factory().createPurchaseOrder();
+ order.setDate(orderDate);
+ supplier.getPurchaseOrders().add(order);
+ resource.getContents().add(order);
+ OrderDetail detail = getModel1Factory().createOrderDetail();
+ detail.setPrice(orderDetailPrice);
+ order.getOrderDetails().add(detail);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ assertEquals(1, transaction.getRevisionDeltas().size());
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ assertEquals(4, resource.getContents().size());
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ assertEquals(4, resource.getContents().size());
+ Supplier supplier = (Supplier)resource.getContents().get(2);
+ assertEquals(currentSupplierName, supplier.getName());
+ assertEquals(1, supplier.getPurchaseOrders().size());
+ PurchaseOrder order = supplier.getPurchaseOrders().get(0);
+ assertNotNull(order);
+ assertEquals(orderDate, order.getDate());
+ assertEquals(1, order.getOrderDetails().size());
+ OrderDetail detail = order.getOrderDetails().get(0);
+ assertNotNull(detail);
+ assertEquals(orderDetailPrice, detail.getPrice());
+ }
+
+ @CleanRepositoriesBefore
+ public void testMoveObject() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Create a new elements");
+ Supplier supplier2 = getModel1Factory().createSupplier();
+ supplier2.setName("supplier" + System.currentTimeMillis());
+ resource.getContents().add(supplier2);
+ msg("Move first supplier");
+ Supplier supplier1 = (Supplier)resource.getContents().get(0);
+ resource.getContents().move(1, supplier1);
+ assertEquals(supplierName, ((Supplier)resource.getContents().get(1)).getName());
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ assertEquals(supplierName, ((Supplier)resource.getContents().get(1)).getName());
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ assertEquals(1, view.getRootResource().getContents().size());
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ assertEquals(supplierName, ((Supplier)resource.getContents().get(1)).getName());
+ }
+
+ public void testClearObjects() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Create a new elements");
+ Supplier supplier2 = getModel1Factory().createSupplier();
+ supplier2.setName("supplier" + System.currentTimeMillis());
+ resource.getContents().add(supplier2);
+ msg("Clear contents");
+ resource.getContents().clear();
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ assertEquals(0, resource.getContents().size());
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ assertEquals(0, resource.getContents().size());
+ }
+
+ public void testUnsetValue() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ supplier.setName(null);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.isDirty());
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ assertNull(supplier.getName());
+ push(transaction, pushTransaction);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath(resourcePath));
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ assertNull(supplier.getName());
+ }
+
+ public void testConflictWithRemovedObject() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Make a diff in existing element");
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ supplier.setName(null);
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Open transaction & commit changes to repo");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ resource.getContents().remove(0);
+ transaction.commit();
+ session.close();
+ }
+
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ try
+ {
+ openPushTransaction(transaction, file);
+ fail("ObjectNotFoundException expected");
+ }
+ catch (ObjectNotFoundException expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ public void testConflictWithModifiedObject() throws Exception
+ {
+ {
+ msg("Open session & local transaction");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction);
+ file = pushTransaction.getFile();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ msg("Make a diff in existing element");
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ supplier.setName("" + System.currentTimeMillis());
+ msg("Commit");
+ pushTransaction.commit();
+ session.close();
+ }
+
+ {
+ msg("Open transaction & commit changes to repo");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
+ Supplier supplier = (Supplier)resource.getContents().get(0);
+ supplier.setName("" + System.currentTimeMillis());
+ transaction.commit();
+ session.close();
+ }
+
+ msg("Reload previous local session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
+ assertEquals(true, transaction.hasConflict());
+
+ try
+ {
+ pushTransaction.push();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ protected CDOPushTransaction openPushTransaction(CDOTransaction transaction) throws IOException
+ {
+ return new CDOPushTransaction(transaction);
+ }
+
+ protected CDOPushTransaction openPushTransaction(CDOTransaction transaction, File file) throws IOException
+ {
+ return new CDOPushTransaction(transaction, file);
+ }
+
+ protected void push(CDOTransaction transaction, CDOPushTransaction pushTransaction) throws CommitException
+ {
+ msg("Publish previous modifications");
+ pushTransaction.push();
+ assertEquals(false, transaction.isDirty());
+ }
+
+ private void populateRepository()
+ {
+ msg("Populate the repository the classic way");
+ msg("Create resource");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(resourcePath));
+
+ msg("Populate resource");
+ Supplier supplier0 = getModel1Factory().createSupplier();
+ supplier0.setName(supplierName);
+ resource.getContents().add(supplier0);
+ Company company0 = getModel1Factory().createCompany();
+ resource.getContents().add(company0);
+
+ try
+ {
+ msg("Commit");
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionWithoutReconstructSavepointsTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionWithoutReconstructSavepointsTest.java
index 88fc711930..a13d14fd6e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionWithoutReconstructSavepointsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PushTransactionWithoutReconstructSavepointsTest.java
@@ -1,29 +1,29 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.transaction.CDOPushTransaction;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class PushTransactionWithoutReconstructSavepointsTest extends PushTransactionTest
-{
- @Override
- protected CDOPushTransaction openPushTransaction(CDOTransaction transaction, File file) throws IOException
- {
- return new CDOPushTransaction(transaction, file, false);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.transaction.CDOPushTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class PushTransactionWithoutReconstructSavepointsTest extends PushTransactionTest
+{
+ @Override
+ protected CDOPushTransaction openPushTransaction(CDOTransaction transaction, File file) throws IOException
+ {
+ return new CDOPushTransaction(transaction, file, false);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RemoteSessionManagerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RemoteSessionManagerTest.java
index 24171e2b64..1524e05036 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RemoteSessionManagerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RemoteSessionManagerTest.java
@@ -1,297 +1,297 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSession;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionEvent;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
-
-import org.eclipse.net4j.util.container.ContainerEventAdapter;
-import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
-import java.util.Arrays;
-
-/**
- * @author Eike Stepper
- */
-public class RemoteSessionManagerTest extends AbstractCDOTest
-{
- public void testRemoteSessionOpened() throws Exception
- {
- final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
-
- CDOSession session1 = openSession();
- session1.getRemoteSessionManager().addListener(new ContainerEventAdapter<CDORemoteSession>()
- {
- @Override
- protected void onAdded(IContainer<CDORemoteSession> container, CDORemoteSession session)
- {
- result1.setValue(session.getSessionID());
- }
- });
-
- CDOSession session2 = openSession();
-
- assertEquals(session2.getSessionID(), (int)result1.getValue());
- session2.close();
- session1.close();
- }
-
- public void testRemoteSessionClosed() throws Exception
- {
- final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
-
- CDOSession session1 = openSession();
- session1.getRemoteSessionManager().addListener(new ContainerEventAdapter<CDORemoteSession>()
- {
- @Override
- protected void onRemoved(IContainer<CDORemoteSession> container, CDORemoteSession session)
- {
- result1.setValue(session.getSessionID());
- }
- });
-
- CDOSession session2 = openSession();
- session2.close();
-
- assertEquals(session2.getSessionID(), (int)result1.getValue());
- session2.close();
- session1.close();
- }
-
- public void testSubscribeByForce() throws Exception
- {
- final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
-
- CDOSession session1 = openSession();
- session1.getRemoteSessionManager().addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDORemoteSessionEvent.SubscriptionChanged)
- {
- CDORemoteSessionEvent.SubscriptionChanged e = (CDORemoteSessionEvent.SubscriptionChanged)event;
- if (e.isSubscribed())
- {
- result1.setValue(e.getRemoteSession().getSessionID());
- }
- else
- {
- result1.setValue(-1);
- }
- }
- }
- });
-
- CDOSession session2 = openSession();
- session2.getRemoteSessionManager().setForceSubscription(true);
-
- assertEquals(session2.getSessionID(), (int)result1.getValue());
- session2.close();
- session1.close();
- }
-
- public void testSubscribeByListen() throws Exception
- {
- final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
-
- CDOSession session1 = openSession();
- session1.getRemoteSessionManager().addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDORemoteSessionEvent.SubscriptionChanged)
- {
- CDORemoteSessionEvent.SubscriptionChanged e = (CDORemoteSessionEvent.SubscriptionChanged)event;
- if (e.isSubscribed())
- {
- result1.setValue(e.getRemoteSession().getSessionID());
- }
- else
- {
- result1.setValue(-1);
- }
- }
- }
- });
-
- CDOSession session2 = openSession();
- session2.getRemoteSessionManager().addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- }
- });
-
- assertEquals(session2.getSessionID(), (int)result1.getValue());
- session2.close();
- session1.close();
- }
-
- public void testUnsubscribeByForce() throws Exception
- {
- final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
-
- CDOSession session1 = openSession();
- session1.getRemoteSessionManager().addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDORemoteSessionEvent.SubscriptionChanged)
- {
- CDORemoteSessionEvent.SubscriptionChanged e = (CDORemoteSessionEvent.SubscriptionChanged)event;
- if (!e.isSubscribed())
- {
- result1.setValue(e.getRemoteSession().getSessionID());
- }
- }
- }
- });
-
- CDOSession session2 = openSession();
- session2.getRemoteSessionManager().setForceSubscription(true);
- session2.getRemoteSessionManager().setForceSubscription(false);
-
- assertEquals(session2.getSessionID(), (int)result1.getValue());
- session2.close();
- session1.close();
- }
-
- public void testUnsubscribeByListen100() throws Exception
- {
- for (int i = 0; i < 100; i++)
- {
- testUnsubscribeByListen();
- }
- }
-
- public void testUnsubscribeByListen() throws Exception
- {
- final AsyncResult<Integer> subscribed = new AsyncResult<Integer>();
- final AsyncResult<Integer> unsubscribed = new AsyncResult<Integer>();
-
- CDOSession session1 = openSession();
- session1.getRemoteSessionManager().addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDORemoteSessionEvent.SubscriptionChanged)
- {
- CDORemoteSessionEvent.SubscriptionChanged e = (CDORemoteSessionEvent.SubscriptionChanged)event;
- if (e.isSubscribed())
- {
- subscribed.setValue(e.getRemoteSession().getSessionID());
- }
- else
- {
- unsubscribed.setValue(e.getRemoteSession().getSessionID());
- }
- }
- }
- });
-
- CDOSession session2 = openSession();
- IListener listener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- // Do nothing
- }
- };
-
- session2.getRemoteSessionManager().addListener(listener);
- assertEquals(session2.getSessionID(), (int)subscribed.getValue());
-
- session2.getRemoteSessionManager().removeListener(listener);
- assertEquals(session2.getSessionID(), (int)unsubscribed.getValue());
-
- session2.close();
- session1.close();
- }
-
- public void testCustomData() throws Exception
- {
- final AsyncResult<byte[]> result1 = new AsyncResult<byte[]>();
-
- CDOSession session1 = openSession();
- session1.getRemoteSessionManager().addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDORemoteSessionEvent.MessageReceived)
- {
- CDORemoteSessionEvent.MessageReceived e = (CDORemoteSessionEvent.MessageReceived)event;
- result1.setValue(e.getMessage().getData());
- }
- }
- });
-
- CDOSession session2 = openSession();
- session2.getRemoteSessionManager().setForceSubscription(true);
-
- byte[] data = "This is a custom data test".getBytes();
- CDORemoteSession remoteSession = session2.getRemoteSessionManager().getRemoteSessions()[0];
- remoteSession.sendMessage(new CDORemoteSessionMessage("type", data));
-
- assertEquals(true, Arrays.equals(data, result1.getValue()));
- session2.close();
- session1.close();
- }
-
- public void testCustomDataLocallyUnsubscribed() throws Exception
- {
- final AsyncResult<byte[]> result1 = new AsyncResult<byte[]>();
-
- CDOSession session1 = openSession();
- session1.getRemoteSessionManager().addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDORemoteSessionEvent.MessageReceived)
- {
- CDORemoteSessionEvent.MessageReceived e = (CDORemoteSessionEvent.MessageReceived)event;
- result1.setValue(e.getMessage().getData());
- }
- }
- });
-
- CDOSession session2 = openSession();
-
- byte[] data = "This is a custom data test".getBytes();
- CDORemoteSession remoteSession = session2.getRemoteSessionManager().getRemoteSessions()[0];
-
- boolean sent = remoteSession.sendMessage(new CDORemoteSessionMessage("type", data));
- assertEquals(true, sent);
-
- session2.close();
- session1.close();
- }
-
- public void testCustomDataRemotelyUnsubscribed() throws Exception
- {
- CDOSession session1 = openSession();
- CDOSession session2 = openSession();
- session2.getRemoteSessionManager().setForceSubscription(true);
-
- byte[] data = "This is a custom data test".getBytes();
- CDORemoteSession remoteSession = session2.getRemoteSessionManager().getRemoteSessions()[0];
-
- boolean sent = remoteSession.sendMessage(new CDORemoteSessionMessage("type", data));
- assertEquals(false, sent);
-
- session2.close();
- session1.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.remote.CDORemoteSession;
+import org.eclipse.emf.cdo.session.remote.CDORemoteSessionEvent;
+import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
+
+import org.eclipse.net4j.util.container.ContainerEventAdapter;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import java.util.Arrays;
+
+/**
+ * @author Eike Stepper
+ */
+public class RemoteSessionManagerTest extends AbstractCDOTest
+{
+ public void testRemoteSessionOpened() throws Exception
+ {
+ final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
+
+ CDOSession session1 = openSession();
+ session1.getRemoteSessionManager().addListener(new ContainerEventAdapter<CDORemoteSession>()
+ {
+ @Override
+ protected void onAdded(IContainer<CDORemoteSession> container, CDORemoteSession session)
+ {
+ result1.setValue(session.getSessionID());
+ }
+ });
+
+ CDOSession session2 = openSession();
+
+ assertEquals(session2.getSessionID(), (int)result1.getValue());
+ session2.close();
+ session1.close();
+ }
+
+ public void testRemoteSessionClosed() throws Exception
+ {
+ final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
+
+ CDOSession session1 = openSession();
+ session1.getRemoteSessionManager().addListener(new ContainerEventAdapter<CDORemoteSession>()
+ {
+ @Override
+ protected void onRemoved(IContainer<CDORemoteSession> container, CDORemoteSession session)
+ {
+ result1.setValue(session.getSessionID());
+ }
+ });
+
+ CDOSession session2 = openSession();
+ session2.close();
+
+ assertEquals(session2.getSessionID(), (int)result1.getValue());
+ session2.close();
+ session1.close();
+ }
+
+ public void testSubscribeByForce() throws Exception
+ {
+ final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
+
+ CDOSession session1 = openSession();
+ session1.getRemoteSessionManager().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDORemoteSessionEvent.SubscriptionChanged)
+ {
+ CDORemoteSessionEvent.SubscriptionChanged e = (CDORemoteSessionEvent.SubscriptionChanged)event;
+ if (e.isSubscribed())
+ {
+ result1.setValue(e.getRemoteSession().getSessionID());
+ }
+ else
+ {
+ result1.setValue(-1);
+ }
+ }
+ }
+ });
+
+ CDOSession session2 = openSession();
+ session2.getRemoteSessionManager().setForceSubscription(true);
+
+ assertEquals(session2.getSessionID(), (int)result1.getValue());
+ session2.close();
+ session1.close();
+ }
+
+ public void testSubscribeByListen() throws Exception
+ {
+ final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
+
+ CDOSession session1 = openSession();
+ session1.getRemoteSessionManager().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDORemoteSessionEvent.SubscriptionChanged)
+ {
+ CDORemoteSessionEvent.SubscriptionChanged e = (CDORemoteSessionEvent.SubscriptionChanged)event;
+ if (e.isSubscribed())
+ {
+ result1.setValue(e.getRemoteSession().getSessionID());
+ }
+ else
+ {
+ result1.setValue(-1);
+ }
+ }
+ }
+ });
+
+ CDOSession session2 = openSession();
+ session2.getRemoteSessionManager().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ }
+ });
+
+ assertEquals(session2.getSessionID(), (int)result1.getValue());
+ session2.close();
+ session1.close();
+ }
+
+ public void testUnsubscribeByForce() throws Exception
+ {
+ final AsyncResult<Integer> result1 = new AsyncResult<Integer>();
+
+ CDOSession session1 = openSession();
+ session1.getRemoteSessionManager().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDORemoteSessionEvent.SubscriptionChanged)
+ {
+ CDORemoteSessionEvent.SubscriptionChanged e = (CDORemoteSessionEvent.SubscriptionChanged)event;
+ if (!e.isSubscribed())
+ {
+ result1.setValue(e.getRemoteSession().getSessionID());
+ }
+ }
+ }
+ });
+
+ CDOSession session2 = openSession();
+ session2.getRemoteSessionManager().setForceSubscription(true);
+ session2.getRemoteSessionManager().setForceSubscription(false);
+
+ assertEquals(session2.getSessionID(), (int)result1.getValue());
+ session2.close();
+ session1.close();
+ }
+
+ public void testUnsubscribeByListen100() throws Exception
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ testUnsubscribeByListen();
+ }
+ }
+
+ public void testUnsubscribeByListen() throws Exception
+ {
+ final AsyncResult<Integer> subscribed = new AsyncResult<Integer>();
+ final AsyncResult<Integer> unsubscribed = new AsyncResult<Integer>();
+
+ CDOSession session1 = openSession();
+ session1.getRemoteSessionManager().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDORemoteSessionEvent.SubscriptionChanged)
+ {
+ CDORemoteSessionEvent.SubscriptionChanged e = (CDORemoteSessionEvent.SubscriptionChanged)event;
+ if (e.isSubscribed())
+ {
+ subscribed.setValue(e.getRemoteSession().getSessionID());
+ }
+ else
+ {
+ unsubscribed.setValue(e.getRemoteSession().getSessionID());
+ }
+ }
+ }
+ });
+
+ CDOSession session2 = openSession();
+ IListener listener = new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ // Do nothing
+ }
+ };
+
+ session2.getRemoteSessionManager().addListener(listener);
+ assertEquals(session2.getSessionID(), (int)subscribed.getValue());
+
+ session2.getRemoteSessionManager().removeListener(listener);
+ assertEquals(session2.getSessionID(), (int)unsubscribed.getValue());
+
+ session2.close();
+ session1.close();
+ }
+
+ public void testCustomData() throws Exception
+ {
+ final AsyncResult<byte[]> result1 = new AsyncResult<byte[]>();
+
+ CDOSession session1 = openSession();
+ session1.getRemoteSessionManager().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDORemoteSessionEvent.MessageReceived)
+ {
+ CDORemoteSessionEvent.MessageReceived e = (CDORemoteSessionEvent.MessageReceived)event;
+ result1.setValue(e.getMessage().getData());
+ }
+ }
+ });
+
+ CDOSession session2 = openSession();
+ session2.getRemoteSessionManager().setForceSubscription(true);
+
+ byte[] data = "This is a custom data test".getBytes();
+ CDORemoteSession remoteSession = session2.getRemoteSessionManager().getRemoteSessions()[0];
+ remoteSession.sendMessage(new CDORemoteSessionMessage("type", data));
+
+ assertEquals(true, Arrays.equals(data, result1.getValue()));
+ session2.close();
+ session1.close();
+ }
+
+ public void testCustomDataLocallyUnsubscribed() throws Exception
+ {
+ final AsyncResult<byte[]> result1 = new AsyncResult<byte[]>();
+
+ CDOSession session1 = openSession();
+ session1.getRemoteSessionManager().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDORemoteSessionEvent.MessageReceived)
+ {
+ CDORemoteSessionEvent.MessageReceived e = (CDORemoteSessionEvent.MessageReceived)event;
+ result1.setValue(e.getMessage().getData());
+ }
+ }
+ });
+
+ CDOSession session2 = openSession();
+
+ byte[] data = "This is a custom data test".getBytes();
+ CDORemoteSession remoteSession = session2.getRemoteSessionManager().getRemoteSessions()[0];
+
+ boolean sent = remoteSession.sendMessage(new CDORemoteSessionMessage("type", data));
+ assertEquals(true, sent);
+
+ session2.close();
+ session1.close();
+ }
+
+ public void testCustomDataRemotelyUnsubscribed() throws Exception
+ {
+ CDOSession session1 = openSession();
+ CDOSession session2 = openSession();
+ session2.getRemoteSessionManager().setForceSubscription(true);
+
+ byte[] data = "This is a custom data test".getBytes();
+ CDORemoteSession remoteSession = session2.getRemoteSessionManager().getRemoteSessions()[0];
+
+ boolean sent = remoteSession.sendMessage(new CDORemoteSessionMessage("type", data));
+ assertEquals(false, sent);
+
+ session2.close();
+ session1.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java
index 01d0c0db26..431cc0281b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java
@@ -1,392 +1,392 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.CDOServerUtil;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.ISessionManager;
-import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
-import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalStore;
-import org.eclipse.emf.cdo.spi.server.ObjectWriteAccessHandler;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.impl.EPackageImpl;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class RepositoryTest extends AbstractCDOTest
-{
- public void testInsertProperties() throws Exception
- {
- Map<String, String> expected = new HashMap<String, String>();
- expected.put("BOOLEAN", "true");
- expected.put("INTEGER", "1234567");
- expected.put("LONG", "12345671234567");
- expected.put("DOUBLE", "1234567.1234567");
- expected.put("STRING", "Arbitrary text");
-
- InternalStore store = getRepository().getStore();
- store.setPersistentProperties(expected);
-
- Map<String, String> actual = store.getPersistentProperties(expected.keySet());
- assertEquals(expected, actual);
- }
-
- public void testUpdateProperties() throws Exception
- {
- Map<String, String> expected = new HashMap<String, String>();
- expected.put("BOOLEAN", "true");
- expected.put("INTEGER", "1234567");
- expected.put("LONG", "12345671234567");
- expected.put("DOUBLE", "1234567.1234567");
- expected.put("STRING", "Arbitrary text");
-
- InternalStore store = getRepository().getStore();
- store.setPersistentProperties(expected);
-
- expected.put("BOOLEAN", "false");
- expected.put("INTEGER", "555555");
- expected.put("LONG", "5555555555555555");
- expected.put("DOUBLE", "555555.555555");
- expected.put("STRING", "Different text");
- store.setPersistentProperties(expected);
-
- Map<String, String> actual = store.getPersistentProperties(expected.keySet());
- assertEquals(expected, actual);
- }
-
- public void testRemoveProperties() throws Exception
- {
- Map<String, String> expected = new HashMap<String, String>();
- expected.put("BOOLEAN", "true");
- expected.put("INTEGER", "1234567");
- expected.put("LONG", "12345671234567");
- expected.put("DOUBLE", "1234567.1234567");
- expected.put("STRING", "Arbitrary text");
-
- InternalStore store = getRepository().getStore();
- store.setPersistentProperties(expected);
-
- Map<String, String> actual = store.getPersistentProperties(expected.keySet());
- assertEquals(expected, actual);
-
- Set<String> names = new HashSet<String>(Arrays.asList(new String[] { "INTEGER", "DOUBLE" }));
- store.removePersistentProperties(names);
-
- expected.remove("INTEGER");
- expected.remove("DOUBLE");
- actual = store.getPersistentProperties(expected.keySet());
- assertEquals(expected, actual);
- }
-
- public void testSessionClosed() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- resource.getContents().add(createCustomer("Eike"));
- transaction.commit(); // Ensure that model1 is committed to the repository
-
- ISessionManager sessionManager = getRepository().getSessionManager();
- assertEquals(1, sessionManager.getSessions().length);
-
- session.close();
- sleep(100);
- assertEquals(0, sessionManager.getSessions().length);
- }
-
- /**
- * See bug 329254
- */
- @Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
- // hibernate will recreate the systeminfo table at repository
- // restart (this is due to test settings)
- @Skips("Hibernate")
- public void testLastCommitTime() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- resource.getContents().add(createCustomer("Eike"));
- long timeStamp = transaction.commit().getTimeStamp();
- session.close();
-
- InternalRepository repository = restartRepository();
- assertEquals(timeStamp, repository.getLastCommitTimeStamp());
- }
-
- public void testWriteAccessHandlers() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- resource.getContents().add(createCustomer("Eike"));
- transaction.commit(); // Ensure that model1 is committed to the repository
-
- getRepository().addHandler(new IRepository.WriteAccessHandler()
- {
- public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor) throws RuntimeException
- {
- // Use the package registry of the commit context to catch new packages!
- EPackage model1Package = commitContext.getPackageRegistry().getEPackage(getModel1Package().getNsURI());
- EClass customerClass = (EClass)model1Package.getEClassifier("Customer");
- EStructuralFeature nameFeature = customerClass.getEStructuralFeature("name");
-
- for (CDORevision revision : commitContext.getNewObjects())
- {
- if (revision.getEClass() == customerClass)
- {
- String name = (String)revision.data().get(nameFeature, 0);
- if ("Admin".equals(name))
- {
- throw new IllegalStateException("Adding a customer with name 'Admin' is not allowed");
- }
- }
- }
- }
-
- public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor)
- {
- }
- });
-
- resource.getContents().add(createCustomer("Simon"));
- transaction.commit();
- resource.getContents().add(createCustomer("Admin"));
-
- try
- {
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- // Success
- transaction.rollback();
- }
-
- resource.getContents().add(createCustomer("Martin"));
- transaction.commit();
- resource.getContents().add(createCustomer("Nick"));
- transaction.commit();
- session.close();
- }
-
- public void testWriteAccessHandlers_WithServerCDOView() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- resource.getContents().add(createCustomer("Eike"));
- transaction.commit(); // Ensure that model1 is committed to the repository
-
- getRepository().addHandler(new IRepository.WriteAccessHandler()
- {
- public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor) throws RuntimeException
- {
- CDOView view = CDOServerUtil.openView(commitContext, isConfig(LEGACY));
- for (CDORevision revision : commitContext.getNewObjects())
- {
- EObject object = view.getObject(revision.getID());
- object = CDOUtil.getEObject(object); // Make legacy mode happy
- if (object instanceof Customer)
- {
- Customer customer = (Customer)object;
- String name = customer.getName();
- if ("Admin".equals(name))
- {
- throw new IllegalStateException("Adding a customer with name 'Admin' is not allowed");
- }
- }
- }
-
- view.close();
- }
-
- public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor)
- {
- }
- });
-
- resource.getContents().add(createCustomer("Simon"));
- transaction.commit();
- resource.getContents().add(createCustomer("Admin"));
-
- try
- {
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- // Success
- transaction.rollback();
- }
-
- resource.getContents().add(createCustomer("Martin"));
- transaction.commit();
- resource.getContents().add(createCustomer("Nick"));
- transaction.commit();
- session.close();
- }
-
- public void testObjectWriteAccessHandler() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- resource.getContents().add(createCustomer("Eike"));
- transaction.commit(); // Ensure that model1 is committed to the repository
-
- getRepository().addHandler(new ObjectWriteAccessHandler(isConfig(LEGACY))
- {
- @Override
- protected void handleTransactionBeforeCommitting(OMMonitor monitor) throws RuntimeException
- {
- for (EObject object : getNewObjects())
- {
- if (object instanceof Customer)
- {
- Customer customer = (Customer)object;
- String name = customer.getName();
- if ("Admin".equals(name))
- {
- throw new IllegalStateException("Adding a customer with name 'Admin' is not allowed");
- }
- }
- }
- }
- });
-
- resource.getContents().add(createCustomer("Simon"));
- transaction.commit();
- resource.getContents().add(createCustomer("Admin"));
-
- try
- {
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- // Success
- transaction.rollback();
- }
-
- resource.getContents().add(createCustomer("Martin"));
- transaction.commit();
- resource.getContents().add(createCustomer("Nick"));
- transaction.commit();
- session.close();
- }
-
- @CleanRepositoriesBefore
- public void testReadAccessHandlers() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- resource.getContents().add(createCustomer("Eike"));
- resource.getContents().add(createCustomer("Simon"));
- resource.getContents().add(createCustomer("Admin"));
- resource.getContents().add(createCustomer("Martin"));
- resource.getContents().add(createCustomer("Nick"));
- transaction.commit();
- session.close();
- }
-
- getRepository().addHandler(new CDOServerUtil.RepositoryReadAccessValidator()
- {
- EPackage model1Package = getRepository().getPackageRegistry().getEPackage(getModel1Package().getNsURI());
-
- EClass customerClass = (EClass)model1Package.getEClassifier("Customer");
-
- EStructuralFeature nameFeature = customerClass.getEStructuralFeature("name");
-
- @Override
- protected String validate(ISession session, CDORevision revision)
- {
- EClass eClass = revision.getEClass();
- EPackage ePackage = eClass.getEPackage();
- assertNotSame("Revision has dynamic package: " + ePackage.getName(), EPackageImpl.class.getName(), ePackage
- .getClass().getName());
-
- if (eClass == customerClass)
- {
- String name = (String)revision.data().get(nameFeature, 0);
- if ("Admin".equals(name))
- {
- return "Confidential!";
- }
- }
-
- return null;
- }
- });
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/res1"));
- int read = 0;
-
- try
- {
- for (EObject object : resource.getContents())
- {
- Customer customer = (Customer)object;
- System.out.println(customer.getName());
- ++read;
- }
- }
- catch (Exception ex)
- {
- }
-
- assertEquals(2, read);
- session.close();
- }
-
- private Customer createCustomer(String name)
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName(name);
- return customer;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.CDOServerUtil;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.server.ISessionManager;
+import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalStore;
+import org.eclipse.emf.cdo.spi.server.ObjectWriteAccessHandler;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class RepositoryTest extends AbstractCDOTest
+{
+ public void testInsertProperties() throws Exception
+ {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("BOOLEAN", "true");
+ expected.put("INTEGER", "1234567");
+ expected.put("LONG", "12345671234567");
+ expected.put("DOUBLE", "1234567.1234567");
+ expected.put("STRING", "Arbitrary text");
+
+ InternalStore store = getRepository().getStore();
+ store.setPersistentProperties(expected);
+
+ Map<String, String> actual = store.getPersistentProperties(expected.keySet());
+ assertEquals(expected, actual);
+ }
+
+ public void testUpdateProperties() throws Exception
+ {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("BOOLEAN", "true");
+ expected.put("INTEGER", "1234567");
+ expected.put("LONG", "12345671234567");
+ expected.put("DOUBLE", "1234567.1234567");
+ expected.put("STRING", "Arbitrary text");
+
+ InternalStore store = getRepository().getStore();
+ store.setPersistentProperties(expected);
+
+ expected.put("BOOLEAN", "false");
+ expected.put("INTEGER", "555555");
+ expected.put("LONG", "5555555555555555");
+ expected.put("DOUBLE", "555555.555555");
+ expected.put("STRING", "Different text");
+ store.setPersistentProperties(expected);
+
+ Map<String, String> actual = store.getPersistentProperties(expected.keySet());
+ assertEquals(expected, actual);
+ }
+
+ public void testRemoveProperties() throws Exception
+ {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("BOOLEAN", "true");
+ expected.put("INTEGER", "1234567");
+ expected.put("LONG", "12345671234567");
+ expected.put("DOUBLE", "1234567.1234567");
+ expected.put("STRING", "Arbitrary text");
+
+ InternalStore store = getRepository().getStore();
+ store.setPersistentProperties(expected);
+
+ Map<String, String> actual = store.getPersistentProperties(expected.keySet());
+ assertEquals(expected, actual);
+
+ Set<String> names = new HashSet<String>(Arrays.asList(new String[] { "INTEGER", "DOUBLE" }));
+ store.removePersistentProperties(names);
+
+ expected.remove("INTEGER");
+ expected.remove("DOUBLE");
+ actual = store.getPersistentProperties(expected.keySet());
+ assertEquals(expected, actual);
+ }
+
+ public void testSessionClosed() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(createCustomer("Eike"));
+ transaction.commit(); // Ensure that model1 is committed to the repository
+
+ ISessionManager sessionManager = getRepository().getSessionManager();
+ assertEquals(1, sessionManager.getSessions().length);
+
+ session.close();
+ sleep(100);
+ assertEquals(0, sessionManager.getSessions().length);
+ }
+
+ /**
+ * See bug 329254
+ */
+ @Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
+ // hibernate will recreate the systeminfo table at repository
+ // restart (this is due to test settings)
+ @Skips("Hibernate")
+ public void testLastCommitTime() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(createCustomer("Eike"));
+ long timeStamp = transaction.commit().getTimeStamp();
+ session.close();
+
+ InternalRepository repository = restartRepository();
+ assertEquals(timeStamp, repository.getLastCommitTimeStamp());
+ }
+
+ public void testWriteAccessHandlers() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(createCustomer("Eike"));
+ transaction.commit(); // Ensure that model1 is committed to the repository
+
+ getRepository().addHandler(new IRepository.WriteAccessHandler()
+ {
+ public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor) throws RuntimeException
+ {
+ // Use the package registry of the commit context to catch new packages!
+ EPackage model1Package = commitContext.getPackageRegistry().getEPackage(getModel1Package().getNsURI());
+ EClass customerClass = (EClass)model1Package.getEClassifier("Customer");
+ EStructuralFeature nameFeature = customerClass.getEStructuralFeature("name");
+
+ for (CDORevision revision : commitContext.getNewObjects())
+ {
+ if (revision.getEClass() == customerClass)
+ {
+ String name = (String)revision.data().get(nameFeature, 0);
+ if ("Admin".equals(name))
+ {
+ throw new IllegalStateException("Adding a customer with name 'Admin' is not allowed");
+ }
+ }
+ }
+ }
+
+ public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor)
+ {
+ }
+ });
+
+ resource.getContents().add(createCustomer("Simon"));
+ transaction.commit();
+ resource.getContents().add(createCustomer("Admin"));
+
+ try
+ {
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ // Success
+ transaction.rollback();
+ }
+
+ resource.getContents().add(createCustomer("Martin"));
+ transaction.commit();
+ resource.getContents().add(createCustomer("Nick"));
+ transaction.commit();
+ session.close();
+ }
+
+ public void testWriteAccessHandlers_WithServerCDOView() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(createCustomer("Eike"));
+ transaction.commit(); // Ensure that model1 is committed to the repository
+
+ getRepository().addHandler(new IRepository.WriteAccessHandler()
+ {
+ public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor) throws RuntimeException
+ {
+ CDOView view = CDOServerUtil.openView(commitContext, isConfig(LEGACY));
+ for (CDORevision revision : commitContext.getNewObjects())
+ {
+ EObject object = view.getObject(revision.getID());
+ object = CDOUtil.getEObject(object); // Make legacy mode happy
+ if (object instanceof Customer)
+ {
+ Customer customer = (Customer)object;
+ String name = customer.getName();
+ if ("Admin".equals(name))
+ {
+ throw new IllegalStateException("Adding a customer with name 'Admin' is not allowed");
+ }
+ }
+ }
+
+ view.close();
+ }
+
+ public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor)
+ {
+ }
+ });
+
+ resource.getContents().add(createCustomer("Simon"));
+ transaction.commit();
+ resource.getContents().add(createCustomer("Admin"));
+
+ try
+ {
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ // Success
+ transaction.rollback();
+ }
+
+ resource.getContents().add(createCustomer("Martin"));
+ transaction.commit();
+ resource.getContents().add(createCustomer("Nick"));
+ transaction.commit();
+ session.close();
+ }
+
+ public void testObjectWriteAccessHandler() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(createCustomer("Eike"));
+ transaction.commit(); // Ensure that model1 is committed to the repository
+
+ getRepository().addHandler(new ObjectWriteAccessHandler(isConfig(LEGACY))
+ {
+ @Override
+ protected void handleTransactionBeforeCommitting(OMMonitor monitor) throws RuntimeException
+ {
+ for (EObject object : getNewObjects())
+ {
+ if (object instanceof Customer)
+ {
+ Customer customer = (Customer)object;
+ String name = customer.getName();
+ if ("Admin".equals(name))
+ {
+ throw new IllegalStateException("Adding a customer with name 'Admin' is not allowed");
+ }
+ }
+ }
+ }
+ });
+
+ resource.getContents().add(createCustomer("Simon"));
+ transaction.commit();
+ resource.getContents().add(createCustomer("Admin"));
+
+ try
+ {
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ // Success
+ transaction.rollback();
+ }
+
+ resource.getContents().add(createCustomer("Martin"));
+ transaction.commit();
+ resource.getContents().add(createCustomer("Nick"));
+ transaction.commit();
+ session.close();
+ }
+
+ @CleanRepositoriesBefore
+ public void testReadAccessHandlers() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(createCustomer("Eike"));
+ resource.getContents().add(createCustomer("Simon"));
+ resource.getContents().add(createCustomer("Admin"));
+ resource.getContents().add(createCustomer("Martin"));
+ resource.getContents().add(createCustomer("Nick"));
+ transaction.commit();
+ session.close();
+ }
+
+ getRepository().addHandler(new CDOServerUtil.RepositoryReadAccessValidator()
+ {
+ EPackage model1Package = getRepository().getPackageRegistry().getEPackage(getModel1Package().getNsURI());
+
+ EClass customerClass = (EClass)model1Package.getEClassifier("Customer");
+
+ EStructuralFeature nameFeature = customerClass.getEStructuralFeature("name");
+
+ @Override
+ protected String validate(ISession session, CDORevision revision)
+ {
+ EClass eClass = revision.getEClass();
+ EPackage ePackage = eClass.getEPackage();
+ assertNotSame("Revision has dynamic package: " + ePackage.getName(), EPackageImpl.class.getName(), ePackage
+ .getClass().getName());
+
+ if (eClass == customerClass)
+ {
+ String name = (String)revision.data().get(nameFeature, 0);
+ if ("Admin".equals(name))
+ {
+ return "Confidential!";
+ }
+ }
+
+ return null;
+ }
+ });
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/res1"));
+ int read = 0;
+
+ try
+ {
+ for (EObject object : resource.getContents())
+ {
+ Customer customer = (Customer)object;
+ System.out.println(customer.getName());
+ ++read;
+ }
+ }
+ catch (Exception ex)
+ {
+ }
+
+ assertEquals(2, read);
+ session.close();
+ }
+
+ private Customer createCustomer(String name)
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName(name);
+ return customer;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java
index 1603f3fa45..50f8c675cd 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java
@@ -1,236 +1,236 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOSavepoint;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class ResourceModificationTrackingTest extends AbstractCDOTest
-{
- public void testResourceModificationTracking() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
- CDOResource resource2 = transaction.createResource(getResourcePath("/my/resource2"));
- Company company = getModel1Factory().createCompany();
- resource1.getContents().add(company);
- transaction.commit();
-
- // Modification tracking is NOT enabled by default
- company.setName("foobar");
- assertEquals(false, resource1.isModified());
- assertEquals(false, resource2.isModified());
- transaction.commit();
-
- // Enable modification tracking in a particular resource
- resource1.setTrackingModification(true);
- company.setName("foobar2");
- assertEquals(true, resource1.isModified());
- assertEquals(false, resource2.isModified());
-
- transaction.commit();
- assertEquals(false, resource1.isModified());
- assertEquals(false, resource2.isModified());
-
- // Perform changes in a resource that does not track changes
- // but is in the same CDOView as one that does have it activated
-
- resource2.getContents().add(getModel1Factory().createCompany());
- assertEquals(false, resource2.isModified());
-
- transaction.commit();
- assertEquals(false, resource2.isModified());
- }
-
- public void testResourceModificationTracking2() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
- transaction.commit();
-
- resource1.setTrackingModification(true);
- assertEquals(false, resource1.isModified());
-
- resource1.getContents().add(company);
- assertEquals(true, resource1.isModified());
-
- resource1.getContents().remove(company);
- assertEquals(true, resource1.isModified());
- }
-
- /**
- * Check Resource modification for NEW Resources
- */
- public void testNewResourceModificationTracking() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
- resource1.setTrackingModification(true);
- assertEquals(false, resource1.isModified());
-
- Company company = getModel1Factory().createCompany();
- company.setName("foobar");
- resource1.getContents().add(company);
- assertEquals(true, resource1.isModified());
-
- transaction.commit();
- assertEquals(false, resource1.isModified());
- }
-
- /**
- * Check Resource modification for NEW Resources
- */
- public void testNewResourceModificationTracking2() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
- resource1.setTrackingModification(true);
- assertEquals(false, resource1.isModified());
-
- resource1.getContents().add(company);
- assertEquals(true, resource1.isModified());
-
- resource1.getContents().remove(company);
- assertEquals(true, resource1.isModified());
- }
-
- /**
- * Check Resource modification for NEW Resources
- */
- public void testIgnoreChangesBeforeTrackingEnablement() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
- resource1.setTrackingModification(false);
- assertEquals(false, resource1.isModified());
-
- Company company = getModel1Factory().createCompany();
- resource1.getContents().add(company);
- resource1.setTrackingModification(true);
- assertEquals(false, resource1.isModified());
-
- company.setName("foobar");
- assertEquals(true, resource1.isModified());
-
- transaction.commit();
- assertEquals(false, resource1.isModified());
- }
-
- /**
- * This test is wrong. Undo is not spec'ed !!!
- * <p>
- * If a NEW Resource gets its content removed, then we shall consider its back to isModified = false
- */
- public void _testNewResourceModificationTrackingUndo() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
- resource1.setTrackingModification(true);
- assertEquals(false, resource1.isModified());
-
- Company company1 = getModel1Factory().createCompany();
- company1.setName("foobar1");
- Company company2 = getModel1Factory().createCompany();
- company2.setName("foobar2");
- resource1.getContents().add(company1);
- resource1.getContents().add(company2);
- assertEquals(true, resource1.isModified());
-
- resource1.getContents().remove(company1);
- assertEquals(true, resource1.isModified());
-
- resource1.getContents().remove(company2);
- assertEquals(false, resource1.isModified());
- }
-
- public void testRollbackOperation() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
- Company company = getModel1Factory().createCompany();
- resource1.getContents().add(company);
- transaction.commit();
-
- // Enable modification tracking
- resource1.setTrackingModification(true);
- company.setName("foobar2");
- assertEquals(true, resource1.isModified());
-
- transaction.rollback();
- assertEquals(false, resource1.isModified());
- }
-
- public void testPartialRollbackOperation() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
- Company company1 = getModel1Factory().createCompany();
- Company company2 = getModel1Factory().createCompany();
- resource1.getContents().add(company1);
- resource1.getContents().add(company2);
- transaction.commit();
-
- // Enable modification tracking
- resource1.setTrackingModification(true);
- CDOSavepoint savePoint1 = transaction.setSavepoint();
- company1.setName("foobar2");
- CDOSavepoint savePoint2 = transaction.setSavepoint();
- company2.setName("foobar2");
- assertEquals(true, resource1.isModified());
-
- savePoint2.rollback();
- assertEquals(true, resource1.isModified());
-
- savePoint1.rollback();
- assertEquals(false, resource1.isModified());
- }
-
- public void testResourceModificationTrackingNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource1"));
- resource.setTrackingModification(true);
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- // Add a Listener
- TestAdapter testAdapter = new TestAdapter();
- resource.eAdapters().add(testAdapter);
- company.setName("foobar");
- assertEquals(Resource.RESOURCE__IS_MODIFIED, testAdapter.getNotifications()[0].getFeatureID(null));
- transaction.commit();
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOSavepoint;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class ResourceModificationTrackingTest extends AbstractCDOTest
+{
+ public void testResourceModificationTracking() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ CDOResource resource2 = transaction.createResource(getResourcePath("/my/resource2"));
+ Company company = getModel1Factory().createCompany();
+ resource1.getContents().add(company);
+ transaction.commit();
+
+ // Modification tracking is NOT enabled by default
+ company.setName("foobar");
+ assertEquals(false, resource1.isModified());
+ assertEquals(false, resource2.isModified());
+ transaction.commit();
+
+ // Enable modification tracking in a particular resource
+ resource1.setTrackingModification(true);
+ company.setName("foobar2");
+ assertEquals(true, resource1.isModified());
+ assertEquals(false, resource2.isModified());
+
+ transaction.commit();
+ assertEquals(false, resource1.isModified());
+ assertEquals(false, resource2.isModified());
+
+ // Perform changes in a resource that does not track changes
+ // but is in the same CDOView as one that does have it activated
+
+ resource2.getContents().add(getModel1Factory().createCompany());
+ assertEquals(false, resource2.isModified());
+
+ transaction.commit();
+ assertEquals(false, resource2.isModified());
+ }
+
+ public void testResourceModificationTracking2() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ transaction.commit();
+
+ resource1.setTrackingModification(true);
+ assertEquals(false, resource1.isModified());
+
+ resource1.getContents().add(company);
+ assertEquals(true, resource1.isModified());
+
+ resource1.getContents().remove(company);
+ assertEquals(true, resource1.isModified());
+ }
+
+ /**
+ * Check Resource modification for NEW Resources
+ */
+ public void testNewResourceModificationTracking() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ resource1.setTrackingModification(true);
+ assertEquals(false, resource1.isModified());
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("foobar");
+ resource1.getContents().add(company);
+ assertEquals(true, resource1.isModified());
+
+ transaction.commit();
+ assertEquals(false, resource1.isModified());
+ }
+
+ /**
+ * Check Resource modification for NEW Resources
+ */
+ public void testNewResourceModificationTracking2() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ resource1.setTrackingModification(true);
+ assertEquals(false, resource1.isModified());
+
+ resource1.getContents().add(company);
+ assertEquals(true, resource1.isModified());
+
+ resource1.getContents().remove(company);
+ assertEquals(true, resource1.isModified());
+ }
+
+ /**
+ * Check Resource modification for NEW Resources
+ */
+ public void testIgnoreChangesBeforeTrackingEnablement() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ resource1.setTrackingModification(false);
+ assertEquals(false, resource1.isModified());
+
+ Company company = getModel1Factory().createCompany();
+ resource1.getContents().add(company);
+ resource1.setTrackingModification(true);
+ assertEquals(false, resource1.isModified());
+
+ company.setName("foobar");
+ assertEquals(true, resource1.isModified());
+
+ transaction.commit();
+ assertEquals(false, resource1.isModified());
+ }
+
+ /**
+ * This test is wrong. Undo is not spec'ed !!!
+ * <p>
+ * If a NEW Resource gets its content removed, then we shall consider its back to isModified = false
+ */
+ public void _testNewResourceModificationTrackingUndo() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ resource1.setTrackingModification(true);
+ assertEquals(false, resource1.isModified());
+
+ Company company1 = getModel1Factory().createCompany();
+ company1.setName("foobar1");
+ Company company2 = getModel1Factory().createCompany();
+ company2.setName("foobar2");
+ resource1.getContents().add(company1);
+ resource1.getContents().add(company2);
+ assertEquals(true, resource1.isModified());
+
+ resource1.getContents().remove(company1);
+ assertEquals(true, resource1.isModified());
+
+ resource1.getContents().remove(company2);
+ assertEquals(false, resource1.isModified());
+ }
+
+ public void testRollbackOperation() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ Company company = getModel1Factory().createCompany();
+ resource1.getContents().add(company);
+ transaction.commit();
+
+ // Enable modification tracking
+ resource1.setTrackingModification(true);
+ company.setName("foobar2");
+ assertEquals(true, resource1.isModified());
+
+ transaction.rollback();
+ assertEquals(false, resource1.isModified());
+ }
+
+ public void testPartialRollbackOperation() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ Company company1 = getModel1Factory().createCompany();
+ Company company2 = getModel1Factory().createCompany();
+ resource1.getContents().add(company1);
+ resource1.getContents().add(company2);
+ transaction.commit();
+
+ // Enable modification tracking
+ resource1.setTrackingModification(true);
+ CDOSavepoint savePoint1 = transaction.setSavepoint();
+ company1.setName("foobar2");
+ CDOSavepoint savePoint2 = transaction.setSavepoint();
+ company2.setName("foobar2");
+ assertEquals(true, resource1.isModified());
+
+ savePoint2.rollback();
+ assertEquals(true, resource1.isModified());
+
+ savePoint1.rollback();
+ assertEquals(false, resource1.isModified());
+ }
+
+ public void testResourceModificationTrackingNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource1"));
+ resource.setTrackingModification(true);
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // Add a Listener
+ TestAdapter testAdapter = new TestAdapter();
+ resource.eAdapters().add(testAdapter);
+ company.setName("foobar");
+ assertEquals(Resource.RESOURCE__IS_MODIFIED, testAdapter.getNotifications()[0].getFeatureID(null));
+ transaction.commit();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaCascadingBranchesTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaCascadingBranchesTest.java
index c123f2a995..f71557aeac 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaCascadingBranchesTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaCascadingBranchesTest.java
@@ -1,302 +1,302 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-
-/**
- * @author Eike Stepper
- */
-@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
-public class RevisionDeltaCascadingBranchesTest extends RevisionDeltaTest
-{
- @Override
- protected void testStoreDelta(ListManipulator manipulator)
- {
- BasicEList<Company> referenceSubSub = new BasicEList<Company>();
- BasicEList<Company> referenceSub = new BasicEList<Company>();
- BasicEList<Company> referenceMain = new BasicEList<Company>();
-
- long timestampBaseSubBranch = 0L;
- long timestampBaseSubSubBranch = 0L;
- int subBranchID = 0;
- int subsubBranchID = 0;
-
- // main branch
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- addCompaniesToList(resource.getContents(), 0, 10);
- addCompaniesToList(referenceMain, 0, 10);
- addCompaniesToList(referenceSub, 0, 10);
- addCompaniesToList(referenceSubSub, 0, 10);
-
- try
- {
- CDOCommitInfo info = transaction.commit();
- assertEquals(mainBranch, info.getBranch());
- timestampBaseSubBranch = info.getTimeStamp();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- // main branch - second batch
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- addCompaniesToList(resource.getContents(), 10, 15);
- addCompaniesToList(referenceMain, 10, 15);
-
- try
- {
- CDOCommitInfo info = transaction.commit();
- assertEquals(mainBranch, info.getBranch());
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- // sub branch - second batch
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOBranch subBranch = mainBranch.createBranch("subBranch", timestampBaseSubBranch);
- subBranchID = subBranch.getID();
-
- CDOTransaction transaction = session.openTransaction(subBranch);
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- addCompaniesToList(resource.getContents(), 10, 15);
- addCompaniesToList(referenceSub, 10, 15);
- addCompaniesToList(referenceSubSub, 10, 15);
-
- try
- {
- CDOCommitInfo info = transaction.commit();
- assertEquals(subBranch, info.getBranch());
- timestampBaseSubSubBranch = info.getTimeStamp();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- // sub branch - third batch
- {
- CDOSession session = openSession();
- CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
- CDOTransaction transaction = session.openTransaction(subBranch);
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- addCompaniesToList(resource.getContents(), 15, 20);
- addCompaniesToList(referenceSub, 15, 20);
-
- try
- {
- CDOCommitInfo info = transaction.commit();
- assertEquals(subBranch, info.getBranch());
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- // sub branch - third batch
- {
- CDOSession session = openSession();
- CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
- CDOBranch subsubBranch = subBranch.createBranch("subsubBranch", timestampBaseSubSubBranch);
- subsubBranchID = subsubBranch.getID();
-
- CDOTransaction transaction = session.openTransaction(subsubBranch);
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- addCompaniesToList(resource.getContents(), 15, 20);
- addCompaniesToList(referenceSubSub, 15, 20);
-
- try
- {
- CDOCommitInfo info = transaction.commit();
- assertEquals(subsubBranch, info.getBranch());
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- // do manipulations in sub branch
- {
- CDOSession session = openSession();
- CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
- CDOTransaction transaction = session.openTransaction(subBranch);
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- manipulator.doManipulations(resource.getContents());
- manipulator.doManipulations(referenceSub);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- // do manipulations in sub-sub branch
- {
- CDOSession session = openSession();
- CDOBranch subsubBranch = session.getBranchManager().getBranch(subsubBranchID);
- CDOTransaction transaction = session.openTransaction(subsubBranch);
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- manipulator.doManipulations(resource.getContents());
- manipulator.doManipulations(referenceSubSub);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOBranch subsubBranch = session.getBranchManager().getBranch(subsubBranchID);
- CDOView view = session.openView(subsubBranch);
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- assertEquals(referenceSubSub.size(), resource.getContents().size());
-
- for (int i = 0; i < referenceSubSub.size(); i++)
- {
- assertEquals(referenceSubSub.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
- }
-
- view.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
- CDOView view = session.openView(subBranch);
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- assertEquals(referenceSub.size(), resource.getContents().size());
-
- for (int i = 0; i < referenceSub.size(); i++)
- {
- assertEquals(referenceSub.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
- }
-
- view.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- assertEquals(referenceMain.size(), resource.getContents().size());
-
- for (int i = 0; i < referenceMain.size(); i++)
- {
- assertEquals(referenceMain.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
- }
-
- view.close();
- session.close();
- }
- }
-
- @SuppressWarnings("unchecked")
- protected void addCompaniesToList(@SuppressWarnings("rawtypes") EList list, int from, int to)
- {
- for (int i = from; i < to; i++)
- {
- String name = "company " + i;
- Company company = getModel1Factory().createCompany();
- company.setName(name);
- list.add(company);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * @author Eike Stepper
+ */
+@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+public class RevisionDeltaCascadingBranchesTest extends RevisionDeltaTest
+{
+ @Override
+ protected void testStoreDelta(ListManipulator manipulator)
+ {
+ BasicEList<Company> referenceSubSub = new BasicEList<Company>();
+ BasicEList<Company> referenceSub = new BasicEList<Company>();
+ BasicEList<Company> referenceMain = new BasicEList<Company>();
+
+ long timestampBaseSubBranch = 0L;
+ long timestampBaseSubSubBranch = 0L;
+ int subBranchID = 0;
+ int subsubBranchID = 0;
+
+ // main branch
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ addCompaniesToList(resource.getContents(), 0, 10);
+ addCompaniesToList(referenceMain, 0, 10);
+ addCompaniesToList(referenceSub, 0, 10);
+ addCompaniesToList(referenceSubSub, 0, 10);
+
+ try
+ {
+ CDOCommitInfo info = transaction.commit();
+ assertEquals(mainBranch, info.getBranch());
+ timestampBaseSubBranch = info.getTimeStamp();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ // main branch - second batch
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ addCompaniesToList(resource.getContents(), 10, 15);
+ addCompaniesToList(referenceMain, 10, 15);
+
+ try
+ {
+ CDOCommitInfo info = transaction.commit();
+ assertEquals(mainBranch, info.getBranch());
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ // sub branch - second batch
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", timestampBaseSubBranch);
+ subBranchID = subBranch.getID();
+
+ CDOTransaction transaction = session.openTransaction(subBranch);
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ addCompaniesToList(resource.getContents(), 10, 15);
+ addCompaniesToList(referenceSub, 10, 15);
+ addCompaniesToList(referenceSubSub, 10, 15);
+
+ try
+ {
+ CDOCommitInfo info = transaction.commit();
+ assertEquals(subBranch, info.getBranch());
+ timestampBaseSubSubBranch = info.getTimeStamp();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ // sub branch - third batch
+ {
+ CDOSession session = openSession();
+ CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
+ CDOTransaction transaction = session.openTransaction(subBranch);
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ addCompaniesToList(resource.getContents(), 15, 20);
+ addCompaniesToList(referenceSub, 15, 20);
+
+ try
+ {
+ CDOCommitInfo info = transaction.commit();
+ assertEquals(subBranch, info.getBranch());
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ // sub branch - third batch
+ {
+ CDOSession session = openSession();
+ CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
+ CDOBranch subsubBranch = subBranch.createBranch("subsubBranch", timestampBaseSubSubBranch);
+ subsubBranchID = subsubBranch.getID();
+
+ CDOTransaction transaction = session.openTransaction(subsubBranch);
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ addCompaniesToList(resource.getContents(), 15, 20);
+ addCompaniesToList(referenceSubSub, 15, 20);
+
+ try
+ {
+ CDOCommitInfo info = transaction.commit();
+ assertEquals(subsubBranch, info.getBranch());
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ // do manipulations in sub branch
+ {
+ CDOSession session = openSession();
+ CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
+ CDOTransaction transaction = session.openTransaction(subBranch);
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ manipulator.doManipulations(resource.getContents());
+ manipulator.doManipulations(referenceSub);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ // do manipulations in sub-sub branch
+ {
+ CDOSession session = openSession();
+ CDOBranch subsubBranch = session.getBranchManager().getBranch(subsubBranchID);
+ CDOTransaction transaction = session.openTransaction(subsubBranch);
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ manipulator.doManipulations(resource.getContents());
+ manipulator.doManipulations(referenceSubSub);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOBranch subsubBranch = session.getBranchManager().getBranch(subsubBranchID);
+ CDOView view = session.openView(subsubBranch);
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ assertEquals(referenceSubSub.size(), resource.getContents().size());
+
+ for (int i = 0; i < referenceSubSub.size(); i++)
+ {
+ assertEquals(referenceSubSub.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
+ }
+
+ view.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
+ CDOView view = session.openView(subBranch);
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ assertEquals(referenceSub.size(), resource.getContents().size());
+
+ for (int i = 0; i < referenceSub.size(); i++)
+ {
+ assertEquals(referenceSub.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
+ }
+
+ view.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ assertEquals(referenceMain.size(), resource.getContents().size());
+
+ for (int i = 0; i < referenceMain.size(); i++)
+ {
+ assertEquals(referenceMain.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
+ }
+
+ view.close();
+ session.close();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void addCompaniesToList(@SuppressWarnings("rawtypes") EList list, int from, int to)
+ {
+ for (int i = from; i < to; i++)
+ {
+ String name = "company " + i;
+ Company company = getModel1Factory().createCompany();
+ company.setName(name);
+ list.add(company);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaInBranchTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaInBranchTest.java
index 77100bfad3..416032fa69 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaInBranchTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaInBranchTest.java
@@ -1,201 +1,201 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-
-/**
- * @author Eike Stepper
- */
-@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
-public class RevisionDeltaInBranchTest extends RevisionDeltaTest
-{
- @Override
- protected void testStoreDelta(ListManipulator manipulator)
- {
- BasicEList<Company> referenceSub = new BasicEList<Company>();
- BasicEList<Company> referenceMain = new BasicEList<Company>();
-
- long timestampBaseBranch = 0L;
- int subBranchID = 0;
-
- // main branch
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- addCompaniesToList(resource.getContents(), 0, 10);
- addCompaniesToList(referenceMain, 0, 10);
- addCompaniesToList(referenceSub, 0, 10);
-
- try
- {
- CDOCommitInfo info = transaction.commit();
- assertEquals(mainBranch, info.getBranch());
- timestampBaseBranch = info.getTimeStamp();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- // main branch - second batch
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- addCompaniesToList(resource.getContents(), 10, 15);
- addCompaniesToList(referenceMain, 10, 15);
-
- try
- {
- CDOCommitInfo info = transaction.commit();
- assertEquals(mainBranch, info.getBranch());
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- // sub branch - second batch
- {
- CDOSession session = openSession();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOBranch subBranch = mainBranch.createBranch("subBranch", timestampBaseBranch);
- subBranchID = subBranch.getID();
-
- CDOTransaction transaction = session.openTransaction(subBranch);
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- addCompaniesToList(resource.getContents(), 10, 20);
- addCompaniesToList(referenceSub, 10, 20);
-
- try
- {
- CDOCommitInfo info = transaction.commit();
- assertEquals(subBranch, info.getBranch());
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- // do manipulations in branch
- {
- CDOSession session = openSession();
- CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
- CDOTransaction transaction = session.openTransaction(subBranch);
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- manipulator.doManipulations(resource.getContents());
- manipulator.doManipulations(referenceSub);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
- CDOView view = session.openView(subBranch);
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- assertEquals(referenceSub.size(), resource.getContents().size());
-
- for (int i = 0; i < referenceSub.size(); i++)
- {
- assertEquals(referenceSub.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
- }
-
- view.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- assertEquals(referenceMain.size(), resource.getContents().size());
-
- for (int i = 0; i < referenceMain.size(); i++)
- {
- assertEquals(referenceMain.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
- }
-
- view.close();
- session.close();
- }
- }
-
- @SuppressWarnings("unchecked")
- protected void addCompaniesToList(@SuppressWarnings("rawtypes") EList list, int from, int to)
- {
- for (int i = from; i < to; i++)
- {
- String name = "company " + i;
- Company company = getModel1Factory().createCompany();
- company.setName(name);
- list.add(company);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * @author Eike Stepper
+ */
+@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+public class RevisionDeltaInBranchTest extends RevisionDeltaTest
+{
+ @Override
+ protected void testStoreDelta(ListManipulator manipulator)
+ {
+ BasicEList<Company> referenceSub = new BasicEList<Company>();
+ BasicEList<Company> referenceMain = new BasicEList<Company>();
+
+ long timestampBaseBranch = 0L;
+ int subBranchID = 0;
+
+ // main branch
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ addCompaniesToList(resource.getContents(), 0, 10);
+ addCompaniesToList(referenceMain, 0, 10);
+ addCompaniesToList(referenceSub, 0, 10);
+
+ try
+ {
+ CDOCommitInfo info = transaction.commit();
+ assertEquals(mainBranch, info.getBranch());
+ timestampBaseBranch = info.getTimeStamp();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ // main branch - second batch
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ addCompaniesToList(resource.getContents(), 10, 15);
+ addCompaniesToList(referenceMain, 10, 15);
+
+ try
+ {
+ CDOCommitInfo info = transaction.commit();
+ assertEquals(mainBranch, info.getBranch());
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ // sub branch - second batch
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOBranch subBranch = mainBranch.createBranch("subBranch", timestampBaseBranch);
+ subBranchID = subBranch.getID();
+
+ CDOTransaction transaction = session.openTransaction(subBranch);
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ addCompaniesToList(resource.getContents(), 10, 20);
+ addCompaniesToList(referenceSub, 10, 20);
+
+ try
+ {
+ CDOCommitInfo info = transaction.commit();
+ assertEquals(subBranch, info.getBranch());
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ // do manipulations in branch
+ {
+ CDOSession session = openSession();
+ CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
+ CDOTransaction transaction = session.openTransaction(subBranch);
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ manipulator.doManipulations(resource.getContents());
+ manipulator.doManipulations(referenceSub);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOBranch subBranch = session.getBranchManager().getBranch(subBranchID);
+ CDOView view = session.openView(subBranch);
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ assertEquals(referenceSub.size(), resource.getContents().size());
+
+ for (int i = 0; i < referenceSub.size(); i++)
+ {
+ assertEquals(referenceSub.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
+ }
+
+ view.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ assertEquals(referenceMain.size(), resource.getContents().size());
+
+ for (int i = 0; i < referenceMain.size(); i++)
+ {
+ assertEquals(referenceMain.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
+ }
+
+ view.close();
+ session.close();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void addCompaniesToList(@SuppressWarnings("rawtypes") EList list, int from, int to)
+ {
+ for (int i = from; i < to; i++)
+ {
+ String name = "company " + i;
+ Company company = getModel1Factory().createCompany();
+ company.setName(name);
+ list.add(company);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java
index 9185c0dc17..0fb046cbda 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java
@@ -1,754 +1,754 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOListFeatureDeltaImpl;
-import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.tests.model3.NodeD;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-
-/**
- * See bug 201266
- *
- * @author Simon McDuff
- */
-public class RevisionDeltaTest extends AbstractCDOTest
-{
- public RevisionDeltaTest()
- {
- }
-
- public void testBasicRevisionDelta() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
-
- Company company1 = getModel1Factory().createCompany();
- Category category1 = getModel1Factory().createCategory();
-
- resource1.getContents().add(company1);
- company1.getCategories().add(category1);
-
- company1.setName("TEST");
- InternalCDORevision rev1 = getCopyCDORevision(company1);
-
- // Test simple attributes
- company1.setName("TEST3");
- InternalCDORevision rev2 = getCopyCDORevision(company1);
-
- CDORevisionDelta revisionDelta = rev2.compare(rev1);
- assertEquals(1, revisionDelta.getFeatureDeltas().size());
- CDOSetFeatureDelta setDelta = (CDOSetFeatureDelta)revisionDelta.getFeatureDeltas().get(0);
- assertEquals("TEST3", setDelta.getValue());
-
- // Test List clear
- company1.getCategories().clear();
- InternalCDORevision rev3 = getCopyCDORevision(company1);
-
- CDORevisionDelta revisionDelta3 = rev3.compare(rev2);
- assertEquals(1, revisionDelta3.getFeatureDeltas().size());
- CDOListFeatureDeltaImpl delta3List = (CDOListFeatureDeltaImpl)revisionDelta3.getFeatureDeltas().get(0);
-
- assertEquals(1, delta3List.getListChanges().size());
- assertEquals(true, delta3List.getListChanges().get(0) instanceof CDOClearFeatureDelta);
-
- // Test List Add
- for (int i = 0; i < 5; i++)
- {
- Category category = getModel1Factory().createCategory();
- company1.getCategories().add(category);
- }
-
- InternalCDORevision rev4 = getCopyCDORevision(company1);
-
- CDORevisionDelta revisionDelta4 = rev4.compare(rev3);
- assertEquals(1, revisionDelta4.getFeatureDeltas().size());
- CDOListFeatureDeltaImpl delta4List = (CDOListFeatureDeltaImpl)revisionDelta4.getFeatureDeltas().get(0);
-
- assertEquals(5, delta4List.getListChanges().size());
- assertEquals(true, delta4List.getListChanges().get(0) instanceof CDOAddFeatureDelta);
- transaction.rollback();
- transaction.close();
- session.close();
- }
-
- /**
- * Sending deltas doesn't adjust CDOIDs
- * <p>
- * See bug 214374
- */
- public void testBugzilla214374() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- resource.getContents().add(salesOrder);
- transaction.commit();
-
- Customer customer = getModel1Factory().createCustomer();
- salesOrder.setCustomer(customer);
-
- resource.getContents().add(customer);
- transaction.commit();
- transaction.close();
-
- CDOTransaction transaction2 = session.openTransaction();
- SalesOrder salesOrder2 = (SalesOrder)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(salesOrder)
- .cdoID(), true));
- CDORevision salesRevision = CDOUtil.getCDOObject(salesOrder2).cdoRevision();
- EStructuralFeature customerFeature = getModel1Package().getSalesOrder_Customer();
-
- Object value = salesRevision.data().get(customerFeature, 0);
- assertEquals(true, value instanceof CDOID);
- transaction2.close();
- session.close();
- }
-
- /**
- * CDOView.getRevision() does not work for transactions/dirty objects (INVALID)
- * <p>
- * See bug 214431
- */
- public void testBugzilla214431() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- resource.getContents().add(salesOrder);
- transaction.commit();
-
- salesOrder.setId(4711);
- assertNotSame(CDOUtil.getCDOObject(salesOrder).cdoRevision(),
- ((InternalCDOTransaction)transaction).getRevision(CDOUtil.getCDOObject(salesOrder).cdoID(), true));
- assertEquals(CDOUtil.getCDOObject(salesOrder).cdoRevision(),
- transaction.getDirtyObjects().get(CDOUtil.getCDOObject(salesOrder).cdoID()).cdoRevision());
- transaction.close();
- session.close();
- }
-
- /**
- * CDOView.getRevision() does not work for transactions/dirty objects (INVALID)
- * <p>
- * See bug 214374
- */
- public void testBugzilla214374_HandleClear() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- resource.getContents().add(salesOrder);
- customer.getSalesOrders().add(salesOrder);
- customer.getSalesOrders().add(salesOrder);
- transaction.commit();
-
- salesOrder = getModel1Factory().createSalesOrder();
- customer = getModel1Factory().createCustomer();
- resource.getContents().add(salesOrder);
- resource.getContents().add(customer);
- salesOrder.setCustomer(customer);
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- /**
- * java.lang.IllegalStateException with MEMStore
- * <p>
- * See bug 243282
- */
- public void testBugzilla243282_Exception() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
-
- transaction.commit();
-
- InternalCDORevisionManager revisionManager = getRepository().getRevisionManager();
- CDORevision revision = CDOUtil.getCDOObject(customer).cdoRevision();
- revisionManager.getCache().removeRevision(revision.getID(), revision);
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- resource.getContents().add(salesOrder);
- customer.getSalesOrders().add(salesOrder);
-
- IStore store = getRepository().getStore();
- if (store instanceof MEMStore)
- {
- MEMStore memStore = (MEMStore)store;
- CDORevisionUtil.dumpAllRevisions(memStore.getAllRevisions(), IOUtil.OUT());
- }
-
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- @SuppressWarnings("unused")
- public void testDetachWithXRef() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- NodeD a = getModel3Factory().createNodeD();
- NodeD b = getModel3Factory().createNodeD();
- NodeD c = getModel3Factory().createNodeD();
-
- a.getChildren().add(b);
- c.getOtherNodes().add(b);
-
- resource.getContents().add(a);
- resource.getContents().add(c);
-
- if (true)
- {
- transaction.commit();
- transaction.close();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/test1"));
- }
-
- // Start test logic
-
- a = (NodeD)resource.getContents().get(0);
- b = a.getChildren().get(0);
- c = (NodeD)resource.getContents().get(1);
-
- a.getChildren().remove(0);
- Object[] cB = c.getOtherNodes().toArray();
-
- CDORevisionDelta aDelta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(a).cdoID());
- CDORevisionDelta cDelta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(c).cdoID());
-
- session.close();
- }
-
- @SuppressWarnings("unused")
- public void testDetachWithXRef_Remove() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- NodeD a = getModel3Factory().createNodeD();
- NodeD b = getModel3Factory().createNodeD();
- NodeD c = getModel3Factory().createNodeD();
-
- a.getChildren().add(b);
- c.getOtherNodes().add(b);
-
- resource.getContents().add(a);
- resource.getContents().add(c);
-
- if (true)
- {
- transaction.commit();
- transaction.close();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/test1"));
- }
-
- // Start test logic
-
- a = (NodeD)resource.getContents().get(0);
- b = a.getChildren().get(0);
- c = (NodeD)resource.getContents().get(1);
-
- a.getChildren().remove(0);
- c.getOtherNodes().remove(0);
-
- Object[] cB = c.getOtherNodes().toArray();
-
- CDORevisionDelta aDelta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(a).cdoID());
- CDORevisionDelta cDelta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(c).cdoID());
-
- CDOListFeatureDelta list = (CDOListFeatureDelta)cDelta.getFeatureDelta(getModel3Package().getNodeD_OtherNodes());
- assertEquals(1, list.getListChanges().size());
-
- session.close();
- }
-
- public void testListRemoveMiddle()
- {
- testStoreDelta(new ListManipulator()
- {
- public void doManipulations(EList<?> list)
- {
- list.remove(5);
- }
- });
- }
-
- public void testListRemoveLast()
- {
- testStoreDelta(new ListManipulator()
- {
- public void doManipulations(EList<?> list)
- {
- list.remove(list.size() - 1);
- }
- });
- }
-
- public void testListRemoveFirst()
- {
- testStoreDelta(new ListManipulator()
- {
- public void doManipulations(EList<?> list)
- {
- list.remove(0);
- }
- });
- }
-
- public void testListSimpleMove()
- {
- testStoreDelta(new ListManipulator()
- {
- public void doManipulations(EList<?> list)
- {
- list.move(2, 7);
- }
- });
- }
-
- public void testListMoveToLast()
- {
- testStoreDelta(new ListManipulator()
- {
- public void doManipulations(EList<?> list)
- {
- list.move(2, list.size() - 1);
- }
- });
- }
-
- public void testListMoveToFirst()
- {
- testStoreDelta(new ListManipulator()
- {
- public void doManipulations(EList<?> list)
- {
- list.move(2, 0);
- }
- });
- }
-
- public void testListTwoIndependentMoves()
- {
- testStoreDelta(new ListManipulator()
- {
- public void doManipulations(EList<?> list)
- {
- list.move(1, 3);
- list.move(7, 4);
- }
- });
- }
-
- public void testListTwoIntersectingMoves()
- {
- testStoreDelta(new ListManipulator()
- {
- public void doManipulations(EList<?> list)
- {
- list.move(1, 7);
- list.move(3, 4);
- }
- });
- }
-
- public void testListInsertFirst()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry");
- l.add(0, company);
- }
- });
- }
-
- public void testListInsertMiddle()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry");
- l.add(5, company);
- }
- });
- }
-
- public void testListInsertLast()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry");
- l.add(company);
- }
- });
- }
-
- public void testListMultipleOpsWithClear()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
-
- l.remove(4);
- l.remove(7);
-
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry 1");
- l.add(5, company);
-
- l.move(1, 2);
- l.move(7, 0);
-
- l.clear();
-
- company = getModel1Factory().createCompany();
- company.setName("NewEntry 2");
- l.add(company);
-
- company = getModel1Factory().createCompany();
- company.setName("NewEntry 3");
- l.add(company);
-
- company = getModel1Factory().createCompany();
- company.setName("NewEntry 4");
- l.add(0, company);
-
- l.move(1, 2);
- }
- });
- }
-
- public void testListMultipleOps()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
-
- l.remove(7);
-
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry 1");
- l.add(5, company);
-
- l.move(1, 2);
-
- company = getModel1Factory().createCompany();
- company.setName("NewEntry 2");
- l.add(company);
-
- l.move(7, 0);
-
- company = getModel1Factory().createCompany();
- company.setName("NewEntry 3");
- l.add(company);
-
- l.remove(4);
-
- company = getModel1Factory().createCompany();
- company.setName("NewEntry 4");
- l.add(0, company);
-
- l.move(1, 2);
- }
- });
- }
-
- public void testMultipleInserts()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry 1");
- l.add(7, company);
- company = getModel1Factory().createCompany();
- company.setName("NewEntry 2");
- l.add(12, company);
- }
- });
- }
-
- public void testInsertAndRemove()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry 1");
- l.add(7, company);
- l.remove(12);
- }
- });
- }
-
- public void testInsertAndMove()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry 1");
- l.add(7, company);
- l.move(12, 7);
- }
- });
- }
-
- public void testMoveAndDelete()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- l.move(12, 7);
- l.remove(12);
- }
- });
- }
-
- public void testInsertAndMoveAndRemove()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry 1");
- l.add(7, company);
- l.move(12, 7);
- l.remove(12);
- }
- });
- }
-
- public void testInsertAndSet()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry 1");
- l.add(7, company);
- Company company2 = getModel1Factory().createCompany();
- company2.setName("NewEntry 2");
- l.set(7, company2);
- l.add(19, company); // <- needed because the set operation makes the company a dangling reference
- }
- });
- }
-
- public void testSetAndRemove()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- Company company = getModel1Factory().createCompany();
- company.setName("NewEntry 1");
- Company oldCompany = l.get(7);
- l.set(7, company);
- l.add(19, oldCompany);
- l.remove(7); // <- needed because the set operation makes the company a dangling reference
- }
- });
- }
-
- public void testMultipleRemoves()
- {
- testStoreDelta(new ListManipulator()
- {
- @SuppressWarnings("unchecked")
- public void doManipulations(EList<?> list)
- {
- EList<Company> l = (EList<Company>)list;
- l.remove(7);
- l.remove(12);
- }
- });
- }
-
- private InternalCDORevision getCopyCDORevision(Object object)
- {
- return (InternalCDORevision)CDOUtil.getCDOObject((EObject)object).cdoRevision().copy();
- }
-
- protected void testStoreDelta(ListManipulator manipulator)
- {
- BasicEList<Company> reference = new BasicEList<Company>();
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- for (int i = 0; i < 20; i++)
- {
- String name = "company " + i;
- Company company = getModel1Factory().createCompany();
- company.setName(name);
- resource.getContents().add(company);
-
- company = getModel1Factory().createCompany();
- company.setName(name);
- reference.add(company);
- }
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- manipulator.doManipulations(resource.getContents());
- manipulator.doManipulations(reference);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- assertEquals(reference.size(), resource.getContents().size());
-
- for (int i = 0; i < reference.size(); i++)
- {
- assertEquals(reference.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
- }
-
- view.close();
- session.close();
- }
- }
-
- /**
- * @author Simon McDuff
- */
- protected static interface ListManipulator
- {
- public void doManipulations(EList<?> list);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOListFeatureDeltaImpl;
+import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.tests.model3.NodeD;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+
+/**
+ * See bug 201266
+ *
+ * @author Simon McDuff
+ */
+public class RevisionDeltaTest extends AbstractCDOTest
+{
+ public RevisionDeltaTest()
+ {
+ }
+
+ public void testBasicRevisionDelta() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+
+ Company company1 = getModel1Factory().createCompany();
+ Category category1 = getModel1Factory().createCategory();
+
+ resource1.getContents().add(company1);
+ company1.getCategories().add(category1);
+
+ company1.setName("TEST");
+ InternalCDORevision rev1 = getCopyCDORevision(company1);
+
+ // Test simple attributes
+ company1.setName("TEST3");
+ InternalCDORevision rev2 = getCopyCDORevision(company1);
+
+ CDORevisionDelta revisionDelta = rev2.compare(rev1);
+ assertEquals(1, revisionDelta.getFeatureDeltas().size());
+ CDOSetFeatureDelta setDelta = (CDOSetFeatureDelta)revisionDelta.getFeatureDeltas().get(0);
+ assertEquals("TEST3", setDelta.getValue());
+
+ // Test List clear
+ company1.getCategories().clear();
+ InternalCDORevision rev3 = getCopyCDORevision(company1);
+
+ CDORevisionDelta revisionDelta3 = rev3.compare(rev2);
+ assertEquals(1, revisionDelta3.getFeatureDeltas().size());
+ CDOListFeatureDeltaImpl delta3List = (CDOListFeatureDeltaImpl)revisionDelta3.getFeatureDeltas().get(0);
+
+ assertEquals(1, delta3List.getListChanges().size());
+ assertEquals(true, delta3List.getListChanges().get(0) instanceof CDOClearFeatureDelta);
+
+ // Test List Add
+ for (int i = 0; i < 5; i++)
+ {
+ Category category = getModel1Factory().createCategory();
+ company1.getCategories().add(category);
+ }
+
+ InternalCDORevision rev4 = getCopyCDORevision(company1);
+
+ CDORevisionDelta revisionDelta4 = rev4.compare(rev3);
+ assertEquals(1, revisionDelta4.getFeatureDeltas().size());
+ CDOListFeatureDeltaImpl delta4List = (CDOListFeatureDeltaImpl)revisionDelta4.getFeatureDeltas().get(0);
+
+ assertEquals(5, delta4List.getListChanges().size());
+ assertEquals(true, delta4List.getListChanges().get(0) instanceof CDOAddFeatureDelta);
+ transaction.rollback();
+ transaction.close();
+ session.close();
+ }
+
+ /**
+ * Sending deltas doesn't adjust CDOIDs
+ * <p>
+ * See bug 214374
+ */
+ public void testBugzilla214374() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ resource.getContents().add(salesOrder);
+ transaction.commit();
+
+ Customer customer = getModel1Factory().createCustomer();
+ salesOrder.setCustomer(customer);
+
+ resource.getContents().add(customer);
+ transaction.commit();
+ transaction.close();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ SalesOrder salesOrder2 = (SalesOrder)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(salesOrder)
+ .cdoID(), true));
+ CDORevision salesRevision = CDOUtil.getCDOObject(salesOrder2).cdoRevision();
+ EStructuralFeature customerFeature = getModel1Package().getSalesOrder_Customer();
+
+ Object value = salesRevision.data().get(customerFeature, 0);
+ assertEquals(true, value instanceof CDOID);
+ transaction2.close();
+ session.close();
+ }
+
+ /**
+ * CDOView.getRevision() does not work for transactions/dirty objects (INVALID)
+ * <p>
+ * See bug 214431
+ */
+ public void testBugzilla214431() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ resource.getContents().add(salesOrder);
+ transaction.commit();
+
+ salesOrder.setId(4711);
+ assertNotSame(CDOUtil.getCDOObject(salesOrder).cdoRevision(),
+ ((InternalCDOTransaction)transaction).getRevision(CDOUtil.getCDOObject(salesOrder).cdoID(), true));
+ assertEquals(CDOUtil.getCDOObject(salesOrder).cdoRevision(),
+ transaction.getDirtyObjects().get(CDOUtil.getCDOObject(salesOrder).cdoID()).cdoRevision());
+ transaction.close();
+ session.close();
+ }
+
+ /**
+ * CDOView.getRevision() does not work for transactions/dirty objects (INVALID)
+ * <p>
+ * See bug 214374
+ */
+ public void testBugzilla214374_HandleClear() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ resource.getContents().add(salesOrder);
+ customer.getSalesOrders().add(salesOrder);
+ customer.getSalesOrders().add(salesOrder);
+ transaction.commit();
+
+ salesOrder = getModel1Factory().createSalesOrder();
+ customer = getModel1Factory().createCustomer();
+ resource.getContents().add(salesOrder);
+ resource.getContents().add(customer);
+ salesOrder.setCustomer(customer);
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ /**
+ * java.lang.IllegalStateException with MEMStore
+ * <p>
+ * See bug 243282
+ */
+ public void testBugzilla243282_Exception() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+
+ transaction.commit();
+
+ InternalCDORevisionManager revisionManager = getRepository().getRevisionManager();
+ CDORevision revision = CDOUtil.getCDOObject(customer).cdoRevision();
+ revisionManager.getCache().removeRevision(revision.getID(), revision);
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ resource.getContents().add(salesOrder);
+ customer.getSalesOrders().add(salesOrder);
+
+ IStore store = getRepository().getStore();
+ if (store instanceof MEMStore)
+ {
+ MEMStore memStore = (MEMStore)store;
+ CDORevisionUtil.dumpAllRevisions(memStore.getAllRevisions(), IOUtil.OUT());
+ }
+
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ @SuppressWarnings("unused")
+ public void testDetachWithXRef() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ NodeD a = getModel3Factory().createNodeD();
+ NodeD b = getModel3Factory().createNodeD();
+ NodeD c = getModel3Factory().createNodeD();
+
+ a.getChildren().add(b);
+ c.getOtherNodes().add(b);
+
+ resource.getContents().add(a);
+ resource.getContents().add(c);
+
+ if (true)
+ {
+ transaction.commit();
+ transaction.close();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/test1"));
+ }
+
+ // Start test logic
+
+ a = (NodeD)resource.getContents().get(0);
+ b = a.getChildren().get(0);
+ c = (NodeD)resource.getContents().get(1);
+
+ a.getChildren().remove(0);
+ Object[] cB = c.getOtherNodes().toArray();
+
+ CDORevisionDelta aDelta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(a).cdoID());
+ CDORevisionDelta cDelta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(c).cdoID());
+
+ session.close();
+ }
+
+ @SuppressWarnings("unused")
+ public void testDetachWithXRef_Remove() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ NodeD a = getModel3Factory().createNodeD();
+ NodeD b = getModel3Factory().createNodeD();
+ NodeD c = getModel3Factory().createNodeD();
+
+ a.getChildren().add(b);
+ c.getOtherNodes().add(b);
+
+ resource.getContents().add(a);
+ resource.getContents().add(c);
+
+ if (true)
+ {
+ transaction.commit();
+ transaction.close();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/test1"));
+ }
+
+ // Start test logic
+
+ a = (NodeD)resource.getContents().get(0);
+ b = a.getChildren().get(0);
+ c = (NodeD)resource.getContents().get(1);
+
+ a.getChildren().remove(0);
+ c.getOtherNodes().remove(0);
+
+ Object[] cB = c.getOtherNodes().toArray();
+
+ CDORevisionDelta aDelta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(a).cdoID());
+ CDORevisionDelta cDelta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(c).cdoID());
+
+ CDOListFeatureDelta list = (CDOListFeatureDelta)cDelta.getFeatureDelta(getModel3Package().getNodeD_OtherNodes());
+ assertEquals(1, list.getListChanges().size());
+
+ session.close();
+ }
+
+ public void testListRemoveMiddle()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ public void doManipulations(EList<?> list)
+ {
+ list.remove(5);
+ }
+ });
+ }
+
+ public void testListRemoveLast()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ public void doManipulations(EList<?> list)
+ {
+ list.remove(list.size() - 1);
+ }
+ });
+ }
+
+ public void testListRemoveFirst()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ public void doManipulations(EList<?> list)
+ {
+ list.remove(0);
+ }
+ });
+ }
+
+ public void testListSimpleMove()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ public void doManipulations(EList<?> list)
+ {
+ list.move(2, 7);
+ }
+ });
+ }
+
+ public void testListMoveToLast()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ public void doManipulations(EList<?> list)
+ {
+ list.move(2, list.size() - 1);
+ }
+ });
+ }
+
+ public void testListMoveToFirst()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ public void doManipulations(EList<?> list)
+ {
+ list.move(2, 0);
+ }
+ });
+ }
+
+ public void testListTwoIndependentMoves()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ public void doManipulations(EList<?> list)
+ {
+ list.move(1, 3);
+ list.move(7, 4);
+ }
+ });
+ }
+
+ public void testListTwoIntersectingMoves()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ public void doManipulations(EList<?> list)
+ {
+ list.move(1, 7);
+ list.move(3, 4);
+ }
+ });
+ }
+
+ public void testListInsertFirst()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry");
+ l.add(0, company);
+ }
+ });
+ }
+
+ public void testListInsertMiddle()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry");
+ l.add(5, company);
+ }
+ });
+ }
+
+ public void testListInsertLast()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry");
+ l.add(company);
+ }
+ });
+ }
+
+ public void testListMultipleOpsWithClear()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+
+ l.remove(4);
+ l.remove(7);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry 1");
+ l.add(5, company);
+
+ l.move(1, 2);
+ l.move(7, 0);
+
+ l.clear();
+
+ company = getModel1Factory().createCompany();
+ company.setName("NewEntry 2");
+ l.add(company);
+
+ company = getModel1Factory().createCompany();
+ company.setName("NewEntry 3");
+ l.add(company);
+
+ company = getModel1Factory().createCompany();
+ company.setName("NewEntry 4");
+ l.add(0, company);
+
+ l.move(1, 2);
+ }
+ });
+ }
+
+ public void testListMultipleOps()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+
+ l.remove(7);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry 1");
+ l.add(5, company);
+
+ l.move(1, 2);
+
+ company = getModel1Factory().createCompany();
+ company.setName("NewEntry 2");
+ l.add(company);
+
+ l.move(7, 0);
+
+ company = getModel1Factory().createCompany();
+ company.setName("NewEntry 3");
+ l.add(company);
+
+ l.remove(4);
+
+ company = getModel1Factory().createCompany();
+ company.setName("NewEntry 4");
+ l.add(0, company);
+
+ l.move(1, 2);
+ }
+ });
+ }
+
+ public void testMultipleInserts()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry 1");
+ l.add(7, company);
+ company = getModel1Factory().createCompany();
+ company.setName("NewEntry 2");
+ l.add(12, company);
+ }
+ });
+ }
+
+ public void testInsertAndRemove()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry 1");
+ l.add(7, company);
+ l.remove(12);
+ }
+ });
+ }
+
+ public void testInsertAndMove()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry 1");
+ l.add(7, company);
+ l.move(12, 7);
+ }
+ });
+ }
+
+ public void testMoveAndDelete()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ l.move(12, 7);
+ l.remove(12);
+ }
+ });
+ }
+
+ public void testInsertAndMoveAndRemove()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry 1");
+ l.add(7, company);
+ l.move(12, 7);
+ l.remove(12);
+ }
+ });
+ }
+
+ public void testInsertAndSet()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry 1");
+ l.add(7, company);
+ Company company2 = getModel1Factory().createCompany();
+ company2.setName("NewEntry 2");
+ l.set(7, company2);
+ l.add(19, company); // <- needed because the set operation makes the company a dangling reference
+ }
+ });
+ }
+
+ public void testSetAndRemove()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ Company company = getModel1Factory().createCompany();
+ company.setName("NewEntry 1");
+ Company oldCompany = l.get(7);
+ l.set(7, company);
+ l.add(19, oldCompany);
+ l.remove(7); // <- needed because the set operation makes the company a dangling reference
+ }
+ });
+ }
+
+ public void testMultipleRemoves()
+ {
+ testStoreDelta(new ListManipulator()
+ {
+ @SuppressWarnings("unchecked")
+ public void doManipulations(EList<?> list)
+ {
+ EList<Company> l = (EList<Company>)list;
+ l.remove(7);
+ l.remove(12);
+ }
+ });
+ }
+
+ private InternalCDORevision getCopyCDORevision(Object object)
+ {
+ return (InternalCDORevision)CDOUtil.getCDOObject((EObject)object).cdoRevision().copy();
+ }
+
+ protected void testStoreDelta(ListManipulator manipulator)
+ {
+ BasicEList<Company> reference = new BasicEList<Company>();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ for (int i = 0; i < 20; i++)
+ {
+ String name = "company " + i;
+ Company company = getModel1Factory().createCompany();
+ company.setName(name);
+ resource.getContents().add(company);
+
+ company = getModel1Factory().createCompany();
+ company.setName(name);
+ reference.add(company);
+ }
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ manipulator.doManipulations(resource.getContents());
+ manipulator.doManipulations(reference);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ assertEquals(reference.size(), resource.getContents().size());
+
+ for (int i = 0; i < reference.size(); i++)
+ {
+ assertEquals(reference.get(i).getName(), ((Company)resource.getContents().get(i)).getName());
+ }
+
+ view.close();
+ session.close();
+ }
+ }
+
+ /**
+ * @author Simon McDuff
+ */
+ protected static interface ListManipulator
+ {
+ public void doManipulations(EList<?> list);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java
index 0ce546f4a7..c35295d3c4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-/**
- * @author Eike Stepper
- */
-public class RevisionManagerClientSideTest extends RevisionManagerTest
-{
- @Override
- protected InternalCDORevisionManager getRevisionManager(InternalRepository repository, InternalCDOSession session)
- {
- return session.getRevisionManager();
- }
-
- @Override
- protected String getLocation()
- {
- return "Client";
- }
-
- @Override
- protected void dumpCache(CDOBranchPoint branchPoint)
- {
- BranchingTest.dump("ServerCache", repository.getRevisionManager().getCache().getAllRevisions());
- super.dumpCache(branchPoint);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
+
+/**
+ * @author Eike Stepper
+ */
+public class RevisionManagerClientSideTest extends RevisionManagerTest
+{
+ @Override
+ protected InternalCDORevisionManager getRevisionManager(InternalRepository repository, InternalCDOSession session)
+ {
+ return session.getRevisionManager();
+ }
+
+ @Override
+ protected String getLocation()
+ {
+ return "Client";
+ }
+
+ @Override
+ protected void dumpCache(CDOBranchPoint branchPoint)
+ {
+ BranchingTest.dump("ServerCache", repository.getRevisionManager().getCache().getAllRevisions());
+ super.dumpCache(branchPoint);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RollbackTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RollbackTest.java
index 60b79cffe0..cd9921a743 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RollbackTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RollbackTest.java
@@ -1,161 +1,161 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author Eike Stepper
- */
-public class RollbackTest extends AbstractCDOTest
-{
- public void testRollbackSameSession() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- CDOTransaction transaction2 = session.openTransaction();
- flow1(transaction1, transaction2);
- }
-
- public void testRollbackSeparateSession() throws Exception
- {
- // Client1
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
-
- // Client2
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
-
- flow1(transaction1, transaction2);
- }
-
- protected void flow1(CDOTransaction transaction1, CDOTransaction transaction2) throws CommitException
- {
- // Client1
- CDOResource resource1 = transaction1.createResource(getResourcePath("/test1"));
- Company company1 = getModel1Factory().createCompany();
- resource1.getContents().add(company1);
- Category category1 = getModel1Factory().createCategory();
- company1.getCategories().add(category1);
- long commitTime = transaction1.commit().getTimeStamp();
-
- // Client2
- transaction2.waitForUpdate(commitTime, DEFAULT_TIMEOUT);
- CDOResource resource2 = transaction2.getResource(getResourcePath("/test1"));
- Company company2 = (Company)resource2.getContents().get(0); // Infrequent exceptions in legacy mode
- Category category2 = company2.getCategories().get(0);
- category2.setName("client2");
- Product1 product2 = getModel1Factory().createProduct1();
- product2.setName("product2");
- category2.getProducts().add(product2);
-
- // Client1
- category1.setName("client1");
- Product1 product1 = getModel1Factory().createProduct1();
- product1.setName("product1");
- category1.getProducts().add(product1);
-
- msg("Checking state of category");
- CDOObject cdoObjectCategory1 = CDOUtil.getCDOObject(category1);
- CDOObject cdoObjectProduct1 = CDOUtil.getCDOObject(product1);
-
- msg("Object should contain internalEObject");
- EStructuralFeature category_Products1 = getModel1Package().getCategory_Products();
- Object testObject = cdoObjectCategory1.cdoRevision().data().get(category_Products1, 0);
- assertEquals(product1, testObject);
-
- commitTime = transaction1.commit().getTimeStamp();
-
- msg("Object should contain CDOID");
- testObject = cdoObjectCategory1.cdoRevision().data().get(category_Products1, 0);
- assertEquals(cdoObjectProduct1.cdoID(), testObject);
-
- transaction2.waitForUpdate(commitTime, DEFAULT_TIMEOUT);
-
- // Client2
- assertEquals(true, transaction2.isDirty());
- assertEquals(true, transaction2.hasConflict());
-
- try
- {
- commitTime = transaction2.commit().getTimeStamp();
- fail("CommitException expected");
- }
- catch (CommitException ex)
- {
- // Commit process should no have changed state of the object
- CDOObject cdoObjectCategory2 = CDOUtil.getCDOObject(category2);
- EStructuralFeature category_Products2 = getModel1Package().getCategory_Products();
- testObject = cdoObjectCategory2.cdoRevision().data().get(category_Products2, 0);
- assertEquals(product2, testObject);
- transaction2.rollback();
- }
-
- assertEquals(false, transaction2.isDirty());
- assertEquals(false, transaction2.hasConflict());
-
- assertEquals("client1", category2.getName());
- category2.setName("client2");
-
- commitTime = transaction2.commit().getTimeStamp();
-
- assertEquals(false, transaction2.isDirty());
- assertEquals(false, transaction2.hasConflict());
- assertEquals("client2", category2.getName());
-
- transaction1.waitForUpdate(commitTime, DEFAULT_TIMEOUT);
-
- // Client1
- assertEquals(false, transaction1.isDirty());
- assertEquals(false, transaction1.hasConflict());
- assertEquals("client2", category1.getName());
- }
-
- /**
- * Bug 296680.
- */
- public void test_Bugzilla_296680() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res"));
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/res"));
-
- Company company = (Company)resource.getContents().get(0);
- company.setName("MyCompany");
-
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.setSavepoint();
- resource.getContents().remove(1);
-
- transaction.rollback();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * @author Eike Stepper
+ */
+public class RollbackTest extends AbstractCDOTest
+{
+ public void testRollbackSameSession() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ CDOTransaction transaction2 = session.openTransaction();
+ flow1(transaction1, transaction2);
+ }
+
+ public void testRollbackSeparateSession() throws Exception
+ {
+ // Client1
+ CDOSession session1 = openSession();
+ CDOTransaction transaction1 = session1.openTransaction();
+
+ // Client2
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+
+ flow1(transaction1, transaction2);
+ }
+
+ protected void flow1(CDOTransaction transaction1, CDOTransaction transaction2) throws CommitException
+ {
+ // Client1
+ CDOResource resource1 = transaction1.createResource(getResourcePath("/test1"));
+ Company company1 = getModel1Factory().createCompany();
+ resource1.getContents().add(company1);
+ Category category1 = getModel1Factory().createCategory();
+ company1.getCategories().add(category1);
+ long commitTime = transaction1.commit().getTimeStamp();
+
+ // Client2
+ transaction2.waitForUpdate(commitTime, DEFAULT_TIMEOUT);
+ CDOResource resource2 = transaction2.getResource(getResourcePath("/test1"));
+ Company company2 = (Company)resource2.getContents().get(0); // Infrequent exceptions in legacy mode
+ Category category2 = company2.getCategories().get(0);
+ category2.setName("client2");
+ Product1 product2 = getModel1Factory().createProduct1();
+ product2.setName("product2");
+ category2.getProducts().add(product2);
+
+ // Client1
+ category1.setName("client1");
+ Product1 product1 = getModel1Factory().createProduct1();
+ product1.setName("product1");
+ category1.getProducts().add(product1);
+
+ msg("Checking state of category");
+ CDOObject cdoObjectCategory1 = CDOUtil.getCDOObject(category1);
+ CDOObject cdoObjectProduct1 = CDOUtil.getCDOObject(product1);
+
+ msg("Object should contain internalEObject");
+ EStructuralFeature category_Products1 = getModel1Package().getCategory_Products();
+ Object testObject = cdoObjectCategory1.cdoRevision().data().get(category_Products1, 0);
+ assertEquals(product1, testObject);
+
+ commitTime = transaction1.commit().getTimeStamp();
+
+ msg("Object should contain CDOID");
+ testObject = cdoObjectCategory1.cdoRevision().data().get(category_Products1, 0);
+ assertEquals(cdoObjectProduct1.cdoID(), testObject);
+
+ transaction2.waitForUpdate(commitTime, DEFAULT_TIMEOUT);
+
+ // Client2
+ assertEquals(true, transaction2.isDirty());
+ assertEquals(true, transaction2.hasConflict());
+
+ try
+ {
+ commitTime = transaction2.commit().getTimeStamp();
+ fail("CommitException expected");
+ }
+ catch (CommitException ex)
+ {
+ // Commit process should no have changed state of the object
+ CDOObject cdoObjectCategory2 = CDOUtil.getCDOObject(category2);
+ EStructuralFeature category_Products2 = getModel1Package().getCategory_Products();
+ testObject = cdoObjectCategory2.cdoRevision().data().get(category_Products2, 0);
+ assertEquals(product2, testObject);
+ transaction2.rollback();
+ }
+
+ assertEquals(false, transaction2.isDirty());
+ assertEquals(false, transaction2.hasConflict());
+
+ assertEquals("client1", category2.getName());
+ category2.setName("client2");
+
+ commitTime = transaction2.commit().getTimeStamp();
+
+ assertEquals(false, transaction2.isDirty());
+ assertEquals(false, transaction2.hasConflict());
+ assertEquals("client2", category2.getName());
+
+ transaction1.waitForUpdate(commitTime, DEFAULT_TIMEOUT);
+
+ // Client1
+ assertEquals(false, transaction1.isDirty());
+ assertEquals(false, transaction1.hasConflict());
+ assertEquals("client2", category1.getName());
+ }
+
+ /**
+ * Bug 296680.
+ */
+ public void test_Bugzilla_296680() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res"));
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/res"));
+
+ Company company = (Company)resource.getContents().get(0);
+ company.setName("MyCompany");
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.setSavepoint();
+ resource.getContents().remove(1);
+
+ transaction.rollback();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java
index 8275e568a7..c1ec724e43 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java
@@ -1,758 +1,758 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-
-import java.sql.Date;
-
-/**
- * @author Martin Fluegge
- */
-public class SetFeatureTest extends AbstractCDOTest
-{
- public void testUnsettableDateNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDate(),
- getModel2Package().getUnsettable1_UnsettableDate().getDefaultValue());
- }
-
- public void testUnsettableStringNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableString(),
- getModel2Package().getUnsettable1_UnsettableString().getDefaultValue());
- }
-
- public void testNotUnsettableBooleanNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableBoolean(),
- true);
- }
-
- public void testNotUnsettableBooleanNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableBoolean(),
- new Boolean(false));
- }
-
- public void testNotUnsettableBooleanNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableBoolean(),
- getModel2Package().getNotUnsettable_NotUnsettableBoolean().getDefaultValue());
- }
-
- public void testNotUnsettableByteNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableByte(),
- (byte)10);
- }
-
- public void testNotUnsettableByteNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableByte(),
- new Byte((byte)25));
- }
-
- public void testNotUnsettableByteNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableByte(),
- getModel2Package().getNotUnsettable_NotUnsettableByte().getDefaultValue());
- }
-
- public void testNotUnsettableCharNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableChar(), 'c');
- }
-
- public void testNotUnsettableCharNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableChar(),
- new Character('c'));
- }
-
- public void testNotUnsettableCharNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableChar(),
- getModel2Package().getNotUnsettable_NotUnsettableChar().getDefaultValue());
- }
-
- public void testNotUnsettableDateNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDate(),
- new Date(0));
- }
-
- public void testNotUnsettableDateNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDate(),
- getModel2Package().getNotUnsettable_NotUnsettableDate().getDefaultValue());
- }
-
- public void testNotUnsettableDoubleNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDouble(),
- 15.03d);
- }
-
- public void testNotUnsettableDoubleNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDouble(),
- new Double(19.79));
- }
-
- public void testNotUnsettableDoubleNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDouble(),
- getModel2Package().getNotUnsettable_NotUnsettableDouble().getDefaultValue());
- }
-
- public void testNotUnsettableFloatNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableFloat(),
- 15.03f);
- }
-
- public void testNotUnsettableFloatNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableFloat(),
- new Float(19.79f));
- }
-
- public void testNotUnsettableFloatNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableFloat(),
- getModel2Package().getNotUnsettable_NotUnsettableFloat().getDefaultValue());
- }
-
- public void testNotUnsettableIntNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableInt(), 15);
- }
-
- public void testNotUnsettableIntNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableInt(),
- new Integer(15));
- }
-
- public void testNotUnsettableIntNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableInt(),
- getModel2Package().getNotUnsettable_NotUnsettableInt().getDefaultValue());
- }
-
- public void testNotUnsettableLongNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableLong(), 15L);
- }
-
- public void testNotUnsettableLongNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableLong(),
- new Long(15031979L));
- }
-
- public void testNotUnsettableLongNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableLong(),
- getModel2Package().getNotUnsettable_NotUnsettableLong().getDefaultValue());
- }
-
- public void testNotUnsettableShortNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableShort(),
- (short)15);
- }
-
- public void testNotUnsettableShortNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableShort(),
- new Short((short)15));
- }
-
- public void testNotUnsettableShortNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableShort(),
- getModel2Package().getNotUnsettable_NotUnsettableShort().getDefaultValue());
- }
-
- public void testNotUnsettableStringNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableString(),
- "Martin");
- }
-
- public void testNotUnsettableStringNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableString(),
- new String("Martin"));
- }
-
- public void testNotUnsettableStringNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableString(),
- getModel2Package().getNotUnsettable_NotUnsettableString().getDefaultValue());
- }
-
- public void testNotUnsettableVATNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableVAT(),
- VAT.VAT7);
- }
-
- public void testNotUnsettableVATNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableVAT(),
- getModel2Package().getNotUnsettable_NotUnsettableVAT().getDefaultValue());
- }
-
- public void testNotUnsettableWithDefaultBoolean() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableBoolean(), true);
- }
-
- public void testNotUnsettableWithDefaultBoolean2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableBoolean(), new Boolean(false));
- }
-
- public void testNotUnsettableWithDefaultBoolean_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableBoolean(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableBoolean().getDefaultValue());
- }
-
- public void testNotUnsettableWithDefaultByte() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableByte(), (byte)10);
- }
-
- public void testNotUnsettableWithDefaultByte2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableByte(), new Byte((byte)25));
- }
-
- public void testNotUnsettableWithDefaultByte_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableByte(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableByte().getDefaultValue());
- }
-
- public void testNotUnsettableWithDefaultChar() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableChar(), 'c');
- }
-
- public void testNotUnsettableWithDefaultChart2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableChar(), new Character('c'));
- }
-
- public void testNotUnsettableWithDefaultChar_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableChar(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableChar().getDefaultValue());
- }
-
- public void testNotUnsettableWithDefaultDate() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableDate(), new Date(0));
- }
-
- public void testNotUnsettableWithDefaultDate_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableDate(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableDate().getDefaultValue());
- }
-
- public void testNotUnsettableWithDefaultDouble() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableDouble(), 15.03d);
- }
-
- public void testNotUnsettableWithDefaultDouble2() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableDouble(), new Double(15.03d));
- }
-
- public void testNotUnsettableWithDefaultDouble_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableDouble(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableDouble().getDefaultValue());
- }
-
- public void testNotUnsettableWithDefaultVAT() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableVAT(), VAT.VAT7);
- }
-
- public void testNotUnsettableWithDefaultVAT_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableVAT(), getModel2Package()
- .getNotUnsettableWithDefault_NotUnsettableVAT().getDefaultValue());
- }
-
- public void testUnsettableBooleanNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableBoolean(), true);
- }
-
- public void testUnsettableBooleanNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableBoolean(),
- new Boolean(false));
- }
-
- public void testUnsettableBooleanNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableBoolean(),
- getModel2Package().getUnsettable1_UnsettableBoolean().getDefaultValue());
- }
-
- public void testUnsettableByteNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableByte(), (byte)10);
- }
-
- public void testUnsettableByteNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableByte(), new Byte(
- (byte)25));
- }
-
- public void testUnsettableByteNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableByte(),
- getModel2Package().getUnsettable1_UnsettableByte().getDefaultValue());
- }
-
- public void testUnsettableCharNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableChar(), 'c');
- }
-
- public void testUnsettableCharNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableChar(),
- new Character('c'));
- }
-
- public void testUnsettableCharNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableChar(),
- getModel2Package().getUnsettable1_UnsettableChar().getDefaultValue());
- }
-
- public void testUnsettableDateNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDate(), new Date(0));
- }
-
- public void testUnsettableDoubleNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDouble(), 15.03d);
- }
-
- public void testUnsettableDoubleNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDouble(), new Double(
- 19.79));
- }
-
- public void testUnsettableDoubleNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDouble(),
- getModel2Package().getUnsettable1_UnsettableDouble().getDefaultValue());
- }
-
- public void testUnsettableFloatNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableFloat(), 15.03f);
- }
-
- public void testUnsettableFloatNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableFloat(), new Float(
- 19.79f));
- }
-
- public void testUnsettableFloatNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableFloat(),
- getModel2Package().getUnsettable1_UnsettableFloat().getDefaultValue());
- }
-
- public void testUnsettableIntNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableInt(), 15);
- }
-
- public void testUnsettableIntNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableInt(),
- new Integer(15));
- }
-
- public void testUnsettableIntNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableInt(),
- getModel2Package().getUnsettable1_UnsettableInt().getDefaultValue());
- }
-
- public void testUnsettableLongNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableLong(), 15L);
- }
-
- public void testUnsettableShortNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableShort(), (short)15);
- }
-
- public void testUnsettableShortNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableShort(), new Short(
- (short)15));
- }
-
- public void testUnsettableShortNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableShort(),
- getModel2Package().getUnsettable1_UnsettableShort().getDefaultValue());
- }
-
- public void testUnsettableStringNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableString(), "Martin");
- }
-
- public void testUnsettableStringNoDefault2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableString(), new String(
- "Martin"));
- }
-
- public void testUnsettableVATNoDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableVAT(), VAT.VAT7);
- }
-
- public void testUnsettableVATNoDefault_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableVAT(),
- getModel2Package().getUnsettable1_UnsettableVAT().getDefaultValue());
- }
-
- public void testUnsettableWithDefaultBoolean() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableBoolean(), true);
- }
-
- public void testUnsettableWithDefaultBoolean2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableBoolean(), new Boolean(false));
- }
-
- public void testUnsettableWithDefaultByte() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableByte(), (byte)10);
- }
-
- public void testUnsettableWithDefaultByte2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableByte(), new Byte((byte)25));
- }
-
- public void testUnsettableWithDefaultByte_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableByte(), getModel2Package().getUnsettable2WithDefault_UnsettableByte()
- .getDefaultValue());
- }
-
- public void testUnsettableWithDefaultChar() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableChar(), 'c');
- }
-
- public void testUnsettableWithDefaultCharNo() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableChar(), new Character('c'));
- }
-
- public void testUnsettableWithDefaultChar_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableChar(), getModel2Package().getUnsettable2WithDefault_UnsettableChar()
- .getDefaultValue());
- }
-
- public void testUnsettableWithDefaultDate() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableDate(), new Date(0));
- }
-
- public void testUnsettableWithDefaultDate_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableDate(), getModel2Package().getUnsettable2WithDefault_UnsettableDate()
- .getDefaultValue());
- }
-
- public void testUnsettableWithDefaultDouble() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableDouble(), 15.03d);
- }
-
- public void testUnsettableWithDefaultDouble2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableDouble(), new Double(19.79));
- }
-
- public void testUnsettableWithDefaultDouble_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableDouble(), getModel2Package().getUnsettable2WithDefault_UnsettableDouble()
- .getDefaultValue());
- }
-
- public void testUnsettableWithDefaultFloat() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableFloat(), 15.03f);
- }
-
- public void testUnsettableWithDefaultFloat2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableFloat(), new Float(19.79f));
- }
-
- public void testUnsettableWithDefaultFloat_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableFloat(), getModel2Package().getUnsettable2WithDefault_UnsettableFloat()
- .getDefaultValue());
- }
-
- public void testUnsettableWithDefaultInt() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableInt(), 15);
- }
-
- public void testUnsettableWithDefaultInt2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableInt(), new Integer(15));
- }
-
- public void testUnsettableWithDefaultInt_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableInt(), getModel2Package().getUnsettable2WithDefault_UnsettableInt()
- .getDefaultValue());
- }
-
- public void testUnsettableWithDefaultLong() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableLong(), 15L);
- }
-
- public void testUnsettableWithDefaultShort() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableShort(), (short)15);
- }
-
- public void testUnsettableWithDefaultShort2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableShort(), new Short((short)15));
- }
-
- public void testUnsettableWithDefaultShort_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableShort(), getModel2Package().getUnsettable2WithDefault_UnsettableShort()
- .getDefaultValue());
- }
-
- public void testUnsettableWithDefaultString() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableString(), "Martin");
- }
-
- public void testUnsettableWithDefaultString2() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableString(), new String("Martin"));
- }
-
- public void testUnsettableWithDefaultString_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableString(), getModel2Package().getUnsettable2WithDefault_UnsettableString()
- .getDefaultValue());
- }
-
- public void testUnsettableWithDefaultVAT() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableVAT(), VAT.VAT7);
- }
-
- public void testUnsettableWithDefaultVAT_SetDefault() throws Exception
- {
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
- .getUnsettable2WithDefault_UnsettableVAT(), getModel2Package().getUnsettable2WithDefault_UnsettableVAT()
- .getDefaultValue());
- }
-
- private void testIsSet(EObject object, EStructuralFeature feature, Object value) throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- assertEquals(false, object.eIsSet(feature));
-
- object.eSet(feature, value);
-
- if (!feature.isUnsettable() && ObjectUtil.equals(feature.getDefaultValue(), value))
- {
- assertEquals(false, object.eIsSet(feature));
- }
- else
- {
- assertEquals(true, object.eIsSet(feature));
- }
-
- object.eUnset(feature);
-
- assertEquals(false, object.eIsSet(feature));
- assertEquals(true, ObjectUtil.equals(object.eGet(feature), feature.getDefaultValue()));
-
- object.eSet(feature, value);
-
- if (!feature.isUnsettable() && ObjectUtil.equals(feature.getDefaultValue(), value))
- {
- assertEquals(false, object.eIsSet(feature));
- }
- else
- {
- assertEquals(true, object.eIsSet(feature));
- }
-
- resource.getContents().add(object);
-
- transaction.commit();
-
- if (!feature.isUnsettable() && ObjectUtil.equals(feature.getDefaultValue(), value))
- {
- assertEquals(false, object.eIsSet(feature));
- }
- else
- {
- assertEquals(true, object.eIsSet(feature));
- }
-
- assertEquals(((InternalCDOTransaction)transaction).getStore().isSet((InternalEObject)object, feature),
- object.eIsSet(feature));
-
- session.close();
-
- // ---------- open new session --------------
-
- session = openSession();
-
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/test1"), true);
-
- object = resource.getContents().get(0);
- if (!feature.isUnsettable() && ObjectUtil.equals(feature.getDefaultValue(), value))
- {
- assertEquals(false, object.eIsSet(feature));
- }
- else
- {
- assertEquals(true, object.eIsSet(feature));
- }
-
- object.eUnset(feature);
-
- assertEquals(false, object.eIsSet(feature));
- assertEquals(true, ObjectUtil.equals(object.eGet(feature), feature.getDefaultValue()));
- assertEquals(((InternalCDOTransaction)transaction).getStore().isSet((InternalEObject)object, feature),
- object.eIsSet(feature));
-
- transaction.commit();
-
- assertEquals(false, object.eIsSet(feature));
- assertEquals(((InternalCDOTransaction)transaction).getStore().isSet((InternalEObject)object, feature),
- object.eIsSet(feature));
-
- session.close();
-
- // ---------- open new session --------------
-
- session = openSession();
-
- transaction = session.openTransaction();
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test1"));
-
- object = resource.getContents().get(0);
- assertEquals(false, object.eIsSet(feature));
-
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+
+import java.sql.Date;
+
+/**
+ * @author Martin Fluegge
+ */
+public class SetFeatureTest extends AbstractCDOTest
+{
+ public void testUnsettableDateNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDate(),
+ getModel2Package().getUnsettable1_UnsettableDate().getDefaultValue());
+ }
+
+ public void testUnsettableStringNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableString(),
+ getModel2Package().getUnsettable1_UnsettableString().getDefaultValue());
+ }
+
+ public void testNotUnsettableBooleanNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableBoolean(),
+ true);
+ }
+
+ public void testNotUnsettableBooleanNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableBoolean(),
+ new Boolean(false));
+ }
+
+ public void testNotUnsettableBooleanNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableBoolean(),
+ getModel2Package().getNotUnsettable_NotUnsettableBoolean().getDefaultValue());
+ }
+
+ public void testNotUnsettableByteNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableByte(),
+ (byte)10);
+ }
+
+ public void testNotUnsettableByteNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableByte(),
+ new Byte((byte)25));
+ }
+
+ public void testNotUnsettableByteNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableByte(),
+ getModel2Package().getNotUnsettable_NotUnsettableByte().getDefaultValue());
+ }
+
+ public void testNotUnsettableCharNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableChar(), 'c');
+ }
+
+ public void testNotUnsettableCharNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableChar(),
+ new Character('c'));
+ }
+
+ public void testNotUnsettableCharNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableChar(),
+ getModel2Package().getNotUnsettable_NotUnsettableChar().getDefaultValue());
+ }
+
+ public void testNotUnsettableDateNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDate(),
+ new Date(0));
+ }
+
+ public void testNotUnsettableDateNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDate(),
+ getModel2Package().getNotUnsettable_NotUnsettableDate().getDefaultValue());
+ }
+
+ public void testNotUnsettableDoubleNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDouble(),
+ 15.03d);
+ }
+
+ public void testNotUnsettableDoubleNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDouble(),
+ new Double(19.79));
+ }
+
+ public void testNotUnsettableDoubleNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDouble(),
+ getModel2Package().getNotUnsettable_NotUnsettableDouble().getDefaultValue());
+ }
+
+ public void testNotUnsettableFloatNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableFloat(),
+ 15.03f);
+ }
+
+ public void testNotUnsettableFloatNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableFloat(),
+ new Float(19.79f));
+ }
+
+ public void testNotUnsettableFloatNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableFloat(),
+ getModel2Package().getNotUnsettable_NotUnsettableFloat().getDefaultValue());
+ }
+
+ public void testNotUnsettableIntNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableInt(), 15);
+ }
+
+ public void testNotUnsettableIntNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableInt(),
+ new Integer(15));
+ }
+
+ public void testNotUnsettableIntNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableInt(),
+ getModel2Package().getNotUnsettable_NotUnsettableInt().getDefaultValue());
+ }
+
+ public void testNotUnsettableLongNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableLong(), 15L);
+ }
+
+ public void testNotUnsettableLongNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableLong(),
+ new Long(15031979L));
+ }
+
+ public void testNotUnsettableLongNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableLong(),
+ getModel2Package().getNotUnsettable_NotUnsettableLong().getDefaultValue());
+ }
+
+ public void testNotUnsettableShortNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableShort(),
+ (short)15);
+ }
+
+ public void testNotUnsettableShortNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableShort(),
+ new Short((short)15));
+ }
+
+ public void testNotUnsettableShortNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableShort(),
+ getModel2Package().getNotUnsettable_NotUnsettableShort().getDefaultValue());
+ }
+
+ public void testNotUnsettableStringNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableString(),
+ "Martin");
+ }
+
+ public void testNotUnsettableStringNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableString(),
+ new String("Martin"));
+ }
+
+ public void testNotUnsettableStringNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableString(),
+ getModel2Package().getNotUnsettable_NotUnsettableString().getDefaultValue());
+ }
+
+ public void testNotUnsettableVATNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableVAT(),
+ VAT.VAT7);
+ }
+
+ public void testNotUnsettableVATNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableVAT(),
+ getModel2Package().getNotUnsettable_NotUnsettableVAT().getDefaultValue());
+ }
+
+ public void testNotUnsettableWithDefaultBoolean() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableBoolean(), true);
+ }
+
+ public void testNotUnsettableWithDefaultBoolean2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableBoolean(), new Boolean(false));
+ }
+
+ public void testNotUnsettableWithDefaultBoolean_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableBoolean(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableBoolean().getDefaultValue());
+ }
+
+ public void testNotUnsettableWithDefaultByte() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableByte(), (byte)10);
+ }
+
+ public void testNotUnsettableWithDefaultByte2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableByte(), new Byte((byte)25));
+ }
+
+ public void testNotUnsettableWithDefaultByte_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableByte(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableByte().getDefaultValue());
+ }
+
+ public void testNotUnsettableWithDefaultChar() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableChar(), 'c');
+ }
+
+ public void testNotUnsettableWithDefaultChart2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableChar(), new Character('c'));
+ }
+
+ public void testNotUnsettableWithDefaultChar_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableChar(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableChar().getDefaultValue());
+ }
+
+ public void testNotUnsettableWithDefaultDate() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableDate(), new Date(0));
+ }
+
+ public void testNotUnsettableWithDefaultDate_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableDate(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableDate().getDefaultValue());
+ }
+
+ public void testNotUnsettableWithDefaultDouble() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableDouble(), 15.03d);
+ }
+
+ public void testNotUnsettableWithDefaultDouble2() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableDouble(), new Double(15.03d));
+ }
+
+ public void testNotUnsettableWithDefaultDouble_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableDouble(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableDouble().getDefaultValue());
+ }
+
+ public void testNotUnsettableWithDefaultVAT() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableVAT(), VAT.VAT7);
+ }
+
+ public void testNotUnsettableWithDefaultVAT_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableVAT(), getModel2Package()
+ .getNotUnsettableWithDefault_NotUnsettableVAT().getDefaultValue());
+ }
+
+ public void testUnsettableBooleanNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableBoolean(), true);
+ }
+
+ public void testUnsettableBooleanNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableBoolean(),
+ new Boolean(false));
+ }
+
+ public void testUnsettableBooleanNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableBoolean(),
+ getModel2Package().getUnsettable1_UnsettableBoolean().getDefaultValue());
+ }
+
+ public void testUnsettableByteNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableByte(), (byte)10);
+ }
+
+ public void testUnsettableByteNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableByte(), new Byte(
+ (byte)25));
+ }
+
+ public void testUnsettableByteNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableByte(),
+ getModel2Package().getUnsettable1_UnsettableByte().getDefaultValue());
+ }
+
+ public void testUnsettableCharNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableChar(), 'c');
+ }
+
+ public void testUnsettableCharNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableChar(),
+ new Character('c'));
+ }
+
+ public void testUnsettableCharNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableChar(),
+ getModel2Package().getUnsettable1_UnsettableChar().getDefaultValue());
+ }
+
+ public void testUnsettableDateNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDate(), new Date(0));
+ }
+
+ public void testUnsettableDoubleNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDouble(), 15.03d);
+ }
+
+ public void testUnsettableDoubleNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDouble(), new Double(
+ 19.79));
+ }
+
+ public void testUnsettableDoubleNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDouble(),
+ getModel2Package().getUnsettable1_UnsettableDouble().getDefaultValue());
+ }
+
+ public void testUnsettableFloatNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableFloat(), 15.03f);
+ }
+
+ public void testUnsettableFloatNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableFloat(), new Float(
+ 19.79f));
+ }
+
+ public void testUnsettableFloatNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableFloat(),
+ getModel2Package().getUnsettable1_UnsettableFloat().getDefaultValue());
+ }
+
+ public void testUnsettableIntNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableInt(), 15);
+ }
+
+ public void testUnsettableIntNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableInt(),
+ new Integer(15));
+ }
+
+ public void testUnsettableIntNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableInt(),
+ getModel2Package().getUnsettable1_UnsettableInt().getDefaultValue());
+ }
+
+ public void testUnsettableLongNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableLong(), 15L);
+ }
+
+ public void testUnsettableShortNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableShort(), (short)15);
+ }
+
+ public void testUnsettableShortNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableShort(), new Short(
+ (short)15));
+ }
+
+ public void testUnsettableShortNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableShort(),
+ getModel2Package().getUnsettable1_UnsettableShort().getDefaultValue());
+ }
+
+ public void testUnsettableStringNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableString(), "Martin");
+ }
+
+ public void testUnsettableStringNoDefault2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableString(), new String(
+ "Martin"));
+ }
+
+ public void testUnsettableVATNoDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableVAT(), VAT.VAT7);
+ }
+
+ public void testUnsettableVATNoDefault_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableVAT(),
+ getModel2Package().getUnsettable1_UnsettableVAT().getDefaultValue());
+ }
+
+ public void testUnsettableWithDefaultBoolean() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableBoolean(), true);
+ }
+
+ public void testUnsettableWithDefaultBoolean2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableBoolean(), new Boolean(false));
+ }
+
+ public void testUnsettableWithDefaultByte() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableByte(), (byte)10);
+ }
+
+ public void testUnsettableWithDefaultByte2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableByte(), new Byte((byte)25));
+ }
+
+ public void testUnsettableWithDefaultByte_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableByte(), getModel2Package().getUnsettable2WithDefault_UnsettableByte()
+ .getDefaultValue());
+ }
+
+ public void testUnsettableWithDefaultChar() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableChar(), 'c');
+ }
+
+ public void testUnsettableWithDefaultCharNo() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableChar(), new Character('c'));
+ }
+
+ public void testUnsettableWithDefaultChar_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableChar(), getModel2Package().getUnsettable2WithDefault_UnsettableChar()
+ .getDefaultValue());
+ }
+
+ public void testUnsettableWithDefaultDate() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableDate(), new Date(0));
+ }
+
+ public void testUnsettableWithDefaultDate_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableDate(), getModel2Package().getUnsettable2WithDefault_UnsettableDate()
+ .getDefaultValue());
+ }
+
+ public void testUnsettableWithDefaultDouble() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableDouble(), 15.03d);
+ }
+
+ public void testUnsettableWithDefaultDouble2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableDouble(), new Double(19.79));
+ }
+
+ public void testUnsettableWithDefaultDouble_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableDouble(), getModel2Package().getUnsettable2WithDefault_UnsettableDouble()
+ .getDefaultValue());
+ }
+
+ public void testUnsettableWithDefaultFloat() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableFloat(), 15.03f);
+ }
+
+ public void testUnsettableWithDefaultFloat2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableFloat(), new Float(19.79f));
+ }
+
+ public void testUnsettableWithDefaultFloat_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableFloat(), getModel2Package().getUnsettable2WithDefault_UnsettableFloat()
+ .getDefaultValue());
+ }
+
+ public void testUnsettableWithDefaultInt() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableInt(), 15);
+ }
+
+ public void testUnsettableWithDefaultInt2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableInt(), new Integer(15));
+ }
+
+ public void testUnsettableWithDefaultInt_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableInt(), getModel2Package().getUnsettable2WithDefault_UnsettableInt()
+ .getDefaultValue());
+ }
+
+ public void testUnsettableWithDefaultLong() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableLong(), 15L);
+ }
+
+ public void testUnsettableWithDefaultShort() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableShort(), (short)15);
+ }
+
+ public void testUnsettableWithDefaultShort2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableShort(), new Short((short)15));
+ }
+
+ public void testUnsettableWithDefaultShort_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableShort(), getModel2Package().getUnsettable2WithDefault_UnsettableShort()
+ .getDefaultValue());
+ }
+
+ public void testUnsettableWithDefaultString() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableString(), "Martin");
+ }
+
+ public void testUnsettableWithDefaultString2() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableString(), new String("Martin"));
+ }
+
+ public void testUnsettableWithDefaultString_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableString(), getModel2Package().getUnsettable2WithDefault_UnsettableString()
+ .getDefaultValue());
+ }
+
+ public void testUnsettableWithDefaultVAT() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableVAT(), VAT.VAT7);
+ }
+
+ public void testUnsettableWithDefaultVAT_SetDefault() throws Exception
+ {
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
+ .getUnsettable2WithDefault_UnsettableVAT(), getModel2Package().getUnsettable2WithDefault_UnsettableVAT()
+ .getDefaultValue());
+ }
+
+ private void testIsSet(EObject object, EStructuralFeature feature, Object value) throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ assertEquals(false, object.eIsSet(feature));
+
+ object.eSet(feature, value);
+
+ if (!feature.isUnsettable() && ObjectUtil.equals(feature.getDefaultValue(), value))
+ {
+ assertEquals(false, object.eIsSet(feature));
+ }
+ else
+ {
+ assertEquals(true, object.eIsSet(feature));
+ }
+
+ object.eUnset(feature);
+
+ assertEquals(false, object.eIsSet(feature));
+ assertEquals(true, ObjectUtil.equals(object.eGet(feature), feature.getDefaultValue()));
+
+ object.eSet(feature, value);
+
+ if (!feature.isUnsettable() && ObjectUtil.equals(feature.getDefaultValue(), value))
+ {
+ assertEquals(false, object.eIsSet(feature));
+ }
+ else
+ {
+ assertEquals(true, object.eIsSet(feature));
+ }
+
+ resource.getContents().add(object);
+
+ transaction.commit();
+
+ if (!feature.isUnsettable() && ObjectUtil.equals(feature.getDefaultValue(), value))
+ {
+ assertEquals(false, object.eIsSet(feature));
+ }
+ else
+ {
+ assertEquals(true, object.eIsSet(feature));
+ }
+
+ assertEquals(((InternalCDOTransaction)transaction).getStore().isSet((InternalEObject)object, feature),
+ object.eIsSet(feature));
+
+ session.close();
+
+ // ---------- open new session --------------
+
+ session = openSession();
+
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/test1"), true);
+
+ object = resource.getContents().get(0);
+ if (!feature.isUnsettable() && ObjectUtil.equals(feature.getDefaultValue(), value))
+ {
+ assertEquals(false, object.eIsSet(feature));
+ }
+ else
+ {
+ assertEquals(true, object.eIsSet(feature));
+ }
+
+ object.eUnset(feature);
+
+ assertEquals(false, object.eIsSet(feature));
+ assertEquals(true, ObjectUtil.equals(object.eGet(feature), feature.getDefaultValue()));
+ assertEquals(((InternalCDOTransaction)transaction).getStore().isSet((InternalEObject)object, feature),
+ object.eIsSet(feature));
+
+ transaction.commit();
+
+ assertEquals(false, object.eIsSet(feature));
+ assertEquals(((InternalCDOTransaction)transaction).getStore().isSet((InternalEObject)object, feature),
+ object.eIsSet(feature));
+
+ session.close();
+
+ // ---------- open new session --------------
+
+ session = openSession();
+
+ transaction = session.openTransaction();
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test1"));
+
+ object = resource.getContents().get(0);
+ assertEquals(false, object.eIsSet(feature));
+
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java
index 71f0c66bbe..0f3b12be47 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java
@@ -1,525 +1,525 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchImpl;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.ISessionConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * @author Eike Stepper
- */
-@Requires(ISessionConfig.CAPABILITY_NET4J_JVM)
-public class StateMachineTest extends AbstractCDOTest
-{
- private static final long TIMESTAMP = 12345678;
-
- private static final CDOBranch BRANCH = new CDOBranchImpl.Main(null, false, 0L);
-
- // ///////////////////////////////////////////////////
-
- public void test_TRANSIENT_with_ATTACH() throws Exception
- {
- // Attach resource
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- assertNew(resource, transaction);
- assertEquals(URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
- resource.getURI());
- assertEquals(transaction.getResourceSet(), resource.getResourceSet());
-
- // Attach single object
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- assertTransient(supplier);
- resource.getContents().add(supplier);
- assertNew(supplier, transaction);
- assertEquals(transaction, CDOUtil.getCDOObject(supplier).cdoView());
- assertEquals(resource, CDOUtil.getCDOObject(supplier).cdoDirectResource());
- assertEquals(resource, supplier.eResource());
- assertEquals(null, supplier.eContainer());
-
- // Attach object tree
- Category cat1 = getModel1Factory().createCategory();
- cat1.setName("CAT1");
- Category cat2 = getModel1Factory().createCategory();
- cat2.setName("CAT2");
- cat1.getCategories().add(cat2);
- Product1 p1 = getModel1Factory().createProduct1();
- p1.setName("P1");
- cat1.getProducts().add(p1);
- Product1 p2 = getModel1Factory().createProduct1();
- p2.setName("P2");
- cat1.getProducts().add(p2);
- Product1 p3 = getModel1Factory().createProduct1();
- p3.setName("P3");
- cat2.getProducts().add(p3);
- assertTransient(cat1);
- assertTransient(cat2);
- assertTransient(p1);
- assertTransient(p2);
- assertTransient(p3);
- resource.getContents().add(cat1);
- assertNew(cat1, transaction);
- assertNew(cat2, transaction);
- assertNew(p1, transaction);
- assertNew(p2, transaction);
- assertNew(p3, transaction);
- }
-
- public void _____test_TRANSIENT_with_DETACH() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- assertTransient(supplier);
- try
- {
- detach(supplier);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- assertFailure(expected);
- }
- }
-
- public void test_TRANSIENT_with_READ() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- assertTransient(supplier);
- read(supplier);
- }
-
- public void test_TRANSIENT_with_WRITE() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- assertTransient(supplier);
- write(supplier);
- }
-
- public void test_TRANSIENT_with_INVALIDATE() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- assertTransient(supplier);
- invalidate(supplier);
- assertTransient(supplier);
- }
-
- public void test_TRANSIENT_with_COMMIT() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- assertTransient(supplier);
- try
- {
- commit(supplier, new CommitTransactionResult(null, BRANCH.getPoint(TIMESTAMP), CDOBranchPoint.UNSPECIFIED_DATE));
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- assertFailure(expected);
- }
- }
-
- public void test_TRANSIENT_with_ROLLBACK() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- assertTransient(supplier);
-
- // Rollback locally
- try
- {
- rollback(supplier);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- assertFailure(expected);
- }
-
- // Rollback remotely
- try
- {
- rollback(supplier);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- assertFailure(expected);
- }
- }
-
- // ///////////////////////////////////////////////////
-
- public void test_PREPARED_with_ATTACH() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- setState(supplier, CDOState.PREPARED);
-
- try
- {
- testAttach(CDOUtil.getCDOObject(supplier));
- fail("Expected NullPointerException due to revision==null");
- }
- catch (NullPointerException ex)
- {
- }
- }
-
- public void test_PREPARED_with_DETACH() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- setState(supplier, CDOState.PREPARED);
-
- try
- {
- detach(supplier);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- assertFailure(expected);
- }
- }
-
- public void test_PREPARED_with_READ() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- setState(supplier, CDOState.PREPARED);
- read(supplier);
- assertEquals(CDOState.PREPARED, CDOUtil.getCDOObject(supplier).cdoState());
- }
-
- public void test_PREPARED_with_WRITE() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- setState(supplier, CDOState.PREPARED);
-
- try
- {
- write(supplier);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- assertFailure(expected);
- }
- }
-
- public void test_PREPARED_with_INVALIDATE() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- setState(supplier, CDOState.PREPARED);
-
- try
- {
- invalidate(supplier);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- assertFailure(expected);
- }
- }
-
- public void test_PREPARED_with_COMMIT() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- setState(supplier, CDOState.PREPARED);
-
- try
- {
- commit(supplier, new CommitTransactionResult(null, BRANCH.getPoint(TIMESTAMP), CDOBranchPoint.UNSPECIFIED_DATE));
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- assertFailure(expected);
- }
- }
-
- public void test_PREPARED_with_ROLLBACK() throws Exception
- {
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- setState(supplier, CDOState.PREPARED);
-
- try
- {
- rollback(supplier);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- assertFailure(expected);
- }
- }
-
- // ///////////////////////////////////////////////////
-
- public void test_NEW_with_ATTACH() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- assertNew(resource, transaction);
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- resource.getContents().add(supplier); // ATTACH
- assertNew(supplier, transaction);
- }
-
- public void _____test_NEW_with_DETACH() throws Exception
- {
- // Detach single object
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- assertNew(resource, transaction);
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- resource.getContents().add(supplier); // ATTACH
- assertNew(supplier, transaction);
-
- detach(supplier);
- assertTransient(supplier);
-
- // Detach object tree
- Category cat1 = getModel1Factory().createCategory();
- cat1.setName("CAT1");
- Category cat2 = getModel1Factory().createCategory();
- cat2.setName("CAT2");
- cat1.getCategories().add(cat2);
- Product1 p1 = getModel1Factory().createProduct1();
- p1.setName("P1");
- cat1.getProducts().add(p1);
- Product1 p2 = getModel1Factory().createProduct1();
- p2.setName("P2");
- cat1.getProducts().add(p2);
- Product1 p3 = getModel1Factory().createProduct1();
- p3.setName("P3");
- cat2.getProducts().add(p3);
- resource.getContents().add(cat1);
- assertNew(cat1, transaction);
- assertNew(cat2, transaction);
- assertNew(p1, transaction);
- assertNew(p2, transaction);
- assertNew(p3, transaction);
- System.out.println();
- System.out.println();
- System.out.println();
- System.out.println();
- resource.getContents().remove(cat1);
- assertTransient(cat1);
- assertTransient(cat2);
- assertTransient(p1);
- assertTransient(p2);
- assertTransient(p3);
- }
-
- public void test_REATTACH() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Category cat1 = getModel1Factory().createCategory();
- cat1.setName("CAT1");
- resource.getContents().add(cat1);
- Category cat2 = getModel1Factory().createCategory();
- cat2.setName("CAT2");
- resource.getContents().add(cat2);
- Product1 p1 = getModel1Factory().createProduct1();
- p1.setName("P1");
- cat1.getProducts().add(p1);
- assertNew(cat1, transaction);
- assertNew(cat2, transaction);
- assertNew(p1, transaction);
-
- System.out.println();
- System.out.println();
- System.out.println();
- System.out.println();
- System.out.println();
-
- CDOID id = CDOUtil.getCDOObject(p1).cdoID();
- cat2.getProducts().add(p1);
- assertNew(p1, transaction);
- assertEquals(id, CDOUtil.getCDOObject(p1).cdoID());
- }
-
- public void test_NEW_with_READ() throws Exception
- {
- }
-
- public void test_NEW_with_WRITE() throws Exception
- {
- }
-
- public void test_NEW_with_INVALIDATE() throws Exception
- {
- }
-
- public void test_NEW_with_COMMIT() throws Exception
- {
- }
-
- public void test_NEW_with_ROLLBACK() throws Exception
- {
- }
-
- private static void assertFailure(IllegalStateException ex)
- {
- IOUtil.print(ex);
- assertEquals("Expected FAIL transition", true, ex.getMessage().startsWith("Failing event "));
- }
-
- private static void setState(EObject object, CDOState state)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- if (cdoObject != null)
- {
- ((InternalCDOObject)cdoObject).cdoInternalSetState(state);
- }
- }
-
- private static void detach(EObject object)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- if (cdoObject != null)
- {
- CDOStateMachine.INSTANCE.detach((InternalCDOObject)cdoObject);
- }
- }
-
- private static void read(EObject object)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- if (cdoObject != null)
- {
- CDOStateMachine.INSTANCE.read((InternalCDOObject)cdoObject);
- }
- }
-
- private static void write(EObject object)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- if (cdoObject != null)
- {
- CDOStateMachine.INSTANCE.write((InternalCDOObject)cdoObject);
- }
- }
-
- private static void invalidate(EObject object)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- if (cdoObject != null)
- {
- CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoObject, null, CDOBranchPoint.UNSPECIFIED_DATE);
- }
- }
-
- private static void commit(EObject object, CommitTransactionResult result)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- if (cdoObject != null)
- {
- CDOStateMachine.INSTANCE.commit((InternalCDOObject)cdoObject, result);
- }
- }
-
- private static void rollback(EObject object)
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- if (cdoObject != null)
- {
- CDOStateMachine.INSTANCE.rollback((InternalCDOObject)cdoObject);
- }
- }
-
- private static void testAttach(EObject object) throws Exception
- {
- CDOObject cdoObject = CDOUtil.getCDOObject(object);
- if (cdoObject != null)
- {
- invokeMethod(cdoObject, "testAttach");
- }
- }
-
- private static void invokeMethod(CDOObject object, String methodName) throws Exception
- {
- Method method = null;
-
- try
- {
- method = CDOStateMachine.class.getDeclaredMethod(methodName, new Class[] { InternalCDOObject.class });
- method.setAccessible(true);
- method.invoke(CDOStateMachine.INSTANCE, object);
- }
- catch (RuntimeException ex)
- {
- throw ex;
- }
- catch (InvocationTargetException ex)
- {
- throw (Exception)ex.getTargetException();
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- fail("Reflection problem: " + ex.getMessage());
- }
- finally
- {
- if (method != null)
- {
- method.setAccessible(false);
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.common.branch.CDOBranchImpl;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.ISessionConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * @author Eike Stepper
+ */
+@Requires(ISessionConfig.CAPABILITY_NET4J_JVM)
+public class StateMachineTest extends AbstractCDOTest
+{
+ private static final long TIMESTAMP = 12345678;
+
+ private static final CDOBranch BRANCH = new CDOBranchImpl.Main(null, false, 0L);
+
+ // ///////////////////////////////////////////////////
+
+ public void test_TRANSIENT_with_ATTACH() throws Exception
+ {
+ // Attach resource
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ assertNew(resource, transaction);
+ assertEquals(URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
+ resource.getURI());
+ assertEquals(transaction.getResourceSet(), resource.getResourceSet());
+
+ // Attach single object
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ assertTransient(supplier);
+ resource.getContents().add(supplier);
+ assertNew(supplier, transaction);
+ assertEquals(transaction, CDOUtil.getCDOObject(supplier).cdoView());
+ assertEquals(resource, CDOUtil.getCDOObject(supplier).cdoDirectResource());
+ assertEquals(resource, supplier.eResource());
+ assertEquals(null, supplier.eContainer());
+
+ // Attach object tree
+ Category cat1 = getModel1Factory().createCategory();
+ cat1.setName("CAT1");
+ Category cat2 = getModel1Factory().createCategory();
+ cat2.setName("CAT2");
+ cat1.getCategories().add(cat2);
+ Product1 p1 = getModel1Factory().createProduct1();
+ p1.setName("P1");
+ cat1.getProducts().add(p1);
+ Product1 p2 = getModel1Factory().createProduct1();
+ p2.setName("P2");
+ cat1.getProducts().add(p2);
+ Product1 p3 = getModel1Factory().createProduct1();
+ p3.setName("P3");
+ cat2.getProducts().add(p3);
+ assertTransient(cat1);
+ assertTransient(cat2);
+ assertTransient(p1);
+ assertTransient(p2);
+ assertTransient(p3);
+ resource.getContents().add(cat1);
+ assertNew(cat1, transaction);
+ assertNew(cat2, transaction);
+ assertNew(p1, transaction);
+ assertNew(p2, transaction);
+ assertNew(p3, transaction);
+ }
+
+ public void _____test_TRANSIENT_with_DETACH() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ assertTransient(supplier);
+ try
+ {
+ detach(supplier);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ assertFailure(expected);
+ }
+ }
+
+ public void test_TRANSIENT_with_READ() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ assertTransient(supplier);
+ read(supplier);
+ }
+
+ public void test_TRANSIENT_with_WRITE() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ assertTransient(supplier);
+ write(supplier);
+ }
+
+ public void test_TRANSIENT_with_INVALIDATE() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ assertTransient(supplier);
+ invalidate(supplier);
+ assertTransient(supplier);
+ }
+
+ public void test_TRANSIENT_with_COMMIT() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ assertTransient(supplier);
+ try
+ {
+ commit(supplier, new CommitTransactionResult(null, BRANCH.getPoint(TIMESTAMP), CDOBranchPoint.UNSPECIFIED_DATE));
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ assertFailure(expected);
+ }
+ }
+
+ public void test_TRANSIENT_with_ROLLBACK() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ assertTransient(supplier);
+
+ // Rollback locally
+ try
+ {
+ rollback(supplier);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ assertFailure(expected);
+ }
+
+ // Rollback remotely
+ try
+ {
+ rollback(supplier);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ assertFailure(expected);
+ }
+ }
+
+ // ///////////////////////////////////////////////////
+
+ public void test_PREPARED_with_ATTACH() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ setState(supplier, CDOState.PREPARED);
+
+ try
+ {
+ testAttach(CDOUtil.getCDOObject(supplier));
+ fail("Expected NullPointerException due to revision==null");
+ }
+ catch (NullPointerException ex)
+ {
+ }
+ }
+
+ public void test_PREPARED_with_DETACH() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ setState(supplier, CDOState.PREPARED);
+
+ try
+ {
+ detach(supplier);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ assertFailure(expected);
+ }
+ }
+
+ public void test_PREPARED_with_READ() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ setState(supplier, CDOState.PREPARED);
+ read(supplier);
+ assertEquals(CDOState.PREPARED, CDOUtil.getCDOObject(supplier).cdoState());
+ }
+
+ public void test_PREPARED_with_WRITE() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ setState(supplier, CDOState.PREPARED);
+
+ try
+ {
+ write(supplier);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ assertFailure(expected);
+ }
+ }
+
+ public void test_PREPARED_with_INVALIDATE() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ setState(supplier, CDOState.PREPARED);
+
+ try
+ {
+ invalidate(supplier);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ assertFailure(expected);
+ }
+ }
+
+ public void test_PREPARED_with_COMMIT() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ setState(supplier, CDOState.PREPARED);
+
+ try
+ {
+ commit(supplier, new CommitTransactionResult(null, BRANCH.getPoint(TIMESTAMP), CDOBranchPoint.UNSPECIFIED_DATE));
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ assertFailure(expected);
+ }
+ }
+
+ public void test_PREPARED_with_ROLLBACK() throws Exception
+ {
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ setState(supplier, CDOState.PREPARED);
+
+ try
+ {
+ rollback(supplier);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ assertFailure(expected);
+ }
+ }
+
+ // ///////////////////////////////////////////////////
+
+ public void test_NEW_with_ATTACH() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ assertNew(resource, transaction);
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ resource.getContents().add(supplier); // ATTACH
+ assertNew(supplier, transaction);
+ }
+
+ public void _____test_NEW_with_DETACH() throws Exception
+ {
+ // Detach single object
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ assertNew(resource, transaction);
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ resource.getContents().add(supplier); // ATTACH
+ assertNew(supplier, transaction);
+
+ detach(supplier);
+ assertTransient(supplier);
+
+ // Detach object tree
+ Category cat1 = getModel1Factory().createCategory();
+ cat1.setName("CAT1");
+ Category cat2 = getModel1Factory().createCategory();
+ cat2.setName("CAT2");
+ cat1.getCategories().add(cat2);
+ Product1 p1 = getModel1Factory().createProduct1();
+ p1.setName("P1");
+ cat1.getProducts().add(p1);
+ Product1 p2 = getModel1Factory().createProduct1();
+ p2.setName("P2");
+ cat1.getProducts().add(p2);
+ Product1 p3 = getModel1Factory().createProduct1();
+ p3.setName("P3");
+ cat2.getProducts().add(p3);
+ resource.getContents().add(cat1);
+ assertNew(cat1, transaction);
+ assertNew(cat2, transaction);
+ assertNew(p1, transaction);
+ assertNew(p2, transaction);
+ assertNew(p3, transaction);
+ System.out.println();
+ System.out.println();
+ System.out.println();
+ System.out.println();
+ resource.getContents().remove(cat1);
+ assertTransient(cat1);
+ assertTransient(cat2);
+ assertTransient(p1);
+ assertTransient(p2);
+ assertTransient(p3);
+ }
+
+ public void test_REATTACH() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Category cat1 = getModel1Factory().createCategory();
+ cat1.setName("CAT1");
+ resource.getContents().add(cat1);
+ Category cat2 = getModel1Factory().createCategory();
+ cat2.setName("CAT2");
+ resource.getContents().add(cat2);
+ Product1 p1 = getModel1Factory().createProduct1();
+ p1.setName("P1");
+ cat1.getProducts().add(p1);
+ assertNew(cat1, transaction);
+ assertNew(cat2, transaction);
+ assertNew(p1, transaction);
+
+ System.out.println();
+ System.out.println();
+ System.out.println();
+ System.out.println();
+ System.out.println();
+
+ CDOID id = CDOUtil.getCDOObject(p1).cdoID();
+ cat2.getProducts().add(p1);
+ assertNew(p1, transaction);
+ assertEquals(id, CDOUtil.getCDOObject(p1).cdoID());
+ }
+
+ public void test_NEW_with_READ() throws Exception
+ {
+ }
+
+ public void test_NEW_with_WRITE() throws Exception
+ {
+ }
+
+ public void test_NEW_with_INVALIDATE() throws Exception
+ {
+ }
+
+ public void test_NEW_with_COMMIT() throws Exception
+ {
+ }
+
+ public void test_NEW_with_ROLLBACK() throws Exception
+ {
+ }
+
+ private static void assertFailure(IllegalStateException ex)
+ {
+ IOUtil.print(ex);
+ assertEquals("Expected FAIL transition", true, ex.getMessage().startsWith("Failing event "));
+ }
+
+ private static void setState(EObject object, CDOState state)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ if (cdoObject != null)
+ {
+ ((InternalCDOObject)cdoObject).cdoInternalSetState(state);
+ }
+ }
+
+ private static void detach(EObject object)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ if (cdoObject != null)
+ {
+ CDOStateMachine.INSTANCE.detach((InternalCDOObject)cdoObject);
+ }
+ }
+
+ private static void read(EObject object)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ if (cdoObject != null)
+ {
+ CDOStateMachine.INSTANCE.read((InternalCDOObject)cdoObject);
+ }
+ }
+
+ private static void write(EObject object)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ if (cdoObject != null)
+ {
+ CDOStateMachine.INSTANCE.write((InternalCDOObject)cdoObject);
+ }
+ }
+
+ private static void invalidate(EObject object)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ if (cdoObject != null)
+ {
+ CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoObject, null, CDOBranchPoint.UNSPECIFIED_DATE);
+ }
+ }
+
+ private static void commit(EObject object, CommitTransactionResult result)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ if (cdoObject != null)
+ {
+ CDOStateMachine.INSTANCE.commit((InternalCDOObject)cdoObject, result);
+ }
+ }
+
+ private static void rollback(EObject object)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ if (cdoObject != null)
+ {
+ CDOStateMachine.INSTANCE.rollback((InternalCDOObject)cdoObject);
+ }
+ }
+
+ private static void testAttach(EObject object) throws Exception
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ if (cdoObject != null)
+ {
+ invokeMethod(cdoObject, "testAttach");
+ }
+ }
+
+ private static void invokeMethod(CDOObject object, String methodName) throws Exception
+ {
+ Method method = null;
+
+ try
+ {
+ method = CDOStateMachine.class.getDeclaredMethod(methodName, new Class[] { InternalCDOObject.class });
+ method.setAccessible(true);
+ method.invoke(CDOStateMachine.INSTANCE, object);
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (InvocationTargetException ex)
+ {
+ throw (Exception)ex.getTargetException();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ fail("Reflection problem: " + ex.getMessage());
+ }
+ finally
+ {
+ if (method != null)
+ {
+ method.setAccessible(false);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StickyViewsTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StickyViewsTest.java
index 3eb14ab941..b07e5e790a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StickyViewsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StickyViewsTest.java
@@ -1,380 +1,380 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.ObjectNotFoundException;
-
-import org.eclipse.emf.common.util.EList;
-
-/**
- * @author Caspar De Groot
- */
-// Sticky behavior is only enabled when store supports auditing, so these tests are
-// meaningless and/or guaranteed to fail if this is not the case
-@Requires(IRepositoryConfig.CAPABILITY_AUDITING)
-public class StickyViewsTest extends AbstractCDOTest
-{
- private static final int N_CATEGORIES = 3;
-
- public void test_removeLast() throws CommitException
- {
- test(new AbstractClosure()
- {
- public void doChange(EList<Category> categories)
- {
- categories.remove(N_CATEGORIES - 1);
- }
- });
- }
-
- public void test_removeFirst() throws CommitException
- {
- test(new AbstractClosure()
- {
- public void doChange(EList<Category> categories)
- {
- categories.remove(0);
- }
- });
- }
-
- public void test_changeName() throws CommitException
- {
- test(new AbstractClosure()
- {
- public void doChange(EList<Category> categories)
- {
- categories.get(0).setName("zzz");
- }
-
- @Override
- public void verify(EList<Category> categories)
- {
- assertEquals("category0", categories.get(0).getName());
- }
- });
- }
-
- private void test(Closure closure) throws CommitException
- {
- // Create a company with N categories
- Company company1 = getModel1Factory().createCompany();
- company1.setName("company");
- for (int i = 0; i < N_CATEGORIES; i++)
- {
- Category category = getModel1Factory().createCategory();
- company1.getCategories().add(category);
- category.setName("category" + i);
- }
-
- // Persist it
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- CDOResource res = transaction1.createResource(getResourcePath("/res1"));
- res.getContents().add(company1);
- transaction1.commit();
-
- assertEquals(N_CATEGORIES, company1.getCategories().size());
-
- // Fetch the same company in another session/tx
- CDOSession session2 = openSession();
- session2.options().setPassiveUpdateEnabled(false);
- CDOTransaction transaction2 = session2.openTransaction();
- CDOResource res2 = transaction2.getResource(getResourcePath("/res1"));
- Company company2 = (Company)res2.getContents().get(0);
-
- // In the 1st session, manipulate the categories
- closure.doChange(company1.getCategories());
- transaction1.commit();
-
- // Clear server-side cache to force loading of revisions from IStore
- IRepository repo = getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
- ((InternalCDORevisionManager)repo.getRevisionManager()).getCache().clear();
-
- // Verify that in 2nd session, all categories still appear to be present
- closure.verify(company2.getCategories());
-
- msg("Done");
-
- transaction1.close();
- session.close();
-
- session2.close();
- transaction2.close();
- }
-
- /**
- * Ensures that a newly committed object in this tx, can be reloaded from the server.
- */
- public void test_newCommittedObject() throws CommitException
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
-
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/res1"));
- Company company1 = getModel1Factory().createCompany();
- res.getContents().add(company1);
- tx.commit();
-
- // Make dirty, then roll back, so as to force PROXY state
- //
- company1.setName("company1");
- tx.rollback();
-
- // Clear cache to force loading of revisions from server
- //
- ((InternalCDORevisionManager)session.getRevisionManager()).getCache().clear();
-
- // Clear server-side cache to force loading of revisions from IStore
- //
- IRepository repo = getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
- ((InternalCDORevisionManager)repo.getRevisionManager()).getCache().clear();
-
- assertClean(CDOUtil.getCDOObject(company1), tx);
-
- msg(company1.getName());
-
- CDOID id = CDOUtil.getCDOObject(company1).cdoID();
- company1 = null;
-
- CDOObject obj = tx.getObject(id);
- assertNotNull(obj);
-
- session.close();
- }
-
- /**
- * Ensures that an object that was updated and committed in this tx, can be reloaded in its *updated* state from the
- * server.
- */
- public void test_dirtyCommittedObject() throws CommitException
- {
- // Put a company in the repo
- {
- CDOSession sess = openSession();
- CDOTransaction tx = sess.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/res1"));
- Company company1 = getModel1Factory().createCompany();
- company1.setName("aaa");
- res.getContents().add(company1);
- tx.commit();
- sess.close();
- }
-
- // Load it up in a different, sticky session
- {
- CDOSession sess = openSession();
- CDOTransaction tx = sess.openTransaction();
- sess.options().setPassiveUpdateEnabled(false);
- CDOResource res = tx.getResource(getResourcePath("/res1"));
-
- // Save with a new name
- Company company1 = (Company)res.getContents().get(0);
- company1.setName("bbb");
- tx.commit();
-
- // Make dirty then roll back, so as to force PROXY state
- company1.setName("ccc");
- tx.rollback();
-
- assertClean(CDOUtil.getCDOObject(company1), tx);
-
- // Clear cache to force loading of revisions from server
- ((InternalCDORevisionManager)sess.getRevisionManager()).getCache().clear();
-
- // Clear server-side cache to force loading of revisions from IStore
- IRepository repo = getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
- ((InternalCDORevisionManager)repo.getRevisionManager()).getCache().clear();
-
- String name = company1.getName();
- assertEquals("bbb", name);
- sess.close();
- }
- }
-
- /**
- * Ensures that an object that was removed in this tx, can no longer be loaded (even though the sticky time is still
- * set to a time when the object still existed!)
- */
- public void test_detachedCommittedObject() throws CommitException
- {
- // Put a company in the repo
- {
- CDOSession sess = openSession();
- CDOTransaction tx = sess.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/res1"));
- Company company1 = getModel1Factory().createCompany();
- company1.setName("aaa");
- res.getContents().add(company1);
- tx.commit();
- sess.close();
- }
-
- // Load it up in a different, sticky session
- {
- CDOSession sess = openSession();
- CDOTransaction tx = sess.openTransaction();
- sess.options().setPassiveUpdateEnabled(false);
- CDOResource res = tx.getResource(getResourcePath("/res1"));
-
- // Remove it
- Company company1 = (Company)res.getContents().get(0);
- CDOID companyID = CDOUtil.getCDOObject(company1).cdoID();
- res.getContents().remove(company1);
- tx.commit();
-
- // Clear cache to force loading of revisions from server
- //
- ((InternalCDORevisionManager)sess.getRevisionManager()).getCache().clear();
-
- // Clear server-side cache to force loading of revisions from IStore
- //
- IRepository repo = getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
- ((InternalCDORevisionManager)repo.getRevisionManager()).getCache().clear();
-
- try
- {
- tx.getObject(companyID);
- fail("Should have thrown " + ObjectNotFoundException.class.getSimpleName());
- }
- catch (ObjectNotFoundException e)
- {
- // Good
- }
-
- sess.close();
- }
- }
-
- public void test_refresh() throws CommitException
- {
- CDOSession sess = openSession();
- CDOTransaction tx = sess.openTransaction();
- sess.options().setPassiveUpdateEnabled(false);
-
- CDOResource res = tx.createResource(getResourcePath("/res1"));
- Company company1 = getModel1Factory().createCompany();
- company1.setName("aaa");
- res.getContents().add(company1);
- tx.commit(); // Puts the company in committedSinceLastRefresh
-
- sess.refresh(); // Removes the company from committedSinceLastRefresh
-
- // Make dirty then rollback to force proxy
- company1.setName("bbb");
- tx.rollback();
-
- // Clear cache to force loading of revisions from server
- //
- ((InternalCDORevisionManager)sess.getRevisionManager()).getCache().clear();
-
- doOtherSession(); // Creates a new revision on the server
-
- assertClean(CDOUtil.getCDOObject(company1), tx);
- assertEquals("The company name should not have the value set in the other session", "aaa", company1.getName());
-
- sess.close();
- }
-
- public void test_otherSessionCommittedLatest() throws CommitException
- {
- CDOSession sess = openSession();
- CDOTransaction tx = sess.openTransaction();
- sess.options().setPassiveUpdateEnabled(false);
-
- CDOResource res = tx.createResource(getResourcePath("/res1"));
- Company company1 = getModel1Factory().createCompany();
- company1.setName("aaa");
- res.getContents().add(company1);
- tx.commit(); // Puts the company in committedSinceLastRefresh
-
- // Make dirty then rollback to force proxy
- company1.setName("bbb");
- tx.rollback();
-
- // Clear cache to force loading of revisions from server
- ((InternalCDORevisionManager)sess.getRevisionManager()).getCache().clear();
-
- doOtherSession(); // Creates a new revision on the server
-
- assertClean(CDOUtil.getCDOObject(company1), tx);
-
- // Verify that this session still fetches the revision that *this* session just committed,
- // rather than the latest revision, which was committed by the other session
- assertEquals("aaa", company1.getName());
-
- sess.close();
- }
-
- private void doOtherSession() throws CommitException
- {
- CDOSession sess = openSession();
- CDOTransaction tx = sess.openTransaction();
- CDOResource res = tx.getResource(getResourcePath("/res1"));
- Company company1 = (Company)res.getContents().get(0);
- company1.setName("ccc");
- tx.commit();
- tx.close();
- sess.close();
- }
-
- /**
- * @author Caspar De Groot
- */
- private interface Closure
- {
- public void doChange(EList<Category> categories);
-
- public void verify(EList<Category> categories);
- }
-
- /**
- * @author Caspar De Groot
- */
- private abstract class AbstractClosure implements Closure
- {
- public void verify(EList<Category> categories)
- {
- assertEquals(N_CATEGORIES, categories.size());
-
- // Now fetch each category in the 2nd session
- for (int i = 0; i < N_CATEGORIES; i++)
- {
- msg("Getting index " + i);
- assertEquals(N_CATEGORIES, categories.size());
-
- try
- {
- Category cat = categories.get(i);
- assertNotNull(cat);
- }
- catch (ObjectNotFoundException e)
- {
- fail("Should not have thrown " + ObjectNotFoundException.class.getName());
- }
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * @author Caspar De Groot
+ */
+// Sticky behavior is only enabled when store supports auditing, so these tests are
+// meaningless and/or guaranteed to fail if this is not the case
+@Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+public class StickyViewsTest extends AbstractCDOTest
+{
+ private static final int N_CATEGORIES = 3;
+
+ public void test_removeLast() throws CommitException
+ {
+ test(new AbstractClosure()
+ {
+ public void doChange(EList<Category> categories)
+ {
+ categories.remove(N_CATEGORIES - 1);
+ }
+ });
+ }
+
+ public void test_removeFirst() throws CommitException
+ {
+ test(new AbstractClosure()
+ {
+ public void doChange(EList<Category> categories)
+ {
+ categories.remove(0);
+ }
+ });
+ }
+
+ public void test_changeName() throws CommitException
+ {
+ test(new AbstractClosure()
+ {
+ public void doChange(EList<Category> categories)
+ {
+ categories.get(0).setName("zzz");
+ }
+
+ @Override
+ public void verify(EList<Category> categories)
+ {
+ assertEquals("category0", categories.get(0).getName());
+ }
+ });
+ }
+
+ private void test(Closure closure) throws CommitException
+ {
+ // Create a company with N categories
+ Company company1 = getModel1Factory().createCompany();
+ company1.setName("company");
+ for (int i = 0; i < N_CATEGORIES; i++)
+ {
+ Category category = getModel1Factory().createCategory();
+ company1.getCategories().add(category);
+ category.setName("category" + i);
+ }
+
+ // Persist it
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ CDOResource res = transaction1.createResource(getResourcePath("/res1"));
+ res.getContents().add(company1);
+ transaction1.commit();
+
+ assertEquals(N_CATEGORIES, company1.getCategories().size());
+
+ // Fetch the same company in another session/tx
+ CDOSession session2 = openSession();
+ session2.options().setPassiveUpdateEnabled(false);
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource res2 = transaction2.getResource(getResourcePath("/res1"));
+ Company company2 = (Company)res2.getContents().get(0);
+
+ // In the 1st session, manipulate the categories
+ closure.doChange(company1.getCategories());
+ transaction1.commit();
+
+ // Clear server-side cache to force loading of revisions from IStore
+ IRepository repo = getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
+ ((InternalCDORevisionManager)repo.getRevisionManager()).getCache().clear();
+
+ // Verify that in 2nd session, all categories still appear to be present
+ closure.verify(company2.getCategories());
+
+ msg("Done");
+
+ transaction1.close();
+ session.close();
+
+ session2.close();
+ transaction2.close();
+ }
+
+ /**
+ * Ensures that a newly committed object in this tx, can be reloaded from the server.
+ */
+ public void test_newCommittedObject() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/res1"));
+ Company company1 = getModel1Factory().createCompany();
+ res.getContents().add(company1);
+ tx.commit();
+
+ // Make dirty, then roll back, so as to force PROXY state
+ //
+ company1.setName("company1");
+ tx.rollback();
+
+ // Clear cache to force loading of revisions from server
+ //
+ ((InternalCDORevisionManager)session.getRevisionManager()).getCache().clear();
+
+ // Clear server-side cache to force loading of revisions from IStore
+ //
+ IRepository repo = getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
+ ((InternalCDORevisionManager)repo.getRevisionManager()).getCache().clear();
+
+ assertClean(CDOUtil.getCDOObject(company1), tx);
+
+ msg(company1.getName());
+
+ CDOID id = CDOUtil.getCDOObject(company1).cdoID();
+ company1 = null;
+
+ CDOObject obj = tx.getObject(id);
+ assertNotNull(obj);
+
+ session.close();
+ }
+
+ /**
+ * Ensures that an object that was updated and committed in this tx, can be reloaded in its *updated* state from the
+ * server.
+ */
+ public void test_dirtyCommittedObject() throws CommitException
+ {
+ // Put a company in the repo
+ {
+ CDOSession sess = openSession();
+ CDOTransaction tx = sess.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/res1"));
+ Company company1 = getModel1Factory().createCompany();
+ company1.setName("aaa");
+ res.getContents().add(company1);
+ tx.commit();
+ sess.close();
+ }
+
+ // Load it up in a different, sticky session
+ {
+ CDOSession sess = openSession();
+ CDOTransaction tx = sess.openTransaction();
+ sess.options().setPassiveUpdateEnabled(false);
+ CDOResource res = tx.getResource(getResourcePath("/res1"));
+
+ // Save with a new name
+ Company company1 = (Company)res.getContents().get(0);
+ company1.setName("bbb");
+ tx.commit();
+
+ // Make dirty then roll back, so as to force PROXY state
+ company1.setName("ccc");
+ tx.rollback();
+
+ assertClean(CDOUtil.getCDOObject(company1), tx);
+
+ // Clear cache to force loading of revisions from server
+ ((InternalCDORevisionManager)sess.getRevisionManager()).getCache().clear();
+
+ // Clear server-side cache to force loading of revisions from IStore
+ IRepository repo = getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
+ ((InternalCDORevisionManager)repo.getRevisionManager()).getCache().clear();
+
+ String name = company1.getName();
+ assertEquals("bbb", name);
+ sess.close();
+ }
+ }
+
+ /**
+ * Ensures that an object that was removed in this tx, can no longer be loaded (even though the sticky time is still
+ * set to a time when the object still existed!)
+ */
+ public void test_detachedCommittedObject() throws CommitException
+ {
+ // Put a company in the repo
+ {
+ CDOSession sess = openSession();
+ CDOTransaction tx = sess.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/res1"));
+ Company company1 = getModel1Factory().createCompany();
+ company1.setName("aaa");
+ res.getContents().add(company1);
+ tx.commit();
+ sess.close();
+ }
+
+ // Load it up in a different, sticky session
+ {
+ CDOSession sess = openSession();
+ CDOTransaction tx = sess.openTransaction();
+ sess.options().setPassiveUpdateEnabled(false);
+ CDOResource res = tx.getResource(getResourcePath("/res1"));
+
+ // Remove it
+ Company company1 = (Company)res.getContents().get(0);
+ CDOID companyID = CDOUtil.getCDOObject(company1).cdoID();
+ res.getContents().remove(company1);
+ tx.commit();
+
+ // Clear cache to force loading of revisions from server
+ //
+ ((InternalCDORevisionManager)sess.getRevisionManager()).getCache().clear();
+
+ // Clear server-side cache to force loading of revisions from IStore
+ //
+ IRepository repo = getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
+ ((InternalCDORevisionManager)repo.getRevisionManager()).getCache().clear();
+
+ try
+ {
+ tx.getObject(companyID);
+ fail("Should have thrown " + ObjectNotFoundException.class.getSimpleName());
+ }
+ catch (ObjectNotFoundException e)
+ {
+ // Good
+ }
+
+ sess.close();
+ }
+ }
+
+ public void test_refresh() throws CommitException
+ {
+ CDOSession sess = openSession();
+ CDOTransaction tx = sess.openTransaction();
+ sess.options().setPassiveUpdateEnabled(false);
+
+ CDOResource res = tx.createResource(getResourcePath("/res1"));
+ Company company1 = getModel1Factory().createCompany();
+ company1.setName("aaa");
+ res.getContents().add(company1);
+ tx.commit(); // Puts the company in committedSinceLastRefresh
+
+ sess.refresh(); // Removes the company from committedSinceLastRefresh
+
+ // Make dirty then rollback to force proxy
+ company1.setName("bbb");
+ tx.rollback();
+
+ // Clear cache to force loading of revisions from server
+ //
+ ((InternalCDORevisionManager)sess.getRevisionManager()).getCache().clear();
+
+ doOtherSession(); // Creates a new revision on the server
+
+ assertClean(CDOUtil.getCDOObject(company1), tx);
+ assertEquals("The company name should not have the value set in the other session", "aaa", company1.getName());
+
+ sess.close();
+ }
+
+ public void test_otherSessionCommittedLatest() throws CommitException
+ {
+ CDOSession sess = openSession();
+ CDOTransaction tx = sess.openTransaction();
+ sess.options().setPassiveUpdateEnabled(false);
+
+ CDOResource res = tx.createResource(getResourcePath("/res1"));
+ Company company1 = getModel1Factory().createCompany();
+ company1.setName("aaa");
+ res.getContents().add(company1);
+ tx.commit(); // Puts the company in committedSinceLastRefresh
+
+ // Make dirty then rollback to force proxy
+ company1.setName("bbb");
+ tx.rollback();
+
+ // Clear cache to force loading of revisions from server
+ ((InternalCDORevisionManager)sess.getRevisionManager()).getCache().clear();
+
+ doOtherSession(); // Creates a new revision on the server
+
+ assertClean(CDOUtil.getCDOObject(company1), tx);
+
+ // Verify that this session still fetches the revision that *this* session just committed,
+ // rather than the latest revision, which was committed by the other session
+ assertEquals("aaa", company1.getName());
+
+ sess.close();
+ }
+
+ private void doOtherSession() throws CommitException
+ {
+ CDOSession sess = openSession();
+ CDOTransaction tx = sess.openTransaction();
+ CDOResource res = tx.getResource(getResourcePath("/res1"));
+ Company company1 = (Company)res.getContents().get(0);
+ company1.setName("ccc");
+ tx.commit();
+ tx.close();
+ sess.close();
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private interface Closure
+ {
+ public void doChange(EList<Category> categories);
+
+ public void verify(EList<Category> categories);
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private abstract class AbstractClosure implements Closure
+ {
+ public void verify(EList<Category> categories)
+ {
+ assertEquals(N_CATEGORIES, categories.size());
+
+ // Now fetch each category in the 2nd session
+ for (int i = 0; i < N_CATEGORIES; i++)
+ {
+ msg("Getting index " + i);
+ assertEquals(N_CATEGORIES, categories.size());
+
+ try
+ {
+ Category cat = categories.get(i);
+ assertNotNull(cat);
+ }
+ catch (ObjectNotFoundException e)
+ {
+ fail("Should not have thrown " + ObjectNotFoundException.class.getName());
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionHandlerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionHandlerTest.java
index 15ad079a0b..505706adb4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionHandlerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionHandlerTest.java
@@ -1,465 +1,465 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.transaction.CDOAsyncTransactionHandler;
-import org.eclipse.emf.cdo.transaction.CDOCommitContext;
-import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.transaction.CDOTransactionHandler;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Simon McDuff
- */
-public class TransactionHandlerTest extends AbstractCDOTest
-{
- private static final String VETO_MESSAGE = "Simulated veto";
-
- public TransactionHandlerTest()
- {
- }
-
- public void testAttachingObject() throws Exception
- {
- CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(handler);
-
- CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
-
- assertEquals(true, handler.getListOfAddingObject().contains(resource1));
-
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
-
- resource1.getContents().add(order);
- assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(order)));
- assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(orderDetail)));
-
- transaction.close();
- session.close();
- }
-
- public void testAttachingResourceVeto() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(new CDODefaultTransactionHandler()
- {
- @Override
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- veto();
- }
- });
-
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
-
- try
- {
- transaction.getOrCreateResource(getResourcePath("/test1"));
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException ex)
- {
- assertEquals(VETO_MESSAGE, ex.getMessage());
- }
- finally
- {
- session.close();
- }
- }
-
- public void testAttachingObjectVeto() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
-
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- transaction.addTransactionHandler(new CDODefaultTransactionHandler()
- {
- @Override
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- veto();
- }
- });
-
- try
- {
- resource.getContents().add(order);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException ex)
- {
- assertEquals(VETO_MESSAGE, ex.getMessage());
- }
- finally
- {
- session.close();
- }
- }
-
- public void testDetachingObject() throws Exception
- {
- CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(handler);
-
- CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
-
- resource1.getContents().add(order);
- assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(order)));
- assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(orderDetail)));
-
- msg("Remove Object");
- order.getOrderDetails().remove(orderDetail);
- assertEquals(true, handler.getListOfDetachingObject().contains(CDOUtil.getCDOObject(orderDetail)));
-
- resource1.delete(null);
- assertEquals(true, handler.getListOfDetachingObject().contains(resource1));
-
- transaction.close();
- session.close();
- }
-
- public void testDetachingObjectVeto() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(new CDODefaultTransactionHandler()
- {
- @Override
- public void detachingObject(CDOTransaction transaction, CDOObject object)
- {
- veto();
- }
- });
-
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
-
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(order);
-
- try
- {
- order.getOrderDetails().remove(orderDetail);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException ex)
- {
- assertEquals(VETO_MESSAGE, ex.getMessage());
- }
- finally
- {
- session.close();
- }
- }
-
- public void testModifyingObject() throws Exception
- {
- CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(handler);
-
- CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
-
- resource1.getContents().add(order);
- assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(order)));
- assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(orderDetail)));
-
- msg("Modifying Object");
- assertEquals(false, handler.getListOfModifyinObject().contains(orderDetail));
- orderDetail.setPrice(1.0f);
- assertEquals(true, handler.getListOfModifyinObject().contains(CDOUtil.getCDOObject(orderDetail)));
- transaction.close();
- session.close();
- }
-
- public void testModifyingResourceVeto() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(new CDODefaultTransactionHandler()
- {
- @Override
- public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
- {
- veto();
- }
- });
-
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
-
- try
- {
- transaction.getOrCreateResource(getResourcePath("/test1"));
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException ex)
- {
- assertEquals(VETO_MESSAGE, ex.getMessage());
- }
- finally
- {
- session.close();
- }
- }
-
- public void testModifyingObjectVeto() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
-
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(order);
-
- transaction.addTransactionHandler(new CDODefaultTransactionHandler()
- {
- @Override
- public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
- {
- veto();
- }
- });
-
- try
- {
- orderDetail.setPrice(1.0f);
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException ex)
- {
- assertEquals(VETO_MESSAGE, ex.getMessage());
- }
- finally
- {
- session.close();
- }
- }
-
- public void testCommitting() throws Exception
- {
- CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(handler);
-
- transaction.getOrCreateResource(getResourcePath("/test1"));
- transaction.commit();
- assertEquals(1, handler.getNumberOfCommit());
-
- transaction.close();
- session.close();
- }
-
- public void testRollbacked() throws Exception
- {
- CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(handler);
-
- transaction.getOrCreateResource(getResourcePath("/test1"));
-
- transaction.rollback();
- assertEquals(1, handler.getNumberOfRollback());
-
- transaction.close();
- session.close();
- }
-
- public void testAsyncTransactionHandler() throws Exception
- {
- final CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
- CDOAsyncTransactionHandler asyncHandler = new CDOAsyncTransactionHandler(handler);
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- Order order = getModel1Factory().createPurchaseOrder();
- final Company company = getModel1Factory().createCompany();
-
- final CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(company);
-
- transaction.addTransactionHandler(new CDOAsyncTransactionHandler(new CDOTransactionHandler()
- {
- public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta)
- {
- // Create READ access to see if we have deadlock
- company.getCity();
- }
-
- public void detachingObject(CDOTransaction transaction, CDOObject object)
- {
- // Create READ access to see if we have deadlock
- company.getCity();
- }
-
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- // Create READ access to see if we have deadlock
- company.getCity();
- }
-
- public void rolledBackTransaction(CDOTransaction transaction)
- {
- }
-
- public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- }
-
- public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- }
- }));
-
- transaction.addTransactionHandler(asyncHandler);
- resource.getContents().add(order); // 1 modif + 1 attach
- resource.getContents().remove(order); // 1 modif + 1 detach
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return handler.listOfAddingObject.size() == 1 && handler.listOfDetachingObject.size() == 1
- && handler.listOfModifyinObject.size() == 2;
- }
- }.assertNoTimeOut();
-
- // Wait a little bit to let the async finish. It is only there to not have Transaction not active exception and
- // mislead the test.
- sleep(300);
- session.close();
- }
-
- protected void veto()
- {
- throw new IllegalStateException(VETO_MESSAGE);
- }
-
- /**
- * @author Simon McDuff
- */
- private static class CDOAccumulateTransactionHandler implements CDOTransactionHandler
- {
- private List<CDOObject> listOfAddingObject = new ArrayList<CDOObject>();
-
- private List<CDOObject> listOfDetachingObject = new ArrayList<CDOObject>();
-
- private List<CDOObject> listOfModifyinObject = new ArrayList<CDOObject>();
-
- private int numberOfCommit;
-
- private int numberOfRollback;
-
- public CDOAccumulateTransactionHandler()
- {
- }
-
- public List<CDOObject> getListOfAddingObject()
- {
- return listOfAddingObject;
- }
-
- public List<CDOObject> getListOfDetachingObject()
- {
- return listOfDetachingObject;
- }
-
- public List<CDOObject> getListOfModifyinObject()
- {
- return listOfModifyinObject;
- }
-
- public int getNumberOfCommit()
- {
- return numberOfCommit;
- }
-
- public int getNumberOfRollback()
- {
- return numberOfRollback;
- }
-
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- listOfAddingObject.add(object);
- }
-
- public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- numberOfCommit++;
- }
-
- public void detachingObject(CDOTransaction transaction, CDOObject object)
- {
- listOfDetachingObject.add(object);
- }
-
- public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta)
- {
- listOfModifyinObject.add(object);
- }
-
- public void rolledBackTransaction(CDOTransaction transaction)
- {
- numberOfRollback++;
- }
-
- public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.transaction.CDOAsyncTransactionHandler;
+import org.eclipse.emf.cdo.transaction.CDOCommitContext;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandler;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Simon McDuff
+ */
+public class TransactionHandlerTest extends AbstractCDOTest
+{
+ private static final String VETO_MESSAGE = "Simulated veto";
+
+ public TransactionHandlerTest()
+ {
+ }
+
+ public void testAttachingObject() throws Exception
+ {
+ CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(handler);
+
+ CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
+
+ assertEquals(true, handler.getListOfAddingObject().contains(resource1));
+
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+
+ resource1.getContents().add(order);
+ assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(order)));
+ assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(orderDetail)));
+
+ transaction.close();
+ session.close();
+ }
+
+ public void testAttachingResourceVeto() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler()
+ {
+ @Override
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ veto();
+ }
+ });
+
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+
+ try
+ {
+ transaction.getOrCreateResource(getResourcePath("/test1"));
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException ex)
+ {
+ assertEquals(VETO_MESSAGE, ex.getMessage());
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ public void testAttachingObjectVeto() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler()
+ {
+ @Override
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ veto();
+ }
+ });
+
+ try
+ {
+ resource.getContents().add(order);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException ex)
+ {
+ assertEquals(VETO_MESSAGE, ex.getMessage());
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ public void testDetachingObject() throws Exception
+ {
+ CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(handler);
+
+ CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+
+ resource1.getContents().add(order);
+ assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(order)));
+ assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(orderDetail)));
+
+ msg("Remove Object");
+ order.getOrderDetails().remove(orderDetail);
+ assertEquals(true, handler.getListOfDetachingObject().contains(CDOUtil.getCDOObject(orderDetail)));
+
+ resource1.delete(null);
+ assertEquals(true, handler.getListOfDetachingObject().contains(resource1));
+
+ transaction.close();
+ session.close();
+ }
+
+ public void testDetachingObjectVeto() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler()
+ {
+ @Override
+ public void detachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ veto();
+ }
+ });
+
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(order);
+
+ try
+ {
+ order.getOrderDetails().remove(orderDetail);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException ex)
+ {
+ assertEquals(VETO_MESSAGE, ex.getMessage());
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ public void testModifyingObject() throws Exception
+ {
+ CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(handler);
+
+ CDOResource resource1 = transaction.getOrCreateResource(getResourcePath("/test1"));
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+
+ resource1.getContents().add(order);
+ assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(order)));
+ assertEquals(true, handler.getListOfAddingObject().contains(CDOUtil.getCDOObject(orderDetail)));
+
+ msg("Modifying Object");
+ assertEquals(false, handler.getListOfModifyinObject().contains(orderDetail));
+ orderDetail.setPrice(1.0f);
+ assertEquals(true, handler.getListOfModifyinObject().contains(CDOUtil.getCDOObject(orderDetail)));
+ transaction.close();
+ session.close();
+ }
+
+ public void testModifyingResourceVeto() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler()
+ {
+ @Override
+ public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
+ {
+ veto();
+ }
+ });
+
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+
+ try
+ {
+ transaction.getOrCreateResource(getResourcePath("/test1"));
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException ex)
+ {
+ assertEquals(VETO_MESSAGE, ex.getMessage());
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ public void testModifyingObjectVeto() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(order);
+
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler()
+ {
+ @Override
+ public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
+ {
+ veto();
+ }
+ });
+
+ try
+ {
+ orderDetail.setPrice(1.0f);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException ex)
+ {
+ assertEquals(VETO_MESSAGE, ex.getMessage());
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ public void testCommitting() throws Exception
+ {
+ CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(handler);
+
+ transaction.getOrCreateResource(getResourcePath("/test1"));
+ transaction.commit();
+ assertEquals(1, handler.getNumberOfCommit());
+
+ transaction.close();
+ session.close();
+ }
+
+ public void testRollbacked() throws Exception
+ {
+ CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(handler);
+
+ transaction.getOrCreateResource(getResourcePath("/test1"));
+
+ transaction.rollback();
+ assertEquals(1, handler.getNumberOfRollback());
+
+ transaction.close();
+ session.close();
+ }
+
+ public void testAsyncTransactionHandler() throws Exception
+ {
+ final CDOAccumulateTransactionHandler handler = new CDOAccumulateTransactionHandler();
+ CDOAsyncTransactionHandler asyncHandler = new CDOAsyncTransactionHandler(handler);
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ Order order = getModel1Factory().createPurchaseOrder();
+ final Company company = getModel1Factory().createCompany();
+
+ final CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+
+ transaction.addTransactionHandler(new CDOAsyncTransactionHandler(new CDOTransactionHandler()
+ {
+ public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta)
+ {
+ // Create READ access to see if we have deadlock
+ company.getCity();
+ }
+
+ public void detachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ // Create READ access to see if we have deadlock
+ company.getCity();
+ }
+
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ // Create READ access to see if we have deadlock
+ company.getCity();
+ }
+
+ public void rolledBackTransaction(CDOTransaction transaction)
+ {
+ }
+
+ public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ }
+
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ }
+ }));
+
+ transaction.addTransactionHandler(asyncHandler);
+ resource.getContents().add(order); // 1 modif + 1 attach
+ resource.getContents().remove(order); // 1 modif + 1 detach
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return handler.listOfAddingObject.size() == 1 && handler.listOfDetachingObject.size() == 1
+ && handler.listOfModifyinObject.size() == 2;
+ }
+ }.assertNoTimeOut();
+
+ // Wait a little bit to let the async finish. It is only there to not have Transaction not active exception and
+ // mislead the test.
+ sleep(300);
+ session.close();
+ }
+
+ protected void veto()
+ {
+ throw new IllegalStateException(VETO_MESSAGE);
+ }
+
+ /**
+ * @author Simon McDuff
+ */
+ private static class CDOAccumulateTransactionHandler implements CDOTransactionHandler
+ {
+ private List<CDOObject> listOfAddingObject = new ArrayList<CDOObject>();
+
+ private List<CDOObject> listOfDetachingObject = new ArrayList<CDOObject>();
+
+ private List<CDOObject> listOfModifyinObject = new ArrayList<CDOObject>();
+
+ private int numberOfCommit;
+
+ private int numberOfRollback;
+
+ public CDOAccumulateTransactionHandler()
+ {
+ }
+
+ public List<CDOObject> getListOfAddingObject()
+ {
+ return listOfAddingObject;
+ }
+
+ public List<CDOObject> getListOfDetachingObject()
+ {
+ return listOfDetachingObject;
+ }
+
+ public List<CDOObject> getListOfModifyinObject()
+ {
+ return listOfModifyinObject;
+ }
+
+ public int getNumberOfCommit()
+ {
+ return numberOfCommit;
+ }
+
+ public int getNumberOfRollback()
+ {
+ return numberOfRollback;
+ }
+
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ listOfAddingObject.add(object);
+ }
+
+ public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ numberOfCommit++;
+ }
+
+ public void detachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ listOfDetachingObject.add(object);
+ }
+
+ public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta)
+ {
+ listOfModifyinObject.add(object);
+ }
+
+ public void rolledBackTransaction(CDOTransaction transaction)
+ {
+ numberOfRollback++;
+ }
+
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java
index 0b30557df3..dc95536b80 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java
@@ -1,627 +1,627 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest;
-import org.eclipse.emf.cdo.net4j.CDONet4jSession;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.commit.CDOCommitInfoUtil;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOCommitContext;
-import org.eclipse.emf.cdo.transaction.CDOPushTransaction;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
-import org.eclipse.emf.cdo.transaction.CDOTransactionHandler2;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.ReflectUtil;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import java.io.File;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * See bug 213782, bug 201366
- *
- * @author Simon McDuff
- */
-public class TransactionTest extends AbstractCDOTest
-{
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- OMPlatform.INSTANCE.setDebugging(false);
- }
-
- public void testCommitAfterClose() throws Exception
- {
- CDOSession session = openSession();
- assertEquals(true, LifecycleUtil.isActive(session));
- assertEquals(false, session.isClosed());
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(getModel1Factory().createCompany());
- assertEquals(true, LifecycleUtil.isActive(transaction));
- assertEquals(false, transaction.isClosed());
-
- session.close();
- assertEquals(false, LifecycleUtil.isActive(session));
- assertEquals(true, session.isClosed());
- assertEquals(false, LifecycleUtil.isActive(transaction));
- assertEquals(true, transaction.isClosed());
-
- try
- {
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- // SUCCESS
- }
- }
-
- /**
- * See bug 335432
- */
- public void testLastUpdateTime() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(getModel1Factory().createCompany());
-
- long timeStamp = transaction.commit().getTimeStamp();
- assertEquals(timeStamp, session.getLastUpdateTime());
- assertEquals(timeStamp, transaction.getLastUpdateTime());
- }
-
- public void testCreateManySessions() throws Exception
- {
- {
- IOUtil.OUT().println("Opening session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.createResource(getResourcePath("/test2"));
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- for (int i = 0; i < 100; i++)
- {
- IOUtil.OUT().println("Session " + i);
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test2"));
- Category category = getModel1Factory().createCategory();
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
- }
- }
-
- public void testCreateManyTransactions() throws Exception
- {
- IOUtil.OUT().println("Opening session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test2"));
- transaction.commit();
- transaction.close();
-
- long lastDuration = 0;
- for (int i = 0; i < 100; i++)
- {
- IOUtil.OUT().println("Transaction " + i + " (" + lastDuration + ")");
- lastDuration = System.currentTimeMillis();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/test2"));
-
- Category category = getModel1Factory().createCategory();
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- lastDuration = System.currentTimeMillis() - lastDuration;
- }
-
- session.close();
- }
-
- public void testCreateManySessionsAndTransactionsMultiThread() throws Exception
- {
- final long TIMEOUT = 2 * 120L;
- final int THREADS = 5;
-
- final List<Exception> exceptions = new ArrayList<Exception>();
- final CountDownLatch latch = new CountDownLatch(THREADS);
- List<Thread> threadList = new ArrayList<Thread>();
- for (int i = 0; i < THREADS; i++)
- {
- final int id = i;
- threadList.add(new Thread("TEST-THREAD-" + id)
- {
- @Override
- public void run()
- {
- try
- {
- IOUtil.OUT().println("Thread " + id + ": Started");
- for (int i = 0; i < 100; i++)
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- IOUtil.OUT().println("Thread " + id + ": Session + Transaction " + i);
- transaction.close();
- session.close();
- }
-
- IOUtil.OUT().println("Thread " + id + ": Done");
- }
- catch (Exception ex)
- {
- System.out.println("Thread " + id + ": " + ex.getClass().getName() + ": " + ex.getMessage());
- synchronized (exceptions)
- {
- exceptions.add(ex);
- }
- }
- finally
- {
- latch.countDown();
- }
- }
- });
- }
-
- for (Thread thread : threadList)
- {
- thread.start();
- }
-
- boolean timedOut = !latch.await(TIMEOUT, TimeUnit.SECONDS);
-
- for (Exception ex : exceptions)
- {
- System.out.println();
- System.out.println();
- IOUtil.print(ex);
- }
-
- if (timedOut)
- {
- fail("Timeout after " + TIMEOUT + " seconds");
- }
- else
- {
- assertEquals(0, exceptions.size());
- }
- }
-
- public void testPushModeNewObjects() throws Exception
- {
- IOUtil.OUT().println("Creating category1");
- Category category1 = getModel1Factory().createCategory();
- category1.setName("category1");
-
- IOUtil.OUT().println("Creating category2");
- Category category2 = getModel1Factory().createCategory();
- category2.setName("category2");
-
- IOUtil.OUT().println("Creating category3");
- Category category3 = getModel1Factory().createCategory();
- category3.setName("category3");
-
- IOUtil.OUT().println("Creating company");
- Company company = getModel1Factory().createCompany();
- company.setName("Foundation");
-
- IOUtil.OUT().println("Adding categories");
- company.getCategories().add(category1);
- category1.getCategories().add(category2);
- category1.getCategories().add(category3);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOPushTransaction pushTransaction = new CDOPushTransaction(transaction);
- File file = pushTransaction.getFile();
-
- CDOResource resource = pushTransaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(company);
-
- pushTransaction.commit();
- pushTransaction.close();
- transaction = session.openTransaction();
- pushTransaction = new CDOPushTransaction(transaction, file);
- pushTransaction.push();
-
- session.close();
- session = openSession();
-
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test1"));
- company = (Company)resource.getContents().get(0);
- assertEquals("Foundation", company.getName());
- assertEquals(1, company.getCategories().size());
- assertEquals(2, company.getCategories().get(0).getCategories().size());
- session.close();
- }
-
- public void testPushModeDeltas() throws Exception
- {
- IOUtil.OUT().println("Creating category1");
- Category category1 = getModel1Factory().createCategory();
- category1.setName("category1");
-
- IOUtil.OUT().println("Creating company");
- Company company = getModel1Factory().createCompany();
- company.setName("Foundation");
-
- IOUtil.OUT().println("Adding categories");
- company.getCategories().add(category1);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOPushTransaction pushTransaction = new CDOPushTransaction(transaction);
- File file = pushTransaction.getFile();
-
- CDOResource resource = pushTransaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(company);
-
- pushTransaction.commit();
-
- IOUtil.OUT().println("Creating category2");
- Category category2 = getModel1Factory().createCategory();
- category2.setName("category2");
- category1.getCategories().add(category2);
-
- IOUtil.OUT().println("Creating category3");
- Category category3 = getModel1Factory().createCategory();
- category3.setName("category3");
- category1.getCategories().add(category3);
-
- pushTransaction.commit();
- pushTransaction.close();
-
- transaction = session.openTransaction();
- pushTransaction = new CDOPushTransaction(transaction, file);
- pushTransaction.push();
-
- session.close();
- session = openSession();
-
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test1"));
- company = (Company)resource.getContents().get(0);
- assertEquals("Foundation", company.getName());
- assertEquals(1, company.getCategories().size());
- assertEquals(2, company.getCategories().get(0).getCategories().size());
- session.close();
- }
-
- public void testAutoRollbackOnConflictEvent() throws Exception
- {
- final CDOSession session1 = openSession();
- final CDOTransaction transaction1 = session1.openTransaction();
-
- CDOResource resource1 = transaction1.createResource(getResourcePath("/test"));
- Category category1 = getModel1Factory().createCategory();
- resource1.getContents().add(category1);
- transaction1.commit();
-
- final CDOSession session2 = openSession();
- final CDOTransaction transaction2 = session2.openTransaction();
- transaction2.addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOTransactionConflictEvent)
- {
- transaction2.rollback();
- }
- }
- });
-
- final CountDownLatch rollback = new CountDownLatch(1);
- transaction2.addTransactionHandler(new CDOTransactionHandler2()
- {
- public void rolledBackTransaction(CDOTransaction transaction)
- {
- IOUtil.OUT().println("rollback");
- rollback.countDown();
- }
-
- public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- }
-
- public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- }
- });
-
- CDOResource resource2 = transaction2.getResource(getResourcePath("/test"));
- Category category2 = (Category)resource2.getContents().get(0);
- category2.setName("session2");
-
- category1.setName("session1");
- transaction1.commit();
-
- rollback.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- category2.setName("session2");
- transaction2.commit();
- }
-
- /**
- * Bug 283131
- */
- public void testRollbackWithNotification() throws CommitException
- {
- Category category = getModel1Factory().createCategory();
- category.setName("name1");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/test"));
-
- resource1.getContents().add(category);
- transaction.commit();
-
- category.setName("name2");
-
- TestAdapter testAdapter = new TestAdapter();
- category.eAdapters().add(testAdapter);
-
- transaction.rollback();
-
- Notification[] notifications = testAdapter.getNotifications();
- assertEquals(1, notifications.length);
-
- Notification notification = notifications[0];
- assertEquals("name2", notification.getOldStringValue());
- assertEquals("name1", notification.getNewStringValue());
- }
-
- public void testManualRollbackOnConflictException() throws Exception
- {
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
-
- CDOResource resource1 = transaction1.createResource(getResourcePath("/test"));
- Category category1 = getModel1Factory().createCategory();
- resource1.getContents().add(category1);
- transaction1.commit();
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
-
- CDOResource resource2 = transaction2.getResource(getResourcePath("/test"));
- Category category2 = (Category)resource2.getContents().get(0);
- category2.setName("session2");
-
- category1.setName("session1");
- commitAndSync(transaction1, transaction2);
- IOUtil.OUT().println("After transaction1.commit(): " + CDOUtil.getCDOObject(category1).cdoRevision());
-
- CDOObject cdoCategory2 = CDOUtil.getCDOObject(category2);
-
- try
- {
- IOUtil.OUT().println("Before transaction2.commit(): " + cdoCategory2.cdoRevision());
- category2.setName("session2");
-
- transaction2.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- IOUtil.OUT().println("Before transaction2.rollback(): " + cdoCategory2.cdoRevision());
- transaction2.rollback();
- IOUtil.OUT().println("After transaction2.rollback(): " + cdoCategory2.cdoRevision());
- }
-
- category2.setName("session2");
-
- IOUtil.OUT().println("Before transaction2.commit():");
- CDOCommitInfoUtil.dump(IOUtil.OUT(), transaction2.getChangeSetData());
-
- transaction2.commit();
- IOUtil.OUT().println("After transaction2.commit(): " + cdoCategory2.cdoRevision());
- assertEquals(3, cdoCategory2.cdoRevision().getVersion());
- }
-
- public void testLongCommit() throws Exception
- {
- OMPlatform.INSTANCE.setDebugging(true);
-
- CDOCommitInfoHandler handler = new CDOCommitInfoHandler()
- {
- public void handleCommitInfo(CDOCommitInfo commitInfo)
- {
- sleep(3000L);
- }
- };
-
- IRepository repository = getRepository();
- repository.addCommitInfoHandler(handler);
-
- try
- {
- CDOSession session = openSession();
- if (session instanceof CDONet4jSession)
- {
- ((CDONet4jSession)session).options().setCommitTimeout(1);
-
- }
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(getModel1Factory().createCompany());
-
- transaction.commit();
- }
- finally
- {
- repository.removeCommitInfoHandler(handler);
- }
- }
-
- public void _testLongCommit2() throws Exception
- {
- OMPlatform.INSTANCE.setDebugging(true);
- Field field = ReflectUtil.getField(CommitTransactionRequest.class, "sleepMillisForTesting");
-
- try
- {
- ReflectUtil.setValue(field, null, 1000L);
-
- org.eclipse.emf.cdo.net4j.CDONet4jSession session = (org.eclipse.emf.cdo.net4j.CDONet4jSession)openSession();
- session.options().setCommitTimeout(60);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
-
- for (int i = 0; i < 300; i++)
- {
- resource.getContents().add(getModel1Factory().createCompany());
- }
-
- transaction.commit();
- }
- finally
- {
- ReflectUtil.setValue(field, null, 0L);
- }
- }
-
- /**
- * Bug 353167.
- */
- public void testReattachCommit() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(company);
- transaction.commit();
-
- resource.getContents().remove(company);
- resource.getContents().add(company);
- transaction.commit();
- }
-
- /**
- * Bug 353167.
- */
- public void testReattachModifyCommit() throws Exception
- {
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(company);
- transaction.commit();
-
- resource.getContents().remove(company);
- resource.getContents().add(company);
- company.setName("ESC");
- transaction.commit();
- }
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/test1"));
- Company company2 = (Company)resource2.getContents().get(0);
- assertEquals("ESC", company2.getName());
- }
-
- /**
- * Bug 353167.
- */
- public void testReattachCommitWithSavepoints() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(company);
- transaction.commit();
-
- resource.getContents().remove(company);
- transaction.setSavepoint();
-
- resource.getContents().add(company);
- transaction.setSavepoint();
- transaction.commit();
- }
-
- /**
- * Bug 353167.
- */
- public void testReattachModifyCommitWithSavepoints() throws Exception
- {
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- resource.getContents().add(company);
- transaction.commit();
-
- resource.getContents().remove(company);
- // transaction.setSavepoint();
-
- resource.getContents().add(company);
- transaction.setSavepoint();
-
- company.setName("ESC");
-
- transaction.commit();
- }
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/test1"));
- Company company2 = (Company)resource2.getContents().get(0);
- assertEquals("ESC", company2.getName());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.commit.CDOCommitInfoUtil;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOCommitContext;
+import org.eclipse.emf.cdo.transaction.CDOPushTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandler2;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * See bug 213782, bug 201366
+ *
+ * @author Simon McDuff
+ */
+public class TransactionTest extends AbstractCDOTest
+{
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ OMPlatform.INSTANCE.setDebugging(false);
+ }
+
+ public void testCommitAfterClose() throws Exception
+ {
+ CDOSession session = openSession();
+ assertEquals(true, LifecycleUtil.isActive(session));
+ assertEquals(false, session.isClosed());
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(getModel1Factory().createCompany());
+ assertEquals(true, LifecycleUtil.isActive(transaction));
+ assertEquals(false, transaction.isClosed());
+
+ session.close();
+ assertEquals(false, LifecycleUtil.isActive(session));
+ assertEquals(true, session.isClosed());
+ assertEquals(false, LifecycleUtil.isActive(transaction));
+ assertEquals(true, transaction.isClosed());
+
+ try
+ {
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ /**
+ * See bug 335432
+ */
+ public void testLastUpdateTime() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(getModel1Factory().createCompany());
+
+ long timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(timeStamp, session.getLastUpdateTime());
+ assertEquals(timeStamp, transaction.getLastUpdateTime());
+ }
+
+ public void testCreateManySessions() throws Exception
+ {
+ {
+ IOUtil.OUT().println("Opening session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.createResource(getResourcePath("/test2"));
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ for (int i = 0; i < 100; i++)
+ {
+ IOUtil.OUT().println("Session " + i);
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test2"));
+ Category category = getModel1Factory().createCategory();
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testCreateManyTransactions() throws Exception
+ {
+ IOUtil.OUT().println("Opening session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test2"));
+ transaction.commit();
+ transaction.close();
+
+ long lastDuration = 0;
+ for (int i = 0; i < 100; i++)
+ {
+ IOUtil.OUT().println("Transaction " + i + " (" + lastDuration + ")");
+ lastDuration = System.currentTimeMillis();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/test2"));
+
+ Category category = getModel1Factory().createCategory();
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ lastDuration = System.currentTimeMillis() - lastDuration;
+ }
+
+ session.close();
+ }
+
+ public void testCreateManySessionsAndTransactionsMultiThread() throws Exception
+ {
+ final long TIMEOUT = 2 * 120L;
+ final int THREADS = 5;
+
+ final List<Exception> exceptions = new ArrayList<Exception>();
+ final CountDownLatch latch = new CountDownLatch(THREADS);
+ List<Thread> threadList = new ArrayList<Thread>();
+ for (int i = 0; i < THREADS; i++)
+ {
+ final int id = i;
+ threadList.add(new Thread("TEST-THREAD-" + id)
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ IOUtil.OUT().println("Thread " + id + ": Started");
+ for (int i = 0; i < 100; i++)
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ IOUtil.OUT().println("Thread " + id + ": Session + Transaction " + i);
+ transaction.close();
+ session.close();
+ }
+
+ IOUtil.OUT().println("Thread " + id + ": Done");
+ }
+ catch (Exception ex)
+ {
+ System.out.println("Thread " + id + ": " + ex.getClass().getName() + ": " + ex.getMessage());
+ synchronized (exceptions)
+ {
+ exceptions.add(ex);
+ }
+ }
+ finally
+ {
+ latch.countDown();
+ }
+ }
+ });
+ }
+
+ for (Thread thread : threadList)
+ {
+ thread.start();
+ }
+
+ boolean timedOut = !latch.await(TIMEOUT, TimeUnit.SECONDS);
+
+ for (Exception ex : exceptions)
+ {
+ System.out.println();
+ System.out.println();
+ IOUtil.print(ex);
+ }
+
+ if (timedOut)
+ {
+ fail("Timeout after " + TIMEOUT + " seconds");
+ }
+ else
+ {
+ assertEquals(0, exceptions.size());
+ }
+ }
+
+ public void testPushModeNewObjects() throws Exception
+ {
+ IOUtil.OUT().println("Creating category1");
+ Category category1 = getModel1Factory().createCategory();
+ category1.setName("category1");
+
+ IOUtil.OUT().println("Creating category2");
+ Category category2 = getModel1Factory().createCategory();
+ category2.setName("category2");
+
+ IOUtil.OUT().println("Creating category3");
+ Category category3 = getModel1Factory().createCategory();
+ category3.setName("category3");
+
+ IOUtil.OUT().println("Creating company");
+ Company company = getModel1Factory().createCompany();
+ company.setName("Foundation");
+
+ IOUtil.OUT().println("Adding categories");
+ company.getCategories().add(category1);
+ category1.getCategories().add(category2);
+ category1.getCategories().add(category3);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOPushTransaction pushTransaction = new CDOPushTransaction(transaction);
+ File file = pushTransaction.getFile();
+
+ CDOResource resource = pushTransaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+
+ pushTransaction.commit();
+ pushTransaction.close();
+ transaction = session.openTransaction();
+ pushTransaction = new CDOPushTransaction(transaction, file);
+ pushTransaction.push();
+
+ session.close();
+ session = openSession();
+
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test1"));
+ company = (Company)resource.getContents().get(0);
+ assertEquals("Foundation", company.getName());
+ assertEquals(1, company.getCategories().size());
+ assertEquals(2, company.getCategories().get(0).getCategories().size());
+ session.close();
+ }
+
+ public void testPushModeDeltas() throws Exception
+ {
+ IOUtil.OUT().println("Creating category1");
+ Category category1 = getModel1Factory().createCategory();
+ category1.setName("category1");
+
+ IOUtil.OUT().println("Creating company");
+ Company company = getModel1Factory().createCompany();
+ company.setName("Foundation");
+
+ IOUtil.OUT().println("Adding categories");
+ company.getCategories().add(category1);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOPushTransaction pushTransaction = new CDOPushTransaction(transaction);
+ File file = pushTransaction.getFile();
+
+ CDOResource resource = pushTransaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+
+ pushTransaction.commit();
+
+ IOUtil.OUT().println("Creating category2");
+ Category category2 = getModel1Factory().createCategory();
+ category2.setName("category2");
+ category1.getCategories().add(category2);
+
+ IOUtil.OUT().println("Creating category3");
+ Category category3 = getModel1Factory().createCategory();
+ category3.setName("category3");
+ category1.getCategories().add(category3);
+
+ pushTransaction.commit();
+ pushTransaction.close();
+
+ transaction = session.openTransaction();
+ pushTransaction = new CDOPushTransaction(transaction, file);
+ pushTransaction.push();
+
+ session.close();
+ session = openSession();
+
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test1"));
+ company = (Company)resource.getContents().get(0);
+ assertEquals("Foundation", company.getName());
+ assertEquals(1, company.getCategories().size());
+ assertEquals(2, company.getCategories().get(0).getCategories().size());
+ session.close();
+ }
+
+ public void testAutoRollbackOnConflictEvent() throws Exception
+ {
+ final CDOSession session1 = openSession();
+ final CDOTransaction transaction1 = session1.openTransaction();
+
+ CDOResource resource1 = transaction1.createResource(getResourcePath("/test"));
+ Category category1 = getModel1Factory().createCategory();
+ resource1.getContents().add(category1);
+ transaction1.commit();
+
+ final CDOSession session2 = openSession();
+ final CDOTransaction transaction2 = session2.openTransaction();
+ transaction2.addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOTransactionConflictEvent)
+ {
+ transaction2.rollback();
+ }
+ }
+ });
+
+ final CountDownLatch rollback = new CountDownLatch(1);
+ transaction2.addTransactionHandler(new CDOTransactionHandler2()
+ {
+ public void rolledBackTransaction(CDOTransaction transaction)
+ {
+ IOUtil.OUT().println("rollback");
+ rollback.countDown();
+ }
+
+ public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ }
+
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ }
+ });
+
+ CDOResource resource2 = transaction2.getResource(getResourcePath("/test"));
+ Category category2 = (Category)resource2.getContents().get(0);
+ category2.setName("session2");
+
+ category1.setName("session1");
+ transaction1.commit();
+
+ rollback.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ category2.setName("session2");
+ transaction2.commit();
+ }
+
+ /**
+ * Bug 283131
+ */
+ public void testRollbackWithNotification() throws CommitException
+ {
+ Category category = getModel1Factory().createCategory();
+ category.setName("name1");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test"));
+
+ resource1.getContents().add(category);
+ transaction.commit();
+
+ category.setName("name2");
+
+ TestAdapter testAdapter = new TestAdapter();
+ category.eAdapters().add(testAdapter);
+
+ transaction.rollback();
+
+ Notification[] notifications = testAdapter.getNotifications();
+ assertEquals(1, notifications.length);
+
+ Notification notification = notifications[0];
+ assertEquals("name2", notification.getOldStringValue());
+ assertEquals("name1", notification.getNewStringValue());
+ }
+
+ public void testManualRollbackOnConflictException() throws Exception
+ {
+ CDOSession session1 = openSession();
+ CDOTransaction transaction1 = session1.openTransaction();
+
+ CDOResource resource1 = transaction1.createResource(getResourcePath("/test"));
+ Category category1 = getModel1Factory().createCategory();
+ resource1.getContents().add(category1);
+ transaction1.commit();
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+
+ CDOResource resource2 = transaction2.getResource(getResourcePath("/test"));
+ Category category2 = (Category)resource2.getContents().get(0);
+ category2.setName("session2");
+
+ category1.setName("session1");
+ commitAndSync(transaction1, transaction2);
+ IOUtil.OUT().println("After transaction1.commit(): " + CDOUtil.getCDOObject(category1).cdoRevision());
+
+ CDOObject cdoCategory2 = CDOUtil.getCDOObject(category2);
+
+ try
+ {
+ IOUtil.OUT().println("Before transaction2.commit(): " + cdoCategory2.cdoRevision());
+ category2.setName("session2");
+
+ transaction2.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ IOUtil.OUT().println("Before transaction2.rollback(): " + cdoCategory2.cdoRevision());
+ transaction2.rollback();
+ IOUtil.OUT().println("After transaction2.rollback(): " + cdoCategory2.cdoRevision());
+ }
+
+ category2.setName("session2");
+
+ IOUtil.OUT().println("Before transaction2.commit():");
+ CDOCommitInfoUtil.dump(IOUtil.OUT(), transaction2.getChangeSetData());
+
+ transaction2.commit();
+ IOUtil.OUT().println("After transaction2.commit(): " + cdoCategory2.cdoRevision());
+ assertEquals(3, cdoCategory2.cdoRevision().getVersion());
+ }
+
+ public void testLongCommit() throws Exception
+ {
+ OMPlatform.INSTANCE.setDebugging(true);
+
+ CDOCommitInfoHandler handler = new CDOCommitInfoHandler()
+ {
+ public void handleCommitInfo(CDOCommitInfo commitInfo)
+ {
+ sleep(3000L);
+ }
+ };
+
+ IRepository repository = getRepository();
+ repository.addCommitInfoHandler(handler);
+
+ try
+ {
+ CDOSession session = openSession();
+ if (session instanceof CDONet4jSession)
+ {
+ ((CDONet4jSession)session).options().setCommitTimeout(1);
+
+ }
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(getModel1Factory().createCompany());
+
+ transaction.commit();
+ }
+ finally
+ {
+ repository.removeCommitInfoHandler(handler);
+ }
+ }
+
+ public void _testLongCommit2() throws Exception
+ {
+ OMPlatform.INSTANCE.setDebugging(true);
+ Field field = ReflectUtil.getField(CommitTransactionRequest.class, "sleepMillisForTesting");
+
+ try
+ {
+ ReflectUtil.setValue(field, null, 1000L);
+
+ org.eclipse.emf.cdo.net4j.CDONet4jSession session = (org.eclipse.emf.cdo.net4j.CDONet4jSession)openSession();
+ session.options().setCommitTimeout(60);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+
+ for (int i = 0; i < 300; i++)
+ {
+ resource.getContents().add(getModel1Factory().createCompany());
+ }
+
+ transaction.commit();
+ }
+ finally
+ {
+ ReflectUtil.setValue(field, null, 0L);
+ }
+ }
+
+ /**
+ * Bug 353167.
+ */
+ public void testReattachCommit() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ resource.getContents().remove(company);
+ resource.getContents().add(company);
+ transaction.commit();
+ }
+
+ /**
+ * Bug 353167.
+ */
+ public void testReattachModifyCommit() throws Exception
+ {
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ resource.getContents().remove(company);
+ resource.getContents().add(company);
+ company.setName("ESC");
+ transaction.commit();
+ }
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/test1"));
+ Company company2 = (Company)resource2.getContents().get(0);
+ assertEquals("ESC", company2.getName());
+ }
+
+ /**
+ * Bug 353167.
+ */
+ public void testReattachCommitWithSavepoints() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ resource.getContents().remove(company);
+ transaction.setSavepoint();
+
+ resource.getContents().add(company);
+ transaction.setSavepoint();
+ transaction.commit();
+ }
+
+ /**
+ * Bug 353167.
+ */
+ public void testReattachModifyCommitWithSavepoints() throws Exception
+ {
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ resource.getContents().remove(company);
+ // transaction.setSavepoint();
+
+ resource.getContents().add(company);
+ transaction.setSavepoint();
+
+ company.setName("ESC");
+
+ transaction.commit();
+ }
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/test1"));
+ Company company2 = (Company)resource2.getContents().get(0);
+ assertEquals("ESC", company2.getName());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/UnsetTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/UnsetTest.java
index 276f87ab7c..6255b5d7b2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/UnsetTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/UnsetTest.java
@@ -1,561 +1,561 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.tests.model2.Unsettable1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
-
-import java.util.Date;
-
-/**
- * @author Eike Stepper
- */
-public class UnsetTest extends AbstractCDOTest
-{
- /**
- * needed for commitAndLoadTx()
- */
- private CDOSession commitAndLoadSession;
-
- /**
- * needed for commitAndLoadTx()
- */
- private CDOTransaction commitAndLoadTransaction;
-
- /**
- * Ensures that properly typed (i.e. usable) default values can be read from dynamic packages.
- * <p>
- * Works only in standalone mode.
- */
- public static void main(String[] args)
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
-
- URI uri = URI.createFileURI("../org.eclipse.emf.cdo.tests.model2/model/model2.ecore");
- Resource resource = resourceSet.getResource(uri, true);
-
- EPackage model2 = (EPackage)resource.getContents().get(0);
- EClass unsettable2 = (EClass)model2.getEClassifier("Unsettable2WithDefault");
- EAttribute unsettableInt = (EAttribute)unsettable2.getEStructuralFeature("unsettableInt");
-
- // Check static default value
- Integer defaultValue = (Integer)unsettableInt.getDefaultValue();
- assertEquals(5, (int)defaultValue);
-
- // Check dynamic default value
- EObject object = EcoreUtil.create(unsettable2);
- Integer value = (Integer)object.eGet(unsettableInt);
- assertEquals((int)defaultValue, (int)value);
- }
-
- public void testReadDefaultValue() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
-
- resource.getContents().add(supplier);
- transaction.commit();
- session.close();
-
- session = openSession();
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test1"));
- supplier = (Supplier)resource.getContents().get(0);
- assertEquals(true, supplier.isPreferred());
- }
-
- public void testWriteDefaultValue() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- supplier.setPreferred(true);
-
- resource.getContents().add(supplier);
- transaction.commit();
- session.close();
-
- session = openSession();
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test1"));
- supplier = (Supplier)resource.getContents().get(0);
- assertEquals(true, supplier.isPreferred());
- }
-
- public void testWriteNonDefaultValue() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.setName("Stepper");
- supplier.setPreferred(false);
-
- resource.getContents().add(supplier);
- transaction.commit();
- session.close();
-
- session = openSession();
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test1"));
- supplier = (Supplier)resource.getContents().get(0);
- assertEquals(false, supplier.isPreferred());
- }
-
- public void testUnsetNonDefaultValue() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- // unsettable.setUnsettableBoolean(true);
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetBoolean() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableBoolean(true);
-
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(true, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetByte() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableByte(Byte.MAX_VALUE);
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(true, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetChar() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableChar('a');
-
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(true, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetDate() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableDate(new Date());
-
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(true, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetDouble() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableDouble(42.34d);
-
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(true, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetFloat() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableFloat(42.34f);
-
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(true, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetLong() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableLong(42L);
-
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(true, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetShort() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableShort(Short.MAX_VALUE);
-
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(true, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetString() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableString("42");
-
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(true, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testIsSetVAT() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableVAT(VAT.VAT15);
-
- Unsettable1 result = commitAndLoad(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(true, result.isSetUnsettableVAT());
- }
-
- public void testIsSetMultipleTimes() throws Exception
- {
- Unsettable1 unsettable = getModel2Factory().createUnsettable1();
- unsettable.setUnsettableInt(42);
-
- Unsettable1 result = commitAndLoadTx(unsettable);
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(true, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
-
- result.setUnsettableByte(Byte.MAX_VALUE);
- result = commitAndLoadTx(result);
-
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(true, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(true, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
-
- result.unsetUnsettableByte();
- result.unsetUnsettableInt();
- result.setUnsettableString("blah");
-
- result = commitAndLoadTx(result);
-
- assertEquals(false, result.isSetUnsettableBoolean());
- assertEquals(false, result.isSetUnsettableByte());
- assertEquals(false, result.isSetUnsettableChar());
- assertEquals(false, result.isSetUnsettableDate());
- assertEquals(false, result.isSetUnsettableDouble());
- assertEquals(false, result.isSetUnsettableFloat());
- assertEquals(false, result.isSetUnsettableInt());
- assertEquals(false, result.isSetUnsettableLong());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(false, result.isSetUnsettableShort());
- assertEquals(true, result.isSetUnsettableString());
- assertEquals(false, result.isSetUnsettableVAT());
- }
-
- public void testUnsettableBaseTypeVsObjectType() throws Exception
- {
- EPackage pkg = EMFUtil.createEPackage("unsettablePackage", "unset",
- "http://cdo.eclipse.org/unsettablePackage.ecore");
- EClass cls = EMFUtil.createEClass(pkg, "unsettableClass", false, false);
- EAttribute baseElement = EMFUtil.createEAttribute(cls, "baseElement", EcorePackage.eINSTANCE.getEInt());
- baseElement.setUnsettable(true);
- baseElement.setDefaultValue(23);
-
- EAttribute objectElement = EMFUtil.createEAttribute(cls, "objectElement",
- EcorePackage.eINSTANCE.getEIntegerObject());
- objectElement.setUnsettable(true);
- objectElement.setDefaultValue(42);
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- {
- EObject test1 = EcoreUtil.create(cls);
- test1.eSet(baseElement, 1);
- test1.eSet(objectElement, 2);
-
- EObject test2 = EcoreUtil.create(cls);
- test2.eSet(baseElement, 23);
- test2.eSet(objectElement, 42);
-
- EObject test3 = EcoreUtil.create(cls);
- test3.eSet(baseElement, null);
- test3.eSet(objectElement, null);
-
- EObject test4 = EcoreUtil.create(cls);
- test4.eUnset(baseElement);
- test4.eUnset(objectElement);
-
- assertEquals(true, test1.eIsSet(baseElement));
- assertEquals(true, test1.eIsSet(objectElement));
- assertEquals(1, test1.eGet(baseElement));
- assertEquals(2, test1.eGet(objectElement));
-
- assertEquals(true, test2.eIsSet(baseElement));
- assertEquals(true, test2.eIsSet(objectElement));
- assertEquals(23, test2.eGet(baseElement));
- assertEquals(42, test2.eGet(objectElement));
-
- // for basetypes, setting value null seems to be equivalent
- // to unset.
- assertEquals(false, test3.eIsSet(baseElement));
- assertEquals(true, test3.eIsSet(objectElement));
- assertEquals(23, test3.eGet(baseElement));
- assertNull(test3.eGet(objectElement));
-
- assertEquals(false, test4.eIsSet(baseElement));
- assertEquals(false, test4.eIsSet(objectElement));
- assertEquals(23, test4.eGet(baseElement));
- assertEquals(42, test4.eGet(objectElement));
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource(getResourcePath("/test1"));
-
- res.getContents().add(test1);
- res.getContents().add(test2);
- res.getContents().add(test3);
- res.getContents().add(test4);
-
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView view = session.openTransaction();
- CDOResource res = view.getResource(getResourcePath("/test1"));
-
- assertEquals(4, res.getContents().size());
- EObject test1 = res.getContents().get(0);
- EObject test2 = res.getContents().get(1);
- EObject test3 = res.getContents().get(2);
- EObject test4 = res.getContents().get(3);
-
- assertEquals(true, test1.eIsSet(baseElement));
- assertEquals(true, test1.eIsSet(objectElement));
- assertEquals(1, test1.eGet(baseElement));
- assertEquals(2, test1.eGet(objectElement));
-
- assertEquals(true, test2.eIsSet(baseElement));
- assertEquals(true, test2.eIsSet(objectElement));
- assertEquals(23, test2.eGet(baseElement));
- assertEquals(42, test2.eGet(objectElement));
-
- assertEquals(false, test3.eIsSet(baseElement));
- assertEquals(true, test3.eIsSet(objectElement));
- assertEquals(23, test3.eGet(baseElement));
- assertNull(test3.eGet(objectElement));
-
- assertEquals(false, test4.eIsSet(baseElement));
- assertEquals(false, test4.eIsSet(objectElement));
- assertEquals(23, test4.eGet(baseElement));
- assertEquals(42, test4.eGet(objectElement));
-
- view.close();
- session.close();
- }
- }
-
- private <T extends EObject> T commitAndLoad(T object) throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- resource.getContents().add(object);
- transaction.commit();
- session.close();
-
- clearCache(getRepository().getRevisionManager());
-
- session = openSession();
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test1"));
-
- @SuppressWarnings("unchecked")
- T result = (T)resource.getContents().get(0);
- return result;
- }
-
- private <T extends EObject> T commitAndLoadTx(T object) throws Exception
- {
- if (commitAndLoadSession == null)
- {
- commitAndLoadSession = openSession();
- commitAndLoadTransaction = commitAndLoadSession.openTransaction();
-
- CDOResource resource = commitAndLoadTransaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(object);
- }
-
- commitAndLoadTransaction.commit();
- commitAndLoadTransaction.close();
- commitAndLoadSession.close();
-
- clearCache(getRepository().getRevisionManager());
-
- commitAndLoadSession = openSession();
- commitAndLoadTransaction = commitAndLoadSession.openTransaction();
- CDOResource resource = commitAndLoadTransaction.getResource(getResourcePath("/test1"));
-
- @SuppressWarnings("unchecked")
- T result = (T)resource.getContents().get(0);
- return result;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.tests.model2.Unsettable1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
+
+import java.util.Date;
+
+/**
+ * @author Eike Stepper
+ */
+public class UnsetTest extends AbstractCDOTest
+{
+ /**
+ * needed for commitAndLoadTx()
+ */
+ private CDOSession commitAndLoadSession;
+
+ /**
+ * needed for commitAndLoadTx()
+ */
+ private CDOTransaction commitAndLoadTransaction;
+
+ /**
+ * Ensures that properly typed (i.e. usable) default values can be read from dynamic packages.
+ * <p>
+ * Works only in standalone mode.
+ */
+ public static void main(String[] args)
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
+
+ URI uri = URI.createFileURI("../org.eclipse.emf.cdo.tests.model2/model/model2.ecore");
+ Resource resource = resourceSet.getResource(uri, true);
+
+ EPackage model2 = (EPackage)resource.getContents().get(0);
+ EClass unsettable2 = (EClass)model2.getEClassifier("Unsettable2WithDefault");
+ EAttribute unsettableInt = (EAttribute)unsettable2.getEStructuralFeature("unsettableInt");
+
+ // Check static default value
+ Integer defaultValue = (Integer)unsettableInt.getDefaultValue();
+ assertEquals(5, (int)defaultValue);
+
+ // Check dynamic default value
+ EObject object = EcoreUtil.create(unsettable2);
+ Integer value = (Integer)object.eGet(unsettableInt);
+ assertEquals((int)defaultValue, (int)value);
+ }
+
+ public void testReadDefaultValue() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+
+ resource.getContents().add(supplier);
+ transaction.commit();
+ session.close();
+
+ session = openSession();
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test1"));
+ supplier = (Supplier)resource.getContents().get(0);
+ assertEquals(true, supplier.isPreferred());
+ }
+
+ public void testWriteDefaultValue() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ supplier.setPreferred(true);
+
+ resource.getContents().add(supplier);
+ transaction.commit();
+ session.close();
+
+ session = openSession();
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test1"));
+ supplier = (Supplier)resource.getContents().get(0);
+ assertEquals(true, supplier.isPreferred());
+ }
+
+ public void testWriteNonDefaultValue() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("Stepper");
+ supplier.setPreferred(false);
+
+ resource.getContents().add(supplier);
+ transaction.commit();
+ session.close();
+
+ session = openSession();
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test1"));
+ supplier = (Supplier)resource.getContents().get(0);
+ assertEquals(false, supplier.isPreferred());
+ }
+
+ public void testUnsetNonDefaultValue() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ // unsettable.setUnsettableBoolean(true);
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetBoolean() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableBoolean(true);
+
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(true, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetByte() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableByte(Byte.MAX_VALUE);
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(true, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetChar() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableChar('a');
+
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(true, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetDate() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableDate(new Date());
+
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(true, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetDouble() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableDouble(42.34d);
+
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(true, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetFloat() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableFloat(42.34f);
+
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(true, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetLong() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableLong(42L);
+
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(true, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetShort() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableShort(Short.MAX_VALUE);
+
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(true, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetString() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableString("42");
+
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(true, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetVAT() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableVAT(VAT.VAT15);
+
+ Unsettable1 result = commitAndLoad(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(true, result.isSetUnsettableVAT());
+ }
+
+ public void testIsSetMultipleTimes() throws Exception
+ {
+ Unsettable1 unsettable = getModel2Factory().createUnsettable1();
+ unsettable.setUnsettableInt(42);
+
+ Unsettable1 result = commitAndLoadTx(unsettable);
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(true, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+
+ result.setUnsettableByte(Byte.MAX_VALUE);
+ result = commitAndLoadTx(result);
+
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(true, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(true, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+
+ result.unsetUnsettableByte();
+ result.unsetUnsettableInt();
+ result.setUnsettableString("blah");
+
+ result = commitAndLoadTx(result);
+
+ assertEquals(false, result.isSetUnsettableBoolean());
+ assertEquals(false, result.isSetUnsettableByte());
+ assertEquals(false, result.isSetUnsettableChar());
+ assertEquals(false, result.isSetUnsettableDate());
+ assertEquals(false, result.isSetUnsettableDouble());
+ assertEquals(false, result.isSetUnsettableFloat());
+ assertEquals(false, result.isSetUnsettableInt());
+ assertEquals(false, result.isSetUnsettableLong());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(false, result.isSetUnsettableShort());
+ assertEquals(true, result.isSetUnsettableString());
+ assertEquals(false, result.isSetUnsettableVAT());
+ }
+
+ public void testUnsettableBaseTypeVsObjectType() throws Exception
+ {
+ EPackage pkg = EMFUtil.createEPackage("unsettablePackage", "unset",
+ "http://cdo.eclipse.org/unsettablePackage.ecore");
+ EClass cls = EMFUtil.createEClass(pkg, "unsettableClass", false, false);
+ EAttribute baseElement = EMFUtil.createEAttribute(cls, "baseElement", EcorePackage.eINSTANCE.getEInt());
+ baseElement.setUnsettable(true);
+ baseElement.setDefaultValue(23);
+
+ EAttribute objectElement = EMFUtil.createEAttribute(cls, "objectElement",
+ EcorePackage.eINSTANCE.getEIntegerObject());
+ objectElement.setUnsettable(true);
+ objectElement.setDefaultValue(42);
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ {
+ EObject test1 = EcoreUtil.create(cls);
+ test1.eSet(baseElement, 1);
+ test1.eSet(objectElement, 2);
+
+ EObject test2 = EcoreUtil.create(cls);
+ test2.eSet(baseElement, 23);
+ test2.eSet(objectElement, 42);
+
+ EObject test3 = EcoreUtil.create(cls);
+ test3.eSet(baseElement, null);
+ test3.eSet(objectElement, null);
+
+ EObject test4 = EcoreUtil.create(cls);
+ test4.eUnset(baseElement);
+ test4.eUnset(objectElement);
+
+ assertEquals(true, test1.eIsSet(baseElement));
+ assertEquals(true, test1.eIsSet(objectElement));
+ assertEquals(1, test1.eGet(baseElement));
+ assertEquals(2, test1.eGet(objectElement));
+
+ assertEquals(true, test2.eIsSet(baseElement));
+ assertEquals(true, test2.eIsSet(objectElement));
+ assertEquals(23, test2.eGet(baseElement));
+ assertEquals(42, test2.eGet(objectElement));
+
+ // for basetypes, setting value null seems to be equivalent
+ // to unset.
+ assertEquals(false, test3.eIsSet(baseElement));
+ assertEquals(true, test3.eIsSet(objectElement));
+ assertEquals(23, test3.eGet(baseElement));
+ assertNull(test3.eGet(objectElement));
+
+ assertEquals(false, test4.eIsSet(baseElement));
+ assertEquals(false, test4.eIsSet(objectElement));
+ assertEquals(23, test4.eGet(baseElement));
+ assertEquals(42, test4.eGet(objectElement));
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/test1"));
+
+ res.getContents().add(test1);
+ res.getContents().add(test2);
+ res.getContents().add(test3);
+ res.getContents().add(test4);
+
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView view = session.openTransaction();
+ CDOResource res = view.getResource(getResourcePath("/test1"));
+
+ assertEquals(4, res.getContents().size());
+ EObject test1 = res.getContents().get(0);
+ EObject test2 = res.getContents().get(1);
+ EObject test3 = res.getContents().get(2);
+ EObject test4 = res.getContents().get(3);
+
+ assertEquals(true, test1.eIsSet(baseElement));
+ assertEquals(true, test1.eIsSet(objectElement));
+ assertEquals(1, test1.eGet(baseElement));
+ assertEquals(2, test1.eGet(objectElement));
+
+ assertEquals(true, test2.eIsSet(baseElement));
+ assertEquals(true, test2.eIsSet(objectElement));
+ assertEquals(23, test2.eGet(baseElement));
+ assertEquals(42, test2.eGet(objectElement));
+
+ assertEquals(false, test3.eIsSet(baseElement));
+ assertEquals(true, test3.eIsSet(objectElement));
+ assertEquals(23, test3.eGet(baseElement));
+ assertNull(test3.eGet(objectElement));
+
+ assertEquals(false, test4.eIsSet(baseElement));
+ assertEquals(false, test4.eIsSet(objectElement));
+ assertEquals(23, test4.eGet(baseElement));
+ assertEquals(42, test4.eGet(objectElement));
+
+ view.close();
+ session.close();
+ }
+ }
+
+ private <T extends EObject> T commitAndLoad(T object) throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ resource.getContents().add(object);
+ transaction.commit();
+ session.close();
+
+ clearCache(getRepository().getRevisionManager());
+
+ session = openSession();
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test1"));
+
+ @SuppressWarnings("unchecked")
+ T result = (T)resource.getContents().get(0);
+ return result;
+ }
+
+ private <T extends EObject> T commitAndLoadTx(T object) throws Exception
+ {
+ if (commitAndLoadSession == null)
+ {
+ commitAndLoadSession = openSession();
+ commitAndLoadTransaction = commitAndLoadSession.openTransaction();
+
+ CDOResource resource = commitAndLoadTransaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(object);
+ }
+
+ commitAndLoadTransaction.commit();
+ commitAndLoadTransaction.close();
+ commitAndLoadSession.close();
+
+ clearCache(getRepository().getRevisionManager());
+
+ commitAndLoadSession = openSession();
+ commitAndLoadTransaction = commitAndLoadSession.openTransaction();
+ CDOResource resource = commitAndLoadTransaction.getResource(getResourcePath("/test1"));
+
+ @SuppressWarnings("unchecked")
+ T result = (T)resource.getContents().get(0);
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java
index 34090c9346..47a8ae4ffc 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java
@@ -1,150 +1,150 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOURIData;
-import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.internal.cdo.session.CDOSessionFactory;
-
-import org.eclipse.net4j.util.container.IPluginContainer;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-import java.io.ByteArrayOutputStream;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class ViewProviderTest extends AbstractCDOTest
-{
- private static final String REPO = RepositoryConfig.REPOSITORY_NAME;
-
- private static final String PATH = "/library/My.company";
-
- private URI uri;
-
- private void checkURI(String uri, boolean valid)
- {
- URI uri1 = URI.createURI(uri);
- CDOURIData data = new CDOURIData(uri1);
- URI uri2 = data.toURI();
- if (valid)
- {
- assertEquals(uri1, uri2);
- }
- else
- {
- assertNotSame(uri1, uri2);
- }
- }
-
- public void testURIs() throws Exception
- {
- checkURI("cdo.net4j.tcp://eike:passw@127.0.0.1:2042/repo/folder/resource", true);
- checkURI("cdo.net4j.tcp://eike@127.0.0.1:2042/repo/folder/resource", true);
- checkURI("cdo.net4j.tcp://127.0.0.1:2042/repo/folder/resource", true);
- checkURI("cdo.net4j.tcp://127.0.0.1:2042/repo/resource", true);
- checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource", true);
- checkURI("cdo.net4j.xyz://127.0.0.1/repo/resource", true);
-
- checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1", true);
- checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&time=12345678987", true);
- checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&transactional=true", true);
-
- checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&time=12345&transactional=false", false);
- checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&transactional=false", false);
- checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&time=HEAD", false);
- checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN", false);
- checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN&time=HEAD", false);
-
- }
-
- private void init() throws CommitException
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setName("ESC");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(PATH));
- resource.getContents().add(product);
- transaction.commit();
- session.close();
-
- uri = URI.createURI(getURIPrefix() + "/" + REPO + getResourcePath(PATH) + "?transactional=true");
- }
-
- public void testNormal() throws Exception
- {
- init();
- URI uri = CDOURIUtil.createResourceURI(REPO, getResourcePath(PATH));
- IPluginContainer.INSTANCE.putElement(CDOSessionFactory.PRODUCT_GROUP, "my-type", "my-description", openSession());
-
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOResource resource = (CDOResource)resourceSet.getResource(uri, true);
-
- String path = resource.getPath();
- assertEquals(getResourcePath(PATH), path);
-
- Product1 product = (Product1)resource.getContents().get(0);
- assertEquals("ESC", product.getName());
- }
-
- public void testConnectionAware() throws Exception
- {
- init();
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOResource resource = (CDOResource)resourceSet.getResource(uri, true);
-
- String path = resource.getPath();
- assertEquals(getResourcePath(PATH), path);
-
- Product1 product = (Product1)resource.getContents().get(0);
- assertEquals("ESC", product.getName());
- }
-
- public void testSerialize() throws Exception
- {
- init();
- ResourceSet resourceSet = new ResourceSetImpl();
- Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
- map.put("xmi", new XMIResourceFactoryImpl());
-
- CDOResource resource = (CDOResource)resourceSet.getResource(uri, true);
- Product1 product = (Product1)resource.getContents().get(0);
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setProduct(product);
-
- Resource volatileResource = resourceSet.createResource(URI.createURI("volatile.xmi"));
- volatileResource.getContents().add(orderDetail);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- volatileResource.save(baos, null);
- String xmi = baos.toString();
- msg("CHECK FOR: " + uri);
- msg(xmi);
- assertEquals(true, xmi.indexOf(uri.toString()) != -1);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOURIData;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.internal.cdo.session.CDOSessionFactory;
+
+import org.eclipse.net4j.util.container.IPluginContainer;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class ViewProviderTest extends AbstractCDOTest
+{
+ private static final String REPO = RepositoryConfig.REPOSITORY_NAME;
+
+ private static final String PATH = "/library/My.company";
+
+ private URI uri;
+
+ private void checkURI(String uri, boolean valid)
+ {
+ URI uri1 = URI.createURI(uri);
+ CDOURIData data = new CDOURIData(uri1);
+ URI uri2 = data.toURI();
+ if (valid)
+ {
+ assertEquals(uri1, uri2);
+ }
+ else
+ {
+ assertNotSame(uri1, uri2);
+ }
+ }
+
+ public void testURIs() throws Exception
+ {
+ checkURI("cdo.net4j.tcp://eike:passw@127.0.0.1:2042/repo/folder/resource", true);
+ checkURI("cdo.net4j.tcp://eike@127.0.0.1:2042/repo/folder/resource", true);
+ checkURI("cdo.net4j.tcp://127.0.0.1:2042/repo/folder/resource", true);
+ checkURI("cdo.net4j.tcp://127.0.0.1:2042/repo/resource", true);
+ checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource", true);
+ checkURI("cdo.net4j.xyz://127.0.0.1/repo/resource", true);
+
+ checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1", true);
+ checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&time=12345678987", true);
+ checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&transactional=true", true);
+
+ checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&time=12345&transactional=false", false);
+ checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&transactional=false", false);
+ checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&time=HEAD", false);
+ checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN", false);
+ checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN&time=HEAD", false);
+
+ }
+
+ private void init() throws CommitException
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("ESC");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(PATH));
+ resource.getContents().add(product);
+ transaction.commit();
+ session.close();
+
+ uri = URI.createURI(getURIPrefix() + "/" + REPO + getResourcePath(PATH) + "?transactional=true");
+ }
+
+ public void testNormal() throws Exception
+ {
+ init();
+ URI uri = CDOURIUtil.createResourceURI(REPO, getResourcePath(PATH));
+ IPluginContainer.INSTANCE.putElement(CDOSessionFactory.PRODUCT_GROUP, "my-type", "my-description", openSession());
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOResource resource = (CDOResource)resourceSet.getResource(uri, true);
+
+ String path = resource.getPath();
+ assertEquals(getResourcePath(PATH), path);
+
+ Product1 product = (Product1)resource.getContents().get(0);
+ assertEquals("ESC", product.getName());
+ }
+
+ public void testConnectionAware() throws Exception
+ {
+ init();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOResource resource = (CDOResource)resourceSet.getResource(uri, true);
+
+ String path = resource.getPath();
+ assertEquals(getResourcePath(PATH), path);
+
+ Product1 product = (Product1)resource.getContents().get(0);
+ assertEquals("ESC", product.getName());
+ }
+
+ public void testSerialize() throws Exception
+ {
+ init();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
+ map.put("xmi", new XMIResourceFactoryImpl());
+
+ CDOResource resource = (CDOResource)resourceSet.getResource(uri, true);
+ Product1 product = (Product1)resource.getContents().get(0);
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setProduct(product);
+
+ Resource volatileResource = resourceSet.createResource(URI.createURI("volatile.xmi"));
+ volatileResource.getContents().add(orderDetail);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ volatileResource.save(baos, null);
+ String xmi = baos.toString();
+ msg("CHECK FOR: " + uri);
+ msg(xmi);
+ assertEquals(true, xmi.indexOf(uri.toString()) != -1);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
index c811899f1a..62d471caaa 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
@@ -1,311 +1,311 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.ref.ReferenceType;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-
-/**
- * @author Eike Stepper
- */
-public class ViewTest extends AbstractCDOTest
-{
- public void testDeactivateWithSession() throws Exception
- {
- CDOSession session = openSession();
- assertEquals(true, LifecycleUtil.isActive(session));
- assertEquals(false, session.isClosed());
-
- CDOView view = session.openView();
- assertEquals(true, LifecycleUtil.isActive(view));
- assertEquals(false, view.isClosed());
-
- session.close();
- assertEquals(false, LifecycleUtil.isActive(session));
- assertEquals(true, session.isClosed());
-
- assertEquals(false, LifecycleUtil.isActive(view));
- assertEquals(true, view.isClosed());
- }
-
- public void testHasResource() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.createResource(getResourcePath("/test1"));
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- assertEquals(true, view.hasResource(getResourcePath("/test1")));
- assertEquals(false, view.hasResource(getResourcePath("/test2")));
- session.close();
- }
-
- public void testIsObjectRegisteredWithNull() throws Exception
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- assertEquals(false, view.isObjectRegistered(null));
- session.close();
- }
-
- public void testGetOrCreateResource() throws Exception
- {
- String id;
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- transaction.commit();
- id = resource.cdoID().toString();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- assertEquals(id, transaction.getOrCreateResource(getResourcePath("/test1")).cdoID().toString());
- assertNotSame(id, transaction.getOrCreateResource(getResourcePath("/test2")).cdoID().toString());
- session.close();
- }
-
- public void testUniqueResourceContents() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- EList<EObject> contents = resource.getContents();
- for (int i = 0; i < 100; i++)
- {
- Company company = getModel1Factory().createCompany();
- company.setName("Company " + i);
- contents.add(company);
- }
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(2, 2));
-
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
- EList<EObject> contents = resource.getContents();
- for (int i = 100; i < 110; i++)
- {
- Company company = getModel1Factory().createCompany();
- company.setName("Company " + i);
- contents.add(company);
- }
-
- CDORevisionData revision = resource.cdoRevision().data();
- EStructuralFeature contentsFeature = EresourcePackage.eINSTANCE.getCDOResource_Contents();
- assertEquals(true, revision.get(contentsFeature, 99) instanceof CDOElementProxy);
- assertEquals(false, revision.get(contentsFeature, 100) instanceof CDOElementProxy);
- session.close();
- }
-
- public void testNonUniqueResourceContents() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- EList<EObject> contents = resource.getContents();
- for (int i = 0; i < 100; i++)
- {
- Company company = getModel1Factory().createCompany();
- company.setName("Company " + i);
- contents.add(company);
- }
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(2, 2));
-
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
- EList<EObject> contents = resource.getContents();
- for (int i = 100; i < 110; i++)
- {
- Company company = getModel1Factory().createCompany();
- company.setName("Company " + i);
- contents.add(company);
- }
-
- CDORevisionData revision = resource.cdoRevision().data();
- EStructuralFeature contentsFeature = EresourcePackage.eINSTANCE.getCDOResource_Contents();
- assertEquals(false, revision.get(contentsFeature, 0) instanceof CDOElementProxy);
- assertEquals(false, revision.get(contentsFeature, 1) instanceof CDOElementProxy);
- assertEquals(true, revision.get(contentsFeature, 2) instanceof CDOElementProxy);
- assertEquals(true, revision.get(contentsFeature, 99) instanceof CDOElementProxy);
- assertEquals(false, revision.get(contentsFeature, 100) instanceof CDOElementProxy);
- session.close();
- }
-
- public void testExternalResourceSet() throws Exception
- {
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction(resourceSet);
- transaction.createResource(getResourcePath("/test1"));
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- assertEquals(true, view.hasResource(getResourcePath("/test1")));
- assertEquals(false, view.hasResource(getResourcePath("/test2")));
- session.close();
- }
-
- public void testContextify() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- transaction.commit();
-
- CDOView view = session.openView();
- CDOResource resource2 = view.getObject(resource);
- assertEquals(getResourcePath("/test1"), resource2.getPath());
- session.close();
- }
-
- @CleanRepositoriesBefore
- public void testContextifyDifferentRepository() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- transaction.commit();
-
- getRepository("repo2");
- CDOSession session2 = openSession("repo2");
- CDOView view = session2.openView();
-
- try
- {
- view.getObject(resource);
- fail("IllegalArgumentException expected");
- }
- catch (IllegalArgumentException success)
- {
- }
- finally
- {
- session.close();
- session2.close();
- }
- }
-
- public void testContextifySameRepository() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- transaction.commit();
-
- CDOSession session2 = openSession();
- CDOView view = session2.openView();
-
- CDOResource object = view.getObject(resource);
- assertNotSame(resource, object);
- assertEquals(resource.cdoID(), object.cdoID());
-
- session.close();
- session2.close();
- }
-
- public void testCacheReferences() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.createResource(getResourcePath("/my/test1"));
- transaction.commit();
-
- transaction.createResource(getResourcePath("/my/test2"));
- transaction.createResource(getResourcePath("/my/test3"));
- transaction.createResource(getResourcePath("/my/test4"));
- transaction.createResource(getResourcePath("/my/test5"));
-
- boolean done;
- done = transaction.options().setCacheReferenceType(ReferenceType.SOFT);
- assertEquals(false, done);
-
- done = transaction.options().setCacheReferenceType(null);
- assertEquals(false, done);
-
- done = transaction.options().setCacheReferenceType(ReferenceType.STRONG);
- assertEquals(true, done);
-
- done = transaction.options().setCacheReferenceType(ReferenceType.SOFT);
- assertEquals(true, done);
-
- done = transaction.options().setCacheReferenceType(ReferenceType.WEAK);
- assertEquals(true, done);
-
- done = transaction.options().setCacheReferenceType(null);
- assertEquals(true, done);
-
- session.close();
- }
-
- public void testViewNotifiesDeactivation()
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
-
- final boolean[] deactivated = { false };
- view.addListener(new LifecycleEventAdapter()
- {
- @Override
- protected void onDeactivated(ILifecycle lifecycle)
- {
- deactivated[0] = true;
- }
- });
-
- view.close();
- assertEquals(true, deactivated[0]);
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.EresourcePackage;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.ref.ReferenceType;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+/**
+ * @author Eike Stepper
+ */
+public class ViewTest extends AbstractCDOTest
+{
+ public void testDeactivateWithSession() throws Exception
+ {
+ CDOSession session = openSession();
+ assertEquals(true, LifecycleUtil.isActive(session));
+ assertEquals(false, session.isClosed());
+
+ CDOView view = session.openView();
+ assertEquals(true, LifecycleUtil.isActive(view));
+ assertEquals(false, view.isClosed());
+
+ session.close();
+ assertEquals(false, LifecycleUtil.isActive(session));
+ assertEquals(true, session.isClosed());
+
+ assertEquals(false, LifecycleUtil.isActive(view));
+ assertEquals(true, view.isClosed());
+ }
+
+ public void testHasResource() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.createResource(getResourcePath("/test1"));
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ assertEquals(true, view.hasResource(getResourcePath("/test1")));
+ assertEquals(false, view.hasResource(getResourcePath("/test2")));
+ session.close();
+ }
+
+ public void testIsObjectRegisteredWithNull() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ assertEquals(false, view.isObjectRegistered(null));
+ session.close();
+ }
+
+ public void testGetOrCreateResource() throws Exception
+ {
+ String id;
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ transaction.commit();
+ id = resource.cdoID().toString();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ assertEquals(id, transaction.getOrCreateResource(getResourcePath("/test1")).cdoID().toString());
+ assertNotSame(id, transaction.getOrCreateResource(getResourcePath("/test2")).cdoID().toString());
+ session.close();
+ }
+
+ public void testUniqueResourceContents() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ EList<EObject> contents = resource.getContents();
+ for (int i = 0; i < 100; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company " + i);
+ contents.add(company);
+ }
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(2, 2));
+
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+ EList<EObject> contents = resource.getContents();
+ for (int i = 100; i < 110; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company " + i);
+ contents.add(company);
+ }
+
+ CDORevisionData revision = resource.cdoRevision().data();
+ EStructuralFeature contentsFeature = EresourcePackage.eINSTANCE.getCDOResource_Contents();
+ assertEquals(true, revision.get(contentsFeature, 99) instanceof CDOElementProxy);
+ assertEquals(false, revision.get(contentsFeature, 100) instanceof CDOElementProxy);
+ session.close();
+ }
+
+ public void testNonUniqueResourceContents() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ EList<EObject> contents = resource.getContents();
+ for (int i = 0; i < 100; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company " + i);
+ contents.add(company);
+ }
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(2, 2));
+
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+ EList<EObject> contents = resource.getContents();
+ for (int i = 100; i < 110; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company " + i);
+ contents.add(company);
+ }
+
+ CDORevisionData revision = resource.cdoRevision().data();
+ EStructuralFeature contentsFeature = EresourcePackage.eINSTANCE.getCDOResource_Contents();
+ assertEquals(false, revision.get(contentsFeature, 0) instanceof CDOElementProxy);
+ assertEquals(false, revision.get(contentsFeature, 1) instanceof CDOElementProxy);
+ assertEquals(true, revision.get(contentsFeature, 2) instanceof CDOElementProxy);
+ assertEquals(true, revision.get(contentsFeature, 99) instanceof CDOElementProxy);
+ assertEquals(false, revision.get(contentsFeature, 100) instanceof CDOElementProxy);
+ session.close();
+ }
+
+ public void testExternalResourceSet() throws Exception
+ {
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+ transaction.createResource(getResourcePath("/test1"));
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ assertEquals(true, view.hasResource(getResourcePath("/test1")));
+ assertEquals(false, view.hasResource(getResourcePath("/test2")));
+ session.close();
+ }
+
+ public void testContextify() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ transaction.commit();
+
+ CDOView view = session.openView();
+ CDOResource resource2 = view.getObject(resource);
+ assertEquals(getResourcePath("/test1"), resource2.getPath());
+ session.close();
+ }
+
+ @CleanRepositoriesBefore
+ public void testContextifyDifferentRepository() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ transaction.commit();
+
+ getRepository("repo2");
+ CDOSession session2 = openSession("repo2");
+ CDOView view = session2.openView();
+
+ try
+ {
+ view.getObject(resource);
+ fail("IllegalArgumentException expected");
+ }
+ catch (IllegalArgumentException success)
+ {
+ }
+ finally
+ {
+ session.close();
+ session2.close();
+ }
+ }
+
+ public void testContextifySameRepository() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ transaction.commit();
+
+ CDOSession session2 = openSession();
+ CDOView view = session2.openView();
+
+ CDOResource object = view.getObject(resource);
+ assertNotSame(resource, object);
+ assertEquals(resource.cdoID(), object.cdoID());
+
+ session.close();
+ session2.close();
+ }
+
+ public void testCacheReferences() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.createResource(getResourcePath("/my/test1"));
+ transaction.commit();
+
+ transaction.createResource(getResourcePath("/my/test2"));
+ transaction.createResource(getResourcePath("/my/test3"));
+ transaction.createResource(getResourcePath("/my/test4"));
+ transaction.createResource(getResourcePath("/my/test5"));
+
+ boolean done;
+ done = transaction.options().setCacheReferenceType(ReferenceType.SOFT);
+ assertEquals(false, done);
+
+ done = transaction.options().setCacheReferenceType(null);
+ assertEquals(false, done);
+
+ done = transaction.options().setCacheReferenceType(ReferenceType.STRONG);
+ assertEquals(true, done);
+
+ done = transaction.options().setCacheReferenceType(ReferenceType.SOFT);
+ assertEquals(true, done);
+
+ done = transaction.options().setCacheReferenceType(ReferenceType.WEAK);
+ assertEquals(true, done);
+
+ done = transaction.options().setCacheReferenceType(null);
+ assertEquals(true, done);
+
+ session.close();
+ }
+
+ public void testViewNotifiesDeactivation()
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ final boolean[] deactivated = { false };
+ view.addListener(new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ deactivated[0] = true;
+ }
+ });
+
+ view.close();
+ assertEquals(true, deactivated[0]);
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java
index 1785b7ea70..3fb7654fc8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java
@@ -1,351 +1,351 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
-import org.eclipse.emf.cdo.tests.model4.GenRefSingleNonContained;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.transaction.CDOUserSavepoint;
-import org.eclipse.emf.cdo.transaction.CDOXATransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.internal.cdo.session.SessionUtil;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-
-import java.util.Date;
-
-/**
- * @author Simon McDuff
- */
-public class XATransactionTest extends AbstractCDOTest
-{
- final static public String REPOSITORY2_NAME = "repo2";
-
- public void testRollback() throws Exception
- {
- getRepository(REPOSITORY2_NAME);
-
- CDOSession sessionA = openSession();
- CDOSession sessionB = openSession(REPOSITORY2_NAME);
-
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
-
- SessionUtil.prepareResourceSet(resourceSet);
- xaTransaction.add(CDOUtil.getViewSet(resourceSet));
-
- sessionA.getPackageRegistry().putEPackage(getModel1Package());
- sessionB.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
- CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
-
- CDOResource resA = transactionA1.createResource("/resA");
- CDOResource resB = transactionB1.createResource("/resB");
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
-
- supplier.getPurchaseOrders().add(purchaseOrder);
- resB.getContents().add(supplier);
- resA.getContents().add(purchaseOrder);
-
- assertNew(resA, transactionA1);
- assertNew(resB, transactionB1);
-
- xaTransaction.rollback();
-
- assertTransient(resA);
- assertTransient(resB);
-
- xaTransaction.commit();
- }
-
- @CleanRepositoriesBefore
- public void testRollback_AfterSetpoint() throws Exception
- {
- skipStoreWithoutExternalReferences();
- getRepository(REPOSITORY2_NAME);
-
- CDOSession sessionA = openSession();
- CDOSession sessionB = openSession(REPOSITORY2_NAME);
-
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
-
- SessionUtil.prepareResourceSet(resourceSet);
- xaTransaction.add(CDOUtil.getViewSet(resourceSet));
-
- sessionA.getPackageRegistry().putEPackage(getModel1Package());
- sessionB.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
- CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
-
- CDOResource resA = transactionA1.createResource("/resA");
- CDOResource resB = transactionB1.createResource("/resB");
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
-
- supplier.getPurchaseOrders().add(purchaseOrder);
- resB.getContents().add(supplier);
- resA.getContents().add(purchaseOrder);
-
- assertNew(resA, transactionA1);
- assertNew(resB, transactionB1);
-
- CDOUserSavepoint savepoint1 = xaTransaction.setSavepoint();
-
- purchaseOrder.setDate(new Date());
- supplier.setCity("OTTAWA");
-
- CDOUserSavepoint savepoint2 = xaTransaction.setSavepoint();
-
- savepoint1.rollback();
-
- assertNew(resA, transactionA1);
- assertNew(resB, transactionB1);
-
- assertEquals(null, supplier.getCity());
- assertEquals(null, purchaseOrder.getDate());
- assertEquals(supplier, purchaseOrder.getSupplier());
-
- try
- {
- savepoint2.rollback();
- fail("Should have an exception");
- }
- catch (Exception ex)
- {
- }
-
- xaTransaction.commit();
- }
-
- // XXX disabled because of Bug 290097
- @Skips("Postgresql")
- public void testCommitFromTransactionDisabled() throws Exception
- {
- skipStoreWithoutExternalReferences();
- getRepository(REPOSITORY2_NAME);
-
- {
- CDOSession sessionA = openSession();
- sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- sessionA.getPackageRegistry().putEPackage(getModel4Package());
-
- CDOSession sessionB = openSession(REPOSITORY2_NAME);
- sessionB.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- sessionB.getPackageRegistry().putEPackage(getModel4Package());
-
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
- CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
-
- CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
- CDOResource resB = transactionB1.createResource(getResourcePath("/resB"));
-
- ((InternalCDOTransaction)transactionA1).setTransactionStrategy(null);
- GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
- GenRefSingleNonContained objectFromResB = getModel4Factory().createGenRefSingleNonContained();
-
- objectFromResA.setElement(objectFromResB);
- resA.getContents().add(objectFromResA);
- resB.getContents().add(objectFromResB);
-
- CDOXATransaction transSet = CDOUtil.createXATransaction();
- transSet.setAllowRequestFromTransactionEnabled(false);
- transSet.add(CDOUtil.getViewSet(resourceSet));
-
- try
- {
- transactionA1.commit();
- fail("CommitException expected");
- }
- catch (CommitException exp)
- {
- }
-
- transSet.commit();
- }
- }
-
- // Skip this test until the problems with XATransactions are solved.
- @Skips({ IModelConfig.CAPABILITY_LEGACY, IRepositoryConfig.CAPABILITY_UUIDS, "DB" })
- public void testNotUsingXATransaction_Exception() throws Exception
- {
- skipStoreWithoutExternalReferences();
- getRepository(REPOSITORY2_NAME);
-
- {
- CDOSession sessionA = openSession();
- sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- sessionA.getPackageRegistry().putEPackage(getModel4Package());
-
- CDOSession sessionB = openSession(REPOSITORY2_NAME);
- sessionB.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- sessionB.getPackageRegistry().putEPackage(getModel4Package());
-
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOTransaction transactionA = sessionA.openTransaction(resourceSet);
- CDOTransaction transactionB = sessionB.openTransaction(resourceSet);
-
- CDOResource resA = transactionA.createResource(getResourcePath("/resA"));
- CDOResource resB = transactionB.createResource(getResourcePath("/resB"));
- GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
- GenRefSingleNonContained objectFromResB = getModel4Factory().createGenRefSingleNonContained();
-
- objectFromResA.setElement(objectFromResB);
- resA.getContents().add(objectFromResA);
- resB.getContents().add(objectFromResB);
-
- try
- {
- transactionA.commit(); // Would not fail with IDGenerationLocation.CLIENT!
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- }
-
- CDOXATransaction transSet = CDOUtil.createXATransaction();
- transSet.add(CDOUtil.getViewSet(resourceSet));
-
- transactionA.commit();
- }
- }
-
- // XXX disabled because of Bug 290097
- @Skips("Postgresql")
- @CleanRepositoriesBefore
- public void test_ExceptionInReadingStream() throws Exception
- {
- skipStoreWithoutExternalReferences();
- getRepository(REPOSITORY2_NAME);
-
- CDOSession sessionA = openSession();
- CDOSession sessionB = openSession(REPOSITORY2_NAME);
-
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
-
- SessionUtil.prepareResourceSet(resourceSet);
- xaTransaction.add(CDOUtil.getViewSet(resourceSet));
-
- sessionA.getPackageRegistry().putEPackage(getModel1Package());
- sessionB.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
- CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
-
- CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
- CDOResource resB = transactionB1.createResource(getResourcePath("/resB"));
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
-
- supplier.getPurchaseOrders().add(purchaseOrder);
- resB.getContents().add(supplier);
- resA.getContents().add(purchaseOrder);
-
- assertNew(resA, transactionA1);
- assertNew(resB, transactionB1);
-
- xaTransaction.commit();
- SpecialPurchaseOrder order = getModel2Factory().createSpecialPurchaseOrder();
- resB.getContents().add(order);
- try
- {
- xaTransaction.commit();
- }
- catch (Exception ignore)
- {
- }
- }
-
- // Skip this test until the problems with XATransactions are solved.
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void _test_ExceptionInWrite() throws Exception
- {
- getRepository(REPOSITORY2_NAME);
- getRepository("repo3");
-
- CDOSession sessionA = openSession();
- CDOSession sessionB = openSession(REPOSITORY2_NAME);
- CDOSession sessionC = openSession("repo3");
-
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
-
- SessionUtil.prepareResourceSet(resourceSet);
- xaTransaction.add(CDOUtil.getViewSet(resourceSet));
-
- sessionA.getPackageRegistry().putEPackage(getModel1Package());
- sessionB.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
- CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
-
- CDOResource resA = transactionA1.createResource("/resA");
- CDOResource resB = transactionB1.createResource("/resB");
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
-
- supplier.getPurchaseOrders().add(purchaseOrder);
- resB.getContents().add(supplier);
- resA.getContents().add(purchaseOrder);
-
- assertNew(resA, transactionA1);
- assertNew(resB, transactionB1);
-
- xaTransaction.commit();
-
- CDOTransaction transactionC1 = sessionC.openTransaction();
- sessionC.getPackageRegistry().putEPackage(getModel1Package());
-
- PurchaseOrder purchaseOrder3 = getModel1Factory().createPurchaseOrder();
- CDOResource resC = transactionC1.createResource("/resC");
- resC.getContents().add(purchaseOrder3);
- supplier.getPurchaseOrders().add(purchaseOrder3);
- purchaseOrder.setDate(new Date());
-
- try
- {
- xaTransaction.commit();
- fail("Should fail");
- }
- catch (Exception ignore)
- {
- }
-
- assertEquals(false, CDOUtil.getCDOObject(supplier).cdoWriteLock().isLocked());
- assertEquals(false, CDOUtil.getCDOObject(purchaseOrder).cdoWriteLock().isLocked());
-
- xaTransaction.rollback();
-
- transactionA1.waitForUpdate(transactionC1.getLastCommitTime(), DEFAULT_TIMEOUT);
- assertEquals(null, purchaseOrder.getDate());
- assertEquals(1, supplier.getPurchaseOrders().size());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
+import org.eclipse.emf.cdo.tests.model4.GenRefSingleNonContained;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOUserSavepoint;
+import org.eclipse.emf.cdo.transaction.CDOXATransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.internal.cdo.session.SessionUtil;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+
+import java.util.Date;
+
+/**
+ * @author Simon McDuff
+ */
+public class XATransactionTest extends AbstractCDOTest
+{
+ final static public String REPOSITORY2_NAME = "repo2";
+
+ public void testRollback() throws Exception
+ {
+ getRepository(REPOSITORY2_NAME);
+
+ CDOSession sessionA = openSession();
+ CDOSession sessionB = openSession(REPOSITORY2_NAME);
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
+
+ SessionUtil.prepareResourceSet(resourceSet);
+ xaTransaction.add(CDOUtil.getViewSet(resourceSet));
+
+ sessionA.getPackageRegistry().putEPackage(getModel1Package());
+ sessionB.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+ CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA1.createResource("/resA");
+ CDOResource resB = transactionB1.createResource("/resB");
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ resB.getContents().add(supplier);
+ resA.getContents().add(purchaseOrder);
+
+ assertNew(resA, transactionA1);
+ assertNew(resB, transactionB1);
+
+ xaTransaction.rollback();
+
+ assertTransient(resA);
+ assertTransient(resB);
+
+ xaTransaction.commit();
+ }
+
+ @CleanRepositoriesBefore
+ public void testRollback_AfterSetpoint() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+ getRepository(REPOSITORY2_NAME);
+
+ CDOSession sessionA = openSession();
+ CDOSession sessionB = openSession(REPOSITORY2_NAME);
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
+
+ SessionUtil.prepareResourceSet(resourceSet);
+ xaTransaction.add(CDOUtil.getViewSet(resourceSet));
+
+ sessionA.getPackageRegistry().putEPackage(getModel1Package());
+ sessionB.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+ CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA1.createResource("/resA");
+ CDOResource resB = transactionB1.createResource("/resB");
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ resB.getContents().add(supplier);
+ resA.getContents().add(purchaseOrder);
+
+ assertNew(resA, transactionA1);
+ assertNew(resB, transactionB1);
+
+ CDOUserSavepoint savepoint1 = xaTransaction.setSavepoint();
+
+ purchaseOrder.setDate(new Date());
+ supplier.setCity("OTTAWA");
+
+ CDOUserSavepoint savepoint2 = xaTransaction.setSavepoint();
+
+ savepoint1.rollback();
+
+ assertNew(resA, transactionA1);
+ assertNew(resB, transactionB1);
+
+ assertEquals(null, supplier.getCity());
+ assertEquals(null, purchaseOrder.getDate());
+ assertEquals(supplier, purchaseOrder.getSupplier());
+
+ try
+ {
+ savepoint2.rollback();
+ fail("Should have an exception");
+ }
+ catch (Exception ex)
+ {
+ }
+
+ xaTransaction.commit();
+ }
+
+ // XXX disabled because of Bug 290097
+ @Skips("Postgresql")
+ public void testCommitFromTransactionDisabled() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+ getRepository(REPOSITORY2_NAME);
+
+ {
+ CDOSession sessionA = openSession();
+ sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ sessionA.getPackageRegistry().putEPackage(getModel4Package());
+
+ CDOSession sessionB = openSession(REPOSITORY2_NAME);
+ sessionB.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ sessionB.getPackageRegistry().putEPackage(getModel4Package());
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+ CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
+ CDOResource resB = transactionB1.createResource(getResourcePath("/resB"));
+
+ ((InternalCDOTransaction)transactionA1).setTransactionStrategy(null);
+ GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
+ GenRefSingleNonContained objectFromResB = getModel4Factory().createGenRefSingleNonContained();
+
+ objectFromResA.setElement(objectFromResB);
+ resA.getContents().add(objectFromResA);
+ resB.getContents().add(objectFromResB);
+
+ CDOXATransaction transSet = CDOUtil.createXATransaction();
+ transSet.setAllowRequestFromTransactionEnabled(false);
+ transSet.add(CDOUtil.getViewSet(resourceSet));
+
+ try
+ {
+ transactionA1.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException exp)
+ {
+ }
+
+ transSet.commit();
+ }
+ }
+
+ // Skip this test until the problems with XATransactions are solved.
+ @Skips({ IModelConfig.CAPABILITY_LEGACY, IRepositoryConfig.CAPABILITY_UUIDS, "DB" })
+ public void testNotUsingXATransaction_Exception() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+ getRepository(REPOSITORY2_NAME);
+
+ {
+ CDOSession sessionA = openSession();
+ sessionA.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ sessionA.getPackageRegistry().putEPackage(getModel4Package());
+
+ CDOSession sessionB = openSession(REPOSITORY2_NAME);
+ sessionB.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ sessionB.getPackageRegistry().putEPackage(getModel4Package());
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transactionA = sessionA.openTransaction(resourceSet);
+ CDOTransaction transactionB = sessionB.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA.createResource(getResourcePath("/resA"));
+ CDOResource resB = transactionB.createResource(getResourcePath("/resB"));
+ GenRefSingleNonContained objectFromResA = getModel4Factory().createGenRefSingleNonContained();
+ GenRefSingleNonContained objectFromResB = getModel4Factory().createGenRefSingleNonContained();
+
+ objectFromResA.setElement(objectFromResB);
+ resA.getContents().add(objectFromResA);
+ resB.getContents().add(objectFromResB);
+
+ try
+ {
+ transactionA.commit(); // Would not fail with IDGenerationLocation.CLIENT!
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+
+ CDOXATransaction transSet = CDOUtil.createXATransaction();
+ transSet.add(CDOUtil.getViewSet(resourceSet));
+
+ transactionA.commit();
+ }
+ }
+
+ // XXX disabled because of Bug 290097
+ @Skips("Postgresql")
+ @CleanRepositoriesBefore
+ public void test_ExceptionInReadingStream() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+ getRepository(REPOSITORY2_NAME);
+
+ CDOSession sessionA = openSession();
+ CDOSession sessionB = openSession(REPOSITORY2_NAME);
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
+
+ SessionUtil.prepareResourceSet(resourceSet);
+ xaTransaction.add(CDOUtil.getViewSet(resourceSet));
+
+ sessionA.getPackageRegistry().putEPackage(getModel1Package());
+ sessionB.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+ CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA1.createResource(getResourcePath("/resA"));
+ CDOResource resB = transactionB1.createResource(getResourcePath("/resB"));
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ resB.getContents().add(supplier);
+ resA.getContents().add(purchaseOrder);
+
+ assertNew(resA, transactionA1);
+ assertNew(resB, transactionB1);
+
+ xaTransaction.commit();
+ SpecialPurchaseOrder order = getModel2Factory().createSpecialPurchaseOrder();
+ resB.getContents().add(order);
+ try
+ {
+ xaTransaction.commit();
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+
+ // Skip this test until the problems with XATransactions are solved.
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void _test_ExceptionInWrite() throws Exception
+ {
+ getRepository(REPOSITORY2_NAME);
+ getRepository("repo3");
+
+ CDOSession sessionA = openSession();
+ CDOSession sessionB = openSession(REPOSITORY2_NAME);
+ CDOSession sessionC = openSession("repo3");
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
+
+ SessionUtil.prepareResourceSet(resourceSet);
+ xaTransaction.add(CDOUtil.getViewSet(resourceSet));
+
+ sessionA.getPackageRegistry().putEPackage(getModel1Package());
+ sessionB.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
+ CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);
+
+ CDOResource resA = transactionA1.createResource("/resA");
+ CDOResource resB = transactionB1.createResource("/resB");
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ resB.getContents().add(supplier);
+ resA.getContents().add(purchaseOrder);
+
+ assertNew(resA, transactionA1);
+ assertNew(resB, transactionB1);
+
+ xaTransaction.commit();
+
+ CDOTransaction transactionC1 = sessionC.openTransaction();
+ sessionC.getPackageRegistry().putEPackage(getModel1Package());
+
+ PurchaseOrder purchaseOrder3 = getModel1Factory().createPurchaseOrder();
+ CDOResource resC = transactionC1.createResource("/resC");
+ resC.getContents().add(purchaseOrder3);
+ supplier.getPurchaseOrders().add(purchaseOrder3);
+ purchaseOrder.setDate(new Date());
+
+ try
+ {
+ xaTransaction.commit();
+ fail("Should fail");
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ assertEquals(false, CDOUtil.getCDOObject(supplier).cdoWriteLock().isLocked());
+ assertEquals(false, CDOUtil.getCDOObject(purchaseOrder).cdoWriteLock().isLocked());
+
+ xaTransaction.rollback();
+
+ transactionA1.waitForUpdate(transactionC1.getLastCommitTime(), DEFAULT_TIMEOUT);
+ assertEquals(null, purchaseOrder.getDate());
+ assertEquals(1, supplier.getPurchaseOrders().size());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XRefTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XRefTest.java
index 4c7a9a4631..4e11cdb80b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XRefTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XRefTest.java
@@ -1,602 +1,602 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Stefan Winkler - additional tests
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOObjectReference;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * 300149: Support remote cross referencing with a convenient API on the client and SPI on the server for the stores to
- * implement https://bugs.eclipse.org/bugs/show_bug.cgi?id=300149
- *
- * @author Eike Stepper
- * @since 4.0
- */
-public class XRefTest extends AbstractCDOTest
-{
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- skipStoreWithoutQueryXRefs();
- }
-
- public void testCrossReferenceMultivalueEReferenceQuery() throws Exception
- {
- PurchaseOrder purchaseOrder1 = getModel1Factory().createPurchaseOrder();
- PurchaseOrder purchaseOrder2 = getModel1Factory().createPurchaseOrder();
- PurchaseOrder purchaseOrder3 = getModel1Factory().createPurchaseOrder();
- PurchaseOrder purchaseOrder4 = getModel1Factory().createPurchaseOrder();
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.getPurchaseOrders().add(purchaseOrder1);
- supplier.getPurchaseOrders().add(purchaseOrder2);
- supplier.getPurchaseOrders().add(purchaseOrder3);
- supplier.getPurchaseOrders().add(purchaseOrder4);
-
- CDOSession session1 = openSession();
- CDOTransaction transaction = session1.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(supplier);
- resource.getContents().add(purchaseOrder1);
- resource.getContents().add(purchaseOrder2);
- resource.getContents().add(purchaseOrder3);
- resource.getContents().add(purchaseOrder4);
-
- transaction.commit();
-
- /******************/
-
- CDOSession session2 = openSession();
- CDOView view = session2.openView();
-
- List<CDOObjectReference> results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(supplier)));
- assertEquals(4, results.size());
-
- for (CDOObjectReference result : results)
- {
- CDOObject sourceObject = result.getSourceObject();
- assertInstanceOf(PurchaseOrder.class, CDOUtil.getEObject(sourceObject));
- }
- }
-
- public void testLocallyDetachedObject() throws Exception
- {
- PurchaseOrder purchaseOrder1 = getModel1Factory().createPurchaseOrder();
- PurchaseOrder purchaseOrder2 = getModel1Factory().createPurchaseOrder();
- PurchaseOrder purchaseOrder3 = getModel1Factory().createPurchaseOrder();
- PurchaseOrder purchaseOrder4 = getModel1Factory().createPurchaseOrder();
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.getPurchaseOrders().add(purchaseOrder1);
- supplier.getPurchaseOrders().add(purchaseOrder2);
- supplier.getPurchaseOrders().add(purchaseOrder3);
- supplier.getPurchaseOrders().add(purchaseOrder4);
-
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
-
- CDOResource resource = transaction1.createResource(getResourcePath("/test1"));
- resource.getContents().add(supplier);
- resource.getContents().add(purchaseOrder1);
- resource.getContents().add(purchaseOrder2);
- resource.getContents().add(purchaseOrder3);
- resource.getContents().add(purchaseOrder4);
-
- transaction1.commit();
-
- /******************/
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- supplier = (Supplier)transaction2.getResource(getResourcePath("/test1")).getContents().remove(0);
-
- List<CDOObjectReference> results = transaction2.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(supplier)));
- assertEquals(4, results.size());
-
- for (CDOObjectReference result : results)
- {
- CDOObject sourceObject = result.getSourceObject();
- assertInstanceOf(PurchaseOrder.class, CDOUtil.getEObject(sourceObject));
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testXRefsToMany() throws Exception
- {
- // create model
- EPackage pkg = EMFUtil.createEPackage("xreftest", "xreftest",
- "http://cdo.emf.eclipse.org/TestModels/XRefTestToMany.ecore");
- EClass cls1 = EMFUtil.createEClass(pkg, "referencer", false, false);
- EAttribute id1 = EMFUtil.createEAttribute(cls1, "id", EcorePackage.eINSTANCE.getEInt());
-
- EClass cls2 = EMFUtil.createEClass(pkg, "referencee", false, false);
- EAttribute id2 = EMFUtil.createEAttribute(cls2, "id", EcorePackage.eINSTANCE.getEInt());
-
- EReference ref = EMFUtil.createEReference(cls1, "ref", cls2, false, true);
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- // create instances
- EObject obj2_1 = EcoreUtil.create(cls2);
- obj2_1.eSet(id2, 11);
- EObject obj2_2 = EcoreUtil.create(cls2);
- obj2_2.eSet(id2, 12);
- EObject obj2_3 = EcoreUtil.create(cls2);
- obj2_3.eSet(id2, 13);
- EObject obj2_4 = EcoreUtil.create(cls2);
- obj2_4.eSet(id2, 14);
-
- EObject obj1_1 = EcoreUtil.create(cls1);
- obj1_1.eSet(id1, 1);
- EObject obj1_2 = EcoreUtil.create(cls1);
- obj1_2.eSet(id1, 2);
- EObject obj1_3 = EcoreUtil.create(cls1);
- obj1_3.eSet(id1, 3);
- EObject obj1_4 = EcoreUtil.create(cls1);
- obj1_4.eSet(id1, 4);
-
- // configure references
- ((EList<EObject>)obj1_1.eGet(ref)).add(obj2_2);
- ((EList<EObject>)obj1_1.eGet(ref)).add(obj2_3);
-
- ((EList<EObject>)obj1_2.eGet(ref)).add(obj2_2);
-
- ((EList<EObject>)obj1_3.eGet(ref)).add(obj2_1);
- ((EList<EObject>)obj1_3.eGet(ref)).add(obj2_2);
-
- // store objects
- CDOSession session1 = openSession();
- CDOTransaction transaction = session1.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().addAll(Arrays.asList(obj1_1, obj1_2, obj1_3, obj1_4, obj2_1, obj2_2, obj2_3, obj2_4));
- transaction.commit();
- transaction.close();
- session1.close();
-
- // check XRefs
- CDOSession session2 = openSession();
- CDOView view = session2.openView();
-
- List<CDOObjectReference> results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_1)));
- assertEquals(1, results.size());
-
- {
- CDOObjectReference result = results.get(0);
- assertEquals(0, result.getSourceIndex());
- // XXX fails!
- // assertEquals(ref, result.getSourceReference());
- CDOObject sourceObject = results.get(0).getSourceObject();
- assertEquals(3, sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id")));
- }
-
- results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_3)));
- assertEquals(1, results.size());
- {
- CDOObjectReference result = results.get(0);
- assertEquals(1, result.getSourceIndex());
- assertEquals(ref.getName(), result.getSourceFeature().getName());
- CDOObject sourceObject = results.get(0).getSourceObject();
- assertEquals(1, sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id")));
- }
-
- results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_2)));
- assertEquals(3, results.size());
-
- boolean found1 = false;
- boolean found2 = false;
- boolean found3 = false;
-
- for (CDOObjectReference result : results)
- {
- assertEquals(ref.getName(), results.get(0).getSourceFeature().getName());
-
- CDOObject sourceObject = result.getSourceObject();
- Integer id = (Integer)sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id"));
- switch (id.intValue())
- {
- case 1:
- assertEquals(0, result.getSourceIndex());
- found1 = true;
- break;
- case 2:
- assertEquals(0, result.getSourceIndex());
- found2 = true;
- break;
- case 3:
- assertEquals(1, result.getSourceIndex());
- found3 = true;
- break;
- default:
- // must not happen!
- assertEquals(true, false);
- }
- }
-
- assertEquals(true, found1 && found2 && found3);
-
- view.close();
- session2.close();
- }
-
- @CleanRepositoriesBefore
- public void testXRefsToOne() throws Exception
- {
- // create model
- EPackage pkg = EMFUtil.createEPackage("xreftest", "xreftest",
- "http://cdo.emf.eclipse.org/TestModels/XRefTestToOne.ecore");
- EClass cls1 = EMFUtil.createEClass(pkg, "referencer", false, false);
- EAttribute id1 = EMFUtil.createEAttribute(cls1, "id", EcorePackage.eINSTANCE.getEInt());
-
- EClass cls2 = EMFUtil.createEClass(pkg, "referencee", false, false);
- EAttribute id2 = EMFUtil.createEAttribute(cls2, "id", EcorePackage.eINSTANCE.getEInt());
-
- EReference ref = EMFUtil.createEReference(cls1, "ref", cls2, false, false);
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- // create instances
- EObject obj2_1 = EcoreUtil.create(cls2);
- obj2_1.eSet(id2, 11);
- EObject obj2_2 = EcoreUtil.create(cls2);
- obj2_2.eSet(id2, 12);
- EObject obj2_3 = EcoreUtil.create(cls2);
- obj2_3.eSet(id2, 13);
- EObject obj2_4 = EcoreUtil.create(cls2);
- obj2_4.eSet(id2, 14);
-
- EObject obj1_1 = EcoreUtil.create(cls1);
- obj1_1.eSet(id1, 1);
- EObject obj1_2 = EcoreUtil.create(cls1);
- obj1_2.eSet(id1, 2);
- EObject obj1_3 = EcoreUtil.create(cls1);
- obj1_3.eSet(id1, 3);
- EObject obj1_4 = EcoreUtil.create(cls1);
- obj1_4.eSet(id1, 4);
-
- // configure references
- obj1_1.eSet(ref, obj2_2);
- obj1_2.eSet(ref, obj2_2);
- obj1_3.eSet(ref, obj2_3);
-
- // store objects
- CDOSession session1 = openSession();
- CDOTransaction transaction = session1.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().addAll(Arrays.asList(obj1_1, obj1_2, obj1_3, obj1_4, obj2_1, obj2_2, obj2_3, obj2_4));
- transaction.commit();
- transaction.close();
- session1.close();
-
- // check XRefs
- CDOSession session2 = openSession();
- CDOView view = session2.openView();
-
- List<CDOObjectReference> results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_1)));
- assertEquals(true, results.isEmpty());
-
- results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_3)));
-
- assertEquals(1, results.size());
- {
- CDOObjectReference result = results.get(0);
- assertEquals(0, result.getSourceIndex());
-
- assertEquals(ref.getName(), result.getSourceFeature().getName());
- CDOObject sourceObject = results.get(0).getSourceObject();
- assertEquals(3, sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id")));
- }
-
- results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_2)));
- assertEquals(2, results.size());
-
- boolean found1 = false;
- boolean found2 = false;
-
- for (CDOObjectReference result : results)
- {
- assertEquals(ref.getName(), results.get(0).getSourceFeature().getName());
-
- CDOObject sourceObject = result.getSourceObject();
- Integer id = (Integer)sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id"));
- assertEquals(true, id == 1 || id == 2);
- assertEquals(0, result.getSourceIndex());
-
- if (id == 1)
- {
- found1 = true;
- }
- else if (id == 2)
- {
- found2 = true;
- }
- }
-
- assertEquals(true, found1 && found2);
-
- view.close();
- session2.close();
- }
-
- @SuppressWarnings({ "unchecked", "unused" })
- public void testSpecificReferences0() throws Exception
- {
- EClass a = EcoreFactory.eINSTANCE.createEClass();
- a.setName("A");
-
- EClass b = EcoreFactory.eINSTANCE.createEClass();
- b.setName("B");
-
- EReference aa1 = addReference(a, a, true);
- EReference aa2 = addReference(a, a, true);
- EReference aa3 = addReference(a, a, false);
- EReference aa4 = addReference(a, a, false);
- EReference ab5 = addReference(a, b, true);
- EReference ab6 = addReference(a, b, true);
- EReference ab7 = addReference(a, b, false);
- EReference ab8 = addReference(a, b, false);
-
- EReference ba1 = addReference(b, a, true);
- EReference ba2 = addReference(b, a, true);
- EReference ba3 = addReference(b, a, false);
- EReference ba4 = addReference(b, a, false);
- EReference bb5 = addReference(b, b, true);
- EReference bb6 = addReference(b, b, true);
- EReference bb7 = addReference(b, b, false);
- EReference bb8 = addReference(b, b, false);
-
- EPackage xref = EcoreFactory.eINSTANCE.createEPackage();
- xref.setName("xref");
- xref.setNsPrefix("xref");
- xref.setNsURI("http://xref");
- xref.getEClassifiers().add(a);
- xref.getEClassifiers().add(b);
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(xref);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- EObject a1 = addObject(resource, a);
- EObject a2 = addObject(resource, a);
- EObject a3 = addObject(resource, a);
- EObject a4 = addObject(resource, a);
-
- EObject b1 = addObject(resource, b);
- EObject b2 = addObject(resource, b);
- EObject b3 = addObject(resource, b);
- EObject b4 = addObject(resource, b);
-
- ((EList<EObject>)a1.eGet(ab5)).add(b1);
- ((EList<EObject>)a1.eGet(ab5)).add(b2);
- ((EList<EObject>)a1.eGet(ab5)).add(b3);
- ((EList<EObject>)a1.eGet(ab5)).add(b4);
-
- ((EList<EObject>)a1.eGet(ab6)).add(b1);
- ((EList<EObject>)a1.eGet(ab6)).add(b2);
- ((EList<EObject>)a1.eGet(ab6)).add(b3);
- ((EList<EObject>)a1.eGet(ab6)).add(b4);
-
- transaction.commit();
-
- /******************/
-
- List<CDOObjectReference> results = transaction.queryXRefs(CDOUtil.getCDOObject(b1));
- assertEquals(2, results.size());
-
- assertEquals(0, results.get(0).getSourceIndex());
- assertEquals(ab5, results.get(0).getSourceFeature());
- assertEquals(a1, results.get(0).getSourceObject());
- assertEquals(b1, results.get(0).getTargetObject());
-
- assertEquals(0, results.get(1).getSourceIndex());
- assertEquals(ab6, results.get(1).getSourceFeature());
- assertEquals(a1, results.get(1).getSourceObject());
- assertEquals(b1, results.get(1).getTargetObject());
- }
-
- @SuppressWarnings({ "unchecked", "unused" })
- public void testSpecificReferences1() throws Exception
- {
- EClass a = EcoreFactory.eINSTANCE.createEClass();
- a.setName("A");
-
- EClass b = EcoreFactory.eINSTANCE.createEClass();
- b.setName("B");
-
- EReference aa1 = addReference(a, a, true);
- EReference aa2 = addReference(a, a, true);
- EReference aa3 = addReference(a, a, false);
- EReference aa4 = addReference(a, a, false);
- EReference ab5 = addReference(a, b, true);
- EReference ab6 = addReference(a, b, true);
- EReference ab7 = addReference(a, b, false);
- EReference ab8 = addReference(a, b, false);
-
- EReference ba1 = addReference(b, a, true);
- EReference ba2 = addReference(b, a, true);
- EReference ba3 = addReference(b, a, false);
- EReference ba4 = addReference(b, a, false);
- EReference bb5 = addReference(b, b, true);
- EReference bb6 = addReference(b, b, true);
- EReference bb7 = addReference(b, b, false);
- EReference bb8 = addReference(b, b, false);
-
- EPackage xref = EcoreFactory.eINSTANCE.createEPackage();
- xref.setName("xref");
- xref.setNsPrefix("xref");
- xref.setNsURI("http://xref");
- xref.getEClassifiers().add(a);
- xref.getEClassifiers().add(b);
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(xref);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- EObject a1 = addObject(resource, a);
- EObject a2 = addObject(resource, a);
- EObject a3 = addObject(resource, a);
- EObject a4 = addObject(resource, a);
-
- EObject b1 = addObject(resource, b);
- EObject b2 = addObject(resource, b);
- EObject b3 = addObject(resource, b);
- EObject b4 = addObject(resource, b);
-
- ((EList<EObject>)a1.eGet(ab5)).add(b1);
- ((EList<EObject>)a1.eGet(ab5)).add(b2);
- ((EList<EObject>)a1.eGet(ab5)).add(b3);
- ((EList<EObject>)a1.eGet(ab5)).add(b4);
-
- ((EList<EObject>)a1.eGet(ab6)).add(b1);
- ((EList<EObject>)a1.eGet(ab6)).add(b2);
- ((EList<EObject>)a1.eGet(ab6)).add(b3);
- ((EList<EObject>)a1.eGet(ab6)).add(b4);
-
- transaction.commit();
-
- /******************/
-
- List<CDOObjectReference> results = transaction.queryXRefs(CDOUtil.getCDOObject(b1), ab5);
- assertEquals(1, results.size());
-
- assertEquals(0, results.get(0).getSourceIndex());
- assertEquals(ab5, results.get(0).getSourceFeature());
- assertEquals(a1, results.get(0).getSourceObject());
- assertEquals(b1, results.get(0).getTargetObject());
- }
-
- @SuppressWarnings({ "unchecked", "unused" })
- public void testSpecificReferences2() throws Exception
- {
- EClass a = EcoreFactory.eINSTANCE.createEClass();
- a.setName("A");
-
- EClass b = EcoreFactory.eINSTANCE.createEClass();
- b.setName("B");
-
- EReference aa1 = addReference(a, a, true);
- EReference aa2 = addReference(a, a, true);
- EReference aa3 = addReference(a, a, false);
- EReference aa4 = addReference(a, a, false);
- EReference ab5 = addReference(a, b, true);
- EReference ab6 = addReference(a, b, true);
- EReference ab7 = addReference(a, b, false);
- EReference ab8 = addReference(a, b, false);
-
- EReference ba1 = addReference(b, a, true);
- EReference ba2 = addReference(b, a, true);
- EReference ba3 = addReference(b, a, false);
- EReference ba4 = addReference(b, a, false);
- EReference bb5 = addReference(b, b, true);
- EReference bb6 = addReference(b, b, true);
- EReference bb7 = addReference(b, b, false);
- EReference bb8 = addReference(b, b, false);
-
- EPackage xref = EcoreFactory.eINSTANCE.createEPackage();
- xref.setName("xref");
- xref.setNsPrefix("xref");
- xref.setNsURI("http://xref");
- xref.getEClassifiers().add(a);
- xref.getEClassifiers().add(b);
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(xref);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- EObject a1 = addObject(resource, a);
- EObject a2 = addObject(resource, a);
- EObject a3 = addObject(resource, a);
- EObject a4 = addObject(resource, a);
-
- EObject b1 = addObject(resource, b);
- EObject b2 = addObject(resource, b);
- EObject b3 = addObject(resource, b);
- EObject b4 = addObject(resource, b);
-
- ((EList<EObject>)a1.eGet(ab5)).add(b1);
- ((EList<EObject>)a1.eGet(ab5)).add(b2);
- ((EList<EObject>)a1.eGet(ab5)).add(b3);
- ((EList<EObject>)a1.eGet(ab5)).add(b4);
-
- ((EList<EObject>)a1.eGet(ab6)).add(b1);
- ((EList<EObject>)a1.eGet(ab6)).add(b2);
- ((EList<EObject>)a1.eGet(ab6)).add(b3);
- ((EList<EObject>)a1.eGet(ab6)).add(b4);
-
- transaction.commit();
-
- /******************/
-
- List<CDOObjectReference> results = transaction.queryXRefs(CDOUtil.getCDOObject(b1), ab6);
- assertEquals(1, results.size());
-
- assertEquals(0, results.get(0).getSourceIndex());
- assertEquals(ab6, results.get(0).getSourceFeature());
- assertEquals(a1, results.get(0).getSourceObject());
- assertEquals(b1, results.get(0).getTargetObject());
- }
-
- private EObject addObject(CDOResource resource, EClass eClass)
- {
- EObject b8 = EcoreUtil.create(eClass);
- resource.getContents().add(b8);
- return b8;
- }
-
- private EReference addReference(EClass source, EClass target, boolean many)
- {
- EReference reference = EcoreFactory.eINSTANCE.createEReference();
- EList<EStructuralFeature> features = source.getEStructuralFeatures();
- features.add(reference);
-
- reference.setName(target.getName().toLowerCase() + features.size());
- reference.setEType(target);
- reference.setUpperBound(many ? -1 : 1);
- return reference;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Stefan Winkler - additional tests
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOObjectReference;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 300149: Support remote cross referencing with a convenient API on the client and SPI on the server for the stores to
+ * implement https://bugs.eclipse.org/bugs/show_bug.cgi?id=300149
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public class XRefTest extends AbstractCDOTest
+{
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ skipStoreWithoutQueryXRefs();
+ }
+
+ public void testCrossReferenceMultivalueEReferenceQuery() throws Exception
+ {
+ PurchaseOrder purchaseOrder1 = getModel1Factory().createPurchaseOrder();
+ PurchaseOrder purchaseOrder2 = getModel1Factory().createPurchaseOrder();
+ PurchaseOrder purchaseOrder3 = getModel1Factory().createPurchaseOrder();
+ PurchaseOrder purchaseOrder4 = getModel1Factory().createPurchaseOrder();
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.getPurchaseOrders().add(purchaseOrder1);
+ supplier.getPurchaseOrders().add(purchaseOrder2);
+ supplier.getPurchaseOrders().add(purchaseOrder3);
+ supplier.getPurchaseOrders().add(purchaseOrder4);
+
+ CDOSession session1 = openSession();
+ CDOTransaction transaction = session1.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(supplier);
+ resource.getContents().add(purchaseOrder1);
+ resource.getContents().add(purchaseOrder2);
+ resource.getContents().add(purchaseOrder3);
+ resource.getContents().add(purchaseOrder4);
+
+ transaction.commit();
+
+ /******************/
+
+ CDOSession session2 = openSession();
+ CDOView view = session2.openView();
+
+ List<CDOObjectReference> results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(supplier)));
+ assertEquals(4, results.size());
+
+ for (CDOObjectReference result : results)
+ {
+ CDOObject sourceObject = result.getSourceObject();
+ assertInstanceOf(PurchaseOrder.class, CDOUtil.getEObject(sourceObject));
+ }
+ }
+
+ public void testLocallyDetachedObject() throws Exception
+ {
+ PurchaseOrder purchaseOrder1 = getModel1Factory().createPurchaseOrder();
+ PurchaseOrder purchaseOrder2 = getModel1Factory().createPurchaseOrder();
+ PurchaseOrder purchaseOrder3 = getModel1Factory().createPurchaseOrder();
+ PurchaseOrder purchaseOrder4 = getModel1Factory().createPurchaseOrder();
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.getPurchaseOrders().add(purchaseOrder1);
+ supplier.getPurchaseOrders().add(purchaseOrder2);
+ supplier.getPurchaseOrders().add(purchaseOrder3);
+ supplier.getPurchaseOrders().add(purchaseOrder4);
+
+ CDOSession session1 = openSession();
+ CDOTransaction transaction1 = session1.openTransaction();
+
+ CDOResource resource = transaction1.createResource(getResourcePath("/test1"));
+ resource.getContents().add(supplier);
+ resource.getContents().add(purchaseOrder1);
+ resource.getContents().add(purchaseOrder2);
+ resource.getContents().add(purchaseOrder3);
+ resource.getContents().add(purchaseOrder4);
+
+ transaction1.commit();
+
+ /******************/
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ supplier = (Supplier)transaction2.getResource(getResourcePath("/test1")).getContents().remove(0);
+
+ List<CDOObjectReference> results = transaction2.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(supplier)));
+ assertEquals(4, results.size());
+
+ for (CDOObjectReference result : results)
+ {
+ CDOObject sourceObject = result.getSourceObject();
+ assertInstanceOf(PurchaseOrder.class, CDOUtil.getEObject(sourceObject));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testXRefsToMany() throws Exception
+ {
+ // create model
+ EPackage pkg = EMFUtil.createEPackage("xreftest", "xreftest",
+ "http://cdo.emf.eclipse.org/TestModels/XRefTestToMany.ecore");
+ EClass cls1 = EMFUtil.createEClass(pkg, "referencer", false, false);
+ EAttribute id1 = EMFUtil.createEAttribute(cls1, "id", EcorePackage.eINSTANCE.getEInt());
+
+ EClass cls2 = EMFUtil.createEClass(pkg, "referencee", false, false);
+ EAttribute id2 = EMFUtil.createEAttribute(cls2, "id", EcorePackage.eINSTANCE.getEInt());
+
+ EReference ref = EMFUtil.createEReference(cls1, "ref", cls2, false, true);
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ // create instances
+ EObject obj2_1 = EcoreUtil.create(cls2);
+ obj2_1.eSet(id2, 11);
+ EObject obj2_2 = EcoreUtil.create(cls2);
+ obj2_2.eSet(id2, 12);
+ EObject obj2_3 = EcoreUtil.create(cls2);
+ obj2_3.eSet(id2, 13);
+ EObject obj2_4 = EcoreUtil.create(cls2);
+ obj2_4.eSet(id2, 14);
+
+ EObject obj1_1 = EcoreUtil.create(cls1);
+ obj1_1.eSet(id1, 1);
+ EObject obj1_2 = EcoreUtil.create(cls1);
+ obj1_2.eSet(id1, 2);
+ EObject obj1_3 = EcoreUtil.create(cls1);
+ obj1_3.eSet(id1, 3);
+ EObject obj1_4 = EcoreUtil.create(cls1);
+ obj1_4.eSet(id1, 4);
+
+ // configure references
+ ((EList<EObject>)obj1_1.eGet(ref)).add(obj2_2);
+ ((EList<EObject>)obj1_1.eGet(ref)).add(obj2_3);
+
+ ((EList<EObject>)obj1_2.eGet(ref)).add(obj2_2);
+
+ ((EList<EObject>)obj1_3.eGet(ref)).add(obj2_1);
+ ((EList<EObject>)obj1_3.eGet(ref)).add(obj2_2);
+
+ // store objects
+ CDOSession session1 = openSession();
+ CDOTransaction transaction = session1.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().addAll(Arrays.asList(obj1_1, obj1_2, obj1_3, obj1_4, obj2_1, obj2_2, obj2_3, obj2_4));
+ transaction.commit();
+ transaction.close();
+ session1.close();
+
+ // check XRefs
+ CDOSession session2 = openSession();
+ CDOView view = session2.openView();
+
+ List<CDOObjectReference> results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_1)));
+ assertEquals(1, results.size());
+
+ {
+ CDOObjectReference result = results.get(0);
+ assertEquals(0, result.getSourceIndex());
+ // XXX fails!
+ // assertEquals(ref, result.getSourceReference());
+ CDOObject sourceObject = results.get(0).getSourceObject();
+ assertEquals(3, sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id")));
+ }
+
+ results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_3)));
+ assertEquals(1, results.size());
+ {
+ CDOObjectReference result = results.get(0);
+ assertEquals(1, result.getSourceIndex());
+ assertEquals(ref.getName(), result.getSourceFeature().getName());
+ CDOObject sourceObject = results.get(0).getSourceObject();
+ assertEquals(1, sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id")));
+ }
+
+ results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_2)));
+ assertEquals(3, results.size());
+
+ boolean found1 = false;
+ boolean found2 = false;
+ boolean found3 = false;
+
+ for (CDOObjectReference result : results)
+ {
+ assertEquals(ref.getName(), results.get(0).getSourceFeature().getName());
+
+ CDOObject sourceObject = result.getSourceObject();
+ Integer id = (Integer)sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id"));
+ switch (id.intValue())
+ {
+ case 1:
+ assertEquals(0, result.getSourceIndex());
+ found1 = true;
+ break;
+ case 2:
+ assertEquals(0, result.getSourceIndex());
+ found2 = true;
+ break;
+ case 3:
+ assertEquals(1, result.getSourceIndex());
+ found3 = true;
+ break;
+ default:
+ // must not happen!
+ assertEquals(true, false);
+ }
+ }
+
+ assertEquals(true, found1 && found2 && found3);
+
+ view.close();
+ session2.close();
+ }
+
+ @CleanRepositoriesBefore
+ public void testXRefsToOne() throws Exception
+ {
+ // create model
+ EPackage pkg = EMFUtil.createEPackage("xreftest", "xreftest",
+ "http://cdo.emf.eclipse.org/TestModels/XRefTestToOne.ecore");
+ EClass cls1 = EMFUtil.createEClass(pkg, "referencer", false, false);
+ EAttribute id1 = EMFUtil.createEAttribute(cls1, "id", EcorePackage.eINSTANCE.getEInt());
+
+ EClass cls2 = EMFUtil.createEClass(pkg, "referencee", false, false);
+ EAttribute id2 = EMFUtil.createEAttribute(cls2, "id", EcorePackage.eINSTANCE.getEInt());
+
+ EReference ref = EMFUtil.createEReference(cls1, "ref", cls2, false, false);
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ // create instances
+ EObject obj2_1 = EcoreUtil.create(cls2);
+ obj2_1.eSet(id2, 11);
+ EObject obj2_2 = EcoreUtil.create(cls2);
+ obj2_2.eSet(id2, 12);
+ EObject obj2_3 = EcoreUtil.create(cls2);
+ obj2_3.eSet(id2, 13);
+ EObject obj2_4 = EcoreUtil.create(cls2);
+ obj2_4.eSet(id2, 14);
+
+ EObject obj1_1 = EcoreUtil.create(cls1);
+ obj1_1.eSet(id1, 1);
+ EObject obj1_2 = EcoreUtil.create(cls1);
+ obj1_2.eSet(id1, 2);
+ EObject obj1_3 = EcoreUtil.create(cls1);
+ obj1_3.eSet(id1, 3);
+ EObject obj1_4 = EcoreUtil.create(cls1);
+ obj1_4.eSet(id1, 4);
+
+ // configure references
+ obj1_1.eSet(ref, obj2_2);
+ obj1_2.eSet(ref, obj2_2);
+ obj1_3.eSet(ref, obj2_3);
+
+ // store objects
+ CDOSession session1 = openSession();
+ CDOTransaction transaction = session1.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().addAll(Arrays.asList(obj1_1, obj1_2, obj1_3, obj1_4, obj2_1, obj2_2, obj2_3, obj2_4));
+ transaction.commit();
+ transaction.close();
+ session1.close();
+
+ // check XRefs
+ CDOSession session2 = openSession();
+ CDOView view = session2.openView();
+
+ List<CDOObjectReference> results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_1)));
+ assertEquals(true, results.isEmpty());
+
+ results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_3)));
+
+ assertEquals(1, results.size());
+ {
+ CDOObjectReference result = results.get(0);
+ assertEquals(0, result.getSourceIndex());
+
+ assertEquals(ref.getName(), result.getSourceFeature().getName());
+ CDOObject sourceObject = results.get(0).getSourceObject();
+ assertEquals(3, sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id")));
+ }
+
+ results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(obj2_2)));
+ assertEquals(2, results.size());
+
+ boolean found1 = false;
+ boolean found2 = false;
+
+ for (CDOObjectReference result : results)
+ {
+ assertEquals(ref.getName(), results.get(0).getSourceFeature().getName());
+
+ CDOObject sourceObject = result.getSourceObject();
+ Integer id = (Integer)sourceObject.eGet(sourceObject.eClass().getEStructuralFeature("id"));
+ assertEquals(true, id == 1 || id == 2);
+ assertEquals(0, result.getSourceIndex());
+
+ if (id == 1)
+ {
+ found1 = true;
+ }
+ else if (id == 2)
+ {
+ found2 = true;
+ }
+ }
+
+ assertEquals(true, found1 && found2);
+
+ view.close();
+ session2.close();
+ }
+
+ @SuppressWarnings({ "unchecked", "unused" })
+ public void testSpecificReferences0() throws Exception
+ {
+ EClass a = EcoreFactory.eINSTANCE.createEClass();
+ a.setName("A");
+
+ EClass b = EcoreFactory.eINSTANCE.createEClass();
+ b.setName("B");
+
+ EReference aa1 = addReference(a, a, true);
+ EReference aa2 = addReference(a, a, true);
+ EReference aa3 = addReference(a, a, false);
+ EReference aa4 = addReference(a, a, false);
+ EReference ab5 = addReference(a, b, true);
+ EReference ab6 = addReference(a, b, true);
+ EReference ab7 = addReference(a, b, false);
+ EReference ab8 = addReference(a, b, false);
+
+ EReference ba1 = addReference(b, a, true);
+ EReference ba2 = addReference(b, a, true);
+ EReference ba3 = addReference(b, a, false);
+ EReference ba4 = addReference(b, a, false);
+ EReference bb5 = addReference(b, b, true);
+ EReference bb6 = addReference(b, b, true);
+ EReference bb7 = addReference(b, b, false);
+ EReference bb8 = addReference(b, b, false);
+
+ EPackage xref = EcoreFactory.eINSTANCE.createEPackage();
+ xref.setName("xref");
+ xref.setNsPrefix("xref");
+ xref.setNsURI("http://xref");
+ xref.getEClassifiers().add(a);
+ xref.getEClassifiers().add(b);
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(xref);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ EObject a1 = addObject(resource, a);
+ EObject a2 = addObject(resource, a);
+ EObject a3 = addObject(resource, a);
+ EObject a4 = addObject(resource, a);
+
+ EObject b1 = addObject(resource, b);
+ EObject b2 = addObject(resource, b);
+ EObject b3 = addObject(resource, b);
+ EObject b4 = addObject(resource, b);
+
+ ((EList<EObject>)a1.eGet(ab5)).add(b1);
+ ((EList<EObject>)a1.eGet(ab5)).add(b2);
+ ((EList<EObject>)a1.eGet(ab5)).add(b3);
+ ((EList<EObject>)a1.eGet(ab5)).add(b4);
+
+ ((EList<EObject>)a1.eGet(ab6)).add(b1);
+ ((EList<EObject>)a1.eGet(ab6)).add(b2);
+ ((EList<EObject>)a1.eGet(ab6)).add(b3);
+ ((EList<EObject>)a1.eGet(ab6)).add(b4);
+
+ transaction.commit();
+
+ /******************/
+
+ List<CDOObjectReference> results = transaction.queryXRefs(CDOUtil.getCDOObject(b1));
+ assertEquals(2, results.size());
+
+ assertEquals(0, results.get(0).getSourceIndex());
+ assertEquals(ab5, results.get(0).getSourceFeature());
+ assertEquals(a1, results.get(0).getSourceObject());
+ assertEquals(b1, results.get(0).getTargetObject());
+
+ assertEquals(0, results.get(1).getSourceIndex());
+ assertEquals(ab6, results.get(1).getSourceFeature());
+ assertEquals(a1, results.get(1).getSourceObject());
+ assertEquals(b1, results.get(1).getTargetObject());
+ }
+
+ @SuppressWarnings({ "unchecked", "unused" })
+ public void testSpecificReferences1() throws Exception
+ {
+ EClass a = EcoreFactory.eINSTANCE.createEClass();
+ a.setName("A");
+
+ EClass b = EcoreFactory.eINSTANCE.createEClass();
+ b.setName("B");
+
+ EReference aa1 = addReference(a, a, true);
+ EReference aa2 = addReference(a, a, true);
+ EReference aa3 = addReference(a, a, false);
+ EReference aa4 = addReference(a, a, false);
+ EReference ab5 = addReference(a, b, true);
+ EReference ab6 = addReference(a, b, true);
+ EReference ab7 = addReference(a, b, false);
+ EReference ab8 = addReference(a, b, false);
+
+ EReference ba1 = addReference(b, a, true);
+ EReference ba2 = addReference(b, a, true);
+ EReference ba3 = addReference(b, a, false);
+ EReference ba4 = addReference(b, a, false);
+ EReference bb5 = addReference(b, b, true);
+ EReference bb6 = addReference(b, b, true);
+ EReference bb7 = addReference(b, b, false);
+ EReference bb8 = addReference(b, b, false);
+
+ EPackage xref = EcoreFactory.eINSTANCE.createEPackage();
+ xref.setName("xref");
+ xref.setNsPrefix("xref");
+ xref.setNsURI("http://xref");
+ xref.getEClassifiers().add(a);
+ xref.getEClassifiers().add(b);
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(xref);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ EObject a1 = addObject(resource, a);
+ EObject a2 = addObject(resource, a);
+ EObject a3 = addObject(resource, a);
+ EObject a4 = addObject(resource, a);
+
+ EObject b1 = addObject(resource, b);
+ EObject b2 = addObject(resource, b);
+ EObject b3 = addObject(resource, b);
+ EObject b4 = addObject(resource, b);
+
+ ((EList<EObject>)a1.eGet(ab5)).add(b1);
+ ((EList<EObject>)a1.eGet(ab5)).add(b2);
+ ((EList<EObject>)a1.eGet(ab5)).add(b3);
+ ((EList<EObject>)a1.eGet(ab5)).add(b4);
+
+ ((EList<EObject>)a1.eGet(ab6)).add(b1);
+ ((EList<EObject>)a1.eGet(ab6)).add(b2);
+ ((EList<EObject>)a1.eGet(ab6)).add(b3);
+ ((EList<EObject>)a1.eGet(ab6)).add(b4);
+
+ transaction.commit();
+
+ /******************/
+
+ List<CDOObjectReference> results = transaction.queryXRefs(CDOUtil.getCDOObject(b1), ab5);
+ assertEquals(1, results.size());
+
+ assertEquals(0, results.get(0).getSourceIndex());
+ assertEquals(ab5, results.get(0).getSourceFeature());
+ assertEquals(a1, results.get(0).getSourceObject());
+ assertEquals(b1, results.get(0).getTargetObject());
+ }
+
+ @SuppressWarnings({ "unchecked", "unused" })
+ public void testSpecificReferences2() throws Exception
+ {
+ EClass a = EcoreFactory.eINSTANCE.createEClass();
+ a.setName("A");
+
+ EClass b = EcoreFactory.eINSTANCE.createEClass();
+ b.setName("B");
+
+ EReference aa1 = addReference(a, a, true);
+ EReference aa2 = addReference(a, a, true);
+ EReference aa3 = addReference(a, a, false);
+ EReference aa4 = addReference(a, a, false);
+ EReference ab5 = addReference(a, b, true);
+ EReference ab6 = addReference(a, b, true);
+ EReference ab7 = addReference(a, b, false);
+ EReference ab8 = addReference(a, b, false);
+
+ EReference ba1 = addReference(b, a, true);
+ EReference ba2 = addReference(b, a, true);
+ EReference ba3 = addReference(b, a, false);
+ EReference ba4 = addReference(b, a, false);
+ EReference bb5 = addReference(b, b, true);
+ EReference bb6 = addReference(b, b, true);
+ EReference bb7 = addReference(b, b, false);
+ EReference bb8 = addReference(b, b, false);
+
+ EPackage xref = EcoreFactory.eINSTANCE.createEPackage();
+ xref.setName("xref");
+ xref.setNsPrefix("xref");
+ xref.setNsURI("http://xref");
+ xref.getEClassifiers().add(a);
+ xref.getEClassifiers().add(b);
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(xref);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ EObject a1 = addObject(resource, a);
+ EObject a2 = addObject(resource, a);
+ EObject a3 = addObject(resource, a);
+ EObject a4 = addObject(resource, a);
+
+ EObject b1 = addObject(resource, b);
+ EObject b2 = addObject(resource, b);
+ EObject b3 = addObject(resource, b);
+ EObject b4 = addObject(resource, b);
+
+ ((EList<EObject>)a1.eGet(ab5)).add(b1);
+ ((EList<EObject>)a1.eGet(ab5)).add(b2);
+ ((EList<EObject>)a1.eGet(ab5)).add(b3);
+ ((EList<EObject>)a1.eGet(ab5)).add(b4);
+
+ ((EList<EObject>)a1.eGet(ab6)).add(b1);
+ ((EList<EObject>)a1.eGet(ab6)).add(b2);
+ ((EList<EObject>)a1.eGet(ab6)).add(b3);
+ ((EList<EObject>)a1.eGet(ab6)).add(b4);
+
+ transaction.commit();
+
+ /******************/
+
+ List<CDOObjectReference> results = transaction.queryXRefs(CDOUtil.getCDOObject(b1), ab6);
+ assertEquals(1, results.size());
+
+ assertEquals(0, results.get(0).getSourceIndex());
+ assertEquals(ab6, results.get(0).getSourceFeature());
+ assertEquals(a1, results.get(0).getSourceObject());
+ assertEquals(b1, results.get(0).getTargetObject());
+ }
+
+ private EObject addObject(CDOResource resource, EClass eClass)
+ {
+ EObject b8 = EcoreUtil.create(eClass);
+ resource.getContents().add(b8);
+ return b8;
+ }
+
+ private EReference addReference(EClass source, EClass target, boolean many)
+ {
+ EReference reference = EcoreFactory.eINSTANCE.createEReference();
+ EList<EStructuralFeature> features = source.getEStructuralFeatures();
+ features.add(reference);
+
+ reference.setName(target.getName().toLowerCase() + features.size());
+ reference.setEType(target);
+ reference.setUpperBound(many ? -1 : 1);
+ return reference;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/_FetchRuleAnalyzerTest_DISABLED_.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/_FetchRuleAnalyzerTest_DISABLED_.java
index 401be6055c..70e5148654 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/_FetchRuleAnalyzerTest_DISABLED_.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/_FetchRuleAnalyzerTest_DISABLED_.java
@@ -1,127 +1,127 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.util.CDOFetchRule;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.internal.cdo.analyzer.CDOFeatureAnalyzerModelBased;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * See bug 202063
- *
- * @author Simon McDuff
- */
-public class _FetchRuleAnalyzerTest_DISABLED_ extends AbstractCDOTest
-{
- public void testLoadObject() throws Exception
- {
- ArrayList<CDOObject> listOfCompany = new ArrayList<CDOObject>();
-
- {
- // disableConsole();
- msg("Opening session");
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test2"));
-
- msg("Creating supplier");
- for (int i = 0; i < 10; i++)
- {
- Company company = getModel1Factory().createCompany();
- company.setCity("CITY" + String.valueOf(i));
-
- for (int j = 0; j < 10; j++)
- {
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- company.getPurchaseOrders().add(purchaseOrder);
-
- Supplier supplier = getModel1Factory().createSupplier();
-
- // Should it detect supplier to make it persistent...
-
- resource.getContents().add(supplier);
- purchaseOrder.setSupplier(supplier);
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- company.getSalesOrders().add(salesOrder);
- }
-
- resource.getContents().add(company);
- listOfCompany.add(CDOUtil.getCDOObject(company));
- }
-
- transaction.commit();
- // session.close();
- enableConsole();
- }
-
- msg("Opening session");
- getTestProperties().put(SessionConfig.PROP_TEST_FETCH_RULE_MANAGER, CDOUtil.createThreadLocalFetchRuleManager());
- CDOSession session = openSession();
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
- transaction.options().setFeatureAnalyzer(CDOUtil.createModelBasedFeatureAnalyzer());
- transaction.options().setRevisionPrefetchingPolicy(CDOUtil.createRevisionPrefetchingPolicy(10));
-
- msg("Getting resource");
- for (CDOObject companyObject : listOfCompany)
- {
- Company company = (Company)CDOUtil.getEObject(transaction.getObject(companyObject.cdoID(), true));
- for (PurchaseOrder purchaseOrder : company.getPurchaseOrders())
- {
- purchaseOrder.getSupplier();
- }
- }
-
- // Number of fetch should be 20.
- assertEquals(20, new CDOFeatureAnalyzerModelBased().getFetchCount());
-
- List<CDOFetchRule> fetchRules = new CDOFeatureAnalyzerModelBased().getFetchRules(null);
-
- assertEquals(2, fetchRules.size());
-
- CDOFetchRule fetchRule1 = fetchRules.get(0);
- EClass eClass = fetchRule1.getEClass();
- assertEquals(getModel1Package().getCompany(), eClass);
- assertEquals(1, fetchRule1.getFeatures().size());
- assertEquals(getModel1Package().getCompany_PurchaseOrders().getName(), fetchRule1.getFeatures().get(0).getName());
-
- CDOFetchRule fetchRule2 = fetchRules.get(1);
- EClass ePurchaseOrder = fetchRule2.getEClass();
- assertEquals(getModel1Package().getPurchaseOrder(), ePurchaseOrder);
- assertEquals(1, fetchRule2.getFeatures().size());
- assertEquals(getModel1Package().getPurchaseOrder_Supplier().getName(), fetchRule2.getFeatures().get(0).getName());
-
- transaction.close();
- // TODO session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.util.CDOFetchRule;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.internal.cdo.analyzer.CDOFeatureAnalyzerModelBased;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * See bug 202063
+ *
+ * @author Simon McDuff
+ */
+public class _FetchRuleAnalyzerTest_DISABLED_ extends AbstractCDOTest
+{
+ public void testLoadObject() throws Exception
+ {
+ ArrayList<CDOObject> listOfCompany = new ArrayList<CDOObject>();
+
+ {
+ // disableConsole();
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test2"));
+
+ msg("Creating supplier");
+ for (int i = 0; i < 10; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setCity("CITY" + String.valueOf(i));
+
+ for (int j = 0; j < 10; j++)
+ {
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ company.getPurchaseOrders().add(purchaseOrder);
+
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ // Should it detect supplier to make it persistent...
+
+ resource.getContents().add(supplier);
+ purchaseOrder.setSupplier(supplier);
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ company.getSalesOrders().add(salesOrder);
+ }
+
+ resource.getContents().add(company);
+ listOfCompany.add(CDOUtil.getCDOObject(company));
+ }
+
+ transaction.commit();
+ // session.close();
+ enableConsole();
+ }
+
+ msg("Opening session");
+ getTestProperties().put(SessionConfig.PROP_TEST_FETCH_RULE_MANAGER, CDOUtil.createThreadLocalFetchRuleManager());
+ CDOSession session = openSession();
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+ transaction.options().setFeatureAnalyzer(CDOUtil.createModelBasedFeatureAnalyzer());
+ transaction.options().setRevisionPrefetchingPolicy(CDOUtil.createRevisionPrefetchingPolicy(10));
+
+ msg("Getting resource");
+ for (CDOObject companyObject : listOfCompany)
+ {
+ Company company = (Company)CDOUtil.getEObject(transaction.getObject(companyObject.cdoID(), true));
+ for (PurchaseOrder purchaseOrder : company.getPurchaseOrders())
+ {
+ purchaseOrder.getSupplier();
+ }
+ }
+
+ // Number of fetch should be 20.
+ assertEquals(20, new CDOFeatureAnalyzerModelBased().getFetchCount());
+
+ List<CDOFetchRule> fetchRules = new CDOFeatureAnalyzerModelBased().getFetchRules(null);
+
+ assertEquals(2, fetchRules.size());
+
+ CDOFetchRule fetchRule1 = fetchRules.get(0);
+ EClass eClass = fetchRule1.getEClass();
+ assertEquals(getModel1Package().getCompany(), eClass);
+ assertEquals(1, fetchRule1.getFeatures().size());
+ assertEquals(getModel1Package().getCompany_PurchaseOrders().getName(), fetchRule1.getFeatures().get(0).getName());
+
+ CDOFetchRule fetchRule2 = fetchRules.get(1);
+ EClass ePurchaseOrder = fetchRule2.getEClass();
+ assertEquals(getModel1Package().getPurchaseOrder(), ePurchaseOrder);
+ assertEquals(1, fetchRule2.getFeatures().size());
+ assertEquals(getModel1Package().getPurchaseOrder_Supplier().getName(), fetchRule2.getFeatures().get(0).getName());
+
+ transaction.close();
+ // TODO session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java
index 4fd17949e0..d1d1f1f152 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java
@@ -1,76 +1,76 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.util.TransportException;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.util.TestRevisionManager;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import java.util.concurrent.TimeoutException;
-
-/**
- * Make timeouts in read-access requests configurable
- * <p>
- * See bug 241464
- *
- * @author Eike Stepper
- */
-public class Bugzilla_241464_Test extends AbstractCDOTest
-{
- public void testBugzilla_241464() throws Exception
- {
- {
- CDOSession session = openSession();
- if (!(session instanceof org.eclipse.emf.cdo.net4j.CDONet4jSession))
- {
- return;
- }
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
- resource.getContents().add(customer);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- TestRevisionManager revisionManager = (TestRevisionManager)getRepository().getRevisionManager();
- revisionManager.setGetRevisionsDelay(10000L); // Make the protocol time out
- ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol().setTimeout(2000L);
-
- try
- {
- Customer customer = (Customer)resource.getContents().get(0);
- System.out.println(customer.getName());
- fail("TransportException expected");
- }
- catch (TransportException expected)
- {
- assertInstanceOf(TimeoutException.class, expected.getCause());
- // SUCCESS
- }
- finally
- {
- revisionManager.setGetRevisionsDelay(0L); // Terminate repo
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.util.TransportException;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.util.TestRevisionManager;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Make timeouts in read-access requests configurable
+ * <p>
+ * See bug 241464
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_241464_Test extends AbstractCDOTest
+{
+ public void testBugzilla_241464() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ if (!(session instanceof org.eclipse.emf.cdo.net4j.CDONet4jSession))
+ {
+ return;
+ }
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+ resource.getContents().add(customer);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ TestRevisionManager revisionManager = (TestRevisionManager)getRepository().getRevisionManager();
+ revisionManager.setGetRevisionsDelay(10000L); // Make the protocol time out
+ ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol().setTimeout(2000L);
+
+ try
+ {
+ Customer customer = (Customer)resource.getContents().get(0);
+ System.out.println(customer.getName());
+ fail("TransportException expected");
+ }
+ catch (TransportException expected)
+ {
+ assertInstanceOf(TimeoutException.class, expected.getCause());
+ // SUCCESS
+ }
+ finally
+ {
+ revisionManager.setGetRevisionsDelay(0L); // Terminate repo
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_243310_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_243310_Test.java
index 074be2023c..e96a74de30 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_243310_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_243310_Test.java
@@ -1,48 +1,48 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * NPE during Transaction.getObject(id, false)
- * <p>
- * See bug 243310
- *
- * @author Eike Stepper
- */
-public class Bugzilla_243310_Test extends AbstractCDOTest
-{
- public void testBugzilla_243310() throws Exception
- {
- CDOSession session = openSession();
-
- CDOTransaction transaction1 = session.openTransaction();
- CDOResource res = transaction1.createResource(getResourcePath("/test1"));
- Company companyTx1 = getModel1Factory().createCompany();
- companyTx1.setName("Company ABC");
- res.getContents().add(companyTx1);
- transaction1.commit();
-
- boolean loadOnDemand = false;
-
- CDOTransaction transaction2 = session.openTransaction();
- CDOID id = CDOUtil.getCDOObject(companyTx1).cdoID();
- Company companyTx2 = (Company)transaction2.getObject(id, loadOnDemand);
- assertNull(companyTx2);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * NPE during Transaction.getObject(id, false)
+ * <p>
+ * See bug 243310
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_243310_Test extends AbstractCDOTest
+{
+ public void testBugzilla_243310() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ CDOResource res = transaction1.createResource(getResourcePath("/test1"));
+ Company companyTx1 = getModel1Factory().createCompany();
+ companyTx1.setName("Company ABC");
+ res.getContents().add(companyTx1);
+ transaction1.commit();
+
+ boolean loadOnDemand = false;
+
+ CDOTransaction transaction2 = session.openTransaction();
+ CDOID id = CDOUtil.getCDOObject(companyTx1).cdoID();
+ Company companyTx2 = (Company)transaction2.getObject(id, loadOnDemand);
+ assertNull(companyTx2);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java
index 364c02a9a1..8ad4e32ae0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java
@@ -1,155 +1,155 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * ArrayIndexOutOfBoundsException when importing resources.
- * <p>
- * See bug 246442
- *
- * @author Simon McDuff
- */
-public class Bugzilla_246442_Test extends AbstractCDOTest
-{
- public void testBugzilla_246442() throws Exception
- {
- CDOID lookupObject = null;
-
- {
- EPackage topPackage = createDynamicEPackage();
-
- EPackage subpackage1 = topPackage.getESubpackages().get(0);
- EClass class1Class = (EClass)subpackage1.getEClassifier("class1");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(topPackage);
-
- CDOTransaction transaction = session.openTransaction();
- CDOObject instance = CDOUtil.getCDOObject(EcoreUtil.create(class1Class));
-
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(instance);
- transaction.commit();
-
- lookupObject = instance.cdoID();
- session.close();
- }
-
- CDOSession session = openSession();
- if (session instanceof org.eclipse.emf.cdo.net4j.CDONet4jSession)
- {
- ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol().setTimeout(2000L);
- }
-
- CDOTransaction transaction = session.openTransaction();
- transaction.getObject(lookupObject);
- }
-
- // public void testBugzilla_246442_lookupEClass() throws Exception
- // {
- // EPackage topPackage = createDynamicEPackage();
- // EPackage subpackage1 = topPackage.getESubpackages().get(0);
- // EClass class1Class = (EClass)subpackage1.getEClassifier("class1");
- // EClass class2Class = (EClass)subpackage1.getEClassifier("class2");
- // EClass class3Class = (EClass)subpackage1.getEClassifier("class3");
- //
- // CDOSession session = openSession();
- // session.getPackageRegistry().putEPackage(topPackage);
- //
- // EClass eClass1 = ModelUtil.getEClass(class1Class,
- // (_CDOSessionPackageManagerImpl)session.getPackageUnitManager());
- // EClass eClass2 = ModelUtil.getEClass(class2Class,
- // (_CDOSessionPackageManagerImpl)session.getPackageUnitManager());
- // EClass eClass3 = ModelUtil.getEClass(class3Class,
- // (_CDOSessionPackageManagerImpl)session.getPackageUnitManager());
- //
- // assertEquals(class1Class.getName(), eClass1.getName());
- // assertEquals(class2Class.getName(), eClass2.getName());
- // assertEquals(class3Class.getName(), eClass3.getName());
- // }
-
- private EPackage createDynamicEPackage()
- {
- final EcoreFactory efactory = EcoreFactory.eINSTANCE;
- final EcorePackage epackage = EcorePackage.eINSTANCE;
-
- // Create a new EPackage and add the new EClasses
- EPackage topPackage = efactory.createEPackage();
- topPackage.setName("toppackage");
- topPackage.setNsPrefix("toppackage");
- topPackage.setNsURI("http:///www.elver.org/toppackage");
-
- EPackage subPackage1 = efactory.createEPackage();
- subPackage1.setName("subPackage1");
- subPackage1.setNsPrefix("subPackage1");
- subPackage1.setNsURI("http:///www.elver.org/subPackage1");
-
- {
- EClass schoolBookEClass = efactory.createEClass();
- schoolBookEClass.setName("class1");
- // create a new attribute for this EClass
- EAttribute level = efactory.createEAttribute();
- level.setName("level");
- level.setEType(epackage.getEInt());
- schoolBookEClass.getEStructuralFeatures().add(level);
- subPackage1.getEClassifiers().add(schoolBookEClass);
- }
-
- {
- EEnum schoolBookEClass = efactory.createEEnum();
- schoolBookEClass.setName("enum");
- subPackage1.getEClassifiers().add(schoolBookEClass);
- }
-
- {
- EClass schoolBookEClass = efactory.createEClass();
- schoolBookEClass.setName("class2");
- // create a new attribute for this EClass
- subPackage1.getEClassifiers().add(schoolBookEClass);
- }
-
- {
- EClass schoolBookEClass = efactory.createEClass();
- schoolBookEClass.setName("class3");
- // create a new attribute for this EClass
- EAttribute level = efactory.createEAttribute();
- level.setName("level");
- level.setEType(epackage.getEInt());
- schoolBookEClass.getEStructuralFeatures().add(level);
- subPackage1.getEClassifiers().add(schoolBookEClass);
- }
-
- EPackage subPackage2 = efactory.createEPackage();
- subPackage2.setName("subPackage2");
- subPackage2.setNsPrefix("subPackage2");
- subPackage2.setNsURI("http:///www.elver.org/subPackage2");
-
- topPackage.getESubpackages().add(subPackage1);
- return topPackage;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * ArrayIndexOutOfBoundsException when importing resources.
+ * <p>
+ * See bug 246442
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_246442_Test extends AbstractCDOTest
+{
+ public void testBugzilla_246442() throws Exception
+ {
+ CDOID lookupObject = null;
+
+ {
+ EPackage topPackage = createDynamicEPackage();
+
+ EPackage subpackage1 = topPackage.getESubpackages().get(0);
+ EClass class1Class = (EClass)subpackage1.getEClassifier("class1");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(topPackage);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOObject instance = CDOUtil.getCDOObject(EcoreUtil.create(class1Class));
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(instance);
+ transaction.commit();
+
+ lookupObject = instance.cdoID();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ if (session instanceof org.eclipse.emf.cdo.net4j.CDONet4jSession)
+ {
+ ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol().setTimeout(2000L);
+ }
+
+ CDOTransaction transaction = session.openTransaction();
+ transaction.getObject(lookupObject);
+ }
+
+ // public void testBugzilla_246442_lookupEClass() throws Exception
+ // {
+ // EPackage topPackage = createDynamicEPackage();
+ // EPackage subpackage1 = topPackage.getESubpackages().get(0);
+ // EClass class1Class = (EClass)subpackage1.getEClassifier("class1");
+ // EClass class2Class = (EClass)subpackage1.getEClassifier("class2");
+ // EClass class3Class = (EClass)subpackage1.getEClassifier("class3");
+ //
+ // CDOSession session = openSession();
+ // session.getPackageRegistry().putEPackage(topPackage);
+ //
+ // EClass eClass1 = ModelUtil.getEClass(class1Class,
+ // (_CDOSessionPackageManagerImpl)session.getPackageUnitManager());
+ // EClass eClass2 = ModelUtil.getEClass(class2Class,
+ // (_CDOSessionPackageManagerImpl)session.getPackageUnitManager());
+ // EClass eClass3 = ModelUtil.getEClass(class3Class,
+ // (_CDOSessionPackageManagerImpl)session.getPackageUnitManager());
+ //
+ // assertEquals(class1Class.getName(), eClass1.getName());
+ // assertEquals(class2Class.getName(), eClass2.getName());
+ // assertEquals(class3Class.getName(), eClass3.getName());
+ // }
+
+ private EPackage createDynamicEPackage()
+ {
+ final EcoreFactory efactory = EcoreFactory.eINSTANCE;
+ final EcorePackage epackage = EcorePackage.eINSTANCE;
+
+ // Create a new EPackage and add the new EClasses
+ EPackage topPackage = efactory.createEPackage();
+ topPackage.setName("toppackage");
+ topPackage.setNsPrefix("toppackage");
+ topPackage.setNsURI("http:///www.elver.org/toppackage");
+
+ EPackage subPackage1 = efactory.createEPackage();
+ subPackage1.setName("subPackage1");
+ subPackage1.setNsPrefix("subPackage1");
+ subPackage1.setNsURI("http:///www.elver.org/subPackage1");
+
+ {
+ EClass schoolBookEClass = efactory.createEClass();
+ schoolBookEClass.setName("class1");
+ // create a new attribute for this EClass
+ EAttribute level = efactory.createEAttribute();
+ level.setName("level");
+ level.setEType(epackage.getEInt());
+ schoolBookEClass.getEStructuralFeatures().add(level);
+ subPackage1.getEClassifiers().add(schoolBookEClass);
+ }
+
+ {
+ EEnum schoolBookEClass = efactory.createEEnum();
+ schoolBookEClass.setName("enum");
+ subPackage1.getEClassifiers().add(schoolBookEClass);
+ }
+
+ {
+ EClass schoolBookEClass = efactory.createEClass();
+ schoolBookEClass.setName("class2");
+ // create a new attribute for this EClass
+ subPackage1.getEClassifiers().add(schoolBookEClass);
+ }
+
+ {
+ EClass schoolBookEClass = efactory.createEClass();
+ schoolBookEClass.setName("class3");
+ // create a new attribute for this EClass
+ EAttribute level = efactory.createEAttribute();
+ level.setName("level");
+ level.setEType(epackage.getEInt());
+ schoolBookEClass.getEStructuralFeatures().add(level);
+ subPackage1.getEClassifiers().add(schoolBookEClass);
+ }
+
+ EPackage subPackage2 = efactory.createEPackage();
+ subPackage2.setName("subPackage2");
+ subPackage2.setNsPrefix("subPackage2");
+ subPackage2.setNsURI("http:///www.elver.org/subPackage2");
+
+ topPackage.getESubpackages().add(subPackage1);
+ return topPackage;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246622_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246622_Test.java
index 1e51d401d2..63a232d249 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246622_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246622_Test.java
@@ -1,144 +1,144 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * 246622: CDOStore.set doesn't affect variable correctly - Could cause memory retention
- * <p>
- * See bug 243310
- *
- * @author Simon McDuff
- */
-public class Bugzilla_246622_Test extends AbstractCDOTest
-{
- public void testContainerAndMany() throws Exception
- {
- CDOSession session = openSession();
-
- CDOTransaction transaction1 = session.openTransaction();
- CDOResource res = transaction1.createResource(getResourcePath("/test1"));
- Order order = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
-
- res.getContents().add(order);
- order.getOrderDetails().add(orderDetail);
- EStructuralFeature order_OrderDetailFeature = getModel1Package().getOrder_OrderDetails();
- assertEquals(orderDetail, CDOUtil.getCDOObject(order).cdoRevision().data().get(order_OrderDetailFeature, 0));
-
- assertEquals(CDOUtil.getCDOObject(order), CDOUtil.getCDOObject(orderDetail).cdoRevision().data().getContainerID());
-
- Order order2 = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
-
- order2.getOrderDetails().add(orderDetail2);
- res.getContents().add(order2);
-
- assertEquals(orderDetail2, CDOUtil.getCDOObject(order2).cdoRevision().data().get(order_OrderDetailFeature, 0));
- assertEquals(order2, CDOUtil.getCDOObject(orderDetail2).cdoRevision().data().getContainerID());
-
- msg("Committing");
- transaction1.commit();
-
- assertEquals(CDOUtil.getCDOObject(orderDetail).cdoID(),
- CDOUtil.getCDOObject(order).cdoRevision().data().get(order_OrderDetailFeature, 0));
- assertEquals(CDOUtil.getCDOObject(orderDetail2).cdoID(),
- CDOUtil.getCDOObject(order2).cdoRevision().data().get(order_OrderDetailFeature, 0));
-
- assertEquals(CDOUtil.getCDOObject(order).cdoID(), CDOUtil.getCDOObject(orderDetail).cdoRevision().data()
- .getContainerID());
- assertEquals(CDOUtil.getCDOObject(order2).cdoID(), CDOUtil.getCDOObject(orderDetail2).cdoRevision().data()
- .getContainerID());
-
- Order order3 = getModel1Factory().createPurchaseOrder();
-
- res.getContents().add(order3);
- order3.getOrderDetails().add(orderDetail2);
-
- assertEquals(CDOUtil.getCDOObject(orderDetail2).cdoID(),
- CDOUtil.getCDOObject(order3).cdoRevision().data().get(order_OrderDetailFeature, 0));
- assertEquals(CDOUtil.getCDOObject(order3), CDOUtil.getCDOObject(orderDetail2).cdoRevision().data().getContainerID());
-
- msg("Committing");
- transaction1.commit();
- }
-
- public void testSet() throws Exception
- {
- CDOSession session = openSession();
-
- CDOTransaction transaction1 = session.openTransaction();
- CDOResource res = transaction1.createResource(getResourcePath("/test1"));
-
- msg("Test set with link before");
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- Supplier supplier = getModel1Factory().createSupplier();
-
- purchaseOrder.setSupplier(supplier);
-
- res.getContents().add(purchaseOrder);
- res.getContents().add(supplier);
-
- EStructuralFeature supplier_PurchaseOrder = getModel1Package().getSupplier_PurchaseOrders();
- EStructuralFeature purchaseOrder_Supplier = getModel1Package().getPurchaseOrder_Supplier();
-
- assertEquals(supplier, CDOUtil.getCDOObject(purchaseOrder).cdoRevision().data().get(purchaseOrder_Supplier, 0));
- assertEquals(purchaseOrder, CDOUtil.getCDOObject(supplier).cdoRevision().data().get(supplier_PurchaseOrder, 0));
-
- msg("Test set with link after");
- PurchaseOrder purchaseOrder2 = getModel1Factory().createPurchaseOrder();
- Supplier supplier2 = getModel1Factory().createSupplier();
-
- res.getContents().add(purchaseOrder2);
- res.getContents().add(supplier2);
- purchaseOrder2.setSupplier(supplier2);
-
- assertEquals(supplier2, CDOUtil.getCDOObject(purchaseOrder2).cdoRevision().data().get(purchaseOrder_Supplier, 0));
- assertEquals(purchaseOrder2, CDOUtil.getCDOObject(supplier2).cdoRevision().data().get(supplier_PurchaseOrder, 0));
-
- msg("Committing");
- transaction1.commit();
-
- assertEquals(CDOUtil.getCDOObject(supplier2).cdoID(), CDOUtil.getCDOObject(purchaseOrder2).cdoRevision().data()
- .get(purchaseOrder_Supplier, 0));
- assertEquals(CDOUtil.getCDOObject(purchaseOrder2).cdoID(), CDOUtil.getCDOObject(supplier2).cdoRevision().data()
- .get(supplier_PurchaseOrder, 0));
-
- assertEquals(CDOUtil.getCDOObject(supplier).cdoID(),
- CDOUtil.getCDOObject(purchaseOrder).cdoRevision().data().get(purchaseOrder_Supplier, 0));
- assertEquals(CDOUtil.getCDOObject(purchaseOrder).cdoID(),
- CDOUtil.getCDOObject(supplier).cdoRevision().data().get(supplier_PurchaseOrder, 0));
-
- msg("Test set with persisted CDOID");
- PurchaseOrder purchaseOrder3 = getModel1Factory().createPurchaseOrder();
- purchaseOrder3.setSupplier(supplier2);
- res.getContents().add(purchaseOrder3);
-
- assertEquals(CDOUtil.getCDOObject(supplier2).cdoID(), CDOUtil.getCDOObject(purchaseOrder3).cdoRevision().data()
- .get(purchaseOrder_Supplier, 0));
- assertEquals(purchaseOrder3, CDOUtil.getCDOObject(supplier2).cdoRevision().data().get(supplier_PurchaseOrder, 1));
-
- msg("Committing");
- transaction1.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * 246622: CDOStore.set doesn't affect variable correctly - Could cause memory retention
+ * <p>
+ * See bug 243310
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_246622_Test extends AbstractCDOTest
+{
+ public void testContainerAndMany() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ CDOResource res = transaction1.createResource(getResourcePath("/test1"));
+ Order order = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+
+ res.getContents().add(order);
+ order.getOrderDetails().add(orderDetail);
+ EStructuralFeature order_OrderDetailFeature = getModel1Package().getOrder_OrderDetails();
+ assertEquals(orderDetail, CDOUtil.getCDOObject(order).cdoRevision().data().get(order_OrderDetailFeature, 0));
+
+ assertEquals(CDOUtil.getCDOObject(order), CDOUtil.getCDOObject(orderDetail).cdoRevision().data().getContainerID());
+
+ Order order2 = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
+
+ order2.getOrderDetails().add(orderDetail2);
+ res.getContents().add(order2);
+
+ assertEquals(orderDetail2, CDOUtil.getCDOObject(order2).cdoRevision().data().get(order_OrderDetailFeature, 0));
+ assertEquals(order2, CDOUtil.getCDOObject(orderDetail2).cdoRevision().data().getContainerID());
+
+ msg("Committing");
+ transaction1.commit();
+
+ assertEquals(CDOUtil.getCDOObject(orderDetail).cdoID(),
+ CDOUtil.getCDOObject(order).cdoRevision().data().get(order_OrderDetailFeature, 0));
+ assertEquals(CDOUtil.getCDOObject(orderDetail2).cdoID(),
+ CDOUtil.getCDOObject(order2).cdoRevision().data().get(order_OrderDetailFeature, 0));
+
+ assertEquals(CDOUtil.getCDOObject(order).cdoID(), CDOUtil.getCDOObject(orderDetail).cdoRevision().data()
+ .getContainerID());
+ assertEquals(CDOUtil.getCDOObject(order2).cdoID(), CDOUtil.getCDOObject(orderDetail2).cdoRevision().data()
+ .getContainerID());
+
+ Order order3 = getModel1Factory().createPurchaseOrder();
+
+ res.getContents().add(order3);
+ order3.getOrderDetails().add(orderDetail2);
+
+ assertEquals(CDOUtil.getCDOObject(orderDetail2).cdoID(),
+ CDOUtil.getCDOObject(order3).cdoRevision().data().get(order_OrderDetailFeature, 0));
+ assertEquals(CDOUtil.getCDOObject(order3), CDOUtil.getCDOObject(orderDetail2).cdoRevision().data().getContainerID());
+
+ msg("Committing");
+ transaction1.commit();
+ }
+
+ public void testSet() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ CDOResource res = transaction1.createResource(getResourcePath("/test1"));
+
+ msg("Test set with link before");
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ Supplier supplier = getModel1Factory().createSupplier();
+
+ purchaseOrder.setSupplier(supplier);
+
+ res.getContents().add(purchaseOrder);
+ res.getContents().add(supplier);
+
+ EStructuralFeature supplier_PurchaseOrder = getModel1Package().getSupplier_PurchaseOrders();
+ EStructuralFeature purchaseOrder_Supplier = getModel1Package().getPurchaseOrder_Supplier();
+
+ assertEquals(supplier, CDOUtil.getCDOObject(purchaseOrder).cdoRevision().data().get(purchaseOrder_Supplier, 0));
+ assertEquals(purchaseOrder, CDOUtil.getCDOObject(supplier).cdoRevision().data().get(supplier_PurchaseOrder, 0));
+
+ msg("Test set with link after");
+ PurchaseOrder purchaseOrder2 = getModel1Factory().createPurchaseOrder();
+ Supplier supplier2 = getModel1Factory().createSupplier();
+
+ res.getContents().add(purchaseOrder2);
+ res.getContents().add(supplier2);
+ purchaseOrder2.setSupplier(supplier2);
+
+ assertEquals(supplier2, CDOUtil.getCDOObject(purchaseOrder2).cdoRevision().data().get(purchaseOrder_Supplier, 0));
+ assertEquals(purchaseOrder2, CDOUtil.getCDOObject(supplier2).cdoRevision().data().get(supplier_PurchaseOrder, 0));
+
+ msg("Committing");
+ transaction1.commit();
+
+ assertEquals(CDOUtil.getCDOObject(supplier2).cdoID(), CDOUtil.getCDOObject(purchaseOrder2).cdoRevision().data()
+ .get(purchaseOrder_Supplier, 0));
+ assertEquals(CDOUtil.getCDOObject(purchaseOrder2).cdoID(), CDOUtil.getCDOObject(supplier2).cdoRevision().data()
+ .get(supplier_PurchaseOrder, 0));
+
+ assertEquals(CDOUtil.getCDOObject(supplier).cdoID(),
+ CDOUtil.getCDOObject(purchaseOrder).cdoRevision().data().get(purchaseOrder_Supplier, 0));
+ assertEquals(CDOUtil.getCDOObject(purchaseOrder).cdoID(),
+ CDOUtil.getCDOObject(supplier).cdoRevision().data().get(supplier_PurchaseOrder, 0));
+
+ msg("Test set with persisted CDOID");
+ PurchaseOrder purchaseOrder3 = getModel1Factory().createPurchaseOrder();
+ purchaseOrder3.setSupplier(supplier2);
+ res.getContents().add(purchaseOrder3);
+
+ assertEquals(CDOUtil.getCDOObject(supplier2).cdoID(), CDOUtil.getCDOObject(purchaseOrder3).cdoRevision().data()
+ .get(purchaseOrder_Supplier, 0));
+ assertEquals(purchaseOrder3, CDOUtil.getCDOObject(supplier2).cdoRevision().data().get(supplier_PurchaseOrder, 1));
+
+ msg("Committing");
+ transaction1.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_247141_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_247141_Test.java
index 94cb317972..37df3a375d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_247141_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_247141_Test.java
@@ -1,143 +1,143 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOLazyContentAdapter;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.ecore.util.EContentAdapter;
-
-/**
- * Create a lazy self-attaching adapter for CDOObject
- * <p>
- * See bug 247141
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_247141_Test extends AbstractCDOTest
-{
- public void testContentAdapterBehaviour() throws Exception
- {
- CDOID id1 = null;
- CDOID id2 = null;
- CDOID id3 = null;
- CDOID id4 = null;
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
-
- Customer customer1 = getModel1Factory().createCustomer();
- Customer customer2 = getModel1Factory().createCustomer();
- resource1.getContents().add(customer1);
- resource1.getContents().add(customer2);
-
- CDOResource resource2 = transaction.createResource(getResourcePath("/test2"));
-
- Customer customer3 = getModel1Factory().createCustomer();
- Customer customer4 = getModel1Factory().createCustomer();
- resource2.getContents().add(customer3);
- resource2.getContents().add(customer4);
-
- transaction.commit();
-
- id1 = CDOUtil.getCDOObject(customer1).cdoID();
- id2 = CDOUtil.getCDOObject(customer2).cdoID();
- id3 = CDOUtil.getCDOObject(customer3).cdoID();
- id4 = CDOUtil.getCDOObject(customer4).cdoID();
-
- transaction.close();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.getResource(getResourcePath("/test1"));
- EContentAdapter adapter = new CDOLazyContentAdapter();
- resource1.eAdapters().add(adapter);
-
- CDOView view = resource1.cdoView();
- CDOObject object1 = view.getObject(id1);
- CDOObject object2 = view.getObject(id2);
-
- // resource1 and all its loaded contents should have been adapted
- assertEquals(true, resource1.eAdapters().contains(adapter));
- assertEquals(true, object1.eAdapters().contains(adapter));
- assertEquals(true, object2.eAdapters().contains(adapter));
-
- // res2 should NOT be adapted, as its not in the content tree of res1
- CDOResource resource2 = transaction.getResource(getResourcePath("/test2"));
- // neither should its children
- CDOObject object3 = view.getObject(id3);
- CDOObject object4 = view.getObject(id4);
-
- assertEquals(false, resource2.eAdapters().contains(adapter));
- assertEquals(false, object3.eAdapters().contains(adapter));
- assertEquals(false, object4.eAdapters().contains(adapter));
-
- // Removing adapter
- adapter.unsetTarget(resource1);
-
- assertEquals(false, object1.eAdapters().contains(adapter));
- assertEquals(false, object2.eAdapters().contains(adapter));
- assertEquals(false, resource1.eAdapters().contains(adapter));
- }
-
- public void testBehaviourOnUncommittedObjects() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
-
- Customer customer1 = getModel1Factory().createCustomer();
- Customer customer2 = getModel1Factory().createCustomer();
- resource1.getContents().add(customer1);
- resource1.getContents().add(customer2);
-
- transaction.commit();
-
- EContentAdapter adapter = new CDOLazyContentAdapter();
- resource1.eAdapters().add(adapter);
-
- // resource1 and all its loaded contents should have been adapted
- assertEquals(true, resource1.eAdapters().contains(adapter));
- assertEquals(true, customer1.eAdapters().contains(adapter));
- assertEquals(true, customer2.eAdapters().contains(adapter));
-
- // Object in "new" state
- Customer customer3 = getModel1Factory().createCustomer();
- Customer customer4 = getModel1Factory().createCustomer();
- resource1.getContents().add(customer3);
- resource1.getContents().add(customer4);
-
- // should have been adapted, too
- assertEquals(true, customer3.eAdapters().contains(adapter));
- assertEquals(true, customer4.eAdapters().contains(adapter));
-
- // Removing adapter
- adapter.unsetTarget(resource1);
-
- // adapters should have been removed
- assertEquals(false, resource1.eAdapters().contains(adapter));
- assertEquals(false, customer1.eAdapters().contains(adapter));
- assertEquals(false, customer2.eAdapters().contains(adapter));
- assertEquals(false, customer3.eAdapters().contains(adapter));
- assertEquals(false, customer4.eAdapters().contains(adapter));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOLazyContentAdapter;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.util.EContentAdapter;
+
+/**
+ * Create a lazy self-attaching adapter for CDOObject
+ * <p>
+ * See bug 247141
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_247141_Test extends AbstractCDOTest
+{
+ public void testContentAdapterBehaviour() throws Exception
+ {
+ CDOID id1 = null;
+ CDOID id2 = null;
+ CDOID id3 = null;
+ CDOID id4 = null;
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+
+ Customer customer1 = getModel1Factory().createCustomer();
+ Customer customer2 = getModel1Factory().createCustomer();
+ resource1.getContents().add(customer1);
+ resource1.getContents().add(customer2);
+
+ CDOResource resource2 = transaction.createResource(getResourcePath("/test2"));
+
+ Customer customer3 = getModel1Factory().createCustomer();
+ Customer customer4 = getModel1Factory().createCustomer();
+ resource2.getContents().add(customer3);
+ resource2.getContents().add(customer4);
+
+ transaction.commit();
+
+ id1 = CDOUtil.getCDOObject(customer1).cdoID();
+ id2 = CDOUtil.getCDOObject(customer2).cdoID();
+ id3 = CDOUtil.getCDOObject(customer3).cdoID();
+ id4 = CDOUtil.getCDOObject(customer4).cdoID();
+
+ transaction.close();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.getResource(getResourcePath("/test1"));
+ EContentAdapter adapter = new CDOLazyContentAdapter();
+ resource1.eAdapters().add(adapter);
+
+ CDOView view = resource1.cdoView();
+ CDOObject object1 = view.getObject(id1);
+ CDOObject object2 = view.getObject(id2);
+
+ // resource1 and all its loaded contents should have been adapted
+ assertEquals(true, resource1.eAdapters().contains(adapter));
+ assertEquals(true, object1.eAdapters().contains(adapter));
+ assertEquals(true, object2.eAdapters().contains(adapter));
+
+ // res2 should NOT be adapted, as its not in the content tree of res1
+ CDOResource resource2 = transaction.getResource(getResourcePath("/test2"));
+ // neither should its children
+ CDOObject object3 = view.getObject(id3);
+ CDOObject object4 = view.getObject(id4);
+
+ assertEquals(false, resource2.eAdapters().contains(adapter));
+ assertEquals(false, object3.eAdapters().contains(adapter));
+ assertEquals(false, object4.eAdapters().contains(adapter));
+
+ // Removing adapter
+ adapter.unsetTarget(resource1);
+
+ assertEquals(false, object1.eAdapters().contains(adapter));
+ assertEquals(false, object2.eAdapters().contains(adapter));
+ assertEquals(false, resource1.eAdapters().contains(adapter));
+ }
+
+ public void testBehaviourOnUncommittedObjects() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+
+ Customer customer1 = getModel1Factory().createCustomer();
+ Customer customer2 = getModel1Factory().createCustomer();
+ resource1.getContents().add(customer1);
+ resource1.getContents().add(customer2);
+
+ transaction.commit();
+
+ EContentAdapter adapter = new CDOLazyContentAdapter();
+ resource1.eAdapters().add(adapter);
+
+ // resource1 and all its loaded contents should have been adapted
+ assertEquals(true, resource1.eAdapters().contains(adapter));
+ assertEquals(true, customer1.eAdapters().contains(adapter));
+ assertEquals(true, customer2.eAdapters().contains(adapter));
+
+ // Object in "new" state
+ Customer customer3 = getModel1Factory().createCustomer();
+ Customer customer4 = getModel1Factory().createCustomer();
+ resource1.getContents().add(customer3);
+ resource1.getContents().add(customer4);
+
+ // should have been adapted, too
+ assertEquals(true, customer3.eAdapters().contains(adapter));
+ assertEquals(true, customer4.eAdapters().contains(adapter));
+
+ // Removing adapter
+ adapter.unsetTarget(resource1);
+
+ // adapters should have been removed
+ assertEquals(false, resource1.eAdapters().contains(adapter));
+ assertEquals(false, customer1.eAdapters().contains(adapter));
+ assertEquals(false, customer2.eAdapters().contains(adapter));
+ assertEquals(false, customer3.eAdapters().contains(adapter));
+ assertEquals(false, customer4.eAdapters().contains(adapter));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248052_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248052_Test.java
index 2d5189eedd..28cacd2534 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248052_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248052_Test.java
@@ -1,54 +1,54 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.bundle.OM;
-
-import java.util.Map;
-
-/**
- * 248052: CDO: UnsupportedOperationException in HibernateStoreAccessor
- * <p>
- * See bug 248052
- *
- * @author Simon McDuff
- */
-public class Bugzilla_248052_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> testProperties = super.getTestProperties();
- testProperties.put(IRepository.Props.SUPPORTING_AUDITS, "false");
- return testProperties;
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- try
- {
- super.doSetUp();
- }
- catch (IllegalStateException ex)
- {
- OM.LOG.info("Expected IllegalStateException", ex);
- }
- }
-
- public void testNoSupportingDeltas() throws Exception
- {
- // Possible failure already in doSetup()
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.bundle.OM;
+
+import java.util.Map;
+
+/**
+ * 248052: CDO: UnsupportedOperationException in HibernateStoreAccessor
+ * <p>
+ * See bug 248052
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_248052_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> testProperties = super.getTestProperties();
+ testProperties.put(IRepository.Props.SUPPORTING_AUDITS, "false");
+ return testProperties;
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ try
+ {
+ super.doSetUp();
+ }
+ catch (IllegalStateException ex)
+ {
+ OM.LOG.info("Expected IllegalStateException", ex);
+ }
+ }
+
+ public void testNoSupportingDeltas() throws Exception
+ {
+ // Possible failure already in doSetup()
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248124_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248124_Test.java
index 4ca0dba90b..39833fc0de 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248124_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248124_Test.java
@@ -1,123 +1,123 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- * Simon McDuff - maintenance
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-/**
- * CDOView.hasResource() is not aware of deleted resources
- * <p>
- * See bug 248117
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_248124_Test extends AbstractCDOTest
-{
- public void testBugzilla_248124_hasResourceWithCommit() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
-
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
- res.delete(null);
- transaction1.commit();
- CDOView view = session.openView();
- assertEquals(false, view.hasResource(getResourcePath(resourcePath)));
- }
-
- public void testBugzilla_248124_getResourceWithCommit() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
-
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
- res.delete(null);
- transaction1.commit();
- CDOView view = session.openView();
-
- try
- {
- view.getResourceSet().getResource(CDOURIUtil.createResourceURI(view, getResourcePath(resourcePath)), true);
- fail("Exception expected");
- }
- catch (Exception expected)
- {
- }
-
- CDOView transaction2 = session.openTransaction();
-
- try
- {
- transaction2.getResourceSet()
- .getResource(CDOURIUtil.createResourceURI(view, getResourcePath(resourcePath)), true);
- fail("RuntimeException expected");
- }
- catch (RuntimeException expected)
- {
- }
- }
-
- public void testBugzilla_248124_hasResourceWithoutCommit() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
-
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
-
- res.delete(null);
- assertEquals(false, transaction1.hasResource(getResourcePath(resourcePath)));
- }
-
- public void testBugzilla_248124_getResourceWithoutCommit() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
-
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
- res.delete(null);
-
- try
- {
- transaction1.getResourceSet().getResource(
- CDOURIUtil.createResourceURI(transaction1, getResourcePath(resourcePath)), true);
- fail("RuntimeException expected");
- }
- catch (RuntimeException expected)
- {
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ * Simon McDuff - maintenance
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * CDOView.hasResource() is not aware of deleted resources
+ * <p>
+ * See bug 248117
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_248124_Test extends AbstractCDOTest
+{
+ public void testBugzilla_248124_hasResourceWithCommit() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+ res.delete(null);
+ transaction1.commit();
+ CDOView view = session.openView();
+ assertEquals(false, view.hasResource(getResourcePath(resourcePath)));
+ }
+
+ public void testBugzilla_248124_getResourceWithCommit() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+ res.delete(null);
+ transaction1.commit();
+ CDOView view = session.openView();
+
+ try
+ {
+ view.getResourceSet().getResource(CDOURIUtil.createResourceURI(view, getResourcePath(resourcePath)), true);
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ }
+
+ CDOView transaction2 = session.openTransaction();
+
+ try
+ {
+ transaction2.getResourceSet()
+ .getResource(CDOURIUtil.createResourceURI(view, getResourcePath(resourcePath)), true);
+ fail("RuntimeException expected");
+ }
+ catch (RuntimeException expected)
+ {
+ }
+ }
+
+ public void testBugzilla_248124_hasResourceWithoutCommit() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+
+ res.delete(null);
+ assertEquals(false, transaction1.hasResource(getResourcePath(resourcePath)));
+ }
+
+ public void testBugzilla_248124_getResourceWithoutCommit() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+ res.delete(null);
+
+ try
+ {
+ transaction1.getResourceSet().getResource(
+ CDOURIUtil.createResourceURI(transaction1, getResourcePath(resourcePath)), true);
+ fail("RuntimeException expected");
+ }
+ catch (RuntimeException expected)
+ {
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248915_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248915_Test.java
index 45e5547ec5..ced70b9b2f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248915_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248915_Test.java
@@ -1,130 +1,130 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Paul Richardson - initial API and implementation
- * Simon McDuff - maintenance
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * Resources fetched using CDOViewImpl.getResource(getResourcePath(CDOID)) not added to ResourceSet
- * <p>
- * See bug 248915
- *
- * @author Paul Richardson
- */
-public class Bugzilla_248915_Test extends AbstractCDOTest
-{
- public void testBugzilla_248915_IncompleteResource() throws Exception
- {
- /* 1) Open first session ready to populate the CDO Server with the data */
- CDOSession session1 = openSession();
- /* 2) Open first transaction ready to populate the CDO server with the data */
- CDOTransaction transaction1 = session1.openTransaction();
-
- /*
- * Session has been established so 3) create the Supplier resource and 4) create the Purchase Order resource.
- */
- CDOResource supplierResource = transaction1.createResource(getResourcePath("/supplierResource"));
- CDOResource poResource = transaction1.createResource(getResourcePath("/poResource"));
-
- /* Create the supplier and add it to its respective resource */
- Supplier mySupplier = getModel1Factory().createSupplier();
- supplierResource.getContents().add(mySupplier);
-
- /* Create the purchase order and add it to its respective resource */
- PurchaseOrder myPurchaseOrder = getModel1Factory().createPurchaseOrder();
- poResource.getContents().add(myPurchaseOrder);
-
- /* 5) Reference the purchase order from the supplier */
- mySupplier.getPurchaseOrders().add(myPurchaseOrder);
-
- /* 6) Commit the transaction thereby saving all the data to the CDO server */
- transaction1.commit();
-
- /* This transaction and session are now redundent and should be discarded */
- transaction1.close();
- session1.close();
- transaction1 = null;
- session1 = null;
- supplierResource = null;
- poResource = null;
- mySupplier = null;
- myPurchaseOrder = null;
-
- /* #### End first phase of persisting the data in the CDO Server #### */
-
- /* #### Start of second phase where the data is fetched from the CDO Server #### */
-
- /* 7) Open a completely new session and transaction onto the persisted data */
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
-
- /* 8) Load the supplier from transaction2, fetching it into transaction2's empty resourceSet */
- CDOResource supplierResource2 = transaction2.getResource(getResourcePath("/supplierResource"));
- Supplier savedSupplier = (Supplier)supplierResource2.getContents().get(0);
-
- if (!isConfig(LEGACY))
- {
- /* Confirm the presence of supplierResource2 in transaction2's resourceSet */
- assertEquals(1, transaction2.getResourceSet().getResources().size());
- }
- else
- {// legacy mode loads the whole tree. So there will be 3 resources
- assertEquals(2, transaction2.getResourceSet().getResources().size());
- }
-
- for (PurchaseOrder po : savedSupplier.getPurchaseOrders())
- {
- /* I believe that the Purchase Order's resource will be set but that its URI is null */
- assertEquals(true, po.eResource().getURI() != null);
- }
-
- /*
- * I believe that only supplierResource2 is in transaction2's resourceSet still despite finding the Purchase Order
- * and its resource.
- */
- assertEquals(2, transaction2.getResourceSet().getResources().size());
-
- transaction2.close();
- session2.close();
- transaction2 = null;
- session2 = null;
- }
-
- public void testBugzilla_248915_DuplicateID() throws Exception
- {
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
-
- CDOResource supplierResource = transaction1.createResource(getResourcePath("/supplierResource"));
-
- transaction1.commit();
- CDOID resID = CDOUtil.getCDOObject(supplierResource).cdoID();
- transaction1.close();
- session1.close();
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- CDOResource resource = (CDOResource)transaction2.getObject(resID);
- CDOResource resource1 = transaction2.getResource(getResourcePath("/supplierResource"));
- assertSame(resource, resource1);
- transaction2.close();
- session2.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Paul Richardson - initial API and implementation
+ * Simon McDuff - maintenance
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * Resources fetched using CDOViewImpl.getResource(getResourcePath(CDOID)) not added to ResourceSet
+ * <p>
+ * See bug 248915
+ *
+ * @author Paul Richardson
+ */
+public class Bugzilla_248915_Test extends AbstractCDOTest
+{
+ public void testBugzilla_248915_IncompleteResource() throws Exception
+ {
+ /* 1) Open first session ready to populate the CDO Server with the data */
+ CDOSession session1 = openSession();
+ /* 2) Open first transaction ready to populate the CDO server with the data */
+ CDOTransaction transaction1 = session1.openTransaction();
+
+ /*
+ * Session has been established so 3) create the Supplier resource and 4) create the Purchase Order resource.
+ */
+ CDOResource supplierResource = transaction1.createResource(getResourcePath("/supplierResource"));
+ CDOResource poResource = transaction1.createResource(getResourcePath("/poResource"));
+
+ /* Create the supplier and add it to its respective resource */
+ Supplier mySupplier = getModel1Factory().createSupplier();
+ supplierResource.getContents().add(mySupplier);
+
+ /* Create the purchase order and add it to its respective resource */
+ PurchaseOrder myPurchaseOrder = getModel1Factory().createPurchaseOrder();
+ poResource.getContents().add(myPurchaseOrder);
+
+ /* 5) Reference the purchase order from the supplier */
+ mySupplier.getPurchaseOrders().add(myPurchaseOrder);
+
+ /* 6) Commit the transaction thereby saving all the data to the CDO server */
+ transaction1.commit();
+
+ /* This transaction and session are now redundent and should be discarded */
+ transaction1.close();
+ session1.close();
+ transaction1 = null;
+ session1 = null;
+ supplierResource = null;
+ poResource = null;
+ mySupplier = null;
+ myPurchaseOrder = null;
+
+ /* #### End first phase of persisting the data in the CDO Server #### */
+
+ /* #### Start of second phase where the data is fetched from the CDO Server #### */
+
+ /* 7) Open a completely new session and transaction onto the persisted data */
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+
+ /* 8) Load the supplier from transaction2, fetching it into transaction2's empty resourceSet */
+ CDOResource supplierResource2 = transaction2.getResource(getResourcePath("/supplierResource"));
+ Supplier savedSupplier = (Supplier)supplierResource2.getContents().get(0);
+
+ if (!isConfig(LEGACY))
+ {
+ /* Confirm the presence of supplierResource2 in transaction2's resourceSet */
+ assertEquals(1, transaction2.getResourceSet().getResources().size());
+ }
+ else
+ {// legacy mode loads the whole tree. So there will be 3 resources
+ assertEquals(2, transaction2.getResourceSet().getResources().size());
+ }
+
+ for (PurchaseOrder po : savedSupplier.getPurchaseOrders())
+ {
+ /* I believe that the Purchase Order's resource will be set but that its URI is null */
+ assertEquals(true, po.eResource().getURI() != null);
+ }
+
+ /*
+ * I believe that only supplierResource2 is in transaction2's resourceSet still despite finding the Purchase Order
+ * and its resource.
+ */
+ assertEquals(2, transaction2.getResourceSet().getResources().size());
+
+ transaction2.close();
+ session2.close();
+ transaction2 = null;
+ session2 = null;
+ }
+
+ public void testBugzilla_248915_DuplicateID() throws Exception
+ {
+ CDOSession session1 = openSession();
+ CDOTransaction transaction1 = session1.openTransaction();
+
+ CDOResource supplierResource = transaction1.createResource(getResourcePath("/supplierResource"));
+
+ transaction1.commit();
+ CDOID resID = CDOUtil.getCDOObject(supplierResource).cdoID();
+ transaction1.close();
+ session1.close();
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource resource = (CDOResource)transaction2.getObject(resID);
+ CDOResource resource1 = transaction2.getResource(getResourcePath("/supplierResource"));
+ assertSame(resource, resource1);
+ transaction2.close();
+ session2.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java
index 21a614a5b5..a8aad09326 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java
@@ -1,116 +1,116 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.GenRefMapNonContained;
-import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.util.EMap;
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * See bug 250036
- *
- * @author Simon McDuff
- */
-public class Bugzilla_250036_Test extends AbstractCDOTest
-{
- public void testBugzilla_250036_Invalidation() throws Exception
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- session.getPackageRegistry().putEPackage(getModel4Package());
-
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("test1"));
- CDOResource resource2 = transaction.createResource(getResourcePath("test2"));
-
- GenRefMapNonContained elementA = getModel4Factory().createGenRefMapNonContained();
- resource1.getContents().add(elementA);
- List<EObject> expectedValue = new ArrayList<EObject>();
- for (int i = 0; i < 10; i++)
- {
- GenRefSingleContained value = getModel4Factory().createGenRefSingleContained();
- elementA.getElements().put(String.valueOf(i), value);
- resource2.getContents().add(value);
- expectedValue.add(value);
- }
-
- transaction.commit();
-
- /********* transaction 2 ***************/
- CDOTransaction transaction2 = session.openTransaction();
- CDOResource resource1FromTx2 = transaction2.getResource(resource1.getPath());
-
- GenRefMapNonContained genRefMap = (GenRefMapNonContained)resource1FromTx2.getContents().get(0);
- assertClean(genRefMap, transaction2);
- assertEquals(10, genRefMap.getElements().size());
- EMap<String, EObject> mapOfEObject = genRefMap.getElements();
- for (int i = 0; i < 10; i++)
- {
- EObject object = mapOfEObject.get(String.valueOf(i));
- assertNotNull(object);
- assertEquals(CDOUtil.getCDOObject(expectedValue.get(i)).cdoID(), CDOUtil.getCDOObject(object).cdoID());
- }
-
- final TestAdapter adapter = new TestAdapter();
- genRefMap.eAdapters().add(adapter);
- transaction2.options().setInvalidationNotificationEnabled(true);
-
- /********* transaction 1 ***************/
- final int counter[] = { 0 };
- for (int i = 10; i < 20; i++)
- {
- GenRefSingleContained value = getModel4Factory().createGenRefSingleContained();
- elementA.getElements().put(String.valueOf(i), value);
- resource2.getContents().add(value);
- expectedValue.add(value);
- ++counter[0];
- }
-
- transaction.commit();
-
- msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // 10 delta notifications from local commit (same session) plus 1 invalidation notification
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1 + counter[0];
- }
- }.assertNoTimeOut();
-
- /********* transaction 2 ***************/
- EMap<String, EObject> mapOfEObjectAfterCommit = genRefMap.getElements();
- assertSame(mapOfEObject, mapOfEObjectAfterCommit);
- assertEquals(20, mapOfEObjectAfterCommit.size());
- for (int i = 0; i < 20; i++)
- {
- EObject object = mapOfEObject.get(String.valueOf(i));
- assertNotNull(object);
- assertEquals(CDOUtil.getCDOObject(expectedValue.get(i)).cdoID(), CDOUtil.getCDOObject(object).cdoID());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.GenRefMapNonContained;
+import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * See bug 250036
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_250036_Test extends AbstractCDOTest
+{
+ public void testBugzilla_250036_Invalidation() throws Exception
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ session.getPackageRegistry().putEPackage(getModel4Package());
+
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("test1"));
+ CDOResource resource2 = transaction.createResource(getResourcePath("test2"));
+
+ GenRefMapNonContained elementA = getModel4Factory().createGenRefMapNonContained();
+ resource1.getContents().add(elementA);
+ List<EObject> expectedValue = new ArrayList<EObject>();
+ for (int i = 0; i < 10; i++)
+ {
+ GenRefSingleContained value = getModel4Factory().createGenRefSingleContained();
+ elementA.getElements().put(String.valueOf(i), value);
+ resource2.getContents().add(value);
+ expectedValue.add(value);
+ }
+
+ transaction.commit();
+
+ /********* transaction 2 ***************/
+ CDOTransaction transaction2 = session.openTransaction();
+ CDOResource resource1FromTx2 = transaction2.getResource(resource1.getPath());
+
+ GenRefMapNonContained genRefMap = (GenRefMapNonContained)resource1FromTx2.getContents().get(0);
+ assertClean(genRefMap, transaction2);
+ assertEquals(10, genRefMap.getElements().size());
+ EMap<String, EObject> mapOfEObject = genRefMap.getElements();
+ for (int i = 0; i < 10; i++)
+ {
+ EObject object = mapOfEObject.get(String.valueOf(i));
+ assertNotNull(object);
+ assertEquals(CDOUtil.getCDOObject(expectedValue.get(i)).cdoID(), CDOUtil.getCDOObject(object).cdoID());
+ }
+
+ final TestAdapter adapter = new TestAdapter();
+ genRefMap.eAdapters().add(adapter);
+ transaction2.options().setInvalidationNotificationEnabled(true);
+
+ /********* transaction 1 ***************/
+ final int counter[] = { 0 };
+ for (int i = 10; i < 20; i++)
+ {
+ GenRefSingleContained value = getModel4Factory().createGenRefSingleContained();
+ elementA.getElements().put(String.valueOf(i), value);
+ resource2.getContents().add(value);
+ expectedValue.add(value);
+ ++counter[0];
+ }
+
+ transaction.commit();
+
+ msg("Checking after commit");
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // 10 delta notifications from local commit (same session) plus 1 invalidation notification
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length == 1 + counter[0];
+ }
+ }.assertNoTimeOut();
+
+ /********* transaction 2 ***************/
+ EMap<String, EObject> mapOfEObjectAfterCommit = genRefMap.getElements();
+ assertSame(mapOfEObject, mapOfEObjectAfterCommit);
+ assertEquals(20, mapOfEObjectAfterCommit.size());
+ for (int i = 0; i < 20; i++)
+ {
+ EObject object = mapOfEObject.get(String.valueOf(i));
+ assertNotNull(object);
+ assertEquals(CDOUtil.getCDOObject(expectedValue.get(i)).cdoID(), CDOUtil.getCDOObject(object).cdoID());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250757_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250757_Test.java
index 8921523bb6..fdbd004ad2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250757_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250757_Test.java
@@ -1,127 +1,127 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- * Simon McDuff - maintenance
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * Persisted objects keeps references to detached objects through deltas
- * <p>
- * See bug 250757
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_250757_Test extends AbstractCDOTest
-{
- public void testAddAndRemoveFromPersistedList() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- EObject obj = getModel1Factory().createCompany();
- res.getContents().add(obj);
- res.getContents().remove(obj);
- transaction1.commit();
- }
-
- public void testAddAndModifyAndRemoveFromPersistedList() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- res.getContents().add(supplier);
- res.getContents().add(purchaseOrder);
- supplier.getPurchaseOrders().add(purchaseOrder);
- transaction1.commit();
-
- res.getContents().remove(purchaseOrder);
- supplier.getPurchaseOrders().remove(purchaseOrder);
- purchaseOrder.setSupplier(null);
- transaction1.commit();
- }
-
- public void testAddAndMoveAndRemoveFromPersistedList() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- EObject obj = getModel1Factory().createCompany();
- res.getContents().add(obj);
- res.getContents().move(1, 0);
- res.getContents().remove(obj);
- transaction1.commit();
- }
-
- public void testAddAndMoveAndRemoveFromPersistedListWithSavePoint() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- EObject obj = getModel1Factory().createCompany();
- res.getContents().add(obj);
-
- transaction1.setSavepoint();
-
- res.getContents().move(1, 0);
- res.getContents().remove(obj);
- transaction1.commit();
- }
-
- public void testAddAndMoveAndRemoveFromPersistedListWithManySavePoint() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- transaction1.setSavepoint();
-
- EObject obj = getModel1Factory().createCompany();
- res.getContents().add(obj);
- transaction1.setSavepoint();
-
- res.getContents().move(1, 0);
- transaction1.setSavepoint();
-
- res.getContents().remove(obj);
- transaction1.setSavepoint();
- transaction1.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ * Simon McDuff - maintenance
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * Persisted objects keeps references to detached objects through deltas
+ * <p>
+ * See bug 250757
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_250757_Test extends AbstractCDOTest
+{
+ public void testAddAndRemoveFromPersistedList() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ EObject obj = getModel1Factory().createCompany();
+ res.getContents().add(obj);
+ res.getContents().remove(obj);
+ transaction1.commit();
+ }
+
+ public void testAddAndModifyAndRemoveFromPersistedList() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ res.getContents().add(supplier);
+ res.getContents().add(purchaseOrder);
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ transaction1.commit();
+
+ res.getContents().remove(purchaseOrder);
+ supplier.getPurchaseOrders().remove(purchaseOrder);
+ purchaseOrder.setSupplier(null);
+ transaction1.commit();
+ }
+
+ public void testAddAndMoveAndRemoveFromPersistedList() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ EObject obj = getModel1Factory().createCompany();
+ res.getContents().add(obj);
+ res.getContents().move(1, 0);
+ res.getContents().remove(obj);
+ transaction1.commit();
+ }
+
+ public void testAddAndMoveAndRemoveFromPersistedListWithSavePoint() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ EObject obj = getModel1Factory().createCompany();
+ res.getContents().add(obj);
+
+ transaction1.setSavepoint();
+
+ res.getContents().move(1, 0);
+ res.getContents().remove(obj);
+ transaction1.commit();
+ }
+
+ public void testAddAndMoveAndRemoveFromPersistedListWithManySavePoint() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ transaction1.setSavepoint();
+
+ EObject obj = getModel1Factory().createCompany();
+ res.getContents().add(obj);
+ transaction1.setSavepoint();
+
+ res.getContents().move(1, 0);
+ transaction1.setSavepoint();
+
+ res.getContents().remove(obj);
+ transaction1.setSavepoint();
+ transaction1.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250910_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250910_Test.java
index b7ecff283f..5e55b64f57 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250910_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250910_Test.java
@@ -1,67 +1,67 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * 250910: IllegalArgumentException: created > revised
- * <p>
- * See bug 250910
- *
- * @author Simon McDuff
- */
-public class Bugzilla_250910_Test extends AbstractCDOTest
-{
- public void testBugzilla_250910() throws Exception
- {
- CDOSession session = openSession();
-
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- Company company = getModel1Factory().createCompany();
-
- res.getContents().add(company);
- transaction1.commit();
-
- CDOID id = CDOUtil.getCDOObject(company).cdoID();
-
- for (int i = 0; i < 20; i++)
- {
- TestAdapter testAdapter = new TestAdapter();
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- company.setName(String.valueOf(i));
-
- Company company2;
- synchronized (transaction2)
- {
- transaction1.commit();
-
- transaction2.options().setInvalidationNotificationEnabled(true);
- company2 = (Company)CDOUtil.getEObject(transaction2.getObject(id, true));
- company2.eAdapters().add(testAdapter);
- }
-
- assertEquals(String.valueOf(i), company2.getName());
- // Need a way to test if an error occured in the invalidation process.
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * 250910: IllegalArgumentException: created > revised
+ * <p>
+ * See bug 250910
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_250910_Test extends AbstractCDOTest
+{
+ public void testBugzilla_250910() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ Company company = getModel1Factory().createCompany();
+
+ res.getContents().add(company);
+ transaction1.commit();
+
+ CDOID id = CDOUtil.getCDOObject(company).cdoID();
+
+ for (int i = 0; i < 20; i++)
+ {
+ TestAdapter testAdapter = new TestAdapter();
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ company.setName(String.valueOf(i));
+
+ Company company2;
+ synchronized (transaction2)
+ {
+ transaction1.commit();
+
+ transaction2.options().setInvalidationNotificationEnabled(true);
+ company2 = (Company)CDOUtil.getEObject(transaction2.getObject(id, true));
+ company2.eAdapters().add(testAdapter);
+ }
+
+ assertEquals(String.valueOf(i), company2.getName());
+ // Need a way to test if an error occured in the invalidation process.
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java
index 484d443e9a..6333333a1f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java
@@ -1,99 +1,99 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- * Simon McDuff - maintenance
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-
-/**
- * NPE in ChangeSubscriptionManager.isPending() while subscribing a pending TRANSIENT-by-removal object
- * <p>
- * See bug 251087
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_251087_Test extends AbstractCDOTest
-{
- public void testSubscription() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
-
- transaction1.options().setInvalidationNotificationEnabled(true);
- transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
-
- Company obj2 = getModel1Factory().createCompany();
-
- TestAdapter testAdapter = new TestAdapter();
-
- obj2.eAdapters().add(testAdapter);
- res.getContents().add(obj2);
- transaction1.commit();
-
- res.getContents().remove(obj2);
- res.getContents().add(obj2);
- res.getContents().remove(obj2);
- transaction1.commit();
- }
-
- public void _testSubscriptionDetached() throws Exception
- {
- CDOSession sessionA = openSession();
- CDOSession sessionB = openSession();
- CDOTransaction transaction1 = sessionA.openTransaction();
-
- transaction1.options().setInvalidationNotificationEnabled(true);
- transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- Company obj2 = getModel1Factory().createCompany();
- res.getContents().add(obj2);
- transaction1.commit();
-
- CDOTransaction transB1 = sessionB.openTransaction();
- CDOID companyID = CDOUtil.getCDOObject(obj2).cdoID();
- Company companyB = (Company)CDOUtil.getEObject(transB1.getObject(companyID));
- transB1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- final TestAdapter testAdapter = new TestAdapter();
- companyB.eAdapters().add(testAdapter);
- assertEquals(true, ((InternalCDOTransaction)transB1).hasSubscription(companyID));
-
- res.getContents().remove(obj2);
- transaction1.commit();
-
- msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
-
- assertEquals(false, ((InternalCDOTransaction)transB1).hasSubscription(companyID));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ * Simon McDuff - maintenance
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+
+/**
+ * NPE in ChangeSubscriptionManager.isPending() while subscribing a pending TRANSIENT-by-removal object
+ * <p>
+ * See bug 251087
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_251087_Test extends AbstractCDOTest
+{
+ public void testSubscription() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+
+ transaction1.options().setInvalidationNotificationEnabled(true);
+ transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+
+ Company obj2 = getModel1Factory().createCompany();
+
+ TestAdapter testAdapter = new TestAdapter();
+
+ obj2.eAdapters().add(testAdapter);
+ res.getContents().add(obj2);
+ transaction1.commit();
+
+ res.getContents().remove(obj2);
+ res.getContents().add(obj2);
+ res.getContents().remove(obj2);
+ transaction1.commit();
+ }
+
+ public void _testSubscriptionDetached() throws Exception
+ {
+ CDOSession sessionA = openSession();
+ CDOSession sessionB = openSession();
+ CDOTransaction transaction1 = sessionA.openTransaction();
+
+ transaction1.options().setInvalidationNotificationEnabled(true);
+ transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ Company obj2 = getModel1Factory().createCompany();
+ res.getContents().add(obj2);
+ transaction1.commit();
+
+ CDOTransaction transB1 = sessionB.openTransaction();
+ CDOID companyID = CDOUtil.getCDOObject(obj2).cdoID();
+ Company companyB = (Company)CDOUtil.getEObject(transB1.getObject(companyID));
+ transB1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ final TestAdapter testAdapter = new TestAdapter();
+ companyB.eAdapters().add(testAdapter);
+ assertEquals(true, ((InternalCDOTransaction)transB1).hasSubscription(companyID));
+
+ res.getContents().remove(obj2);
+ transaction1.commit();
+
+ msg("Checking after commit");
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut();
+
+ assertEquals(false, ((InternalCDOTransaction)transB1).hasSubscription(companyID));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251263_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251263_Test.java
index 95c8c61c50..7c593909d7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251263_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251263_Test.java
@@ -1,187 +1,187 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- * Simon McDuff - maintenance
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * EOpposite reference is not removed
- * <p>
- * See bug 251263
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_251263_Test extends AbstractCDOTest
-{
- public void testEOpposite_AdjustMany() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
-
- transaction1.commit();
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- res.getContents().add(supplier);
- res.getContents().add(purchaseOrder);
- supplier.getPurchaseOrders().add(purchaseOrder);
-
- assertEquals(0, CDOUtil.getCDOObject(purchaseOrder).cdoRevision().getVersion());
- transaction1.commit();
- assertEquals(1, CDOUtil.getCDOObject(purchaseOrder).cdoRevision().getVersion());
-
- res.getContents().remove(purchaseOrder);
- Supplier supplier2 = purchaseOrder.getSupplier();
- PurchaseOrder purchaseOrder2 = supplier.getPurchaseOrders().get(0);
- assertSame(purchaseOrder2, purchaseOrder);
- assertSame(supplier2, supplier);
- assertTransient(purchaseOrder2);
-
- try
- {
- transaction1.commit();
- fail("Dangling Reference Exception expected");
- }
- catch (Exception expected)
- {
- // Success
- }
-
- assertTransient(purchaseOrder2);
-
- CDOResource resB = transaction1.createResource(getResourcePath("testB"));
- resB.getContents().add(purchaseOrder2);
-
- assertEquals(1, CDOUtil.getCDOObject(purchaseOrder2).cdoRevision().getVersion());
- transaction1.commit();
- assertEquals(2, CDOUtil.getCDOObject(purchaseOrder2).cdoRevision().getVersion());
- }
-
- public void testEOpposite_AdjustSingleRef() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- res.getContents().add(supplier);
- res.getContents().add(purchaseOrder);
- supplier.getPurchaseOrders().add(purchaseOrder);
- transaction1.commit();
-
- res.getContents().remove(supplier);
-
- Supplier supplier2 = purchaseOrder.getSupplier();
- PurchaseOrder purchaseOrder2 = supplier.getPurchaseOrders().get(0);
- assertSame(purchaseOrder2, purchaseOrder);
- assertSame(supplier2, supplier);
-
- try
- {
- transaction1.commit();
- fail("Should have dangling reference");
- }
- catch (Exception ignore)
- {
- }
-
- CDOResource resB = transaction1.createResource(getResourcePath("testB"));
- resB.getContents().add(supplier2);
- transaction1.commit();
- }
-
- public void testEOpposite_AdjustSingleRef_NoCommit() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- res.getContents().add(supplier);
- res.getContents().add(purchaseOrder);
- supplier.getPurchaseOrders().add(purchaseOrder);
- res.getContents().remove(supplier);
- Supplier supplier2 = purchaseOrder.getSupplier();
- PurchaseOrder purchaseOrder2 = supplier.getPurchaseOrders().get(0);
- assertSame(purchaseOrder2, purchaseOrder);
- assertSame(supplier2, supplier);
-
- try
- {
- transaction1.commit();
- fail("Should have dangling reference");
- }
- catch (Exception ignore)
- {
- }
-
- CDOResource resB = transaction1.createResource(getResourcePath("testB"));
- resB.getContents().add(supplier2);
- transaction1.commit();
- }
-
- public void testEOpposite_AdjustMany_Persisted() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- res.getContents().add(supplier);
- res.getContents().add(purchaseOrder);
-
- transaction1.commit();
-
- supplier.getPurchaseOrders().add(purchaseOrder);
- res.getContents().remove(purchaseOrder);
-
- Supplier supplier2 = purchaseOrder.getSupplier();
- PurchaseOrder purchaseOrder2 = supplier.getPurchaseOrders().get(0);
- assertSame(purchaseOrder2, purchaseOrder);
- assertSame(supplier2, supplier);
-
- try
- {
- transaction1.commit();
- fail("Should have dangling reference");
- }
- catch (Exception ignore)
- {
- }
-
- CDOResource resB = transaction1.createResource(getResourcePath("testB"));
- resB.getContents().add(purchaseOrder2);
- transaction1.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ * Simon McDuff - maintenance
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * EOpposite reference is not removed
+ * <p>
+ * See bug 251263
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_251263_Test extends AbstractCDOTest
+{
+ public void testEOpposite_AdjustMany() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+
+ transaction1.commit();
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ res.getContents().add(supplier);
+ res.getContents().add(purchaseOrder);
+ supplier.getPurchaseOrders().add(purchaseOrder);
+
+ assertEquals(0, CDOUtil.getCDOObject(purchaseOrder).cdoRevision().getVersion());
+ transaction1.commit();
+ assertEquals(1, CDOUtil.getCDOObject(purchaseOrder).cdoRevision().getVersion());
+
+ res.getContents().remove(purchaseOrder);
+ Supplier supplier2 = purchaseOrder.getSupplier();
+ PurchaseOrder purchaseOrder2 = supplier.getPurchaseOrders().get(0);
+ assertSame(purchaseOrder2, purchaseOrder);
+ assertSame(supplier2, supplier);
+ assertTransient(purchaseOrder2);
+
+ try
+ {
+ transaction1.commit();
+ fail("Dangling Reference Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // Success
+ }
+
+ assertTransient(purchaseOrder2);
+
+ CDOResource resB = transaction1.createResource(getResourcePath("testB"));
+ resB.getContents().add(purchaseOrder2);
+
+ assertEquals(1, CDOUtil.getCDOObject(purchaseOrder2).cdoRevision().getVersion());
+ transaction1.commit();
+ assertEquals(2, CDOUtil.getCDOObject(purchaseOrder2).cdoRevision().getVersion());
+ }
+
+ public void testEOpposite_AdjustSingleRef() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ res.getContents().add(supplier);
+ res.getContents().add(purchaseOrder);
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ transaction1.commit();
+
+ res.getContents().remove(supplier);
+
+ Supplier supplier2 = purchaseOrder.getSupplier();
+ PurchaseOrder purchaseOrder2 = supplier.getPurchaseOrders().get(0);
+ assertSame(purchaseOrder2, purchaseOrder);
+ assertSame(supplier2, supplier);
+
+ try
+ {
+ transaction1.commit();
+ fail("Should have dangling reference");
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ CDOResource resB = transaction1.createResource(getResourcePath("testB"));
+ resB.getContents().add(supplier2);
+ transaction1.commit();
+ }
+
+ public void testEOpposite_AdjustSingleRef_NoCommit() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ res.getContents().add(supplier);
+ res.getContents().add(purchaseOrder);
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ res.getContents().remove(supplier);
+ Supplier supplier2 = purchaseOrder.getSupplier();
+ PurchaseOrder purchaseOrder2 = supplier.getPurchaseOrders().get(0);
+ assertSame(purchaseOrder2, purchaseOrder);
+ assertSame(supplier2, supplier);
+
+ try
+ {
+ transaction1.commit();
+ fail("Should have dangling reference");
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ CDOResource resB = transaction1.createResource(getResourcePath("testB"));
+ resB.getContents().add(supplier2);
+ transaction1.commit();
+ }
+
+ public void testEOpposite_AdjustMany_Persisted() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ res.getContents().add(supplier);
+ res.getContents().add(purchaseOrder);
+
+ transaction1.commit();
+
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ res.getContents().remove(purchaseOrder);
+
+ Supplier supplier2 = purchaseOrder.getSupplier();
+ PurchaseOrder purchaseOrder2 = supplier.getPurchaseOrders().get(0);
+ assertSame(purchaseOrder2, purchaseOrder);
+ assertSame(supplier2, supplier);
+
+ try
+ {
+ transaction1.commit();
+ fail("Should have dangling reference");
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ CDOResource resB = transaction1.createResource(getResourcePath("testB"));
+ resB.getContents().add(purchaseOrder2);
+ transaction1.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java
index 3533cf3590..8b14874473 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java
@@ -1,80 +1,80 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * Resources fetched using CDOViewImpl.getResource(getResourcePath(CDOID)) not added to ResourceSet
- * <p>
- * See bug 251544
- *
- * @author Simon McDuff
- */
-public class Bugzilla_251544_Test extends AbstractCDOTest
-{
- public void testFromPersistedToTransient() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Order order1 = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- Product1 product = getModel1Factory().createProduct1();
- product.setName("product");
-
- EList<EObject> contentList = resource.getContents();
- resource.getContents().add(order1);
- order1.getOrderDetails().add(orderDetail);
- orderDetail.setProduct(product);
-
- EList<OrderDetail> list = order1.getOrderDetails();
- //
- resource.getContents().remove(0); // remove object by index
- list.remove(orderDetail);
- transaction.commit();
-
- resource.delete(null);
-
- assertSame(contentList, resource.getContents());
- }
-
- public void testFromTransientToPersisted() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Order order1 = getModel1Factory().createPurchaseOrder();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- EList<OrderDetail> orderDetails = order1.getOrderDetails();
- order1.getOrderDetails().add(orderDetail);
-
- msg("Persist the graph");
- resource.getContents().add(order1);
- assertSame(orderDetails, order1.getOrderDetails());
- resource.getContents().remove(0); // remove object by index
- assertSame(orderDetails, order1.getOrderDetails());
- assertEquals(true, orderDetails.remove(orderDetail));
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * Resources fetched using CDOViewImpl.getResource(getResourcePath(CDOID)) not added to ResourceSet
+ * <p>
+ * See bug 251544
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_251544_Test extends AbstractCDOTest
+{
+ public void testFromPersistedToTransient() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Order order1 = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("product");
+
+ EList<EObject> contentList = resource.getContents();
+ resource.getContents().add(order1);
+ order1.getOrderDetails().add(orderDetail);
+ orderDetail.setProduct(product);
+
+ EList<OrderDetail> list = order1.getOrderDetails();
+ //
+ resource.getContents().remove(0); // remove object by index
+ list.remove(orderDetail);
+ transaction.commit();
+
+ resource.delete(null);
+
+ assertSame(contentList, resource.getContents());
+ }
+
+ public void testFromTransientToPersisted() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Order order1 = getModel1Factory().createPurchaseOrder();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ EList<OrderDetail> orderDetails = order1.getOrderDetails();
+ order1.getOrderDetails().add(orderDetail);
+
+ msg("Persist the graph");
+ resource.getContents().add(order1);
+ assertSame(orderDetails, order1.getOrderDetails());
+ resource.getContents().remove(0); // remove object by index
+ assertSame(orderDetails, order1.getOrderDetails());
+ assertEquals(true, orderDetails.remove(orderDetail));
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251752_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251752_Test.java
index 58108805ea..548497fb90 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251752_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251752_Test.java
@@ -1,86 +1,86 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.transaction.CDOXATransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * While committing, error in CommitIndicationTransaction.indicating doesn't stop the commit process
- * <p>
- * See bug 251752
- *
- * @author Simon McDuff
- */
-public class Bugzilla_251752_Test extends AbstractCDOTest
-{
- public void testBug_251752() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- CDOResource res = transaction1.createResource(getResourcePath("/test1"));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- CDOResource res2 = transaction2.getResource(getResourcePath("/test1"));
- res.getContents().add(getModel1Factory().createCompany());
- res2.getContents().add(getModel1Factory().createCompany());
- transaction2.commit();
-
- try
- {
- transaction1.commit();
- fail("Exception expected");
- }
- catch (Exception expected)
- {
- // Success
- }
-
- assertEquals(1, res.cdoRevision().getVersion());
- }
-
- public void testBug_251752_XA() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
- xaTransaction.add(CDOUtil.getViewSet(transaction1.getResourceSet()));
-
- CDOResource res = transaction1.createResource(getResourcePath("/test1"));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- CDOResource res2 = transaction2.getResource(getResourcePath("/test1"));
- res.getContents().add(getModel1Factory().createCompany());
- res2.getContents().add(getModel1Factory().createCompany());
- transaction2.commit();
-
- try
- {
- transaction1.commit();
- fail("Exception expected");
- }
- catch (Exception expected)
- {
- // Success
- }
-
- assertEquals(1, res.cdoRevision().getVersion());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOXATransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * While committing, error in CommitIndicationTransaction.indicating doesn't stop the commit process
+ * <p>
+ * See bug 251752
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_251752_Test extends AbstractCDOTest
+{
+ public void testBug_251752() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ CDOResource res = transaction1.createResource(getResourcePath("/test1"));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ CDOResource res2 = transaction2.getResource(getResourcePath("/test1"));
+ res.getContents().add(getModel1Factory().createCompany());
+ res2.getContents().add(getModel1Factory().createCompany());
+ transaction2.commit();
+
+ try
+ {
+ transaction1.commit();
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // Success
+ }
+
+ assertEquals(1, res.cdoRevision().getVersion());
+ }
+
+ public void testBug_251752_XA() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
+ xaTransaction.add(CDOUtil.getViewSet(transaction1.getResourceSet()));
+
+ CDOResource res = transaction1.createResource(getResourcePath("/test1"));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ CDOResource res2 = transaction2.getResource(getResourcePath("/test1"));
+ res.getContents().add(getModel1Factory().createCompany());
+ res2.getContents().add(getModel1Factory().createCompany());
+ transaction2.commit();
+
+ try
+ {
+ transaction1.commit();
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // Success
+ }
+
+ assertEquals(1, res.cdoRevision().getVersion());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java
index 9df91f2551..b70a457f8d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java
@@ -1,92 +1,92 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
-
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-import java.util.Map;
-
-/**
- * NPE when calling audit.setTimeStamp()
- * <p>
- * See bug 252214
- *
- * @author Simon McDuff
- */
-public class Bugzilla_252214_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> testProperties = super.getTestProperties();
- testProperties.put(IRepository.Props.SUPPORTING_AUDITS, "true");
- return testProperties;
- }
-
- public void testBugzilla_252214() throws Exception
- {
- long commitTime1 = 0;
- long commitTime2 = 0;
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("ESC");
- resource.getContents().add(company);
- commitTime1 = transaction.commit().getTimeStamp();
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1);
- assertEquals("ESC", company.getName());
-
- company.setName("Sympedia");
- commitTime2 = transaction.commit().getTimeStamp();
- assertEquals(true, commitTime1 < commitTime2);
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
- assertEquals("Sympedia", company.getName());
- }
-
- CDOSession session = openSession();
- CDOView audit = session.openView(commitTime1);
-
- {
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- Company auditCompany = (Company)auditResource.getContents().get(0);
- CDOObject cdoAuditCompany = CDOUtil.getCDOObject(auditCompany);
- CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, null, CDOBranchPoint.UNSPECIFIED_DATE);
- }
-
- audit.setTimeStamp(commitTime2);
-
- {
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- Company auditCompany = (Company)auditResource.getContents().get(0);
- assertEquals("Sympedia", auditCompany.getName());
- }
-
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
+
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
+
+import java.util.Map;
+
+/**
+ * NPE when calling audit.setTimeStamp()
+ * <p>
+ * See bug 252214
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_252214_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> testProperties = super.getTestProperties();
+ testProperties.put(IRepository.Props.SUPPORTING_AUDITS, "true");
+ return testProperties;
+ }
+
+ public void testBugzilla_252214() throws Exception
+ {
+ long commitTime1 = 0;
+ long commitTime2 = 0;
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("ESC");
+ resource.getContents().add(company);
+ commitTime1 = transaction.commit().getTimeStamp();
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1);
+ assertEquals("ESC", company.getName());
+
+ company.setName("Sympedia");
+ commitTime2 = transaction.commit().getTimeStamp();
+ assertEquals(true, commitTime1 < commitTime2);
+ assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
+ assertEquals("Sympedia", company.getName());
+ }
+
+ CDOSession session = openSession();
+ CDOView audit = session.openView(commitTime1);
+
+ {
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ Company auditCompany = (Company)auditResource.getContents().get(0);
+ CDOObject cdoAuditCompany = CDOUtil.getCDOObject(auditCompany);
+ CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, null, CDOBranchPoint.UNSPECIFIED_DATE);
+ }
+
+ audit.setTimeStamp(commitTime2);
+
+ {
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ Company auditCompany = (Company)auditResource.getContents().get(0);
+ assertEquals("Sympedia", auditCompany.getName());
+ }
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252909_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252909_Test.java
index 03f3c889ea..4c1cfb918a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252909_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252909_Test.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * [DBStore] NPE when trying to update objects
- * <p>
- * See bug 252909
- *
- * @author Simon McDuff
- */
-public class Bugzilla_252909_Test extends AbstractCDOTest
-{
- public void testBugzilla_252909() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- for (int i = 0; i < 10; i++)
- {
- Company company = getModel1Factory().createCompany();
- company.setName("Okidoo");
- resource.getContents().add(company);
- transaction.commit();
-
- clearCache(getRepository().getRevisionManager());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * [DBStore] NPE when trying to update objects
+ * <p>
+ * See bug 252909
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_252909_Test extends AbstractCDOTest
+{
+ public void testBugzilla_252909() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ for (int i = 0; i < 10; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setName("Okidoo");
+ resource.getContents().add(company);
+ transaction.commit();
+
+ clearCache(getRepository().getRevisionManager());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java
index 2dd3d9fb95..020b5c1e7f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java
@@ -1,78 +1,78 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * CDOTransaction.postCommit not adjusting the Transaction/View reference
- * <p>
- * See bug 254489
- *
- * @author Simon McDuff
- */
-public class Bugzilla_254489_Test extends AbstractCDOTest
-{
- public void testBugzilla_254489() throws Exception
- {
- msg("Opening session");
- final CDOSession session = openSession();
-
- // ************************************************************* //
- msg("Opening transaction");
- final CDOTransaction transaction1 = session.openTransaction();
- final CDOTransaction transaction2 = session.openTransaction();
-
- CDOResource res1 = transaction1.createResource(getResourcePath("/res1"));
- final Company companyA1 = getModel1Factory().createCompany();
- res1.getContents().add(companyA1);
-
- transaction1.commit();
-
- transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- CDOResource res2 = transaction2.getResource(getResourcePath("/res1"));
- Company companyA2 = (Company)res2.getContents().get(0);
- final TestAdapter companyA2Adapter = new TestAdapter();
- companyA2.eAdapters().add(companyA2Adapter);
-
- final Category category1A = getModel1Factory().createCategory();
- category1A.setName("category1");
-
- msg("Adding categories");
- companyA1.getCategories().add(category1A);
- transaction1.commit();
-
- msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return companyA2Adapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
-
- Category category2 = (Category)CDOUtil.getEObject((EObject)companyA2Adapter.getNotifications()[0].getNewValue());
- assertNotSame(category2, category1A);
- assertSame(transaction2, CDOUtil.getCDOObject(category2).cdoView());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * CDOTransaction.postCommit not adjusting the Transaction/View reference
+ * <p>
+ * See bug 254489
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_254489_Test extends AbstractCDOTest
+{
+ public void testBugzilla_254489() throws Exception
+ {
+ msg("Opening session");
+ final CDOSession session = openSession();
+
+ // ************************************************************* //
+ msg("Opening transaction");
+ final CDOTransaction transaction1 = session.openTransaction();
+ final CDOTransaction transaction2 = session.openTransaction();
+
+ CDOResource res1 = transaction1.createResource(getResourcePath("/res1"));
+ final Company companyA1 = getModel1Factory().createCompany();
+ res1.getContents().add(companyA1);
+
+ transaction1.commit();
+
+ transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ CDOResource res2 = transaction2.getResource(getResourcePath("/res1"));
+ Company companyA2 = (Company)res2.getContents().get(0);
+ final TestAdapter companyA2Adapter = new TestAdapter();
+ companyA2.eAdapters().add(companyA2Adapter);
+
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ msg("Adding categories");
+ companyA1.getCategories().add(category1A);
+ transaction1.commit();
+
+ msg("Checking after commit");
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return companyA2Adapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut();
+
+ Category category2 = (Category)CDOUtil.getEObject((EObject)companyA2Adapter.getNotifications()[0].getNewValue());
+ assertNotSame(category2, category1A);
+ assertSame(transaction2, CDOUtil.getCDOObject(category2).cdoView());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_255662_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_255662_Test.java
index 86ac199c93..e0410ff446 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_255662_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_255662_Test.java
@@ -1,43 +1,43 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * NPE in CDOResourceImpl.save()
- * <p>
- * See bug 255662
- *
- * @author Simon McDuff
- */
-public class Bugzilla_255662_Test extends AbstractCDOTest
-{
- public void testBugzilla_255662() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- resource.getContents().add(customer);
- resource.save(null);
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * NPE in CDOResourceImpl.save()
+ * <p>
+ * See bug 255662
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_255662_Test extends AbstractCDOTest
+{
+ public void testBugzilla_255662() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ resource.getContents().add(customer);
+ resource.save(null);
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_256141_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_256141_Test.java
index 57b401b717..eeb9a8d8a9 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_256141_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_256141_Test.java
@@ -1,39 +1,39 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model3.subpackage.Class2;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * Lazy packageRegistry fail when adding instance with Eclass in a subpackage See bug 256141
- *
- * @author Simon McDuff
- */
-public class Bugzilla_256141_Test extends AbstractCDOTest
-{
- public void testBugzilla_256141() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("test1"));
-
- Class2 class2 = getModel3SubpackageFactory().createClass2();
- resource1.getContents().add(class2);
-
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model3.subpackage.Class2;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * Lazy packageRegistry fail when adding instance with Eclass in a subpackage See bug 256141
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_256141_Test extends AbstractCDOTest
+{
+ public void testBugzilla_256141() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("test1"));
+
+ Class2 class2 = getModel3SubpackageFactory().createClass2();
+ resource1.getContents().add(class2);
+
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258278_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258278_Test.java
index 3815782233..75d38ca406 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258278_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258278_Test.java
@@ -1,47 +1,47 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * : Multiple resources creation bug
- * <p>
- * See bug 258278
- *
- * @author Simon McDuff
- */
-public class Bugzilla_258278_Test extends AbstractCDOTest
-{
- public void testBugzilla_258278() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.createResource(getResourcePath("/root/folder1/resource1"));
- transaction.createResource(getResourcePath("/root/folder1/resource2"));
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.getResource(getResourcePath("/root/folder1/resource1"));
- assertNotNull(resource1);
- CDOResource resource2 = transaction.getResource(getResourcePath("/root/folder1/resource2"));
- assertNotNull(resource2);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * : Multiple resources creation bug
+ * <p>
+ * See bug 258278
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_258278_Test extends AbstractCDOTest
+{
+ public void testBugzilla_258278() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.createResource(getResourcePath("/root/folder1/resource1"));
+ transaction.createResource(getResourcePath("/root/folder1/resource2"));
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.getResource(getResourcePath("/root/folder1/resource1"));
+ assertNotNull(resource1);
+ CDOResource resource2 = transaction.getResource(getResourcePath("/root/folder1/resource2"));
+ assertNotNull(resource2);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258850_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258850_Test.java
index e00dee8c11..4835402420 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258850_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258850_Test.java
@@ -1,80 +1,80 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.options.IOptionsEvent;
-
-/**
- * 258850: Make Options extend INotifier
- * <p>
- * See bug 258850
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_258850_Test extends AbstractCDOTest
-{
- public void testBugzilla_258278() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- TestListener listener = new TestListener()
- {
- @Override
- public void notifyEvent(IEvent event)
- {
- if (event instanceof IOptionsEvent)
- {
- if (event instanceof CDOView.Options.InvalidationNotificationEvent)
- {
- setSuccess(true);
- }
- }
- }
- };
-
- listener.setSuccess(false);
- transaction.options().addListener(listener);
- transaction.options().setInvalidationNotificationEnabled(true);
-
- assertEquals(true, listener.getSucess());
-
- transaction.commit();
- session.close();
- }
- }
-
- public abstract class TestListener implements IListener
- {
- private boolean success = false;
-
- public void setSuccess(boolean success)
- {
- this.success = success;
- }
-
- public boolean getSucess()
- {
- return success;
- }
-
- public abstract void notifyEvent(IEvent event);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.options.IOptionsEvent;
+
+/**
+ * 258850: Make Options extend INotifier
+ * <p>
+ * See bug 258850
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_258850_Test extends AbstractCDOTest
+{
+ public void testBugzilla_258278() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ TestListener listener = new TestListener()
+ {
+ @Override
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof IOptionsEvent)
+ {
+ if (event instanceof CDOView.Options.InvalidationNotificationEvent)
+ {
+ setSuccess(true);
+ }
+ }
+ }
+ };
+
+ listener.setSuccess(false);
+ transaction.options().addListener(listener);
+ transaction.options().setInvalidationNotificationEnabled(true);
+
+ assertEquals(true, listener.getSucess());
+
+ transaction.commit();
+ session.close();
+ }
+ }
+
+ public abstract class TestListener implements IListener
+ {
+ private boolean success = false;
+
+ public void setSuccess(boolean success)
+ {
+ this.success = success;
+ }
+
+ public boolean getSucess()
+ {
+ return success;
+ }
+
+ public abstract void notifyEvent(IEvent event);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258933_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258933_Test.java
index 0f27580f8a..566678ad9a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258933_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_258933_Test.java
@@ -1,235 +1,235 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * CDORevisionImpl.eIsSet() works incorrectly
- * <p>
- * See bug 258933
- *
- * @author Simon McDuff
- */
-@CleanRepositoriesBefore
-public class Bugzilla_258933_Test extends AbstractCDOTest
-{
- private static final String TOP_PACKAGE_URI = "http:///www.elver.org/toppackage";
-
- private static final String SUB_PACKAGE_URI = "http:///www.elver.org/subPackage1";
-
- private static final Object NIL = new Object();
-
- public void testBugzilla_258933() throws Exception
- {
- // Do not set any value to level. Because 'level' is NOT unsettable we expect isSet==false
- testWithValue("level", NIL, false);
- }
-
- public void testBugzilla_258933_SetToDefaultValue() throws Exception
- {
- // Set level to it's default (10). Because 'level' is NOT unsettable we expect isSet==false
- testWithValue("level", new Integer(10), false);
- }
-
- public void testBugzilla_258933_String_SetToDefaultValue() throws Exception
- {
- // Set level to it's default (Simon). Because 'settable' is NOT unsettable we expect isSet==false
- testWithValue("settable", "Simon", false);
- }
-
- public void testBugzilla_258933_String_SetToNull() throws Exception
- {
- // Set level to null. Because 'settable' is NOT unsettable and null is not the default we expect isSet==true
- testWithValue("settable", null, true);
- }
-
- public void testBugzilla_258933_String_unsettable() throws Exception
- {
- // Do not set any value to settable. Because 'settable' is NOT unsettable we expect isSet==false
- testWithValue("settable", NIL, false);
- }
-
- // Set level to it's default (Simon). Because 'unsettable' is unsettable we expect isSet==true
- public void testBugzilla_258933_String_SetToDefaultValue_unsettable() throws Exception
- {
- testWithValue("unsettable", "Simon", true);
- }
-
- // Set level to null. Because 'unsettable' is unsettable we expect isSet==true
- public void testBugzilla_258933_String_SetToNull_unsettable() throws Exception
- {
- testWithValue("unsettable", null, true);
- }
-
- // Do not set any value to unsettable. Because 'unsettable' is unsettable we expect isSet==false
- public void testBugzilla_258933_String() throws Exception
- {
- testWithValue("unsettable", NIL, false);
- }
-
- private void testWithValue(String featureName, Object initializeValue, boolean isSet) throws Exception
- {
- {
- EPackage topPackage = createDynamicEPackage();
-
- EPackage subpackage1 = topPackage.getESubpackages().get(0);
- EClass class1Class = (EClass)subpackage1.getEClassifier("class1");
- EStructuralFeature feature = class1Class.getEStructuralFeature(featureName);
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(topPackage);
-
- CDOTransaction transaction = session.openTransaction();
- EObject instance = EcoreUtil.create(class1Class);
- if (initializeValue != NIL)
- {
- instance.eSet(feature, initializeValue);
- // instance.eUnset(feature);
- }
-
- assertEquals(isSet, instance.eIsSet(feature));
-
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(instance);
- assertEquals(isSet, instance.eIsSet(feature));
-
- transaction.commit();
- assertEquals(isSet, instance.eIsSet(feature));
-
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- CDOSession session = openSession();
- if (session instanceof org.eclipse.emf.cdo.net4j.CDONet4jSession)
- {
- ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol().setTimeout(2000L);
- }
-
- EPackage subpackage1 = session.getPackageRegistry().getEPackage(SUB_PACKAGE_URI);
- EClass class1Class = (EClass)subpackage1.getEClassifier("class1");
- EStructuralFeature feature = class1Class.getEStructuralFeature(featureName);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
- CDOObject instance = CDOUtil.getCDOObject(resource.getContents().get(0));
- assertEquals(isSet, instance.eIsSet(feature));
-
- resource.getContents().remove(0);
- assertEquals(isSet, instance.eIsSet(feature));
-
- if (feature.isUnsettable())
- {
- instance.eUnset(feature);
- assertEquals(false, instance.eIsSet(feature));
- }
- }
-
- public void testBugzilla_258278_List() throws Exception
- {
- {
- Order order = getModel1Factory().createPurchaseOrder();
- assertEquals(false, order.eIsSet(getModel1Package().getOrder_OrderDetails()));
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(order);
- assertEquals(false, order.eIsSet(getModel1Package().getOrder_OrderDetails()));
-
- transaction.commit();
- assertEquals(false, order.eIsSet(getModel1Package().getOrder_OrderDetails()));
-
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
- Order instance = (Order)transaction.getResource(getResourcePath("/test1")).getContents().get(0);
- assertEquals(false, instance.eIsSet(getModel1Package().getOrder_OrderDetails()));
-
- transaction.getResource(getResourcePath("/test1")).getContents().remove(0);
- assertEquals(false, instance.eIsSet(getModel1Package().getOrder_OrderDetails()));
-
- instance.getOrderDetails().add(getModel1Factory().createOrderDetail());
- }
-
- private EPackage createDynamicEPackage()
- {
- final EcoreFactory efactory = EcoreFactory.eINSTANCE;
- final EcorePackage epackage = EcorePackage.eINSTANCE;
-
- // Create a new EPackage and add the new EClasses
- EPackage topPackage = efactory.createEPackage();
- topPackage.setName("toppackage");
- topPackage.setNsPrefix("toppackage");
- topPackage.setNsURI(TOP_PACKAGE_URI);
-
- EPackage subPackage1 = efactory.createEPackage();
- subPackage1.setName("subPackage1");
- subPackage1.setNsPrefix("subPackage1");
- subPackage1.setNsURI(SUB_PACKAGE_URI);
-
- {
- EClass schoolBookEClass = efactory.createEClass();
- schoolBookEClass.setName("class1");
- // create a new attribute for this EClass
- EAttribute level = efactory.createEAttribute();
- level.setName("level");
- level.setEType(epackage.getEInt());
- level.setUnsettable(false);
- level.setDefaultValue(new Integer(10));
- schoolBookEClass.getEStructuralFeatures().add(level);
-
- EAttribute settable = efactory.createEAttribute();
- settable.setName("settable");
- settable.setEType(epackage.getEString());
- level.setUnsettable(false);
- settable.setDefaultValue(new String("Simon"));
- schoolBookEClass.getEStructuralFeatures().add(settable);
-
- EAttribute unsettable = efactory.createEAttribute();
- unsettable.setName("unsettable");
- unsettable.setEType(epackage.getEString());
- unsettable.setUnsettable(true);
- unsettable.setDefaultValue(new String("Simon"));
- schoolBookEClass.getEStructuralFeatures().add(unsettable);
-
- subPackage1.getEClassifiers().add(schoolBookEClass);
- }
-
- topPackage.getESubpackages().add(subPackage1);
- return topPackage;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * CDORevisionImpl.eIsSet() works incorrectly
+ * <p>
+ * See bug 258933
+ *
+ * @author Simon McDuff
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_258933_Test extends AbstractCDOTest
+{
+ private static final String TOP_PACKAGE_URI = "http:///www.elver.org/toppackage";
+
+ private static final String SUB_PACKAGE_URI = "http:///www.elver.org/subPackage1";
+
+ private static final Object NIL = new Object();
+
+ public void testBugzilla_258933() throws Exception
+ {
+ // Do not set any value to level. Because 'level' is NOT unsettable we expect isSet==false
+ testWithValue("level", NIL, false);
+ }
+
+ public void testBugzilla_258933_SetToDefaultValue() throws Exception
+ {
+ // Set level to it's default (10). Because 'level' is NOT unsettable we expect isSet==false
+ testWithValue("level", new Integer(10), false);
+ }
+
+ public void testBugzilla_258933_String_SetToDefaultValue() throws Exception
+ {
+ // Set level to it's default (Simon). Because 'settable' is NOT unsettable we expect isSet==false
+ testWithValue("settable", "Simon", false);
+ }
+
+ public void testBugzilla_258933_String_SetToNull() throws Exception
+ {
+ // Set level to null. Because 'settable' is NOT unsettable and null is not the default we expect isSet==true
+ testWithValue("settable", null, true);
+ }
+
+ public void testBugzilla_258933_String_unsettable() throws Exception
+ {
+ // Do not set any value to settable. Because 'settable' is NOT unsettable we expect isSet==false
+ testWithValue("settable", NIL, false);
+ }
+
+ // Set level to it's default (Simon). Because 'unsettable' is unsettable we expect isSet==true
+ public void testBugzilla_258933_String_SetToDefaultValue_unsettable() throws Exception
+ {
+ testWithValue("unsettable", "Simon", true);
+ }
+
+ // Set level to null. Because 'unsettable' is unsettable we expect isSet==true
+ public void testBugzilla_258933_String_SetToNull_unsettable() throws Exception
+ {
+ testWithValue("unsettable", null, true);
+ }
+
+ // Do not set any value to unsettable. Because 'unsettable' is unsettable we expect isSet==false
+ public void testBugzilla_258933_String() throws Exception
+ {
+ testWithValue("unsettable", NIL, false);
+ }
+
+ private void testWithValue(String featureName, Object initializeValue, boolean isSet) throws Exception
+ {
+ {
+ EPackage topPackage = createDynamicEPackage();
+
+ EPackage subpackage1 = topPackage.getESubpackages().get(0);
+ EClass class1Class = (EClass)subpackage1.getEClassifier("class1");
+ EStructuralFeature feature = class1Class.getEStructuralFeature(featureName);
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(topPackage);
+
+ CDOTransaction transaction = session.openTransaction();
+ EObject instance = EcoreUtil.create(class1Class);
+ if (initializeValue != NIL)
+ {
+ instance.eSet(feature, initializeValue);
+ // instance.eUnset(feature);
+ }
+
+ assertEquals(isSet, instance.eIsSet(feature));
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(instance);
+ assertEquals(isSet, instance.eIsSet(feature));
+
+ transaction.commit();
+ assertEquals(isSet, instance.eIsSet(feature));
+
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ CDOSession session = openSession();
+ if (session instanceof org.eclipse.emf.cdo.net4j.CDONet4jSession)
+ {
+ ((org.eclipse.emf.cdo.net4j.CDONet4jSession)session).options().getNet4jProtocol().setTimeout(2000L);
+ }
+
+ EPackage subpackage1 = session.getPackageRegistry().getEPackage(SUB_PACKAGE_URI);
+ EClass class1Class = (EClass)subpackage1.getEClassifier("class1");
+ EStructuralFeature feature = class1Class.getEStructuralFeature(featureName);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+ CDOObject instance = CDOUtil.getCDOObject(resource.getContents().get(0));
+ assertEquals(isSet, instance.eIsSet(feature));
+
+ resource.getContents().remove(0);
+ assertEquals(isSet, instance.eIsSet(feature));
+
+ if (feature.isUnsettable())
+ {
+ instance.eUnset(feature);
+ assertEquals(false, instance.eIsSet(feature));
+ }
+ }
+
+ public void testBugzilla_258278_List() throws Exception
+ {
+ {
+ Order order = getModel1Factory().createPurchaseOrder();
+ assertEquals(false, order.eIsSet(getModel1Package().getOrder_OrderDetails()));
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(order);
+ assertEquals(false, order.eIsSet(getModel1Package().getOrder_OrderDetails()));
+
+ transaction.commit();
+ assertEquals(false, order.eIsSet(getModel1Package().getOrder_OrderDetails()));
+
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ Order instance = (Order)transaction.getResource(getResourcePath("/test1")).getContents().get(0);
+ assertEquals(false, instance.eIsSet(getModel1Package().getOrder_OrderDetails()));
+
+ transaction.getResource(getResourcePath("/test1")).getContents().remove(0);
+ assertEquals(false, instance.eIsSet(getModel1Package().getOrder_OrderDetails()));
+
+ instance.getOrderDetails().add(getModel1Factory().createOrderDetail());
+ }
+
+ private EPackage createDynamicEPackage()
+ {
+ final EcoreFactory efactory = EcoreFactory.eINSTANCE;
+ final EcorePackage epackage = EcorePackage.eINSTANCE;
+
+ // Create a new EPackage and add the new EClasses
+ EPackage topPackage = efactory.createEPackage();
+ topPackage.setName("toppackage");
+ topPackage.setNsPrefix("toppackage");
+ topPackage.setNsURI(TOP_PACKAGE_URI);
+
+ EPackage subPackage1 = efactory.createEPackage();
+ subPackage1.setName("subPackage1");
+ subPackage1.setNsPrefix("subPackage1");
+ subPackage1.setNsURI(SUB_PACKAGE_URI);
+
+ {
+ EClass schoolBookEClass = efactory.createEClass();
+ schoolBookEClass.setName("class1");
+ // create a new attribute for this EClass
+ EAttribute level = efactory.createEAttribute();
+ level.setName("level");
+ level.setEType(epackage.getEInt());
+ level.setUnsettable(false);
+ level.setDefaultValue(new Integer(10));
+ schoolBookEClass.getEStructuralFeatures().add(level);
+
+ EAttribute settable = efactory.createEAttribute();
+ settable.setName("settable");
+ settable.setEType(epackage.getEString());
+ level.setUnsettable(false);
+ settable.setDefaultValue(new String("Simon"));
+ schoolBookEClass.getEStructuralFeatures().add(settable);
+
+ EAttribute unsettable = efactory.createEAttribute();
+ unsettable.setName("unsettable");
+ unsettable.setEType(epackage.getEString());
+ unsettable.setUnsettable(true);
+ unsettable.setDefaultValue(new String("Simon"));
+ schoolBookEClass.getEStructuralFeatures().add(unsettable);
+
+ subPackage1.getEClassifiers().add(schoolBookEClass);
+ }
+
+ topPackage.getESubpackages().add(subPackage1);
+ return topPackage;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259695_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259695_Test.java
index d393619977..26dab30569 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259695_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259695_Test.java
@@ -1,59 +1,59 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.GenRefMapNonContained;
-import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ClassCastException on BasicEMap.clear
- * <p>
- * See bug 259695
- *
- * @author Simon McDuff
- */
-public class Bugzilla_259695_Test extends AbstractCDOTest
-{
- public void testBugzilla_259695_ClassCast() throws Exception
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- session.getPackageRegistry().putEPackage(getModel4Package());
-
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("test1"));
-
- GenRefMapNonContained elementA = getModel4Factory().createGenRefMapNonContained();
- resource1.getContents().add(elementA);
- List<EObject> expectedValue = new ArrayList<EObject>();
- for (int i = 0; i < 10; i++)
- {
- GenRefSingleContained value = getModel4Factory().createGenRefSingleContained();
- elementA.getElements().put(String.valueOf(i), value);
- resource1.getContents().add(value);
- expectedValue.add(value);
- }
-
- elementA.getElements().clear();
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.GenRefMapNonContained;
+import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ClassCastException on BasicEMap.clear
+ * <p>
+ * See bug 259695
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_259695_Test extends AbstractCDOTest
+{
+ public void testBugzilla_259695_ClassCast() throws Exception
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ session.getPackageRegistry().putEPackage(getModel4Package());
+
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("test1"));
+
+ GenRefMapNonContained elementA = getModel4Factory().createGenRefMapNonContained();
+ resource1.getContents().add(elementA);
+ List<EObject> expectedValue = new ArrayList<EObject>();
+ for (int i = 0; i < 10; i++)
+ {
+ GenRefSingleContained value = getModel4Factory().createGenRefSingleContained();
+ elementA.getElements().put(String.valueOf(i), value);
+ resource1.getContents().add(value);
+ expectedValue.add(value);
+ }
+
+ elementA.getElements().clear();
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259949_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259949_Test.java
index 33f51d9b43..4a0fb7f896 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259949_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259949_Test.java
@@ -1,67 +1,67 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-/**
- * Make timeouts in read-access requests configurable
- * <p>
- * See bug 241464
- *
- * @author Eike Stepper
- */
-public class Bugzilla_259949_Test extends AbstractCDOTest
-{
- public void testBugzilla_259949() throws Exception
- {
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session1 = openSession();
- session1.options().setPassiveUpdateEnabled(false);
-
- CDOView view1 = session1.openView();
- CDOResource res1 = view1.getResource(getResourcePath("/test1"));
- assertEquals(1, res1.getContents().size());
- assertEquals("customer", ((Customer)res1.getContents().get(0)).getName());
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- CDOResource res2 = transaction2.getResource(getResourcePath("/test1"));
- assertEquals(1, res2.getContents().size());
- assertEquals("customer", ((Customer)res2.getContents().get(0)).getName());
- res2.getContents().clear();
- transaction2.commit();
-
- session1.refresh();
-
- assertEquals(0, res1.getContents().size());
-
- session1.close();
- session2.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * Make timeouts in read-access requests configurable
+ * <p>
+ * See bug 241464
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_259949_Test extends AbstractCDOTest
+{
+ public void testBugzilla_259949() throws Exception
+ {
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session1 = openSession();
+ session1.options().setPassiveUpdateEnabled(false);
+
+ CDOView view1 = session1.openView();
+ CDOResource res1 = view1.getResource(getResourcePath("/test1"));
+ assertEquals(1, res1.getContents().size());
+ assertEquals("customer", ((Customer)res1.getContents().get(0)).getName());
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource res2 = transaction2.getResource(getResourcePath("/test1"));
+ assertEquals(1, res2.getContents().size());
+ assertEquals("customer", ((Customer)res2.getContents().get(0)).getName());
+ res2.getContents().clear();
+ transaction2.commit();
+
+ session1.refresh();
+
+ assertEquals(0, res1.getContents().size());
+
+ session1.close();
+ session2.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260756_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260756_Test.java
index ecc453afa5..2d8a5cce71 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260756_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260756_Test.java
@@ -1,82 +1,82 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOQuery;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * CDOEList::toArray not implemented
- * <p>
- * See bug 260756
- *
- * @author Simon McDuff
- */
-public class Bugzilla_260756_Test extends AbstractCDOTest
-{
- private static final String LANGUAGE = "TEST";
-
- @Requires("MEM")
- public void testBugzilla_260756() throws Exception
- {
- Set<Object> objects = new HashSet<Object>();
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
- objects.add(resource1);
- Company company1 = getModel1Factory().createCompany();
- Category category1 = getModel1Factory().createCategory();
- Category category2 = getModel1Factory().createCategory();
-
- resource1.getContents().add(company1);
- company1.getCategories().add(category1);
- company1.getCategories().add(category2);
-
- objects.add(category1);
- objects.add(category2);
-
- company1.setName("TEST");
-
- transaction.commit();
- System.out.println(category1.eClass().getEPackage().getNsURI());
-
- CDOQuery cdoQuery = transaction.createQuery(LANGUAGE, "QUERYSTRING");
- cdoQuery.setParameter("context", getModel1Package().getCategory());
-
- List<Category> queryResult = cdoQuery.getResult(Category.class);
- assertEquals(2, queryResult.size());
- assertEquals(true, objects.contains(queryResult.get(0)));
- assertEquals(true, objects.contains(queryResult.get(1)));
-
- Object[] array1 = queryResult.toArray();
- Category[] arrayOfCategory = queryResult.toArray(new Category[queryResult.size()]);
- assertEquals(2, array1.length);
- assertEquals(queryResult.get(0), array1[0]);
- assertEquals(queryResult.get(1), array1[1]);
-
- assertEquals(2, arrayOfCategory.length);
- assertEquals(queryResult.get(0), arrayOfCategory[0]);
- assertEquals(queryResult.get(1), arrayOfCategory[1]);
-
- transaction.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOQuery;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * CDOEList::toArray not implemented
+ * <p>
+ * See bug 260756
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_260756_Test extends AbstractCDOTest
+{
+ private static final String LANGUAGE = "TEST";
+
+ @Requires("MEM")
+ public void testBugzilla_260756() throws Exception
+ {
+ Set<Object> objects = new HashSet<Object>();
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+ objects.add(resource1);
+ Company company1 = getModel1Factory().createCompany();
+ Category category1 = getModel1Factory().createCategory();
+ Category category2 = getModel1Factory().createCategory();
+
+ resource1.getContents().add(company1);
+ company1.getCategories().add(category1);
+ company1.getCategories().add(category2);
+
+ objects.add(category1);
+ objects.add(category2);
+
+ company1.setName("TEST");
+
+ transaction.commit();
+ System.out.println(category1.eClass().getEPackage().getNsURI());
+
+ CDOQuery cdoQuery = transaction.createQuery(LANGUAGE, "QUERYSTRING");
+ cdoQuery.setParameter("context", getModel1Package().getCategory());
+
+ List<Category> queryResult = cdoQuery.getResult(Category.class);
+ assertEquals(2, queryResult.size());
+ assertEquals(true, objects.contains(queryResult.get(0)));
+ assertEquals(true, objects.contains(queryResult.get(1)));
+
+ Object[] array1 = queryResult.toArray();
+ Category[] arrayOfCategory = queryResult.toArray(new Category[queryResult.size()]);
+ assertEquals(2, array1.length);
+ assertEquals(queryResult.get(0), array1[0]);
+ assertEquals(queryResult.get(1), array1[1]);
+
+ assertEquals(2, arrayOfCategory.length);
+ assertEquals(queryResult.get(0), arrayOfCategory[0]);
+ assertEquals(queryResult.get(1), arrayOfCategory[1]);
+
+ transaction.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java
index 144a79bb27..70c304c0cf 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java
@@ -1,79 +1,79 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDODeltaNotification;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.OrderAddress;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-/**
- * CDO wrong feature on notification when multiple super types
- * <p>
- * See bug 260764
- *
- * @author Simon McDuff
- */
-public class Bugzilla_260764_Test extends AbstractCDOTest
-{
- public void testBugzilla_260764() throws Exception
- {
- msg("Opening session");
- final CDOSession session = openSession();
-
- // ************************************************************* //
- msg("Opening transaction");
- final CDOTransaction transaction = session.openTransaction();
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
-
- final OrderAddress orderAddress = getModel1Factory().createOrderAddress();
- resourceA.getContents().add(orderAddress);
- transaction.commit();
-
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- final TestAdapter adapter = new TestAdapter();
- orderAddress.eAdapters().add(adapter);
-
- // ************************************************************* //
-
- msg("Opening view");
- final CDOSession session2 = openSession();
-
- final CDOTransaction transaction2 = session2.openTransaction();
- final OrderAddress orderAddress2 = (OrderAddress)CDOUtil.getEObject(transaction2.getObject(
- CDOUtil.getCDOObject(orderAddress).cdoID(), true));
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderAddress2.getOrderDetails().add(orderDetail);
-
- assertEquals(0, adapter.getNotifications().length);
- transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
-
- CDODeltaNotification cdoNotification = (CDODeltaNotification)adapter.getNotifications()[0];
- assertEquals(false, cdoNotification.hasNext());
- assertEquals(getModel1Package().getOrder_OrderDetails(), cdoNotification.getFeature());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDODeltaNotification;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.OrderAddress;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+/**
+ * CDO wrong feature on notification when multiple super types
+ * <p>
+ * See bug 260764
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_260764_Test extends AbstractCDOTest
+{
+ public void testBugzilla_260764() throws Exception
+ {
+ msg("Opening session");
+ final CDOSession session = openSession();
+
+ // ************************************************************* //
+ msg("Opening transaction");
+ final CDOTransaction transaction = session.openTransaction();
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+
+ final OrderAddress orderAddress = getModel1Factory().createOrderAddress();
+ resourceA.getContents().add(orderAddress);
+ transaction.commit();
+
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ final TestAdapter adapter = new TestAdapter();
+ orderAddress.eAdapters().add(adapter);
+
+ // ************************************************************* //
+
+ msg("Opening view");
+ final CDOSession session2 = openSession();
+
+ final CDOTransaction transaction2 = session2.openTransaction();
+ final OrderAddress orderAddress2 = (OrderAddress)CDOUtil.getEObject(transaction2.getObject(
+ CDOUtil.getCDOObject(orderAddress).cdoID(), true));
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderAddress2.getOrderDetails().add(orderDetail);
+
+ assertEquals(0, adapter.getNotifications().length);
+ transaction2.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return adapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut();
+
+ CDODeltaNotification cdoNotification = (CDODeltaNotification)adapter.getNotifications()[0];
+ assertEquals(false, cdoNotification.hasNext());
+ assertEquals(getModel1Package().getOrder_OrderDetails(), cdoNotification.getFeature());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_261218_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_261218_Test.java
index 2e60a44b52..d1418a9787 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_261218_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_261218_Test.java
@@ -1,76 +1,76 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * See bug 261218
- *
- * @author Simon McDuff
- */
-public class Bugzilla_261218_Test extends AbstractCDOTest
-{
- /**
- * CDOListFeatureDeltaImpl.cacheIndices was introduced.
- */
- public void testBugzilla_261218_Containment() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- Resource resource = transaction.getOrCreateResource(getResourcePath("res1"));
-
- Category folder = getModel1Factory().createCategory();
- resource.getContents().add(folder);
-
- IOUtil.OUT().println("Adding...");
- for (int i = 0; i < 10000; ++i)
- {
- Category file = getModel1Factory().createCategory();
- folder.getCategories().add(file);
- }
-
- IOUtil.OUT().println("Committing...");
- transaction.commit();
-
- IOUtil.OUT().println("Removing...");
- for (int i = 9999; i >= 0; --i)
- {
- folder.getCategories().remove(i);
- }
-
- // =>90 seconds
- IOUtil.OUT().println("Committing...");
- transaction.commit();
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- disableConsole();
- super.doSetUp();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- enableConsole();
- super.doTearDown();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * See bug 261218
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_261218_Test extends AbstractCDOTest
+{
+ /**
+ * CDOListFeatureDeltaImpl.cacheIndices was introduced.
+ */
+ public void testBugzilla_261218_Containment() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ Resource resource = transaction.getOrCreateResource(getResourcePath("res1"));
+
+ Category folder = getModel1Factory().createCategory();
+ resource.getContents().add(folder);
+
+ IOUtil.OUT().println("Adding...");
+ for (int i = 0; i < 10000; ++i)
+ {
+ Category file = getModel1Factory().createCategory();
+ folder.getCategories().add(file);
+ }
+
+ IOUtil.OUT().println("Committing...");
+ transaction.commit();
+
+ IOUtil.OUT().println("Removing...");
+ for (int i = 9999; i >= 0; --i)
+ {
+ folder.getCategories().remove(i);
+ }
+
+ // =>90 seconds
+ IOUtil.OUT().println("Committing...");
+ transaction.commit();
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ disableConsole();
+ super.doSetUp();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ enableConsole();
+ super.doTearDown();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_265114_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_265114_Test.java
index bbbcd27547..3600459b75 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_265114_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_265114_Test.java
@@ -1,158 +1,158 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.eresource.CDOResourceFactory;
-import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.emf.cdo.view.CDOViewProvider;
-import org.eclipse.emf.cdo.view.CDOViewProviderRegistry;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.Resource.Factory.Registry;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Attaching adapters to resources does not load them?
- * <p>
- * See bug 265114
- *
- * @author Simon McDuff
- */
-public class Bugzilla_265114_Test extends AbstractCDOTest
-{
- public void testResourceSet() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- CDOSession session = openSession();
- ResourceSet rset = new ResourceSetImpl();
-
- Registry registry = rset.getResourceFactoryRegistry();
- Map<String, Object> map = registry.getProtocolToFactoryMap();
- map.put(CDOProtocolConstants.PROTOCOL_NAME, CDOResourceFactory.INSTANCE);
- CDOViewProvider viewProvider = new CDOViewProviderNewView(session);
- CDOViewProviderRegistry.INSTANCE.addViewProvider(viewProvider);
-
- try
- {
- TransactionEditingDomainSimulatedAdapter adapter = new TransactionEditingDomainSimulatedAdapter();
- rset.eAdapters().add(adapter);
- URI uriResource1 = CDOURIUtil.createResourceURI(session, getResourcePath("res1"));
- Resource resource1 = rset.getResource(uriResource1, true);
-
- CDOObject cdoResource = CDOUtil.getCDOObject((CDOResource)resource1);
- assertEquals(rset, cdoResource.cdoView().getResourceSet());
- assertEquals(1, adapter.getListOfContent().size());
- }
- finally
- {
- CDOViewProviderRegistry.INSTANCE.removeViewProvider(viewProvider);
- }
- }
-
- /**
- * @author Simon McDuff
- */
- public static class CDOViewProviderNewView implements CDOViewProvider
- {
- public static final int PRIORITY = DEFAULT_PRIORITY - 100;
-
- private final CDOSession session;
-
- public CDOViewProviderNewView(CDOSession session)
- {
- this.session = session;
- }
-
- public int getPriority()
- {
- return PRIORITY;
- }
-
- public String getRegex()
- {
- return null;
- }
-
- public CDOView getView(URI uri, ResourceSet resourceSet)
- {
- return session.openTransaction(resourceSet);
- }
-
- public URI getResourceURI(CDOView view, String path)
- {
- return null;
- }
-
- public boolean matchesRegex(URI uri)
- {
- return true;
- }
- }
-
- /**
- * @author Simon McDuff
- */
- public static class TransactionEditingDomainSimulatedAdapter extends AdapterImpl
- {
- private List<EObject> listOfContent = new ArrayList<EObject>();
-
- @Override
- public void notifyChanged(Notification msg)
- {
- if (msg.getEventType() == Notification.ADD)
- {
- Object newResource = msg.getNewValue();
- if (newResource instanceof CDOResourceImpl)
- {
- for (EObject object : ((CDOResource)newResource).getContents())
- {
- listOfContent.add(object);
- }
- }
- }
- }
-
- public List<EObject> getListOfContent()
- {
- return listOfContent;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceFactory;
+import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewProvider;
+import org.eclipse.emf.cdo.view.CDOViewProviderRegistry;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.Resource.Factory.Registry;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Attaching adapters to resources does not load them?
+ * <p>
+ * See bug 265114
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_265114_Test extends AbstractCDOTest
+{
+ public void testResourceSet() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ ResourceSet rset = new ResourceSetImpl();
+
+ Registry registry = rset.getResourceFactoryRegistry();
+ Map<String, Object> map = registry.getProtocolToFactoryMap();
+ map.put(CDOProtocolConstants.PROTOCOL_NAME, CDOResourceFactory.INSTANCE);
+ CDOViewProvider viewProvider = new CDOViewProviderNewView(session);
+ CDOViewProviderRegistry.INSTANCE.addViewProvider(viewProvider);
+
+ try
+ {
+ TransactionEditingDomainSimulatedAdapter adapter = new TransactionEditingDomainSimulatedAdapter();
+ rset.eAdapters().add(adapter);
+ URI uriResource1 = CDOURIUtil.createResourceURI(session, getResourcePath("res1"));
+ Resource resource1 = rset.getResource(uriResource1, true);
+
+ CDOObject cdoResource = CDOUtil.getCDOObject((CDOResource)resource1);
+ assertEquals(rset, cdoResource.cdoView().getResourceSet());
+ assertEquals(1, adapter.getListOfContent().size());
+ }
+ finally
+ {
+ CDOViewProviderRegistry.INSTANCE.removeViewProvider(viewProvider);
+ }
+ }
+
+ /**
+ * @author Simon McDuff
+ */
+ public static class CDOViewProviderNewView implements CDOViewProvider
+ {
+ public static final int PRIORITY = DEFAULT_PRIORITY - 100;
+
+ private final CDOSession session;
+
+ public CDOViewProviderNewView(CDOSession session)
+ {
+ this.session = session;
+ }
+
+ public int getPriority()
+ {
+ return PRIORITY;
+ }
+
+ public String getRegex()
+ {
+ return null;
+ }
+
+ public CDOView getView(URI uri, ResourceSet resourceSet)
+ {
+ return session.openTransaction(resourceSet);
+ }
+
+ public URI getResourceURI(CDOView view, String path)
+ {
+ return null;
+ }
+
+ public boolean matchesRegex(URI uri)
+ {
+ return true;
+ }
+ }
+
+ /**
+ * @author Simon McDuff
+ */
+ public static class TransactionEditingDomainSimulatedAdapter extends AdapterImpl
+ {
+ private List<EObject> listOfContent = new ArrayList<EObject>();
+
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ if (msg.getEventType() == Notification.ADD)
+ {
+ Object newResource = msg.getNewValue();
+ if (newResource instanceof CDOResourceImpl)
+ {
+ for (EObject object : ((CDOResource)newResource).getContents())
+ {
+ listOfContent.add(object);
+ }
+ }
+ }
+ }
+
+ public List<EObject> getListOfContent()
+ {
+ return listOfContent;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java
index 1fa58abccd..51810ea886 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java
@@ -1,62 +1,62 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-/**
- * Change subscription are not registered correctly for new CDOResource objects
- * <p>
- * See bug 266857
- *
- * @author Simon McDuff
- */
-public class Bugzilla_266857_Test extends AbstractCDOTest
-{
- public void testBugzilla_266857() throws Exception
- {
- CDOSession session = openSession();
-
- session.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOTransaction transaction = session.openTransaction();
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- CDOResource resource1 = transaction.createResource(getResourcePath("test1"));
- final TestAdapter testAdapterForResource = new TestAdapter();
- resource1.eAdapters().add(testAdapterForResource);
- transaction.commit();
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- CDOResource resource2 = transaction2.getResource(getResourcePath("test1"));
- Company company2 = getModel1Factory().createCompany();
- resource2.getContents().add(company2);
- assertEquals(0, testAdapterForResource.getNotifications().length);
- transaction2.commit();
-
- msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapterForResource.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+/**
+ * Change subscription are not registered correctly for new CDOResource objects
+ * <p>
+ * See bug 266857
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_266857_Test extends AbstractCDOTest
+{
+ public void testBugzilla_266857() throws Exception
+ {
+ CDOSession session = openSession();
+
+ session.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOTransaction transaction = session.openTransaction();
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("test1"));
+ final TestAdapter testAdapterForResource = new TestAdapter();
+ resource1.eAdapters().add(testAdapterForResource);
+ transaction.commit();
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource resource2 = transaction2.getResource(getResourcePath("test1"));
+ Company company2 = getModel1Factory().createCompany();
+ resource2.getContents().add(company2);
+ assertEquals(0, testAdapterForResource.getNotifications().length);
+ transaction2.commit();
+
+ msg("Checking after commit");
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapterForResource.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java
index 76e66b07a9..367f82aace 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java
@@ -1,86 +1,86 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * IllegalStateException in CDOStore.getRevision
- * <p>
- * See bug 266982
- *
- * @author Simon McDuff
- */
-public class Bugzilla_266982_Test extends AbstractCDOTest
-{
- public void testBugzilla_266982() throws Exception
- {
- final Customer customer = getModel1Factory().createCustomer();
- final boolean done[] = new boolean[1];
- final Exception exception[] = new Exception[1];
- done[0] = false;
- customer.setName("customer");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- Runnable changeObjects = new Runnable()
- {
- public void run()
- {
- try
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- Customer customerToLoad = (Customer)CDOUtil.getEObject(transaction.getObject(CDOUtil.getCDOObject(customer)
- .cdoID()));
- while (!done[0])
- {
- // Could fail if the attach is not thread safe
- customerToLoad.getName();
- }
-
- transaction.close();
- session.close();
- }
- catch (Exception ex)
- {
- exception[0] = ex;
- }
- }
- };
-
- new Thread(changeObjects).start();
-
- for (int i = 0; i < 500 && exception[0] == null; i++)
- {
- customer.setName("Ottawa" + i);
- transaction.commit();
- }
-
- done[0] = true;
- if (exception[0] != null)
- {
- exception[0].printStackTrace();
- fail(exception[0].getMessage());
- }
-
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * IllegalStateException in CDOStore.getRevision
+ * <p>
+ * See bug 266982
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_266982_Test extends AbstractCDOTest
+{
+ public void testBugzilla_266982() throws Exception
+ {
+ final Customer customer = getModel1Factory().createCustomer();
+ final boolean done[] = new boolean[1];
+ final Exception exception[] = new Exception[1];
+ done[0] = false;
+ customer.setName("customer");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ Runnable changeObjects = new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ Customer customerToLoad = (Customer)CDOUtil.getEObject(transaction.getObject(CDOUtil.getCDOObject(customer)
+ .cdoID()));
+ while (!done[0])
+ {
+ // Could fail if the attach is not thread safe
+ customerToLoad.getName();
+ }
+
+ transaction.close();
+ session.close();
+ }
+ catch (Exception ex)
+ {
+ exception[0] = ex;
+ }
+ }
+ };
+
+ new Thread(changeObjects).start();
+
+ for (int i = 0; i < 500 && exception[0] == null; i++)
+ {
+ customer.setName("Ottawa" + i);
+ transaction.commit();
+ }
+
+ done[0] = true;
+ if (exception[0] != null)
+ {
+ exception[0].printStackTrace();
+ fail(exception[0].getMessage());
+ }
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267050_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267050_Test.java
index 664cfdbdb3..cb53c9c5cf 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267050_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267050_Test.java
@@ -1,76 +1,76 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
-import java.util.Collection;
-
-/**
- * Add new packages infos in the Notifications process at the client side
- * <p>
- * See bug 267050
- *
- * @author Simon McDuff
- */
-public class Bugzilla_267050_Test extends AbstractCDOTest
-{
- @CleanRepositoriesBefore
- @SuppressWarnings("unchecked")
- public void testBugzilla_267050() throws Exception
- {
- final Collection<CDOPackageUnit> newPackagesUnits[] = new Collection[1];
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOSession session2 = openSession();
- session2.addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOSessionInvalidationEvent)
- {
- CDOSessionInvalidationEvent e = (CDOSessionInvalidationEvent)event;
- newPackagesUnits[0] = e.getNewPackageUnits();
- }
- }
- });
-
- session.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOResource res = transaction.createResource(getResourcePath("/res"));
- Company specialPurchaseOrder = getModel1Factory().createCompany();
- res.getContents().add(specialPurchaseOrder);
- transaction.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return newPackagesUnits[0] != null;
- }
- }.assertNoTimeOut();
-
- assertEquals(1, newPackagesUnits[0].size());
- assertEquals(getModel1Package().getNsURI(), newPackagesUnits[0].iterator().next().getTopLevelPackageInfo()
- .getPackageURI());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import java.util.Collection;
+
+/**
+ * Add new packages infos in the Notifications process at the client side
+ * <p>
+ * See bug 267050
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_267050_Test extends AbstractCDOTest
+{
+ @CleanRepositoriesBefore
+ @SuppressWarnings("unchecked")
+ public void testBugzilla_267050() throws Exception
+ {
+ final Collection<CDOPackageUnit> newPackagesUnits[] = new Collection[1];
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOSession session2 = openSession();
+ session2.addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOSessionInvalidationEvent)
+ {
+ CDOSessionInvalidationEvent e = (CDOSessionInvalidationEvent)event;
+ newPackagesUnits[0] = e.getNewPackageUnits();
+ }
+ }
+ });
+
+ session.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOResource res = transaction.createResource(getResourcePath("/res"));
+ Company specialPurchaseOrder = getModel1Factory().createCompany();
+ res.getContents().add(specialPurchaseOrder);
+ transaction.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return newPackagesUnits[0] != null;
+ }
+ }.assertNoTimeOut();
+
+ assertEquals(1, newPackagesUnits[0].size());
+ assertEquals(getModel1Package().getNsURI(), newPackagesUnits[0].iterator().next().getTopLevelPackageInfo()
+ .getPackageURI());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java
index 9535979077..a7c21d11d3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java
@@ -1,87 +1,87 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * NullPointerException on reload
- * <p>
- * See bug 267352
- *
- * @author Simon McDuff
- */
-public class Bugzilla_267352_Test extends AbstractCDOTest
-{
- public void testBugzilla_267352() throws Exception
- {
- final Customer customer = getModel1Factory().createCustomer();
- final boolean done[] = new boolean[1];
- final Exception exception[] = new Exception[1];
- done[0] = false;
- customer.setName("customer");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- Runnable changeObjects = new Runnable()
- {
- public void run()
- {
- try
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOObject customerToLoad = transaction.getObject(CDOUtil.getCDOObject(customer).cdoID());
- while (!done[0])
- {
- sleep(10);
-
- // Could fail if the attach is not thread safe
- transaction.reload(customerToLoad);
- }
-
- transaction.close();
- session.close();
- }
- catch (Exception ex)
- {
- exception[0] = ex;
- }
- }
- };
-
- new Thread(changeObjects).start();
- for (int i = 0; i < 100 && exception[0] == null; i++)
- {
- customer.setName("Ottawa" + i);
- transaction.commit();
- }
-
- done[0] = true;
- if (exception[0] != null)
- {
- exception[0].printStackTrace();
- fail(exception[0].getMessage());
- }
-
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * NullPointerException on reload
+ * <p>
+ * See bug 267352
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_267352_Test extends AbstractCDOTest
+{
+ public void testBugzilla_267352() throws Exception
+ {
+ final Customer customer = getModel1Factory().createCustomer();
+ final boolean done[] = new boolean[1];
+ final Exception exception[] = new Exception[1];
+ done[0] = false;
+ customer.setName("customer");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ Runnable changeObjects = new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOObject customerToLoad = transaction.getObject(CDOUtil.getCDOObject(customer).cdoID());
+ while (!done[0])
+ {
+ sleep(10);
+
+ // Could fail if the attach is not thread safe
+ transaction.reload(customerToLoad);
+ }
+
+ transaction.close();
+ session.close();
+ }
+ catch (Exception ex)
+ {
+ exception[0] = ex;
+ }
+ }
+ };
+
+ new Thread(changeObjects).start();
+ for (int i = 0; i < 100 && exception[0] == null; i++)
+ {
+ customer.setName("Ottawa" + i);
+ transaction.commit();
+ }
+
+ done[0] = true;
+ if (exception[0] != null)
+ {
+ exception[0].printStackTrace();
+ fail(exception[0].getMessage());
+ }
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_270429_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_270429_Test.java
index ebd7042474..082e52b5a3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_270429_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_270429_Test.java
@@ -1,99 +1,99 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.MultiContainedElement;
-import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.tests.model4.model4Package;
-import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-/**
- * @author Stefan Winkler
- */
-public class Bugzilla_270429_Test extends AbstractCDOTest
-{
- public void testTwoWayReferenceDeletion() throws CommitException
- {
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model4Package.eINSTANCE);
- session.getPackageRegistry().putEPackage(model4interfacesPackage.eINSTANCE);
-
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test/1"));
-
- RefMultiContained parent = model4Factory.eINSTANCE.createRefMultiContained();
-
- MultiContainedElement child1 = model4Factory.eINSTANCE.createMultiContainedElement();
- child1.setName("Element1");
- child1.setParent(parent);
-
- MultiContainedElement child2 = model4Factory.eINSTANCE.createMultiContainedElement();
- child2.setName("Element2");
- parent.getElements().add(child2);
-
- res.getContents().add(parent);
-
- tx.commit();
-
- tx.close();
- session.close();
- clearCache(getRepository().getRevisionManager());
- }
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model4Package.eINSTANCE);
- session.getPackageRegistry().putEPackage(model4interfacesPackage.eINSTANCE);
-
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.getResource(getResourcePath("/test/1"));
-
- RefMultiContained parent = (RefMultiContained)res.getContents().get(0);
- MultiContainedElement child1 = parent.getElements().get(0);
- MultiContainedElement child2 = parent.getElements().get(1);
-
- assertEquals("Element1", child1.getName());
- assertEquals("Element2", child2.getName());
-
- parent.getElements().remove(child1);
- child2.setParent(null);
-
- tx.commit();
- tx.close();
- session.close();
- clearCache(getRepository().getRevisionManager());
- }
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model4Package.eINSTANCE);
- session.getPackageRegistry().putEPackage(model4interfacesPackage.eINSTANCE);
-
- CDOView tx = session.openView();
- CDOResource res = tx.getResource(getResourcePath("/test/1"));
-
- RefMultiContained parent = (RefMultiContained)res.getContents().get(0);
- assertEquals(0, parent.getElements().size());
-
- tx.close();
- session.close();
- clearCache(getRepository().getRevisionManager());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.MultiContainedElement;
+import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.tests.model4.model4Package;
+import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_270429_Test extends AbstractCDOTest
+{
+ public void testTwoWayReferenceDeletion() throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model4Package.eINSTANCE);
+ session.getPackageRegistry().putEPackage(model4interfacesPackage.eINSTANCE);
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test/1"));
+
+ RefMultiContained parent = model4Factory.eINSTANCE.createRefMultiContained();
+
+ MultiContainedElement child1 = model4Factory.eINSTANCE.createMultiContainedElement();
+ child1.setName("Element1");
+ child1.setParent(parent);
+
+ MultiContainedElement child2 = model4Factory.eINSTANCE.createMultiContainedElement();
+ child2.setName("Element2");
+ parent.getElements().add(child2);
+
+ res.getContents().add(parent);
+
+ tx.commit();
+
+ tx.close();
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+ }
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model4Package.eINSTANCE);
+ session.getPackageRegistry().putEPackage(model4interfacesPackage.eINSTANCE);
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.getResource(getResourcePath("/test/1"));
+
+ RefMultiContained parent = (RefMultiContained)res.getContents().get(0);
+ MultiContainedElement child1 = parent.getElements().get(0);
+ MultiContainedElement child2 = parent.getElements().get(1);
+
+ assertEquals("Element1", child1.getName());
+ assertEquals("Element2", child2.getName());
+
+ parent.getElements().remove(child1);
+ child2.setParent(null);
+
+ tx.commit();
+ tx.close();
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+ }
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model4Package.eINSTANCE);
+ session.getPackageRegistry().putEPackage(model4interfacesPackage.eINSTANCE);
+
+ CDOView tx = session.openView();
+ CDOResource res = tx.getResource(getResourcePath("/test/1"));
+
+ RefMultiContained parent = (RefMultiContained)res.getContents().get(0);
+ assertEquals(0, parent.getElements().size());
+
+ tx.close();
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_272861_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_272861_Test.java
index a34cab811e..7d8927b1b8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_272861_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_272861_Test.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * Bug 272861
- *
- * @author Simon McDuff
- */
-public class Bugzilla_272861_Test extends AbstractCDOTest
-{
- public void test_Bugzilla_271861_Case1() throws Exception
- {
- CDOSession session = openSession();
-
- CDOTransaction trans = session.openTransaction();
- CDOResource res = trans.createResource(getResourcePath("/test/RESOURCE"));
- trans.commit();
-
- res.delete(null);
- res = trans.createResource(getResourcePath("/test/RESOURCE"));
- trans.commit();
-
- trans.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * Bug 272861
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_272861_Test extends AbstractCDOTest
+{
+ public void test_Bugzilla_271861_Case1() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction trans = session.openTransaction();
+ CDOResource res = trans.createResource(getResourcePath("/test/RESOURCE"));
+ trans.commit();
+
+ res.delete(null);
+ res = trans.createResource(getResourcePath("/test/RESOURCE"));
+ trans.commit();
+
+ trans.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273233_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273233_Test.java
index 68bc603d7c..b45d906c93 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273233_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273233_Test.java
@@ -1,133 +1,133 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.spi.cdo.FSMUtil;
-
-/**
- * @author Simon McDuff
- */
-public class Bugzilla_273233_Test extends AbstractCDOTest
-{
- public void test_Bugzilla_273233_Simple() throws Exception
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
-
- CDOTransaction trans = session.openTransaction();
- CDOResource res = trans.createResource(getResourcePath("/test/1"));
-
- trans.commit();
- Company company = getModel1Factory().createCompany();
- res.getContents().add(company);
- session.refresh();
- trans.commit();
- trans.close();
- session.close();
- }
-
- public void test_Bugzilla_273233_TwoSessions() throws Exception
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
-
- CDOTransaction trans = session.openTransaction();
- CDOResource res = trans.createResource(getResourcePath("/test/1"));
-
- trans.commit();
-
- CDOSession session2 = openSession();
- session2.options().setPassiveUpdateEnabled(false);
- CDOTransaction trans2 = session2.openTransaction();
- CDOResource res2 = trans2.getResource(getResourcePath("/test/1"));
-
- // Add company in sess/tx #1
- Company company = getModel1Factory().createCompany();
- res.getContents().add(company);
-
- // Add company in sess/tx #2
- Company company2 = getModel1Factory().createCompany();
- res2.getContents().add(company2);
-
- // Commit tx #1
- trans.commit();
-
- assertEquals(false, FSMUtil.isConflict(res2));
-
- session2.refresh();
- assertEquals(true, FSMUtil.isConflict(res2));
-
- try
- {
- trans2.commit();
- fail("Should have a conflict exception");
- }
- catch (Exception ex)
- {
- //
- }
-
- trans.close();
- session.close();
- }
-
- public void test_Bugzilla_273233_TwoSessionsWithClearCache() throws Exception
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
-
- CDOTransaction trans = session.openTransaction();
- CDOResource res = trans.createResource(getResourcePath("/test/1"));
-
- trans.commit();
-
- CDOSession session2 = openSession();
- session2.options().setPassiveUpdateEnabled(false);
- CDOTransaction trans2 = session2.openTransaction();
- CDOResource res2 = trans2.getResource(getResourcePath("/test/1"));
-
- // Add company in sess/tx #1
- Company company = getModel1Factory().createCompany();
- res.getContents().add(company);
-
- // Add company in sess/tx #2
- Company company2 = getModel1Factory().createCompany();
- res2.getContents().add(company2);
-
- // Commit tx #1
- trans.commit();
-
- clearCache(session2.getRevisionManager());
- assertEquals(false, FSMUtil.isConflict(res2));
-
- session2.refresh();
- assertEquals(true, FSMUtil.isConflict(res2));
-
- try
- {
- trans2.commit();
- fail("Should have a conflict exception");
- }
- catch (Exception ex)
- {
- //
- }
-
- trans.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.spi.cdo.FSMUtil;
+
+/**
+ * @author Simon McDuff
+ */
+public class Bugzilla_273233_Test extends AbstractCDOTest
+{
+ public void test_Bugzilla_273233_Simple() throws Exception
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+
+ CDOTransaction trans = session.openTransaction();
+ CDOResource res = trans.createResource(getResourcePath("/test/1"));
+
+ trans.commit();
+ Company company = getModel1Factory().createCompany();
+ res.getContents().add(company);
+ session.refresh();
+ trans.commit();
+ trans.close();
+ session.close();
+ }
+
+ public void test_Bugzilla_273233_TwoSessions() throws Exception
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+
+ CDOTransaction trans = session.openTransaction();
+ CDOResource res = trans.createResource(getResourcePath("/test/1"));
+
+ trans.commit();
+
+ CDOSession session2 = openSession();
+ session2.options().setPassiveUpdateEnabled(false);
+ CDOTransaction trans2 = session2.openTransaction();
+ CDOResource res2 = trans2.getResource(getResourcePath("/test/1"));
+
+ // Add company in sess/tx #1
+ Company company = getModel1Factory().createCompany();
+ res.getContents().add(company);
+
+ // Add company in sess/tx #2
+ Company company2 = getModel1Factory().createCompany();
+ res2.getContents().add(company2);
+
+ // Commit tx #1
+ trans.commit();
+
+ assertEquals(false, FSMUtil.isConflict(res2));
+
+ session2.refresh();
+ assertEquals(true, FSMUtil.isConflict(res2));
+
+ try
+ {
+ trans2.commit();
+ fail("Should have a conflict exception");
+ }
+ catch (Exception ex)
+ {
+ //
+ }
+
+ trans.close();
+ session.close();
+ }
+
+ public void test_Bugzilla_273233_TwoSessionsWithClearCache() throws Exception
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+
+ CDOTransaction trans = session.openTransaction();
+ CDOResource res = trans.createResource(getResourcePath("/test/1"));
+
+ trans.commit();
+
+ CDOSession session2 = openSession();
+ session2.options().setPassiveUpdateEnabled(false);
+ CDOTransaction trans2 = session2.openTransaction();
+ CDOResource res2 = trans2.getResource(getResourcePath("/test/1"));
+
+ // Add company in sess/tx #1
+ Company company = getModel1Factory().createCompany();
+ res.getContents().add(company);
+
+ // Add company in sess/tx #2
+ Company company2 = getModel1Factory().createCompany();
+ res2.getContents().add(company2);
+
+ // Commit tx #1
+ trans.commit();
+
+ clearCache(session2.getRevisionManager());
+ assertEquals(false, FSMUtil.isConflict(res2));
+
+ session2.refresh();
+ assertEquals(true, FSMUtil.isConflict(res2));
+
+ try
+ {
+ trans2.commit();
+ fail("Should have a conflict exception");
+ }
+ catch (Exception ex)
+ {
+ //
+ }
+
+ trans.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java
index a841cb9901..b9624d761a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java
@@ -1,283 +1,283 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.util.transaction.TransactionException;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Concurrency problem: attribute of enumeration type not updated correctly between two clients
- * <p>
- * See bug 273565
- *
- * @author Simon McDuff
- */
-public class Bugzilla_273565_Test extends AbstractCDOTest
-{
- /**
- * Thread A: Update the value to 3 and 2 only if the value is at 1.<br>
- * Thread B: Update the value to 1 only if the value is at 2.
- * <p>
- * Thread B will load objects.<br>
- * But at the same time will update remote changes.<br>
- * Causing not to have the latest version.
- * <p>
- * See bug 273565
- */
- public void _testBugzilla_273565() throws Exception
- {
- final CountDownLatch start = new CountDownLatch(1);
- final boolean[] done = { false };
- final Exception exception[] = { null };
-
- final OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setPrice(2);
-
- final CDOSession session = openSession();
- final CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(orderDetail);
- transaction.commit();
-
- final CDOID id = CDOUtil.getCDOObject(orderDetail).cdoID();
- Thread threadA = new Thread()
- {
- @Override
- public void run()
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- OrderDetail orderDetail = (OrderDetail)CDOUtil.getEObject(transaction.getObject(id));
-
- try
- {
- start.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- while (!done[0])
- {
- while (orderDetail.getPrice() != 1 && !done[0])
- {
- sleep(1);
- }
-
- try
- {
- orderDetail.setPrice(3);
- transaction.commit();
- }
- catch (CommitException ex)
- {
- transaction.rollback();
- continue;
- }
-
- try
- {
- orderDetail.setPrice(2);
- transaction.commit();
- }
- catch (CommitException ex)
- {
- transaction.rollback();
- continue;
- }
- }
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- exception[0] = ex;
- }
- finally
- {
- session.close();
- }
- }
- };
-
- threadA.setDaemon(true);
- threadA.start();
-
- Thread threadB = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- start.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- for (int i = 0; i < 50 && exception[0] == null; i++)
- {
- try
- {
- orderDetail.setPrice(1);
- transaction.commit();
- }
- catch (TransactionException ex)
- {
- transaction.rollback();
- continue;
- }
-
- while (orderDetail.getPrice() != 2)
- {
- sleep(1);
- }
- }
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- exception[0] = ex;
- }
-
- done[0] = true;
- }
- };
-
- threadB.setDaemon(true);
- threadB.start();
-
- start.countDown();
-
- threadA.join(DEFAULT_TIMEOUT);
- threadA.interrupt();
-
- threadB.join(DEFAULT_TIMEOUT);
- threadB.interrupt();
-
- if (exception[0] != null)
- {
- throw exception[0];
- }
- }
-
- /**
- * See bug 273565
- */
- public void _testBugzilla_273565_Lock() throws Exception
- {
- disableConsole();
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setPrice(2);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(orderDetail);
- transaction.commit();
-
- final CDOID id = CDOUtil.getCDOObject(orderDetail).cdoID();
- session.close();
-
- final CountDownLatch start = new CountDownLatch(1);
- final Exception exception[] = { null };
-
- class Modifier extends Thread
- {
- private float price;
-
- public Modifier(float price)
- {
- setDaemon(true);
- this.price = price;
- }
-
- @Override
- public void run()
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- OrderDetail orderDetail = (OrderDetail)transaction.getObject(id);
-
- try
- {
- start.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- for (int i = 0; i < 5000 && exception[0] == null; i++)
- {
- CDOUtil.getCDOObject(orderDetail).cdoWriteLock().lock(DEFAULT_TIMEOUT);
- System.out.println("\nGot lock: " + price + " --> " + CDOUtil.getCDOObject(orderDetail).cdoRevision());
- sleep(1L);
-
- orderDetail.setPrice(price);
- System.out.println("Committing: " + price);
- transaction.commit();
- sleep(1L);
- }
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- exception[0] = ex;
- }
- finally
- {
- session.close();
- }
- }
- }
-
- Modifier threadA = new Modifier(1);
- threadA.start();
-
- Modifier threadB = new Modifier(2);
- threadB.start();
-
- start.countDown();
-
- threadA.join(DEFAULT_TIMEOUT);
- threadA.interrupt();
-
- threadB.join(DEFAULT_TIMEOUT);
- threadB.interrupt();
-
- if (exception[0] != null)
- {
- throw exception[0];
- }
- }
-
- /**
- * See bug 273565
- */
- public void testBugzilla_273565_NoThreads() throws Exception
- {
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setPrice(1);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(orderDetail);
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- OrderDetail orderDetail2 = (OrderDetail)CDOUtil.getEObject(transaction2.getObject(orderDetail));
-
- CDOUtil.getCDOObject(orderDetail).cdoWriteLock().lock(DEFAULT_TIMEOUT);
- orderDetail.setPrice(2);
-
- boolean locked = CDOUtil.getCDOObject(orderDetail2).cdoWriteLock()
- .tryLock(DEFAULT_TIMEOUT_EXPECTED, TimeUnit.MILLISECONDS);
- assertEquals(false, locked);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.transaction.TransactionException;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Concurrency problem: attribute of enumeration type not updated correctly between two clients
+ * <p>
+ * See bug 273565
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_273565_Test extends AbstractCDOTest
+{
+ /**
+ * Thread A: Update the value to 3 and 2 only if the value is at 1.<br>
+ * Thread B: Update the value to 1 only if the value is at 2.
+ * <p>
+ * Thread B will load objects.<br>
+ * But at the same time will update remote changes.<br>
+ * Causing not to have the latest version.
+ * <p>
+ * See bug 273565
+ */
+ public void _testBugzilla_273565() throws Exception
+ {
+ final CountDownLatch start = new CountDownLatch(1);
+ final boolean[] done = { false };
+ final Exception exception[] = { null };
+
+ final OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setPrice(2);
+
+ final CDOSession session = openSession();
+ final CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(orderDetail);
+ transaction.commit();
+
+ final CDOID id = CDOUtil.getCDOObject(orderDetail).cdoID();
+ Thread threadA = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ OrderDetail orderDetail = (OrderDetail)CDOUtil.getEObject(transaction.getObject(id));
+
+ try
+ {
+ start.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ while (!done[0])
+ {
+ while (orderDetail.getPrice() != 1 && !done[0])
+ {
+ sleep(1);
+ }
+
+ try
+ {
+ orderDetail.setPrice(3);
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ transaction.rollback();
+ continue;
+ }
+
+ try
+ {
+ orderDetail.setPrice(2);
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ transaction.rollback();
+ continue;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ exception[0] = ex;
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+ };
+
+ threadA.setDaemon(true);
+ threadA.start();
+
+ Thread threadB = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ start.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ for (int i = 0; i < 50 && exception[0] == null; i++)
+ {
+ try
+ {
+ orderDetail.setPrice(1);
+ transaction.commit();
+ }
+ catch (TransactionException ex)
+ {
+ transaction.rollback();
+ continue;
+ }
+
+ while (orderDetail.getPrice() != 2)
+ {
+ sleep(1);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ exception[0] = ex;
+ }
+
+ done[0] = true;
+ }
+ };
+
+ threadB.setDaemon(true);
+ threadB.start();
+
+ start.countDown();
+
+ threadA.join(DEFAULT_TIMEOUT);
+ threadA.interrupt();
+
+ threadB.join(DEFAULT_TIMEOUT);
+ threadB.interrupt();
+
+ if (exception[0] != null)
+ {
+ throw exception[0];
+ }
+ }
+
+ /**
+ * See bug 273565
+ */
+ public void _testBugzilla_273565_Lock() throws Exception
+ {
+ disableConsole();
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setPrice(2);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(orderDetail);
+ transaction.commit();
+
+ final CDOID id = CDOUtil.getCDOObject(orderDetail).cdoID();
+ session.close();
+
+ final CountDownLatch start = new CountDownLatch(1);
+ final Exception exception[] = { null };
+
+ class Modifier extends Thread
+ {
+ private float price;
+
+ public Modifier(float price)
+ {
+ setDaemon(true);
+ this.price = price;
+ }
+
+ @Override
+ public void run()
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ OrderDetail orderDetail = (OrderDetail)transaction.getObject(id);
+
+ try
+ {
+ start.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ for (int i = 0; i < 5000 && exception[0] == null; i++)
+ {
+ CDOUtil.getCDOObject(orderDetail).cdoWriteLock().lock(DEFAULT_TIMEOUT);
+ System.out.println("\nGot lock: " + price + " --> " + CDOUtil.getCDOObject(orderDetail).cdoRevision());
+ sleep(1L);
+
+ orderDetail.setPrice(price);
+ System.out.println("Committing: " + price);
+ transaction.commit();
+ sleep(1L);
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ exception[0] = ex;
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+ }
+
+ Modifier threadA = new Modifier(1);
+ threadA.start();
+
+ Modifier threadB = new Modifier(2);
+ threadB.start();
+
+ start.countDown();
+
+ threadA.join(DEFAULT_TIMEOUT);
+ threadA.interrupt();
+
+ threadB.join(DEFAULT_TIMEOUT);
+ threadB.interrupt();
+
+ if (exception[0] != null)
+ {
+ throw exception[0];
+ }
+ }
+
+ /**
+ * See bug 273565
+ */
+ public void testBugzilla_273565_NoThreads() throws Exception
+ {
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setPrice(1);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(orderDetail);
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ OrderDetail orderDetail2 = (OrderDetail)CDOUtil.getEObject(transaction2.getObject(orderDetail));
+
+ CDOUtil.getCDOObject(orderDetail).cdoWriteLock().lock(DEFAULT_TIMEOUT);
+ orderDetail.setPrice(2);
+
+ boolean locked = CDOUtil.getCDOObject(orderDetail2).cdoWriteLock()
+ .tryLock(DEFAULT_TIMEOUT_EXPECTED, TimeUnit.MILLISECONDS);
+ assertEquals(false, locked);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273758_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273758_Test.java
index 28c1e28eb3..9f964ef010 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273758_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273758_Test.java
@@ -1,89 +1,89 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.util.TestEMFUtil;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Export resource miss all of the oneToMany references
- * <p>
- * See bug 273758
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_273758_Test extends AbstractCDOTest
-{
- public void test_export_resource_contents() throws Exception
- {
- {
- // Create 3 root objects: 1 Product1, 2 OrderDetails.
- // Product1 will reference both OrderDetails
-
- Product1 product = getModel1Factory().createProduct1();
- product.setName("product");
- OrderDetail detail1 = getModel1Factory().createOrderDetail();
- detail1.setPrice(1.99f);
- OrderDetail detail2 = getModel1Factory().createOrderDetail();
- detail2.setPrice(9.99f);
-
- product.getOrderDetails().add(detail1);
- product.getOrderDetails().add(detail2);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- resource.getContents().add(product);
- resource.getContents().add(detail1);
- resource.getContents().add(detail2);
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Product1 product2 = (Product1)resource.getContents().get(0);
- // Check in memory Product1 EObject reference integrity
- assertEquals(2, product2.getOrderDetails().size());
-
- Collection<EObject> collection = EcoreUtil.copyAll(resource.getContents());
- List<EObject> sourceContents = new ArrayList<EObject>(collection);
-
- // Target Resource
- File file = createTempFile("exportModel1", null);
- String tempFileURI = file.toURI().toString();
- TestEMFUtil.saveXMI(tempFileURI, sourceContents);
-
- List<EObject> list = TestEMFUtil.loadXMIMultiple(tempFileURI, Model1Package.eINSTANCE);
- Product1 product3 = (Product1)list.get(0);
- assertEquals(2, product3.getOrderDetails().size());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.util.TestEMFUtil;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Export resource miss all of the oneToMany references
+ * <p>
+ * See bug 273758
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_273758_Test extends AbstractCDOTest
+{
+ public void test_export_resource_contents() throws Exception
+ {
+ {
+ // Create 3 root objects: 1 Product1, 2 OrderDetails.
+ // Product1 will reference both OrderDetails
+
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("product");
+ OrderDetail detail1 = getModel1Factory().createOrderDetail();
+ detail1.setPrice(1.99f);
+ OrderDetail detail2 = getModel1Factory().createOrderDetail();
+ detail2.setPrice(9.99f);
+
+ product.getOrderDetails().add(detail1);
+ product.getOrderDetails().add(detail2);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ resource.getContents().add(product);
+ resource.getContents().add(detail1);
+ resource.getContents().add(detail2);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Product1 product2 = (Product1)resource.getContents().get(0);
+ // Check in memory Product1 EObject reference integrity
+ assertEquals(2, product2.getOrderDetails().size());
+
+ Collection<EObject> collection = EcoreUtil.copyAll(resource.getContents());
+ List<EObject> sourceContents = new ArrayList<EObject>(collection);
+
+ // Target Resource
+ File file = createTempFile("exportModel1", null);
+ String tempFileURI = file.toURI().toString();
+ TestEMFUtil.saveXMI(tempFileURI, sourceContents);
+
+ List<EObject> list = TestEMFUtil.loadXMIMultiple(tempFileURI, Model1Package.eINSTANCE);
+ Product1 product3 = (Product1)list.get(0);
+ assertEquals(2, product3.getOrderDetails().size());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_276696_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_276696_Test.java
index 96d854c9d0..5f6cd42c25 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_276696_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_276696_Test.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.ecore.EAttribute;
-
-/**
- * ArrayIndexOutOfBoundsException while unsetting "modified" EAttribute in CDOResource
- * <p>
- * See bug 276696
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_276696_Test extends AbstractCDOTest
-{
- public void testModifiedUnset() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.setModified(true);
-
- EAttribute attrib = (EAttribute)resource.eClass().getEStructuralFeature("modified");
- resource.eUnset(attrib);
-
- transaction.commit();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.EAttribute;
+
+/**
+ * ArrayIndexOutOfBoundsException while unsetting "modified" EAttribute in CDOResource
+ * <p>
+ * See bug 276696
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_276696_Test extends AbstractCDOTest
+{
+ public void testModifiedUnset() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.setModified(true);
+
+ EAttribute attrib = (EAttribute)resource.eClass().getEStructuralFeature("modified");
+ resource.eUnset(attrib);
+
+ transaction.commit();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_278900_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_278900_Test.java
index bcd28670ac..827baddfcb 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_278900_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_278900_Test.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * EObjectValidator.validate_UniqueID broken for CDOObjects
- * <p>
- * See bug 278900
- *
- * @author Simon McDuff
- */
-public class Bugzilla_278900_Test extends AbstractCDOTest
-{
- public void testBugzilla_278900() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
- tx.commit();
-
- try
- {
- res.getEObject("ABBSBD");
- fail("Throwable expected");
- }
- catch (Throwable expected)
- {
- // SUCCESS
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * EObjectValidator.validate_UniqueID broken for CDOObjects
+ * <p>
+ * See bug 278900
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_278900_Test extends AbstractCDOTest
+{
+ public void testBugzilla_278900() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
+ tx.commit();
+
+ try
+ {
+ res.getEObject("ABBSBD");
+ fail("Throwable expected");
+ }
+ catch (Throwable expected)
+ {
+ // SUCCESS
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279565_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279565_Test.java
index 7dea3b64a6..59b6488068 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279565_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279565_Test.java
@@ -1,153 +1,153 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-
-/**
- * Invalid listener might prevent CDOTransaction to close properly
- * <p>
- * See bug 279565
- *
- * @author Eike Stepper
- */
-public class Bugzilla_279565_Test extends AbstractCDOTest
-{
- public void testBugzilla_279565() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- final ResourceSet resourceSet = tx.getResourceSet();
- resourceSet.eAdapters().add(new AdapterImpl()
- {
- @Override
- public void notifyChanged(Notification msg)
- {
- throw new IllegalStateException("Simulated exception");
- }
- });
-
- try
- {
- tx.getOrCreateResource(getResourcePath("/test"));
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException sucess)
- {
- }
-
- tx.close();
-
- new PollingTimeOuter()
- {
-
- @Override
- protected boolean successful()
- {
- return resourceSet.getResources().isEmpty();
- }
- };
- }
-
- public void testBugzilla_279565_OwnResourceSet() throws Exception
- {
- final ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.eAdapters().add(new AdapterImpl()
- {
- @Override
- public void notifyChanged(Notification msg)
- {
- throw new IllegalStateException("Simulated exception");
- }
- });
-
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- tx.getOrCreateResource(getResourcePath("/test"));
- tx.close();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return resourceSet.getResources().isEmpty();
- }
- }.assertNoTimeOut();
- }
-
- public void testBugzilla_279565_TXListener() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- final ResourceSet resourceSet = tx.getResourceSet();
- tx.addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- throw new IllegalStateException("Simulated exception");
- }
- });
-
- tx.getOrCreateResource(getResourcePath("/test"));
- tx.close();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return resourceSet.getResources().isEmpty();
- }
- }.assertNoTimeOut();
- }
-
- public void testBugzilla_279565_AddedFromRemote() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- final ResourceSet resourceSet = tx.getResourceSet();
- resourceSet.eAdapters().add(new AdapterImpl()
- {
- @Override
- public void notifyChanged(Notification msg)
- {
- throw new IllegalStateException("Simulated exception");
- }
- });
-
- CDOSession session2 = openSession();
- CDOTransaction tx2 = session2.openTransaction();
- tx2.getOrCreateResource(getResourcePath("/test"));
- session2.close();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return resourceSet.getResources().size() == 1;
- }
- };
-
- tx.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+/**
+ * Invalid listener might prevent CDOTransaction to close properly
+ * <p>
+ * See bug 279565
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_279565_Test extends AbstractCDOTest
+{
+ public void testBugzilla_279565() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ final ResourceSet resourceSet = tx.getResourceSet();
+ resourceSet.eAdapters().add(new AdapterImpl()
+ {
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ throw new IllegalStateException("Simulated exception");
+ }
+ });
+
+ try
+ {
+ tx.getOrCreateResource(getResourcePath("/test"));
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException sucess)
+ {
+ }
+
+ tx.close();
+
+ new PollingTimeOuter()
+ {
+
+ @Override
+ protected boolean successful()
+ {
+ return resourceSet.getResources().isEmpty();
+ }
+ };
+ }
+
+ public void testBugzilla_279565_OwnResourceSet() throws Exception
+ {
+ final ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.eAdapters().add(new AdapterImpl()
+ {
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ throw new IllegalStateException("Simulated exception");
+ }
+ });
+
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ tx.getOrCreateResource(getResourcePath("/test"));
+ tx.close();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return resourceSet.getResources().isEmpty();
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testBugzilla_279565_TXListener() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ final ResourceSet resourceSet = tx.getResourceSet();
+ tx.addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ throw new IllegalStateException("Simulated exception");
+ }
+ });
+
+ tx.getOrCreateResource(getResourcePath("/test"));
+ tx.close();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return resourceSet.getResources().isEmpty();
+ }
+ }.assertNoTimeOut();
+ }
+
+ public void testBugzilla_279565_AddedFromRemote() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ final ResourceSet resourceSet = tx.getResourceSet();
+ resourceSet.eAdapters().add(new AdapterImpl()
+ {
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ throw new IllegalStateException("Simulated exception");
+ }
+ });
+
+ CDOSession session2 = openSession();
+ CDOTransaction tx2 = session2.openTransaction();
+ tx2.getOrCreateResource(getResourcePath("/test"));
+ session2.close();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return resourceSet.getResources().size() == 1;
+ }
+ };
+
+ tx.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279982_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279982_Test.java
index 60c43b6e03..98da37f12b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279982_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279982_Test.java
@@ -1,214 +1,214 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.model4.GenRefMultiNonContained;
-import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
-import org.eclipse.emf.cdo.tests.model4.GenRefSingleNonContained;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.ObjectNotFoundException;
-import org.eclipse.emf.cdo.view.CDOStaleReferencePolicy;
-
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * Deadlock in CDOView
- * <p>
- * See bug 279982
- *
- * @author Simon McDuff
- */
-public class Bugzilla_279982_Test extends AbstractCDOTest
-{
- // As log as there is no getter interception, stale reference cannot be detected for legacy
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void testBugzilla_279982_Single() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
- tx.options().setStaleReferencePolicy(CDOStaleReferencePolicy.PROXY);
- GenRefSingleContained container = getModel4Factory().createGenRefSingleContained();
- GenRefSingleNonContained reference = getModel4Factory().createGenRefSingleNonContained();
- GenRefSingleNonContained contained = getModel4Factory().createGenRefSingleNonContained();
- container.setElement(contained);
- reference.setElement(contained);
- res.getContents().add(container);
- res.getContents().add(reference);
- tx.commit();
- container.setElement(null);
- tx.commit();
-
- assertNull(container.getElement());
- EObject element = reference.getElement();
- assertNotNull(element);
-
- try
- {
- assertEquals(true, CDOUtil.isStaleObject(element));
- element.eContainer();
- fail("Should fail");
- }
- catch (ObjectNotFoundException ex)
- {
- // ignore
- }
- catch (Exception ex)
- {
- fail("Should have an ObjectNotFoundException");
- }
-
- tx.options().setStaleReferencePolicy(CDOStaleReferencePolicy.EXCEPTION);
-
- try
- {
- reference.getElement();
- fail("Should fail");
- }
- catch (ObjectNotFoundException ex)
- {
- // ignore
- }
- catch (Exception ex)
- {
- fail("Should have an ObjectNotFoundException");
- }
-
- CDOUtil.cleanStaleReference(reference, getModel4Package().getGenRefSingleNonContained_Element());
- assertNull(reference.getElement());
- tx.commit();
-
- clearCache(session.getRevisionManager());
-
- // Verification that the commit is good
- tx = session.openTransaction();
- res = tx.getOrCreateResource(getResourcePath("/resource1"));
- reference = (GenRefSingleNonContained)res.getContents().get(1);
- assertNull(reference.getElement());
- }
-
- // As log as there is no getter interception, stale reference cannot be detected for legacy
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void testBugzilla_279982_Multi() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
- tx.options().setStaleReferencePolicy(CDOStaleReferencePolicy.PROXY);
- GenRefSingleContained container = getModel4Factory().createGenRefSingleContained();
- GenRefMultiNonContained reference = getModel4Factory().createGenRefMultiNonContained();
- GenRefSingleNonContained contained = getModel4Factory().createGenRefSingleNonContained();
- container.setElement(contained);
- reference.getElements().add(contained);
- res.getContents().add(container);
- res.getContents().add(reference);
- tx.commit();
- container.setElement(null);
- tx.commit();
-
- assertNull(container.getElement());
- assertNotNull(reference.getElements().get(0));
-
- tx.options().setStaleReferencePolicy(CDOStaleReferencePolicy.EXCEPTION);
-
- try
- {
- reference.getElements().get(0);
- fail("Should fail");
- }
- catch (ObjectNotFoundException ex)
- {
- // ignore
- }
- catch (Exception ex)
- {
- fail("Should have an ObjectNotFoundException");
- }
-
- CDOUtil.cleanStaleReference(reference, getModel4Package().getGenRefMultiNonContained_Elements(), 0);
- assertEquals(0, reference.getElements().size());
- tx.commit();
-
- clearCache(session.getRevisionManager());
-
- // Verification that the commit is good
- tx = session.openTransaction();
- res = tx.getOrCreateResource(getResourcePath("/resource1"));
- reference = (GenRefMultiNonContained)res.getContents().get(1);
- assertEquals(0, reference.getElements().size());
- }
-
- // As log as there is no getter interception, stale reference cannot be detected for legacy
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void testBugzilla_279982_Multi_RevisionPrefetchingPolicy() throws Exception
- {
- CDOSession session = openSession();
- {
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
- // tx.options().setUnresolveableObjectToNullEnabled(true);
- GenRefSingleContained container = getModel4Factory().createGenRefSingleContained();
- GenRefMultiNonContained reference = getModel4Factory().createGenRefMultiNonContained();
- GenRefSingleNonContained contained = getModel4Factory().createGenRefSingleNonContained();
- GenRefSingleNonContained contained2 = getModel4Factory().createGenRefSingleNonContained();
- container.setElement(contained);
- reference.getElements().add(contained);
- reference.getElements().add(contained2);
- res.getContents().add(container);
- res.getContents().add(reference);
- res.getContents().add(contained2);
- tx.commit();
- res.getContents().remove(contained2);
- tx.commit();
- }
-
- clearCache(session.getRevisionManager());
-
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
-
- tx.options().setRevisionPrefetchingPolicy(CDOUtil.createRevisionPrefetchingPolicy(100));
- GenRefMultiNonContained reference = (GenRefMultiNonContained)res.getContents().get(1);
-
- assertNotNull(reference.getElements().get(0));
-
- try
- {
- assertNotNull(reference.getElements().get(1));
- fail("Should fail");
- }
- catch (ObjectNotFoundException ex)
- {
- // ignore
- }
- catch (Exception ex)
- {
- fail("Should have an ObjectNotFoundException");
- }
-
- CDOUtil.cleanStaleReference(reference, getModel4Package().getGenRefMultiNonContained_Elements(), 0);
- assertEquals(1, reference.getElements().size());
- tx.commit();
-
- clearCache(session.getRevisionManager());
-
- // Verification that the commit is good
- tx = session.openTransaction();
- res = tx.getOrCreateResource(getResourcePath("/resource1"));
- reference = (GenRefMultiNonContained)res.getContents().get(1);
- assertEquals(1, reference.getElements().size());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.model4.GenRefMultiNonContained;
+import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
+import org.eclipse.emf.cdo.tests.model4.GenRefSingleNonContained;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+import org.eclipse.emf.cdo.view.CDOStaleReferencePolicy;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * Deadlock in CDOView
+ * <p>
+ * See bug 279982
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_279982_Test extends AbstractCDOTest
+{
+ // As log as there is no getter interception, stale reference cannot be detected for legacy
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void testBugzilla_279982_Single() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
+ tx.options().setStaleReferencePolicy(CDOStaleReferencePolicy.PROXY);
+ GenRefSingleContained container = getModel4Factory().createGenRefSingleContained();
+ GenRefSingleNonContained reference = getModel4Factory().createGenRefSingleNonContained();
+ GenRefSingleNonContained contained = getModel4Factory().createGenRefSingleNonContained();
+ container.setElement(contained);
+ reference.setElement(contained);
+ res.getContents().add(container);
+ res.getContents().add(reference);
+ tx.commit();
+ container.setElement(null);
+ tx.commit();
+
+ assertNull(container.getElement());
+ EObject element = reference.getElement();
+ assertNotNull(element);
+
+ try
+ {
+ assertEquals(true, CDOUtil.isStaleObject(element));
+ element.eContainer();
+ fail("Should fail");
+ }
+ catch (ObjectNotFoundException ex)
+ {
+ // ignore
+ }
+ catch (Exception ex)
+ {
+ fail("Should have an ObjectNotFoundException");
+ }
+
+ tx.options().setStaleReferencePolicy(CDOStaleReferencePolicy.EXCEPTION);
+
+ try
+ {
+ reference.getElement();
+ fail("Should fail");
+ }
+ catch (ObjectNotFoundException ex)
+ {
+ // ignore
+ }
+ catch (Exception ex)
+ {
+ fail("Should have an ObjectNotFoundException");
+ }
+
+ CDOUtil.cleanStaleReference(reference, getModel4Package().getGenRefSingleNonContained_Element());
+ assertNull(reference.getElement());
+ tx.commit();
+
+ clearCache(session.getRevisionManager());
+
+ // Verification that the commit is good
+ tx = session.openTransaction();
+ res = tx.getOrCreateResource(getResourcePath("/resource1"));
+ reference = (GenRefSingleNonContained)res.getContents().get(1);
+ assertNull(reference.getElement());
+ }
+
+ // As log as there is no getter interception, stale reference cannot be detected for legacy
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void testBugzilla_279982_Multi() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
+ tx.options().setStaleReferencePolicy(CDOStaleReferencePolicy.PROXY);
+ GenRefSingleContained container = getModel4Factory().createGenRefSingleContained();
+ GenRefMultiNonContained reference = getModel4Factory().createGenRefMultiNonContained();
+ GenRefSingleNonContained contained = getModel4Factory().createGenRefSingleNonContained();
+ container.setElement(contained);
+ reference.getElements().add(contained);
+ res.getContents().add(container);
+ res.getContents().add(reference);
+ tx.commit();
+ container.setElement(null);
+ tx.commit();
+
+ assertNull(container.getElement());
+ assertNotNull(reference.getElements().get(0));
+
+ tx.options().setStaleReferencePolicy(CDOStaleReferencePolicy.EXCEPTION);
+
+ try
+ {
+ reference.getElements().get(0);
+ fail("Should fail");
+ }
+ catch (ObjectNotFoundException ex)
+ {
+ // ignore
+ }
+ catch (Exception ex)
+ {
+ fail("Should have an ObjectNotFoundException");
+ }
+
+ CDOUtil.cleanStaleReference(reference, getModel4Package().getGenRefMultiNonContained_Elements(), 0);
+ assertEquals(0, reference.getElements().size());
+ tx.commit();
+
+ clearCache(session.getRevisionManager());
+
+ // Verification that the commit is good
+ tx = session.openTransaction();
+ res = tx.getOrCreateResource(getResourcePath("/resource1"));
+ reference = (GenRefMultiNonContained)res.getContents().get(1);
+ assertEquals(0, reference.getElements().size());
+ }
+
+ // As log as there is no getter interception, stale reference cannot be detected for legacy
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void testBugzilla_279982_Multi_RevisionPrefetchingPolicy() throws Exception
+ {
+ CDOSession session = openSession();
+ {
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
+ // tx.options().setUnresolveableObjectToNullEnabled(true);
+ GenRefSingleContained container = getModel4Factory().createGenRefSingleContained();
+ GenRefMultiNonContained reference = getModel4Factory().createGenRefMultiNonContained();
+ GenRefSingleNonContained contained = getModel4Factory().createGenRefSingleNonContained();
+ GenRefSingleNonContained contained2 = getModel4Factory().createGenRefSingleNonContained();
+ container.setElement(contained);
+ reference.getElements().add(contained);
+ reference.getElements().add(contained2);
+ res.getContents().add(container);
+ res.getContents().add(reference);
+ res.getContents().add(contained2);
+ tx.commit();
+ res.getContents().remove(contained2);
+ tx.commit();
+ }
+
+ clearCache(session.getRevisionManager());
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.getOrCreateResource(getResourcePath("/resource1"));
+
+ tx.options().setRevisionPrefetchingPolicy(CDOUtil.createRevisionPrefetchingPolicy(100));
+ GenRefMultiNonContained reference = (GenRefMultiNonContained)res.getContents().get(1);
+
+ assertNotNull(reference.getElements().get(0));
+
+ try
+ {
+ assertNotNull(reference.getElements().get(1));
+ fail("Should fail");
+ }
+ catch (ObjectNotFoundException ex)
+ {
+ // ignore
+ }
+ catch (Exception ex)
+ {
+ fail("Should have an ObjectNotFoundException");
+ }
+
+ CDOUtil.cleanStaleReference(reference, getModel4Package().getGenRefMultiNonContained_Elements(), 0);
+ assertEquals(1, reference.getElements().size());
+ tx.commit();
+
+ clearCache(session.getRevisionManager());
+
+ // Verification that the commit is good
+ tx = session.openTransaction();
+ res = tx.getOrCreateResource(getResourcePath("/resource1"));
+ reference = (GenRefMultiNonContained)res.getContents().get(1);
+ assertEquals(1, reference.getElements().size());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java
index 00a916b4f9..d5b0750bb5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java
@@ -1,318 +1,318 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.common.notify.Notification;
-
-/**
- * CDOObjects should send normal EMF notifications on rollback.
- * <p>
- * See bug 283131.
- *
- * @author Pascal Lehmann
- * @since 4.0
- */
-public class Bugzilla_283131_Test extends AbstractCDOTest
-{
- public void testRollbackSingleNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- // create initial model.
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- Company company = getModel1Factory().createCompany();
- company.setName("company1");
- resource.getContents().add(company);
- transaction.commit();
-
- // do a single change on object without commit.
- company.setName("company2");
-
- // add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
-
- // rollback.
- transaction.rollback();
-
- // access object.
- company.getName();
-
- // check rollback notifications.
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
-
- assertEquals("company1", testAdapter.getNotifications()[0].getNewValue());
- }
-
- public void testRollbackSingleRemoveNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- // create initial model.
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- Company company = getModel1Factory().createCompany();
- company.getCustomers().add(getModel1Factory().createCustomer());
- resource.getContents().add(company);
- transaction.commit();
-
- // do add containment to object without commit.
- company.getCustomers().add(getModel1Factory().createCustomer());
-
- // add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
-
- // rollback.
- transaction.rollback();
-
- // access object.
- company.getName();
-
- // check rollback notifications.
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
-
- assertEquals(Notification.REMOVE, testAdapter.getNotifications()[0].getEventType());
- assertEquals(getModel1Package().getCompany_Customers(), testAdapter.getNotifications()[0].getFeature());
- }
-
- public void testRollbackSingleAddNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- // create initial model.
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- Company company = getModel1Factory().createCompany();
- company.getCustomers().add(getModel1Factory().createCustomer());
- resource.getContents().add(company);
- transaction.commit();
-
- // do multiple changes on object without commit.
- company.getCustomers().remove(0);
-
- // add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
-
- // rollback.
- transaction.rollback();
-
- // access object.
- company.getName();
-
- // check rollback notifications.
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
-
- assertEquals(Notification.ADD, testAdapter.getNotifications()[0].getEventType());
- assertEquals(getModel1Package().getCompany_Customers(), testAdapter.getNotifications()[0].getFeature());
- }
-
- public void testRollbackManyNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- // create initial model.
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- Company company = getModel1Factory().createCompany();
- company.setName("company1");
- company.setStreet("street1");
- resource.getContents().add(company);
- transaction.commit();
-
- // do multiple changes on object without commit.
- company.setName("company2");
- company.setStreet("street2");
-
- // add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
-
- // rollback.
- transaction.rollback();
-
- // access object.
- company.getName();
-
- // check rollback notifications.
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 2;
- }
- }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
-
- for (Notification notification : testAdapter.getNotifications())
- {
- if (notification.getFeature().equals(getModel1Package().getAddress_Name()))
- {
- assertEquals("company1", notification.getNewValue());
- }
- else if (notification.getFeature().equals(getModel1Package().getAddress_Street()))
- {
- assertEquals("street1", notification.getNewValue());
- }
- else
- {
- fail("Unexpected notification: " + notification);
- }
- }
- }
-
- public void testRollbackSingleConflictNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- // create initial model.
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- Company company = getModel1Factory().createCompany();
- company.setName("company1");
- resource.getContents().add(company);
- transaction.commit();
-
- // do a single change on object without commit.
- company.setName("company2");
-
- // create a conflict on object.
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = transaction2.getObject(company);
- company2.setName("company3");
- commitAndSync(transaction2, transaction);
-
- // add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
-
- // rollback.
- transaction.rollback();
-
- // access object.
- company.getName();
-
- // check rollback notifications.
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
-
- assertEquals("company3", testAdapter.getNotifications()[0].getNewValue());
- }
-
- public void testRollbackManyConflictNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- // create initial model.
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
- Company company = getModel1Factory().createCompany();
- company.setName("company1");
- company.setCity("city1");
- company.getCustomers().add(getModel1Factory().createCustomer());
- resource.getContents().add(company);
- transaction.commit();
-
- // do multiple change on object without commit.
- company.setName("company2");
- company.setCity("city2");
- company.getCustomers().remove(0);
-
- // create a conflict on object.
- CDOTransaction transaction2 = session.openTransaction();
- Company company2 = (Company)CDOUtil.getEObject(transaction2.getObject(company));
- company2.setName("company3");
- company2.setCity("city3");
- company2.getCustomers().add(getModel1Factory().createCustomer());
- commitAndSync(transaction2, transaction);
-
- // add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
-
- // rollback.
- transaction.rollback();
-
- // access object.
- company.getName();
-
- // check rollback notifications.
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 4;
- }
- }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
-
- int customerCounter = 0;
- for (Notification notification : testAdapter.getNotifications())
- {
- if (notification.getFeature().equals(getModel1Package().getCompany_Customers())
- && notification.getEventType() == Notification.ADD)
- {
- customerCounter++;
- }
- else if (notification.getFeature().equals(getModel1Package().getAddress_Name()))
- {
- assertEquals("company3", notification.getNewValue());
- }
- else if (notification.getFeature().equals(getModel1Package().getAddress_City()))
- {
- assertEquals("city3", notification.getNewValue());
- }
- else
- {
- fail("Unexpected notification: " + notification);
- }
- }
-
- assertEquals(company.getCustomers().size(), customerCounter);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.notify.Notification;
+
+/**
+ * CDOObjects should send normal EMF notifications on rollback.
+ * <p>
+ * See bug 283131.
+ *
+ * @author Pascal Lehmann
+ * @since 4.0
+ */
+public class Bugzilla_283131_Test extends AbstractCDOTest
+{
+ public void testRollbackSingleNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ // create initial model.
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ Company company = getModel1Factory().createCompany();
+ company.setName("company1");
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // do a single change on object without commit.
+ company.setName("company2");
+
+ // add adapter.
+ final TestAdapter testAdapter = new TestAdapter();
+ company.eAdapters().add(testAdapter);
+
+ // rollback.
+ transaction.rollback();
+
+ // access object.
+ company.getName();
+
+ // check rollback notifications.
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
+
+ assertEquals("company1", testAdapter.getNotifications()[0].getNewValue());
+ }
+
+ public void testRollbackSingleRemoveNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ // create initial model.
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ Company company = getModel1Factory().createCompany();
+ company.getCustomers().add(getModel1Factory().createCustomer());
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // do add containment to object without commit.
+ company.getCustomers().add(getModel1Factory().createCustomer());
+
+ // add adapter.
+ final TestAdapter testAdapter = new TestAdapter();
+ company.eAdapters().add(testAdapter);
+
+ // rollback.
+ transaction.rollback();
+
+ // access object.
+ company.getName();
+
+ // check rollback notifications.
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
+
+ assertEquals(Notification.REMOVE, testAdapter.getNotifications()[0].getEventType());
+ assertEquals(getModel1Package().getCompany_Customers(), testAdapter.getNotifications()[0].getFeature());
+ }
+
+ public void testRollbackSingleAddNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ // create initial model.
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ Company company = getModel1Factory().createCompany();
+ company.getCustomers().add(getModel1Factory().createCustomer());
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // do multiple changes on object without commit.
+ company.getCustomers().remove(0);
+
+ // add adapter.
+ final TestAdapter testAdapter = new TestAdapter();
+ company.eAdapters().add(testAdapter);
+
+ // rollback.
+ transaction.rollback();
+
+ // access object.
+ company.getName();
+
+ // check rollback notifications.
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
+
+ assertEquals(Notification.ADD, testAdapter.getNotifications()[0].getEventType());
+ assertEquals(getModel1Package().getCompany_Customers(), testAdapter.getNotifications()[0].getFeature());
+ }
+
+ public void testRollbackManyNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ // create initial model.
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ Company company = getModel1Factory().createCompany();
+ company.setName("company1");
+ company.setStreet("street1");
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // do multiple changes on object without commit.
+ company.setName("company2");
+ company.setStreet("street2");
+
+ // add adapter.
+ final TestAdapter testAdapter = new TestAdapter();
+ company.eAdapters().add(testAdapter);
+
+ // rollback.
+ transaction.rollback();
+
+ // access object.
+ company.getName();
+
+ // check rollback notifications.
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 2;
+ }
+ }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
+
+ for (Notification notification : testAdapter.getNotifications())
+ {
+ if (notification.getFeature().equals(getModel1Package().getAddress_Name()))
+ {
+ assertEquals("company1", notification.getNewValue());
+ }
+ else if (notification.getFeature().equals(getModel1Package().getAddress_Street()))
+ {
+ assertEquals("street1", notification.getNewValue());
+ }
+ else
+ {
+ fail("Unexpected notification: " + notification);
+ }
+ }
+ }
+
+ public void testRollbackSingleConflictNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ // create initial model.
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ Company company = getModel1Factory().createCompany();
+ company.setName("company1");
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // do a single change on object without commit.
+ company.setName("company2");
+
+ // create a conflict on object.
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = transaction2.getObject(company);
+ company2.setName("company3");
+ commitAndSync(transaction2, transaction);
+
+ // add adapter.
+ final TestAdapter testAdapter = new TestAdapter();
+ company.eAdapters().add(testAdapter);
+
+ // rollback.
+ transaction.rollback();
+
+ // access object.
+ company.getName();
+
+ // check rollback notifications.
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
+
+ assertEquals("company3", testAdapter.getNotifications()[0].getNewValue());
+ }
+
+ public void testRollbackManyConflictNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ // create initial model.
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+ Company company = getModel1Factory().createCompany();
+ company.setName("company1");
+ company.setCity("city1");
+ company.getCustomers().add(getModel1Factory().createCustomer());
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // do multiple change on object without commit.
+ company.setName("company2");
+ company.setCity("city2");
+ company.getCustomers().remove(0);
+
+ // create a conflict on object.
+ CDOTransaction transaction2 = session.openTransaction();
+ Company company2 = (Company)CDOUtil.getEObject(transaction2.getObject(company));
+ company2.setName("company3");
+ company2.setCity("city3");
+ company2.getCustomers().add(getModel1Factory().createCustomer());
+ commitAndSync(transaction2, transaction);
+
+ // add adapter.
+ final TestAdapter testAdapter = new TestAdapter();
+ company.eAdapters().add(testAdapter);
+
+ // rollback.
+ transaction.rollback();
+
+ // access object.
+ company.getName();
+
+ // check rollback notifications.
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 4;
+ }
+ }.assertNoTimeOut(DEFAULT_TIMEOUT_EXPECTED);
+
+ int customerCounter = 0;
+ for (Notification notification : testAdapter.getNotifications())
+ {
+ if (notification.getFeature().equals(getModel1Package().getCompany_Customers())
+ && notification.getEventType() == Notification.ADD)
+ {
+ customerCounter++;
+ }
+ else if (notification.getFeature().equals(getModel1Package().getAddress_Name()))
+ {
+ assertEquals("company3", notification.getNewValue());
+ }
+ else if (notification.getFeature().equals(getModel1Package().getAddress_City()))
+ {
+ assertEquals("city3", notification.getNewValue());
+ }
+ else
+ {
+ fail("Unexpected notification: " + notification);
+ }
+ }
+
+ assertEquals(company.getCustomers().size(), customerCounter);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_1_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_1_Test.java
index ceb28d4c2b..91d74ac692 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_1_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_1_Test.java
@@ -1,565 +1,565 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.GenRefMultiContained;
-import org.eclipse.emf.cdo.tests.model4.GenRefMultiNonContained;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.tests.model4.model4Package;
-import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.ObjectNotFoundException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.command.BasicCommandStack;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.DragAndDropCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_283985_1_Test extends AbstractCDOTest
-{
- public void testBugzilla283985_PlainSingle() throws CommitException
- {
- runWithClosure(new SingleItemClosure()
- {
- public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
- {
- for (OrderDetail detail : details)
- {
- Order order = (Order)detail.eContainer();
- order.getOrderDetails().remove(detail);
- target.getOrderDetails().add(detail);
- }
- }
- });
- }
-
- public void testBugzilla283985_PlainMultiple() throws CommitException
- {
- runWithClosure(new MultiItemClosure()
- {
- public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
- {
- for (OrderDetail detail : details)
- {
- Order order = (Order)detail.eContainer();
- order.getOrderDetails().remove(detail);
- target.getOrderDetails().add(detail);
- }
- }
- });
- }
-
- public void testBugzilla283985_DragAndDropSingle() throws CommitException
- {
- runWithClosure(new SingleItemClosure()
- {
- public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
- {
- float location = 0.5f;
- int operations = 7;
- int operation = 2;
-
- Command cmd = DragAndDropCommand.create(domain, target, location, operations, operation, details);
- domain.getCommandStack().execute(cmd);
- }
- });
- }
-
- public void testBugzilla283985_DragAndDropMultiple() throws CommitException
- {
- runWithClosure(new MultiItemClosure()
- {
- public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
- {
- float location = 0.5f;
- int operations = 7;
- int operation = 2;
-
- Command cmd = DragAndDropCommand.create(domain, target, location, operations, operation, details);
- domain.getCommandStack().execute(cmd);
- }
- });
- }
-
- public void testBugzilla283985_DragAndDropMultipleMultiparent() throws CommitException
- {
- runWithClosure(new MultiItemMultiParentClosure()
- {
- public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
- {
- float location = 0.5f;
- int operations = 7;
- int operation = 2;
-
- Command cmd = DragAndDropCommand.create(domain, target, location, operations, operation, details);
- domain.getCommandStack().execute(cmd);
- }
- });
- }
-
- public void testBugzilla283985_RemoveAndAddSingle() throws CommitException
- {
- runWithClosure(new SingleItemClosure()
- {
- public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
- {
- Command dragCmd = RemoveCommand.create(domain, details);
- Command dropCmd = AddCommand.create(domain, target, null, details);
- domain.getCommandStack().execute(dragCmd);
- domain.getCommandStack().execute(dropCmd);
- }
- });
- }
-
- public void testBugzilla283985_RemoveAndAddMultiple() throws CommitException
- {
- runWithClosure(new MultiItemClosure()
- {
- public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
- {
- Command dragCmd = RemoveCommand.create(domain, details);
- Command dropCmd = AddCommand.create(domain, target, null, details);
- domain.getCommandStack().execute(dragCmd);
- domain.getCommandStack().execute(dropCmd);
- }
- });
- }
-
- private void runWithClosure(IClosure closure) throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
- r1.getContents().clear();
-
- // Set things up
- Model1Factory factory = getModel1Factory();
- Order order1 = factory.createPurchaseOrder();
- Order order2 = factory.createPurchaseOrder();
- Order order3 = factory.createPurchaseOrder();
- OrderDetail detail1 = factory.createOrderDetail();
- OrderDetail detail2 = factory.createOrderDetail();
- OrderDetail detail3 = factory.createOrderDetail();
- OrderDetail detail4 = factory.createOrderDetail();
- OrderDetail detail5 = factory.createOrderDetail();
- OrderDetail detail6 = factory.createOrderDetail();
- OrderDetail detail7 = factory.createOrderDetail();
- OrderDetail detail8 = factory.createOrderDetail();
- OrderDetail detail9 = factory.createOrderDetail();
- OrderDetail detail10 = factory.createOrderDetail();
- OrderDetail detail11 = factory.createOrderDetail();
- OrderDetail detail12 = factory.createOrderDetail();
- order1.getOrderDetails().add(detail1);
- order1.getOrderDetails().add(detail2);
- order1.getOrderDetails().add(detail3);
- order1.getOrderDetails().add(detail4);
- order2.getOrderDetails().add(detail5);
- order2.getOrderDetails().add(detail6);
- order2.getOrderDetails().add(detail7);
- order2.getOrderDetails().add(detail8);
- order3.getOrderDetails().add(detail9);
- order3.getOrderDetails().add(detail10);
- order3.getOrderDetails().add(detail11);
- order3.getOrderDetails().add(detail12);
- r1.getContents().add(order1);
- r1.getContents().add(order2);
- r1.getContents().add(order3);
-
- // Commit so that everything gets a CDOID
- tx.commit();
-
- // Create some versions
- detail1.setPrice(10.0f);
- tx.commit();
- detail1.setPrice(20.0f);
- tx.commit();
-
- // Ask closure to pick items to be moved
- //
- Collection<OrderDetail> details = closure.pickDetails(new OrderDetail[] { detail1, detail2, detail3, detail4,
- detail5, detail6, detail7, detail8, detail9, detail10, detail11, detail12, });
-
- // Keep references to the current CDOIDs and versions, to be used in the test
- CDOID[] idsBefore = new CDOID[details.size()];
- int[] versionsBefore = new int[details.size()];
- int i = 0;
- for (OrderDetail detail : details)
- {
- idsBefore[i] = CDOUtil.getCDOObject(detail).cdoID();
- versionsBefore[i] = CDOUtil.getCDOObject(detail).cdoRevision().getVersion();
- i++;
- }
-
- // Bring the resourceset under an editing domain
- ResourceSet rs = tx.getResourceSet();
- AdapterFactory adapterFact = new ReflectiveItemProviderAdapterFactory();
- CommandStack cs = new SaneCommandStack();
- EditingDomain domain = new AdapterFactoryEditingDomain(adapterFact, cs, rs);
-
- // Delegate test operation to the closure
- //
- closure.test(domain, details, order3);
-
- // Are the order details' CDOIDs still the same?
- //
- i = 0;
- for (OrderDetail detail : details)
- {
- CDOID idAfter = CDOUtil.getCDOObject(detail).cdoID();
- CDOID idBefore = idsBefore[i];
- assertEquals(idBefore, idAfter);
-
- int versionAfter = CDOUtil.getCDOObject(detail).cdoRevision().getVersion();
- int versionBefore = versionsBefore[i];
- assertEquals(versionBefore, versionAfter);
-
- i++;
- }
-
- tx.commit();
-
- // Check again
- //
- i = 0;
- for (OrderDetail detail : details)
- {
- CDOID idAfter = CDOUtil.getCDOObject(detail).cdoID();
- CDOID idBefore = idsBefore[i];
- assertEquals(idBefore, idAfter);
-
- int versionAfter = CDOUtil.getCDOObject(detail).cdoRevision().getVersion();
- int versionBefore = versionsBefore[i];
- assertEquals(versionBefore + 1, versionAfter);
-
- i++;
- }
-
- session.refresh();
-
- // Check again
- //
- i = 0;
- for (OrderDetail detail : details)
- {
- CDOID idAfter = CDOUtil.getCDOObject(detail).cdoID();
- CDOID idBefore = idsBefore[i];
- assertEquals(idBefore, idAfter);
-
- int versionAfter = CDOUtil.getCDOObject(detail).cdoRevision().getVersion();
- int versionBefore = versionsBefore[i];
- assertEquals(versionBefore + 1, versionAfter);
-
- i++;
- }
-
- tx.close();
- session.close();
- }
-
- public void testEReferencesCorrupted() throws CommitException
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model4Package.eINSTANCE);
- session.getPackageRegistry().putEPackage(model4interfacesPackage.eINSTANCE);
-
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test/1"));
-
- GenRefMultiContained container1 = model4Factory.eINSTANCE.createGenRefMultiContained();
- GenRefMultiContained container2 = model4Factory.eINSTANCE.createGenRefMultiContained();
- ContainedElementNoOpposite element = model4Factory.eINSTANCE.createContainedElementNoOpposite();
- GenRefMultiNonContained referee = model4Factory.eINSTANCE.createGenRefMultiNonContained();
-
- container1.getElements().add(element);
- referee.getElements().add(element);
-
- res.getContents().add(container1);
- res.getContents().add(container2);
- res.getContents().add(referee);
-
- tx.commit();
-
- container1.getElements().remove(element);
- container2.getElements().add(element);
-
- tx.commit();
- tx.close();
-
- // === NEW TX ===
-
- tx = session.openTransaction();
- res = tx.getResource(getResourcePath("/test/1"));
-
- container1 = (GenRefMultiContained)res.getContents().get(0);
- container2 = (GenRefMultiContained)res.getContents().get(1);
- referee = (GenRefMultiNonContained)res.getContents().get(2);
-
- try
- {
- element = (ContainedElementNoOpposite)referee.getElements().get(0);
- }
- catch (ObjectNotFoundException e)
- {
- fail("Should not have thrown ObjectNotFoundException");
- }
-
- tx.close();
- session.close();
- clearCache(getRepository().getRevisionManager());
- }
-
- // TODO Fix bug 344072
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void testAddRemoveSequence() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
- r1.getContents().clear();
-
- // Set things up
- Model1Factory factory = getModel1Factory();
- Order order1 = factory.createPurchaseOrder();
- Order order2 = factory.createPurchaseOrder();
- OrderDetail detail1 = factory.createOrderDetail();
- r1.getContents().add(order1);
- r1.getContents().add(order2);
- order2.getOrderDetails().add(detail1);
- tx.commit();
-
- order2.getOrderDetails().remove(detail1);
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(detail1).cdoState());
-
- order1.getOrderDetails().add(detail1);
- assertEquals(true, order1.getOrderDetails().contains(detail1));
- assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(detail1).cdoState());
-
- order1.getOrderDetails().remove(detail1);
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(detail1).cdoState());
-
- order2.getOrderDetails().add(detail1);
- assertEquals(true, order2.getOrderDetails().contains(detail1));
- assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(detail1).cdoState());
-
- order2.getOrderDetails().remove(detail1);
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(detail1).cdoState());
-
- order1.getOrderDetails().add(detail1);
- assertEquals(true, order1.getOrderDetails().contains(detail1));
- assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(detail1).cdoState());
-
- order1.getOrderDetails().remove(detail1);
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(detail1).cdoState());
-
- tx.commit();
-
- order1.getOrderDetails().add(detail1);
- assertEquals(true, order1.getOrderDetails().contains(detail1));
- order1.getOrderDetails().remove(detail1);
-
- order2.getOrderDetails().add(detail1);
- assertEquals(true, order2.getOrderDetails().contains(detail1));
- order2.getOrderDetails().remove(detail1);
-
- order1.getOrderDetails().add(detail1);
- assertEquals(true, order1.getOrderDetails().contains(detail1));
- order1.getOrderDetails().remove(detail1);
-
- tx.close();
- session.close();
- }
-
- public void testCanDaDmoreThanOnce() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
- r1.getContents().clear();
-
- // Set things up
- Model1Factory factory = getModel1Factory();
- Order order1 = factory.createPurchaseOrder();
- Order order2 = factory.createPurchaseOrder();
- OrderDetail detail1 = factory.createOrderDetail();
- order1.getOrderDetails().add(detail1);
- r1.getContents().add(order1);
- r1.getContents().add(order2);
-
- // Commit so that everything gets a CDOID
- tx.commit();
-
- // Bring the resourceset under an editing domain
- ResourceSet rs = tx.getResourceSet();
- AdapterFactory adapterFact = new ReflectiveItemProviderAdapterFactory();
- CommandStack cs = new SaneCommandStack();
- EditingDomain domain = new AdapterFactoryEditingDomain(adapterFact, cs, rs);
-
- float location = 0.5f;
- int operations = 7;
- int operation = 2;
- Collection<OrderDetail> coll = Collections.singleton(detail1);
-
- assertSame(order1, detail1.eContainer());
-
- // Drag and drop #1
- Command cmd = DragAndDropCommand.create(domain, order2, location, operations, operation, coll);
- domain.getCommandStack().execute(cmd);
- assertSame(order2, detail1.eContainer());
-
- // Drag and drop #2
- cmd = DragAndDropCommand.create(domain, order1, location, operations, operation, coll);
- domain.getCommandStack().execute(cmd);
- assertSame(order1, detail1.eContainer());
- tx.commit();
- assertSame(order1, detail1.eContainer());
-
- assertSame(CDOState.CLEAN, CDOUtil.getCDOObject(detail1).cdoState());
-
- // Drag and drop #3
- cmd = DragAndDropCommand.create(domain, order2, location, operations, operation, coll);
- domain.getCommandStack().execute(cmd);
- assertSame(order2, detail1.eContainer());
-
- tx.commit();
- tx.close();
- session.close();
- }
-
- public void testCanReattachDirtyObject() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
- r1.getContents().clear();
-
- // Set things up
- Model1Factory factory = getModel1Factory();
- Order order1 = factory.createPurchaseOrder();
- Order order2 = factory.createPurchaseOrder();
- OrderDetail detail1 = factory.createOrderDetail();
- r1.getContents().add(order1);
- r1.getContents().add(order2);
- order1.getOrderDetails().add(detail1);
- tx.commit();
-
- // Make the order detail dirty
- final float PRICE = 10.0f;
- detail1.setPrice(PRICE);
-
- // Now move it
- order1.getOrderDetails().remove(detail1);
- order2.getOrderDetails().add(detail1);
- tx.commit();
-
- // See if the price update was incorporated in the commit
- {
- CDOView view = session.openView();
- CDOResource res = view.getResource(getResourcePath("/r1"));
- Order order2prime = (Order)res.getContents().get(1);
- OrderDetail od1 = order2prime.getOrderDetails().get(0);
- assertEquals(PRICE, od1.getPrice());
- view.close();
- }
- }
-
- /**
- * @author Caspar De Groot
- */
- private static class SaneCommandStack extends BasicCommandStack
- {
- @Override
- protected void handleError(Exception exception)
- {
- throw new WrappedException(exception);
- }
- }
-
- /**
- * @author Caspar De Groot
- */
- private interface IClosure
- {
- public void test(EditingDomain domain, Collection<OrderDetail> details, Order target);
-
- public Collection<OrderDetail> pickDetails(OrderDetail[] orderDetails);
- }
-
- /**
- * @author Caspar De Groot
- */
- private static abstract class SingleItemClosure implements IClosure
- {
- public Collection<OrderDetail> pickDetails(OrderDetail[] orderDetails)
- {
- return Collections.singleton(orderDetails[0]);
- }
- }
-
- /**
- * @author Caspar De Groot
- */
- private static abstract class MultiItemClosure implements IClosure
- {
- public Collection<OrderDetail> pickDetails(OrderDetail[] orderDetails)
- {
- List<OrderDetail> details = new LinkedList<OrderDetail>();
- details.add(orderDetails[0]);
- details.add(orderDetails[1]);
- return details;
- }
- }
-
- /**
- * @author Caspar De Groot
- */
- private static abstract class MultiItemMultiParentClosure implements IClosure
- {
- public Collection<OrderDetail> pickDetails(OrderDetail[] orderDetails)
- {
- List<OrderDetail> details = new LinkedList<OrderDetail>();
- details.add(orderDetails[1]);
- details.add(orderDetails[2]);
- details.add(orderDetails[5]);
- details.add(orderDetails[6]);
- return details;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.GenRefMultiContained;
+import org.eclipse.emf.cdo.tests.model4.GenRefMultiNonContained;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.tests.model4.model4Package;
+import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.DragAndDropCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_283985_1_Test extends AbstractCDOTest
+{
+ public void testBugzilla283985_PlainSingle() throws CommitException
+ {
+ runWithClosure(new SingleItemClosure()
+ {
+ public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
+ {
+ for (OrderDetail detail : details)
+ {
+ Order order = (Order)detail.eContainer();
+ order.getOrderDetails().remove(detail);
+ target.getOrderDetails().add(detail);
+ }
+ }
+ });
+ }
+
+ public void testBugzilla283985_PlainMultiple() throws CommitException
+ {
+ runWithClosure(new MultiItemClosure()
+ {
+ public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
+ {
+ for (OrderDetail detail : details)
+ {
+ Order order = (Order)detail.eContainer();
+ order.getOrderDetails().remove(detail);
+ target.getOrderDetails().add(detail);
+ }
+ }
+ });
+ }
+
+ public void testBugzilla283985_DragAndDropSingle() throws CommitException
+ {
+ runWithClosure(new SingleItemClosure()
+ {
+ public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
+ {
+ float location = 0.5f;
+ int operations = 7;
+ int operation = 2;
+
+ Command cmd = DragAndDropCommand.create(domain, target, location, operations, operation, details);
+ domain.getCommandStack().execute(cmd);
+ }
+ });
+ }
+
+ public void testBugzilla283985_DragAndDropMultiple() throws CommitException
+ {
+ runWithClosure(new MultiItemClosure()
+ {
+ public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
+ {
+ float location = 0.5f;
+ int operations = 7;
+ int operation = 2;
+
+ Command cmd = DragAndDropCommand.create(domain, target, location, operations, operation, details);
+ domain.getCommandStack().execute(cmd);
+ }
+ });
+ }
+
+ public void testBugzilla283985_DragAndDropMultipleMultiparent() throws CommitException
+ {
+ runWithClosure(new MultiItemMultiParentClosure()
+ {
+ public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
+ {
+ float location = 0.5f;
+ int operations = 7;
+ int operation = 2;
+
+ Command cmd = DragAndDropCommand.create(domain, target, location, operations, operation, details);
+ domain.getCommandStack().execute(cmd);
+ }
+ });
+ }
+
+ public void testBugzilla283985_RemoveAndAddSingle() throws CommitException
+ {
+ runWithClosure(new SingleItemClosure()
+ {
+ public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
+ {
+ Command dragCmd = RemoveCommand.create(domain, details);
+ Command dropCmd = AddCommand.create(domain, target, null, details);
+ domain.getCommandStack().execute(dragCmd);
+ domain.getCommandStack().execute(dropCmd);
+ }
+ });
+ }
+
+ public void testBugzilla283985_RemoveAndAddMultiple() throws CommitException
+ {
+ runWithClosure(new MultiItemClosure()
+ {
+ public void test(EditingDomain domain, Collection<OrderDetail> details, Order target)
+ {
+ Command dragCmd = RemoveCommand.create(domain, details);
+ Command dropCmd = AddCommand.create(domain, target, null, details);
+ domain.getCommandStack().execute(dragCmd);
+ domain.getCommandStack().execute(dropCmd);
+ }
+ });
+ }
+
+ private void runWithClosure(IClosure closure) throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
+ r1.getContents().clear();
+
+ // Set things up
+ Model1Factory factory = getModel1Factory();
+ Order order1 = factory.createPurchaseOrder();
+ Order order2 = factory.createPurchaseOrder();
+ Order order3 = factory.createPurchaseOrder();
+ OrderDetail detail1 = factory.createOrderDetail();
+ OrderDetail detail2 = factory.createOrderDetail();
+ OrderDetail detail3 = factory.createOrderDetail();
+ OrderDetail detail4 = factory.createOrderDetail();
+ OrderDetail detail5 = factory.createOrderDetail();
+ OrderDetail detail6 = factory.createOrderDetail();
+ OrderDetail detail7 = factory.createOrderDetail();
+ OrderDetail detail8 = factory.createOrderDetail();
+ OrderDetail detail9 = factory.createOrderDetail();
+ OrderDetail detail10 = factory.createOrderDetail();
+ OrderDetail detail11 = factory.createOrderDetail();
+ OrderDetail detail12 = factory.createOrderDetail();
+ order1.getOrderDetails().add(detail1);
+ order1.getOrderDetails().add(detail2);
+ order1.getOrderDetails().add(detail3);
+ order1.getOrderDetails().add(detail4);
+ order2.getOrderDetails().add(detail5);
+ order2.getOrderDetails().add(detail6);
+ order2.getOrderDetails().add(detail7);
+ order2.getOrderDetails().add(detail8);
+ order3.getOrderDetails().add(detail9);
+ order3.getOrderDetails().add(detail10);
+ order3.getOrderDetails().add(detail11);
+ order3.getOrderDetails().add(detail12);
+ r1.getContents().add(order1);
+ r1.getContents().add(order2);
+ r1.getContents().add(order3);
+
+ // Commit so that everything gets a CDOID
+ tx.commit();
+
+ // Create some versions
+ detail1.setPrice(10.0f);
+ tx.commit();
+ detail1.setPrice(20.0f);
+ tx.commit();
+
+ // Ask closure to pick items to be moved
+ //
+ Collection<OrderDetail> details = closure.pickDetails(new OrderDetail[] { detail1, detail2, detail3, detail4,
+ detail5, detail6, detail7, detail8, detail9, detail10, detail11, detail12, });
+
+ // Keep references to the current CDOIDs and versions, to be used in the test
+ CDOID[] idsBefore = new CDOID[details.size()];
+ int[] versionsBefore = new int[details.size()];
+ int i = 0;
+ for (OrderDetail detail : details)
+ {
+ idsBefore[i] = CDOUtil.getCDOObject(detail).cdoID();
+ versionsBefore[i] = CDOUtil.getCDOObject(detail).cdoRevision().getVersion();
+ i++;
+ }
+
+ // Bring the resourceset under an editing domain
+ ResourceSet rs = tx.getResourceSet();
+ AdapterFactory adapterFact = new ReflectiveItemProviderAdapterFactory();
+ CommandStack cs = new SaneCommandStack();
+ EditingDomain domain = new AdapterFactoryEditingDomain(adapterFact, cs, rs);
+
+ // Delegate test operation to the closure
+ //
+ closure.test(domain, details, order3);
+
+ // Are the order details' CDOIDs still the same?
+ //
+ i = 0;
+ for (OrderDetail detail : details)
+ {
+ CDOID idAfter = CDOUtil.getCDOObject(detail).cdoID();
+ CDOID idBefore = idsBefore[i];
+ assertEquals(idBefore, idAfter);
+
+ int versionAfter = CDOUtil.getCDOObject(detail).cdoRevision().getVersion();
+ int versionBefore = versionsBefore[i];
+ assertEquals(versionBefore, versionAfter);
+
+ i++;
+ }
+
+ tx.commit();
+
+ // Check again
+ //
+ i = 0;
+ for (OrderDetail detail : details)
+ {
+ CDOID idAfter = CDOUtil.getCDOObject(detail).cdoID();
+ CDOID idBefore = idsBefore[i];
+ assertEquals(idBefore, idAfter);
+
+ int versionAfter = CDOUtil.getCDOObject(detail).cdoRevision().getVersion();
+ int versionBefore = versionsBefore[i];
+ assertEquals(versionBefore + 1, versionAfter);
+
+ i++;
+ }
+
+ session.refresh();
+
+ // Check again
+ //
+ i = 0;
+ for (OrderDetail detail : details)
+ {
+ CDOID idAfter = CDOUtil.getCDOObject(detail).cdoID();
+ CDOID idBefore = idsBefore[i];
+ assertEquals(idBefore, idAfter);
+
+ int versionAfter = CDOUtil.getCDOObject(detail).cdoRevision().getVersion();
+ int versionBefore = versionsBefore[i];
+ assertEquals(versionBefore + 1, versionAfter);
+
+ i++;
+ }
+
+ tx.close();
+ session.close();
+ }
+
+ public void testEReferencesCorrupted() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model4Package.eINSTANCE);
+ session.getPackageRegistry().putEPackage(model4interfacesPackage.eINSTANCE);
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test/1"));
+
+ GenRefMultiContained container1 = model4Factory.eINSTANCE.createGenRefMultiContained();
+ GenRefMultiContained container2 = model4Factory.eINSTANCE.createGenRefMultiContained();
+ ContainedElementNoOpposite element = model4Factory.eINSTANCE.createContainedElementNoOpposite();
+ GenRefMultiNonContained referee = model4Factory.eINSTANCE.createGenRefMultiNonContained();
+
+ container1.getElements().add(element);
+ referee.getElements().add(element);
+
+ res.getContents().add(container1);
+ res.getContents().add(container2);
+ res.getContents().add(referee);
+
+ tx.commit();
+
+ container1.getElements().remove(element);
+ container2.getElements().add(element);
+
+ tx.commit();
+ tx.close();
+
+ // === NEW TX ===
+
+ tx = session.openTransaction();
+ res = tx.getResource(getResourcePath("/test/1"));
+
+ container1 = (GenRefMultiContained)res.getContents().get(0);
+ container2 = (GenRefMultiContained)res.getContents().get(1);
+ referee = (GenRefMultiNonContained)res.getContents().get(2);
+
+ try
+ {
+ element = (ContainedElementNoOpposite)referee.getElements().get(0);
+ }
+ catch (ObjectNotFoundException e)
+ {
+ fail("Should not have thrown ObjectNotFoundException");
+ }
+
+ tx.close();
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+ }
+
+ // TODO Fix bug 344072
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void testAddRemoveSequence() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
+ r1.getContents().clear();
+
+ // Set things up
+ Model1Factory factory = getModel1Factory();
+ Order order1 = factory.createPurchaseOrder();
+ Order order2 = factory.createPurchaseOrder();
+ OrderDetail detail1 = factory.createOrderDetail();
+ r1.getContents().add(order1);
+ r1.getContents().add(order2);
+ order2.getOrderDetails().add(detail1);
+ tx.commit();
+
+ order2.getOrderDetails().remove(detail1);
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(detail1).cdoState());
+
+ order1.getOrderDetails().add(detail1);
+ assertEquals(true, order1.getOrderDetails().contains(detail1));
+ assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(detail1).cdoState());
+
+ order1.getOrderDetails().remove(detail1);
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(detail1).cdoState());
+
+ order2.getOrderDetails().add(detail1);
+ assertEquals(true, order2.getOrderDetails().contains(detail1));
+ assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(detail1).cdoState());
+
+ order2.getOrderDetails().remove(detail1);
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(detail1).cdoState());
+
+ order1.getOrderDetails().add(detail1);
+ assertEquals(true, order1.getOrderDetails().contains(detail1));
+ assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(detail1).cdoState());
+
+ order1.getOrderDetails().remove(detail1);
+ assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(detail1).cdoState());
+
+ tx.commit();
+
+ order1.getOrderDetails().add(detail1);
+ assertEquals(true, order1.getOrderDetails().contains(detail1));
+ order1.getOrderDetails().remove(detail1);
+
+ order2.getOrderDetails().add(detail1);
+ assertEquals(true, order2.getOrderDetails().contains(detail1));
+ order2.getOrderDetails().remove(detail1);
+
+ order1.getOrderDetails().add(detail1);
+ assertEquals(true, order1.getOrderDetails().contains(detail1));
+ order1.getOrderDetails().remove(detail1);
+
+ tx.close();
+ session.close();
+ }
+
+ public void testCanDaDmoreThanOnce() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
+ r1.getContents().clear();
+
+ // Set things up
+ Model1Factory factory = getModel1Factory();
+ Order order1 = factory.createPurchaseOrder();
+ Order order2 = factory.createPurchaseOrder();
+ OrderDetail detail1 = factory.createOrderDetail();
+ order1.getOrderDetails().add(detail1);
+ r1.getContents().add(order1);
+ r1.getContents().add(order2);
+
+ // Commit so that everything gets a CDOID
+ tx.commit();
+
+ // Bring the resourceset under an editing domain
+ ResourceSet rs = tx.getResourceSet();
+ AdapterFactory adapterFact = new ReflectiveItemProviderAdapterFactory();
+ CommandStack cs = new SaneCommandStack();
+ EditingDomain domain = new AdapterFactoryEditingDomain(adapterFact, cs, rs);
+
+ float location = 0.5f;
+ int operations = 7;
+ int operation = 2;
+ Collection<OrderDetail> coll = Collections.singleton(detail1);
+
+ assertSame(order1, detail1.eContainer());
+
+ // Drag and drop #1
+ Command cmd = DragAndDropCommand.create(domain, order2, location, operations, operation, coll);
+ domain.getCommandStack().execute(cmd);
+ assertSame(order2, detail1.eContainer());
+
+ // Drag and drop #2
+ cmd = DragAndDropCommand.create(domain, order1, location, operations, operation, coll);
+ domain.getCommandStack().execute(cmd);
+ assertSame(order1, detail1.eContainer());
+ tx.commit();
+ assertSame(order1, detail1.eContainer());
+
+ assertSame(CDOState.CLEAN, CDOUtil.getCDOObject(detail1).cdoState());
+
+ // Drag and drop #3
+ cmd = DragAndDropCommand.create(domain, order2, location, operations, operation, coll);
+ domain.getCommandStack().execute(cmd);
+ assertSame(order2, detail1.eContainer());
+
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ public void testCanReattachDirtyObject() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
+ r1.getContents().clear();
+
+ // Set things up
+ Model1Factory factory = getModel1Factory();
+ Order order1 = factory.createPurchaseOrder();
+ Order order2 = factory.createPurchaseOrder();
+ OrderDetail detail1 = factory.createOrderDetail();
+ r1.getContents().add(order1);
+ r1.getContents().add(order2);
+ order1.getOrderDetails().add(detail1);
+ tx.commit();
+
+ // Make the order detail dirty
+ final float PRICE = 10.0f;
+ detail1.setPrice(PRICE);
+
+ // Now move it
+ order1.getOrderDetails().remove(detail1);
+ order2.getOrderDetails().add(detail1);
+ tx.commit();
+
+ // See if the price update was incorporated in the commit
+ {
+ CDOView view = session.openView();
+ CDOResource res = view.getResource(getResourcePath("/r1"));
+ Order order2prime = (Order)res.getContents().get(1);
+ OrderDetail od1 = order2prime.getOrderDetails().get(0);
+ assertEquals(PRICE, od1.getPrice());
+ view.close();
+ }
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private static class SaneCommandStack extends BasicCommandStack
+ {
+ @Override
+ protected void handleError(Exception exception)
+ {
+ throw new WrappedException(exception);
+ }
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private interface IClosure
+ {
+ public void test(EditingDomain domain, Collection<OrderDetail> details, Order target);
+
+ public Collection<OrderDetail> pickDetails(OrderDetail[] orderDetails);
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private static abstract class SingleItemClosure implements IClosure
+ {
+ public Collection<OrderDetail> pickDetails(OrderDetail[] orderDetails)
+ {
+ return Collections.singleton(orderDetails[0]);
+ }
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private static abstract class MultiItemClosure implements IClosure
+ {
+ public Collection<OrderDetail> pickDetails(OrderDetail[] orderDetails)
+ {
+ List<OrderDetail> details = new LinkedList<OrderDetail>();
+ details.add(orderDetails[0]);
+ details.add(orderDetails[1]);
+ return details;
+ }
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private static abstract class MultiItemMultiParentClosure implements IClosure
+ {
+ public Collection<OrderDetail> pickDetails(OrderDetail[] orderDetails)
+ {
+ List<OrderDetail> details = new LinkedList<OrderDetail>();
+ details.add(orderDetails[1]);
+ details.add(orderDetails[2]);
+ details.add(orderDetails[5]);
+ details.add(orderDetails[6]);
+ return details;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_2_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_2_Test.java
index 75d76d95ee..1a260c931d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_2_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_2_Test.java
@@ -1,158 +1,158 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_283985_2_Test extends AbstractCDOTest
-{
- private Order order1, order2;
-
- private OrderDetail detail1, detail2, detail3, detail4;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- order1 = getModel1Factory().createPurchaseOrder();
- order2 = getModel1Factory().createPurchaseOrder();
- detail1 = getModel1Factory().createOrderDetail();
- detail2 = getModel1Factory().createOrderDetail();
- detail3 = getModel1Factory().createOrderDetail();
- detail4 = getModel1Factory().createOrderDetail();
-
- order1.getOrderDetails().add(detail1);
- order1.getOrderDetails().add(detail2);
- order1.getOrderDetails().add(detail3);
- order1.getOrderDetails().add(detail4);
- }
-
- public void testMoveOnce() throws CommitException
- {
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
- r1.getContents().clear();
- r1.getContents().add(order1);
- r1.getContents().add(order2);
-
- boolean contains = order1.getOrderDetails().contains(detail1);
- assertEquals(true, contains);
-
- // Commit so that everything gets a CDOID
- tx.commit();
-
- contains = order1.getOrderDetails().contains(detail1);
- assertEquals(true, contains);
-
- tx.commit();
-
- order1.getOrderDetails().remove(detail1);
- order2.getOrderDetails().add(detail1);
- contains = order2.getOrderDetails().contains(detail1);
- assertEquals(true, contains);
-
- tx.commit();
-
- tx.close();
- session.close();
- }
-
- {
- // Check if all OK if we reload in a new session
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getResource(getResourcePath("/r1"));
- order1 = (Order)r1.getContents().get(0);
- order2 = (Order)r1.getContents().get(1);
-
- // lookup detail object in new transaction
- detail1 = (OrderDetail)CDOUtil.getEObject(tx.getObject(CDOUtil.getCDOObject(detail1).cdoID()));
-
- boolean contains1 = order1.getOrderDetails().contains(detail1);
- boolean contains2 = order2.getOrderDetails().contains(detail1);
- assertEquals(false, contains1);
- assertEquals(true, contains2);
-
- tx.close();
- session.close();
- }
- }
-
- public void testMoveOnceAndBack() throws CommitException
- {
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
- r1.getContents().clear();
- r1.getContents().add(order1);
- r1.getContents().add(order2);
-
- boolean contains = order1.getOrderDetails().contains(detail1);
- assertEquals(true, contains);
-
- // Commit so that everything gets a CDOID
- tx.commit();
-
- contains = order1.getOrderDetails().contains(detail1);
- assertEquals(true, contains);
-
- tx.commit();
-
- order1.getOrderDetails().remove(detail1);
- order2.getOrderDetails().add(detail1);
- contains = order2.getOrderDetails().contains(detail1);
- assertEquals(true, contains);
-
- order2.getOrderDetails().remove(detail1);
- order1.getOrderDetails().add(detail1);
- contains = order1.getOrderDetails().contains(detail1);
- assertEquals(true, contains);
-
- tx.commit();
-
- tx.close();
- session.close();
- }
-
- {
- // Check if all OK if we reload in a new session
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getResource(getResourcePath("/r1"));
- order1 = (Order)r1.getContents().get(0);
- order2 = (Order)r1.getContents().get(1);
- detail1 = (OrderDetail)CDOUtil.getEObject(tx.getObject(CDOUtil.getCDOObject(detail1).cdoID()));
-
- boolean contains1 = order1.getOrderDetails().contains(detail1);
- boolean contains2 = order2.getOrderDetails().contains(detail1);
- assertEquals(false, contains2);
- assertEquals(true, contains1);
-
- tx.close();
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_283985_2_Test extends AbstractCDOTest
+{
+ private Order order1, order2;
+
+ private OrderDetail detail1, detail2, detail3, detail4;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ order1 = getModel1Factory().createPurchaseOrder();
+ order2 = getModel1Factory().createPurchaseOrder();
+ detail1 = getModel1Factory().createOrderDetail();
+ detail2 = getModel1Factory().createOrderDetail();
+ detail3 = getModel1Factory().createOrderDetail();
+ detail4 = getModel1Factory().createOrderDetail();
+
+ order1.getOrderDetails().add(detail1);
+ order1.getOrderDetails().add(detail2);
+ order1.getOrderDetails().add(detail3);
+ order1.getOrderDetails().add(detail4);
+ }
+
+ public void testMoveOnce() throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
+ r1.getContents().clear();
+ r1.getContents().add(order1);
+ r1.getContents().add(order2);
+
+ boolean contains = order1.getOrderDetails().contains(detail1);
+ assertEquals(true, contains);
+
+ // Commit so that everything gets a CDOID
+ tx.commit();
+
+ contains = order1.getOrderDetails().contains(detail1);
+ assertEquals(true, contains);
+
+ tx.commit();
+
+ order1.getOrderDetails().remove(detail1);
+ order2.getOrderDetails().add(detail1);
+ contains = order2.getOrderDetails().contains(detail1);
+ assertEquals(true, contains);
+
+ tx.commit();
+
+ tx.close();
+ session.close();
+ }
+
+ {
+ // Check if all OK if we reload in a new session
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getResource(getResourcePath("/r1"));
+ order1 = (Order)r1.getContents().get(0);
+ order2 = (Order)r1.getContents().get(1);
+
+ // lookup detail object in new transaction
+ detail1 = (OrderDetail)CDOUtil.getEObject(tx.getObject(CDOUtil.getCDOObject(detail1).cdoID()));
+
+ boolean contains1 = order1.getOrderDetails().contains(detail1);
+ boolean contains2 = order2.getOrderDetails().contains(detail1);
+ assertEquals(false, contains1);
+ assertEquals(true, contains2);
+
+ tx.close();
+ session.close();
+ }
+ }
+
+ public void testMoveOnceAndBack() throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1"));
+ r1.getContents().clear();
+ r1.getContents().add(order1);
+ r1.getContents().add(order2);
+
+ boolean contains = order1.getOrderDetails().contains(detail1);
+ assertEquals(true, contains);
+
+ // Commit so that everything gets a CDOID
+ tx.commit();
+
+ contains = order1.getOrderDetails().contains(detail1);
+ assertEquals(true, contains);
+
+ tx.commit();
+
+ order1.getOrderDetails().remove(detail1);
+ order2.getOrderDetails().add(detail1);
+ contains = order2.getOrderDetails().contains(detail1);
+ assertEquals(true, contains);
+
+ order2.getOrderDetails().remove(detail1);
+ order1.getOrderDetails().add(detail1);
+ contains = order1.getOrderDetails().contains(detail1);
+ assertEquals(true, contains);
+
+ tx.commit();
+
+ tx.close();
+ session.close();
+ }
+
+ {
+ // Check if all OK if we reload in a new session
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getResource(getResourcePath("/r1"));
+ order1 = (Order)r1.getContents().get(0);
+ order2 = (Order)r1.getContents().get(1);
+ detail1 = (OrderDetail)CDOUtil.getEObject(tx.getObject(CDOUtil.getCDOObject(detail1).cdoID()));
+
+ boolean contains1 = order1.getOrderDetails().contains(detail1);
+ boolean contains2 = order2.getOrderDetails().contains(detail1);
+ assertEquals(false, contains2);
+ assertEquals(true, contains1);
+
+ tx.close();
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_3_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_3_Test.java
index 1804ad405f..8ad3dbbcc9 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_3_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283985_3_Test.java
@@ -1,170 +1,170 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSavepoint;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_283985_3_Test extends AbstractCDOTest
-{
- private Order order1, order2;
-
- private OrderDetail detail1, detail2, detail3, detail4;
-
- private CDOSession session;
-
- private CDOTransaction transaction;
-
- private CDOResource resource;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- Model1Factory factory = getModel1Factory();
-
- order1 = factory.createPurchaseOrder();
- order2 = factory.createPurchaseOrder();
- detail1 = factory.createOrderDetail();
- detail2 = factory.createOrderDetail();
- detail3 = factory.createOrderDetail();
- detail4 = factory.createOrderDetail();
-
- order1.getOrderDetails().add(detail1);
- order1.getOrderDetails().add(detail2);
- order1.getOrderDetails().add(detail3);
- order1.getOrderDetails().add(detail4);
-
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getOrCreateResource(getResourcePath("/r1"));
- resource.getContents().clear();
- resource.getContents().add(order1);
- resource.getContents().add(order2);
- transaction.commit();
- }
-
- @Override
- public void tearDown() throws Exception
- {
- transaction.close();
- session.close();
- super.tearDown();
- }
-
- // TODO Fix bug 344072
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void test1() throws CommitException
- {
- CDOID id = CDOUtil.getCDOObject(detail1).cdoID();
-
- order1.getOrderDetails().remove(detail1);
- assertTransient(detail1);
-
- transaction.setSavepoint();
- order1.getOrderDetails().add(detail1);
- assertClean(detail1, transaction);
-
- transaction.commit();
- assertEquals(id, CDOUtil.getCDOObject(detail1).cdoID());
- assertEquals(detail1, transaction.getObject(id));
- assertClean(detail1, transaction);
- }
-
- // TODO Fix bug 344072
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void test2() throws CommitException
- {
- InternalCDOSavepoint sp = (InternalCDOSavepoint)transaction.setSavepoint();
- order1.getOrderDetails().remove(detail1);
- assertTransient(detail1);
-
- assertEquals(true, sp.getDetachedObjects().containsValue(CDOUtil.getCDOObject(detail1)));
-
- sp = (InternalCDOSavepoint)transaction.setSavepoint();
- assertEquals(true, sp.getPreviousSavepoint().getDetachedObjects().containsValue(CDOUtil.getCDOObject(detail1)));
-
- order1.getOrderDetails().add(detail1);
- assertEquals(true, sp.getReattachedObjects().containsValue(CDOUtil.getCDOObject(detail1)));
- assertClean(detail1, transaction);
-
- sp.rollback();
- System.out.println(CDOUtil.getCDOObject(detail1).cdoState());
- assertTransient(detail1);
-
- transaction.commit();
- assertEquals(false, order1.getOrderDetails().contains(detail1));
- }
-
- // TODO Fix bug 344072
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void test3() throws CommitException
- {
- CDOID id = CDOUtil.getCDOObject(detail1).cdoID();
-
- transaction.setSavepoint();
- assertClean(detail1, transaction);
-
- order1.getOrderDetails().remove(detail1);
- transaction.setSavepoint();
- assertTransient(detail1);
-
- order1.getOrderDetails().add(detail1);
- transaction.setSavepoint();
- assertClean(detail1, transaction);
-
- order1.getOrderDetails().remove(detail1);
- assertTransient(detail1);
-
- transaction.getLastSavepoint().rollback();
- assertClean(detail1, transaction);
-
- transaction.commit();
-
- assertEquals(true, order1.getOrderDetails().contains(detail1));
- assertEquals(id, CDOUtil.getCDOObject(detail1).cdoID());
- }
-
- /**
- * Bug 312205 - After detach-reattach-rollback, object is not present in tx
- */
- public void test4()
- {
- CDOID id = CDOUtil.getCDOObject(detail1).cdoID();
- assertSame(transaction.getObject(id), CDOUtil.getCDOObject(detail1));
-
- // Detach
- order1.getOrderDetails().remove(detail1);
-
- // And re-attach
- order1.getOrderDetails().add(detail1);
- assertSame(transaction.getObject(id), CDOUtil.getCDOObject(detail1));
-
- transaction.rollback();
- assertSame(transaction.getObject(id), CDOUtil.getCDOObject(detail1));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.spi.cdo.InternalCDOSavepoint;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_283985_3_Test extends AbstractCDOTest
+{
+ private Order order1, order2;
+
+ private OrderDetail detail1, detail2, detail3, detail4;
+
+ private CDOSession session;
+
+ private CDOTransaction transaction;
+
+ private CDOResource resource;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ Model1Factory factory = getModel1Factory();
+
+ order1 = factory.createPurchaseOrder();
+ order2 = factory.createPurchaseOrder();
+ detail1 = factory.createOrderDetail();
+ detail2 = factory.createOrderDetail();
+ detail3 = factory.createOrderDetail();
+ detail4 = factory.createOrderDetail();
+
+ order1.getOrderDetails().add(detail1);
+ order1.getOrderDetails().add(detail2);
+ order1.getOrderDetails().add(detail3);
+ order1.getOrderDetails().add(detail4);
+
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getOrCreateResource(getResourcePath("/r1"));
+ resource.getContents().clear();
+ resource.getContents().add(order1);
+ resource.getContents().add(order2);
+ transaction.commit();
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ transaction.close();
+ session.close();
+ super.tearDown();
+ }
+
+ // TODO Fix bug 344072
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void test1() throws CommitException
+ {
+ CDOID id = CDOUtil.getCDOObject(detail1).cdoID();
+
+ order1.getOrderDetails().remove(detail1);
+ assertTransient(detail1);
+
+ transaction.setSavepoint();
+ order1.getOrderDetails().add(detail1);
+ assertClean(detail1, transaction);
+
+ transaction.commit();
+ assertEquals(id, CDOUtil.getCDOObject(detail1).cdoID());
+ assertEquals(detail1, transaction.getObject(id));
+ assertClean(detail1, transaction);
+ }
+
+ // TODO Fix bug 344072
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void test2() throws CommitException
+ {
+ InternalCDOSavepoint sp = (InternalCDOSavepoint)transaction.setSavepoint();
+ order1.getOrderDetails().remove(detail1);
+ assertTransient(detail1);
+
+ assertEquals(true, sp.getDetachedObjects().containsValue(CDOUtil.getCDOObject(detail1)));
+
+ sp = (InternalCDOSavepoint)transaction.setSavepoint();
+ assertEquals(true, sp.getPreviousSavepoint().getDetachedObjects().containsValue(CDOUtil.getCDOObject(detail1)));
+
+ order1.getOrderDetails().add(detail1);
+ assertEquals(true, sp.getReattachedObjects().containsValue(CDOUtil.getCDOObject(detail1)));
+ assertClean(detail1, transaction);
+
+ sp.rollback();
+ System.out.println(CDOUtil.getCDOObject(detail1).cdoState());
+ assertTransient(detail1);
+
+ transaction.commit();
+ assertEquals(false, order1.getOrderDetails().contains(detail1));
+ }
+
+ // TODO Fix bug 344072
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void test3() throws CommitException
+ {
+ CDOID id = CDOUtil.getCDOObject(detail1).cdoID();
+
+ transaction.setSavepoint();
+ assertClean(detail1, transaction);
+
+ order1.getOrderDetails().remove(detail1);
+ transaction.setSavepoint();
+ assertTransient(detail1);
+
+ order1.getOrderDetails().add(detail1);
+ transaction.setSavepoint();
+ assertClean(detail1, transaction);
+
+ order1.getOrderDetails().remove(detail1);
+ assertTransient(detail1);
+
+ transaction.getLastSavepoint().rollback();
+ assertClean(detail1, transaction);
+
+ transaction.commit();
+
+ assertEquals(true, order1.getOrderDetails().contains(detail1));
+ assertEquals(id, CDOUtil.getCDOObject(detail1).cdoID());
+ }
+
+ /**
+ * Bug 312205 - After detach-reattach-rollback, object is not present in tx
+ */
+ public void test4()
+ {
+ CDOID id = CDOUtil.getCDOObject(detail1).cdoID();
+ assertSame(transaction.getObject(id), CDOUtil.getCDOObject(detail1));
+
+ // Detach
+ order1.getOrderDetails().remove(detail1);
+
+ // And re-attach
+ order1.getOrderDetails().add(detail1);
+ assertSame(transaction.getObject(id), CDOUtil.getCDOObject(detail1));
+
+ transaction.rollback();
+ assertSame(transaction.getObject(id), CDOUtil.getCDOObject(detail1));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_285008_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_285008_Test.java
index 882b555e6d..37efea2b15 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_285008_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_285008_Test.java
@@ -1,149 +1,149 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.MultiNonContainedUnsettableElement;
-import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedUnsettable;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.tests.model4.model4Package;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_285008_Test extends AbstractCDOTest
-{
- private static String RESOURCENAME = "/r1";
-
- public void testCDO_isSet() throws CommitException
- {
- {
- CDOSession session = openSession();
- model4Package p = model4Package.eINSTANCE;
- session.getPackageRegistry().putEPackage(p);
- session.options().setPassiveUpdateEnabled(false);
- model4Factory f = model4Factory.eINSTANCE;
-
- // Ensure that model is suitable for this test
- boolean p1 = p.getRefMultiNonContainedUnsettable_Elements().isMany();
- boolean p2 = p.getRefMultiNonContainedUnsettable_Elements().isUnsettable();
- boolean p3 = !p.getMultiNonContainedUnsettableElement_Parent().isMany();
- boolean p4 = p.getMultiNonContainedUnsettableElement_Parent().isUnsettable();
- boolean p5 = p.getRefMultiNonContainedUnsettable_Elements().getEOpposite() == p
- .getMultiNonContainedUnsettableElement_Parent();
- if (!p1 || !p2 || !p3 || !p4 || !p5)
- {
- throw new RuntimeException("Model does not meet the prerequirements for this test");
- }
-
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
- RefMultiNonContainedUnsettable a = f.createRefMultiNonContainedUnsettable();
- MultiNonContainedUnsettableElement b = f.createMultiNonContainedUnsettableElement();
- r1.getContents().add(a);
- r1.getContents().add(b);
- a.getElements().add(b);
-
- assertEquals(true, a.isSetElements());
-
- tx.commit();
-
- assertEquals(true, a.isSetElements());
-
- tx.close();
- session.close();
- }
-
- // Same tests on isSetElements, but in a new session
- {
- CDOSession session = openSession();
- model4Package p = model4Package.eINSTANCE;
- session.getPackageRegistry().putEPackage(p);
- session.options().setPassiveUpdateEnabled(false);
- CDOTransaction tx = session.openTransaction();
-
- CDOResource r1 = tx.getResource(getResourcePath(RESOURCENAME));
- RefMultiNonContainedUnsettable a = (RefMultiNonContainedUnsettable)r1.getContents().get(0);
-
- assertEquals(true, a.isSetElements());
-
- tx.close();
- session.close();
- }
- }
-
- public void testCDO_crossReferences() throws CommitException
- {
- {
- CDOSession session = openSession();
- model4Package p = model4Package.eINSTANCE;
- session.getPackageRegistry().putEPackage(p);
- session.options().setPassiveUpdateEnabled(false);
- model4Factory f = model4Factory.eINSTANCE;
-
- // Ensure that model is suitable for this test
- boolean p1 = p.getRefMultiNonContainedUnsettable_Elements().isMany();
- boolean p2 = p.getRefMultiNonContainedUnsettable_Elements().isUnsettable();
- boolean p3 = !p.getMultiNonContainedUnsettableElement_Parent().isMany();
- boolean p4 = p.getMultiNonContainedUnsettableElement_Parent().isUnsettable();
- boolean p5 = p.getRefMultiNonContainedUnsettable_Elements().getEOpposite() == p
- .getMultiNonContainedUnsettableElement_Parent();
- if (!p1 || !p2 || !p3 || !p4 || !p5)
- {
- throw new RuntimeException("Model does not meet the prerequirements for this test");
- }
-
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
- RefMultiNonContainedUnsettable a = f.createRefMultiNonContainedUnsettable();
- MultiNonContainedUnsettableElement b = f.createMultiNonContainedUnsettableElement();
- r1.getContents().add(a);
- r1.getContents().add(b);
- a.getElements().add(b);
- tx.commit();
-
- assertEquals(1, a.eCrossReferences().size());
- assertSame(b, a.eCrossReferences().get(0));
-
- assertEquals(1, b.eCrossReferences().size());
- assertSame(a, b.eCrossReferences().get(0));
-
- tx.close();
- session.close();
- }
-
- // Same tests on eCrossReferences, but in a new session
- {
- CDOSession session = openSession();
- model4Package p = model4Package.eINSTANCE;
- session.getPackageRegistry().putEPackage(p);
- session.options().setPassiveUpdateEnabled(false);
- CDOTransaction tx = session.openTransaction();
-
- CDOResource r1 = tx.getResource(getResourcePath(RESOURCENAME));
- RefMultiNonContainedUnsettable a = (RefMultiNonContainedUnsettable)r1.getContents().get(0);
- MultiNonContainedUnsettableElement b = (MultiNonContainedUnsettableElement)r1.getContents().get(1);
-
- assertEquals(1, a.eCrossReferences().size());
- assertSame(b, a.eCrossReferences().get(0));
-
- assertEquals(1, b.eCrossReferences().size());
- assertSame(a, b.eCrossReferences().get(0));
-
- tx.close();
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.MultiNonContainedUnsettableElement;
+import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedUnsettable;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.tests.model4.model4Package;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_285008_Test extends AbstractCDOTest
+{
+ private static String RESOURCENAME = "/r1";
+
+ public void testCDO_isSet() throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ model4Package p = model4Package.eINSTANCE;
+ session.getPackageRegistry().putEPackage(p);
+ session.options().setPassiveUpdateEnabled(false);
+ model4Factory f = model4Factory.eINSTANCE;
+
+ // Ensure that model is suitable for this test
+ boolean p1 = p.getRefMultiNonContainedUnsettable_Elements().isMany();
+ boolean p2 = p.getRefMultiNonContainedUnsettable_Elements().isUnsettable();
+ boolean p3 = !p.getMultiNonContainedUnsettableElement_Parent().isMany();
+ boolean p4 = p.getMultiNonContainedUnsettableElement_Parent().isUnsettable();
+ boolean p5 = p.getRefMultiNonContainedUnsettable_Elements().getEOpposite() == p
+ .getMultiNonContainedUnsettableElement_Parent();
+ if (!p1 || !p2 || !p3 || !p4 || !p5)
+ {
+ throw new RuntimeException("Model does not meet the prerequirements for this test");
+ }
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
+ RefMultiNonContainedUnsettable a = f.createRefMultiNonContainedUnsettable();
+ MultiNonContainedUnsettableElement b = f.createMultiNonContainedUnsettableElement();
+ r1.getContents().add(a);
+ r1.getContents().add(b);
+ a.getElements().add(b);
+
+ assertEquals(true, a.isSetElements());
+
+ tx.commit();
+
+ assertEquals(true, a.isSetElements());
+
+ tx.close();
+ session.close();
+ }
+
+ // Same tests on isSetElements, but in a new session
+ {
+ CDOSession session = openSession();
+ model4Package p = model4Package.eINSTANCE;
+ session.getPackageRegistry().putEPackage(p);
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction tx = session.openTransaction();
+
+ CDOResource r1 = tx.getResource(getResourcePath(RESOURCENAME));
+ RefMultiNonContainedUnsettable a = (RefMultiNonContainedUnsettable)r1.getContents().get(0);
+
+ assertEquals(true, a.isSetElements());
+
+ tx.close();
+ session.close();
+ }
+ }
+
+ public void testCDO_crossReferences() throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ model4Package p = model4Package.eINSTANCE;
+ session.getPackageRegistry().putEPackage(p);
+ session.options().setPassiveUpdateEnabled(false);
+ model4Factory f = model4Factory.eINSTANCE;
+
+ // Ensure that model is suitable for this test
+ boolean p1 = p.getRefMultiNonContainedUnsettable_Elements().isMany();
+ boolean p2 = p.getRefMultiNonContainedUnsettable_Elements().isUnsettable();
+ boolean p3 = !p.getMultiNonContainedUnsettableElement_Parent().isMany();
+ boolean p4 = p.getMultiNonContainedUnsettableElement_Parent().isUnsettable();
+ boolean p5 = p.getRefMultiNonContainedUnsettable_Elements().getEOpposite() == p
+ .getMultiNonContainedUnsettableElement_Parent();
+ if (!p1 || !p2 || !p3 || !p4 || !p5)
+ {
+ throw new RuntimeException("Model does not meet the prerequirements for this test");
+ }
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
+ RefMultiNonContainedUnsettable a = f.createRefMultiNonContainedUnsettable();
+ MultiNonContainedUnsettableElement b = f.createMultiNonContainedUnsettableElement();
+ r1.getContents().add(a);
+ r1.getContents().add(b);
+ a.getElements().add(b);
+ tx.commit();
+
+ assertEquals(1, a.eCrossReferences().size());
+ assertSame(b, a.eCrossReferences().get(0));
+
+ assertEquals(1, b.eCrossReferences().size());
+ assertSame(a, b.eCrossReferences().get(0));
+
+ tx.close();
+ session.close();
+ }
+
+ // Same tests on eCrossReferences, but in a new session
+ {
+ CDOSession session = openSession();
+ model4Package p = model4Package.eINSTANCE;
+ session.getPackageRegistry().putEPackage(p);
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction tx = session.openTransaction();
+
+ CDOResource r1 = tx.getResource(getResourcePath(RESOURCENAME));
+ RefMultiNonContainedUnsettable a = (RefMultiNonContainedUnsettable)r1.getContents().get(0);
+ MultiNonContainedUnsettableElement b = (MultiNonContainedUnsettableElement)r1.getContents().get(1);
+
+ assertEquals(1, a.eCrossReferences().size());
+ assertSame(b, a.eCrossReferences().get(0));
+
+ assertEquals(1, b.eCrossReferences().size());
+ assertSame(a, b.eCrossReferences().get(0));
+
+ tx.close();
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_289932_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_289932_Test.java
index 8f5c66277f..c66b110bfe 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_289932_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_289932_Test.java
@@ -1,45 +1,45 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model5.Doctor;
-import org.eclipse.emf.cdo.tests.model5.TestFeatureMap;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * Objects that are contained by a transient feature could be persisted
- * <p>
- * See bug 289932
- *
- * @author Simon McDuff
- */
-public class Bugzilla_289932_Test extends AbstractCDOTest
-{
- public void testBugzilla_289932() throws Exception
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(getModel5Package());
- CDOTransaction transaction = session.openTransaction();
- CDOResource res1 = transaction.createResource(getResourcePath("/res1"));
-
- TestFeatureMap testFeatureMap = getModel5Factory().createTestFeatureMap();
- Doctor doctor = getModel5Factory().createDoctor();
- testFeatureMap.getDoctors().add(doctor);
- res1.getContents().add(testFeatureMap);
- transaction.commit();
-
- // Transient feature for Doctor, should not persist it.
- assertTransient(doctor);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model5.Doctor;
+import org.eclipse.emf.cdo.tests.model5.TestFeatureMap;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * Objects that are contained by a transient feature could be persisted
+ * <p>
+ * See bug 289932
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_289932_Test extends AbstractCDOTest
+{
+ public void testBugzilla_289932() throws Exception
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(getModel5Package());
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res1 = transaction.createResource(getResourcePath("/res1"));
+
+ TestFeatureMap testFeatureMap = getModel5Factory().createTestFeatureMap();
+ Doctor doctor = getModel5Factory().createDoctor();
+ testFeatureMap.getDoctors().add(doctor);
+ res1.getContents().add(testFeatureMap);
+ transaction.commit();
+
+ // Transient feature for Doctor, should not persist it.
+ assertTransient(doctor);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_293283_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_293283_Test.java
index f81a4301dd..84f012fc6b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_293283_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_293283_Test.java
@@ -1,149 +1,149 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * Bugzilla 293283/314387 - Failed writes on CDOObjects leave bad featureDeltas in transaction
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_293283_Test extends AbstractCDOTest
-{
- private CDOSession session;
-
- private CDOTransaction tx;
-
- private Order order1;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- session = openSession();
- tx = session.openTransaction();
- CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1")); //$NON-NLS-1$
- r1.getContents().clear();
-
- order1 = getModel1Factory().createPurchaseOrder();
- OrderDetail detail1 = getModel1Factory().createOrderDetail();
- OrderDetail detail2 = getModel1Factory().createOrderDetail();
- order1.getOrderDetails().add(detail1);
- order1.getOrderDetails().add(detail2);
- r1.getContents().add(order1);
- tx.commit();
- }
-
- @Override
- public void tearDown() throws Exception
- {
- tx.close();
- session.close();
-
- super.tearDown();
- }
-
- public void test1()
- {
- test(Action.ADD);
- }
-
- public void test2()
- {
- test(Action.SET);
- }
-
- public void test3()
- {
- test(Action.MOVE1);
- }
-
- public void test4()
- {
- test(Action.MOVE2);
- }
-
- public void test5()
- {
- test(Action.REMOVE1);
- }
-
- public void test6()
- {
- test(Action.REMOVE2);
- }
-
- private void test(Action action)
- {
- try
- {
- switch (action)
- {
- case ADD:
- {
- OrderDetail newDetail = getModel1Factory().createOrderDetail();
- order1.getOrderDetails().add(3, newDetail);
- break;
- }
-
- case MOVE1:
- order1.getOrderDetails().move(0, 3);
- break;
-
- case MOVE2:
- order1.getOrderDetails().move(3, 0);
- break;
-
- case REMOVE1:
- order1.getOrderDetails().remove(3);
- break;
-
- case REMOVE2:
- order1.getOrderDetails().remove(-1);
- break;
-
- case SET:
- {
- OrderDetail newDetail = getModel1Factory().createOrderDetail();
- order1.getOrderDetails().set(3, newDetail);
- break;
- }
- }
-
- fail("Should have thrown " + IndexOutOfBoundsException.class.getSimpleName()); //$NON-NLS-1$
- }
- catch (IndexOutOfBoundsException ex)
- {
- // Good
- }
-
- try
- {
- tx.commit();
- }
- catch (Exception e)
- {
- fail("Should have committed cleanly, but failed with " + e.getClass().getName() + "\n" + e.getMessage());
- }
- }
-
- private enum Action
- {
- ADD, MOVE1, MOVE2, REMOVE1, REMOVE2, SET
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * Bugzilla 293283/314387 - Failed writes on CDOObjects leave bad featureDeltas in transaction
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_293283_Test extends AbstractCDOTest
+{
+ private CDOSession session;
+
+ private CDOTransaction tx;
+
+ private Order order1;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ session = openSession();
+ tx = session.openTransaction();
+ CDOResource r1 = tx.getOrCreateResource(getResourcePath("/r1")); //$NON-NLS-1$
+ r1.getContents().clear();
+
+ order1 = getModel1Factory().createPurchaseOrder();
+ OrderDetail detail1 = getModel1Factory().createOrderDetail();
+ OrderDetail detail2 = getModel1Factory().createOrderDetail();
+ order1.getOrderDetails().add(detail1);
+ order1.getOrderDetails().add(detail2);
+ r1.getContents().add(order1);
+ tx.commit();
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ tx.close();
+ session.close();
+
+ super.tearDown();
+ }
+
+ public void test1()
+ {
+ test(Action.ADD);
+ }
+
+ public void test2()
+ {
+ test(Action.SET);
+ }
+
+ public void test3()
+ {
+ test(Action.MOVE1);
+ }
+
+ public void test4()
+ {
+ test(Action.MOVE2);
+ }
+
+ public void test5()
+ {
+ test(Action.REMOVE1);
+ }
+
+ public void test6()
+ {
+ test(Action.REMOVE2);
+ }
+
+ private void test(Action action)
+ {
+ try
+ {
+ switch (action)
+ {
+ case ADD:
+ {
+ OrderDetail newDetail = getModel1Factory().createOrderDetail();
+ order1.getOrderDetails().add(3, newDetail);
+ break;
+ }
+
+ case MOVE1:
+ order1.getOrderDetails().move(0, 3);
+ break;
+
+ case MOVE2:
+ order1.getOrderDetails().move(3, 0);
+ break;
+
+ case REMOVE1:
+ order1.getOrderDetails().remove(3);
+ break;
+
+ case REMOVE2:
+ order1.getOrderDetails().remove(-1);
+ break;
+
+ case SET:
+ {
+ OrderDetail newDetail = getModel1Factory().createOrderDetail();
+ order1.getOrderDetails().set(3, newDetail);
+ break;
+ }
+ }
+
+ fail("Should have thrown " + IndexOutOfBoundsException.class.getSimpleName()); //$NON-NLS-1$
+ }
+ catch (IndexOutOfBoundsException ex)
+ {
+ // Good
+ }
+
+ try
+ {
+ tx.commit();
+ }
+ catch (Exception e)
+ {
+ fail("Should have committed cleanly, but failed with " + e.getClass().getName() + "\n" + e.getMessage());
+ }
+ }
+
+ private enum Action
+ {
+ ADD, MOVE1, MOVE2, REMOVE1, REMOVE2, SET
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_294859_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_294859_Test.java
index 5a1fa5f376..032b4c56bb 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_294859_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_294859_Test.java
@@ -1,120 +1,120 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-
-import java.util.Date;
-
-/**
- * Bug 294859 - Deltas for local changes to objects in CONFLICT state, are not added to tx
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_294859_Test extends AbstractCDOTest
-{
- private static String RESOURCE_NAME = "/r1";
-
- public void test() throws CommitException
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
-
- CDOTransaction tx = session.openTransaction();
-
- // Do NOT use a conflict resolver
-
- CDOResource r1 = tx.createResource(getResourcePath(RESOURCE_NAME));
-
- Company company1 = getModel1Factory().createCompany();
- Company company2 = getModel1Factory().createCompany();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- company1.getPurchaseOrders().add(purchaseOrder);
- r1.getContents().add(company1);
- r1.getContents().add(company2);
- tx.commit();
-
- // Touch the purchaseOrder
- purchaseOrder.setDate(new Date(1000L));
-
- doSecondSession();
-
- // Convenience
- CDOObject cdoPurchaseOrder = CDOUtil.getCDOObject(purchaseOrder);
-
- // The purchaseOrder was touched in both this and 2nd session;
- // we refresh now go cause a conflict
- session.refresh();
- assertEquals(true, cdoPurchaseOrder.cdoState() == CDOState.CONFLICT);
-
- // Touch it again
- purchaseOrder.setDate(new Date(3000L));
-
- // Verify that the delta representing the LAST LOCAL change is in the TX
- //
- CDOSavepointImpl savepoint = (CDOSavepointImpl)((InternalCDOTransaction)tx).getLastSavepoint();
- CDORevisionDelta revDelta = savepoint.getRevisionDeltas().get(cdoPurchaseOrder.cdoID());
- assertNotNull(revDelta);
- assertEquals(true, revDelta.getFeatureDeltas().size() == 1);
- CDOFeatureDelta featDelta = revDelta.getFeatureDeltas().get(0);
- EAttribute eAttr = getModel1Factory().getModel1Package().getPurchaseOrder_Date();
- assertEquals(true, featDelta instanceof CDOSetFeatureDelta);
- CDOSetFeatureDelta setFeatDelta = (CDOSetFeatureDelta)featDelta;
- assertSame(eAttr, setFeatDelta.getFeature());
- assertSame(CDOFeatureDelta.Type.SET, setFeatDelta.getType());
- assertEquals(new Date(3000L), setFeatDelta.getValue());
-
- try
- {
- tx.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- // Correct
- }
-
- tx.close();
- session.close();
- }
-
- private void doSecondSession() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getResource(getResourcePath(RESOURCE_NAME));
- Company c = (Company)r1.getContents().get(0);
-
- // Touch the purchaseOrder
- c.getPurchaseOrders().get(0).setDate(new Date(2000L));
-
- tx.commit();
- tx.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+
+import java.util.Date;
+
+/**
+ * Bug 294859 - Deltas for local changes to objects in CONFLICT state, are not added to tx
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_294859_Test extends AbstractCDOTest
+{
+ private static String RESOURCE_NAME = "/r1";
+
+ public void test() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+
+ CDOTransaction tx = session.openTransaction();
+
+ // Do NOT use a conflict resolver
+
+ CDOResource r1 = tx.createResource(getResourcePath(RESOURCE_NAME));
+
+ Company company1 = getModel1Factory().createCompany();
+ Company company2 = getModel1Factory().createCompany();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ company1.getPurchaseOrders().add(purchaseOrder);
+ r1.getContents().add(company1);
+ r1.getContents().add(company2);
+ tx.commit();
+
+ // Touch the purchaseOrder
+ purchaseOrder.setDate(new Date(1000L));
+
+ doSecondSession();
+
+ // Convenience
+ CDOObject cdoPurchaseOrder = CDOUtil.getCDOObject(purchaseOrder);
+
+ // The purchaseOrder was touched in both this and 2nd session;
+ // we refresh now go cause a conflict
+ session.refresh();
+ assertEquals(true, cdoPurchaseOrder.cdoState() == CDOState.CONFLICT);
+
+ // Touch it again
+ purchaseOrder.setDate(new Date(3000L));
+
+ // Verify that the delta representing the LAST LOCAL change is in the TX
+ //
+ CDOSavepointImpl savepoint = (CDOSavepointImpl)((InternalCDOTransaction)tx).getLastSavepoint();
+ CDORevisionDelta revDelta = savepoint.getRevisionDeltas().get(cdoPurchaseOrder.cdoID());
+ assertNotNull(revDelta);
+ assertEquals(true, revDelta.getFeatureDeltas().size() == 1);
+ CDOFeatureDelta featDelta = revDelta.getFeatureDeltas().get(0);
+ EAttribute eAttr = getModel1Factory().getModel1Package().getPurchaseOrder_Date();
+ assertEquals(true, featDelta instanceof CDOSetFeatureDelta);
+ CDOSetFeatureDelta setFeatDelta = (CDOSetFeatureDelta)featDelta;
+ assertSame(eAttr, setFeatDelta.getFeature());
+ assertSame(CDOFeatureDelta.Type.SET, setFeatDelta.getType());
+ assertEquals(new Date(3000L), setFeatDelta.getValue());
+
+ try
+ {
+ tx.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ // Correct
+ }
+
+ tx.close();
+ session.close();
+ }
+
+ private void doSecondSession() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getResource(getResourcePath(RESOURCE_NAME));
+ Company c = (Company)r1.getContents().get(0);
+
+ // Touch the purchaseOrder
+ c.getPurchaseOrders().get(0).setDate(new Date(2000L));
+
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java
index 27bfba09a2..ffc6fc9f11 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java
@@ -1,143 +1,143 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOSavepoint;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.ObjectNotFoundException;
-
-import org.eclipse.net4j.util.ReflectUtil;
-
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-import java.lang.reflect.Field;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Problems with savepoints and detached elements on complete rollback
- * <p>
- * See https://bugs.eclipse.org/296561
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_296561_Test extends AbstractCDOTest
-{
- public void testBugzilla_296561__checkTransactionObjects() throws Exception
- {
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/test1"));
- Customer customer = (Customer)res.getContents().get(0);
- customer.setName("modified");
-
- Customer customer2 = getModel1Factory().createCustomer();
- customer2.setName("customer2");
-
- res.getContents().add(customer2);
- CDOID id = CDOUtil.getCDOObject(customer2).cdoID();
-
- CDOSavepoint savePoint = transaction.setSavepoint();
- msg(savePoint);
-
- res.getContents().remove(customer2);
-
- try
- {
- transaction.getObject(id);
- fail("ObjectNotFoundException expected");
- }
- catch (ObjectNotFoundException expected)
- {
- }
-
- Field field = ReflectUtil.getField(transaction.getClass(), "objects");
- Object value = ReflectUtil.getValue(field, transaction);
-
- @SuppressWarnings("unchecked")
- ConcurrentMap<CDOID, InternalCDOObject> objects = (ConcurrentMap<CDOID, InternalCDOObject>)value;
- assertEquals(false, objects.containsKey(id));
- }
- }
-
- public void testBugzilla_296561() throws Exception
- {
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- resource.getContents().add(customer);
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/test1"));
-
- Customer customer = (Customer)res.getContents().get(0);
- customer.setName("modified");
-
- Customer customer2 = getModel1Factory().createCustomer();
- customer2.setName("customer2");
-
- res.getContents().add(customer2);
- CDOSavepoint savePoint = transaction.setSavepoint();
-
- res.getContents().remove(customer2);
- savePoint.rollback();
- assertEquals(true, res.getContents().contains(customer2));
- }
-
- {
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource(getResourcePath("/test1"));
- Customer customer = (Customer)res.getContents().get(0);
- customer.setName("modified");
-
- Customer customer2 = getModel1Factory().createCustomer();
- customer2.setName("customer2");
-
- res.getContents().add(customer2);
- transaction.setSavepoint();
- res.getContents().remove(customer2);
- transaction.rollback();
- assertEquals(false, res.getContents().contains(customer2));
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOSavepoint;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+
+import org.eclipse.net4j.util.ReflectUtil;
+
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
+
+import java.lang.reflect.Field;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Problems with savepoints and detached elements on complete rollback
+ * <p>
+ * See https://bugs.eclipse.org/296561
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_296561_Test extends AbstractCDOTest
+{
+ public void testBugzilla_296561__checkTransactionObjects() throws Exception
+ {
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/test1"));
+ Customer customer = (Customer)res.getContents().get(0);
+ customer.setName("modified");
+
+ Customer customer2 = getModel1Factory().createCustomer();
+ customer2.setName("customer2");
+
+ res.getContents().add(customer2);
+ CDOID id = CDOUtil.getCDOObject(customer2).cdoID();
+
+ CDOSavepoint savePoint = transaction.setSavepoint();
+ msg(savePoint);
+
+ res.getContents().remove(customer2);
+
+ try
+ {
+ transaction.getObject(id);
+ fail("ObjectNotFoundException expected");
+ }
+ catch (ObjectNotFoundException expected)
+ {
+ }
+
+ Field field = ReflectUtil.getField(transaction.getClass(), "objects");
+ Object value = ReflectUtil.getValue(field, transaction);
+
+ @SuppressWarnings("unchecked")
+ ConcurrentMap<CDOID, InternalCDOObject> objects = (ConcurrentMap<CDOID, InternalCDOObject>)value;
+ assertEquals(false, objects.containsKey(id));
+ }
+ }
+
+ public void testBugzilla_296561() throws Exception
+ {
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ resource.getContents().add(customer);
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/test1"));
+
+ Customer customer = (Customer)res.getContents().get(0);
+ customer.setName("modified");
+
+ Customer customer2 = getModel1Factory().createCustomer();
+ customer2.setName("customer2");
+
+ res.getContents().add(customer2);
+ CDOSavepoint savePoint = transaction.setSavepoint();
+
+ res.getContents().remove(customer2);
+ savePoint.rollback();
+ assertEquals(true, res.getContents().contains(customer2));
+ }
+
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource(getResourcePath("/test1"));
+ Customer customer = (Customer)res.getContents().get(0);
+ customer.setName("modified");
+
+ Customer customer2 = getModel1Factory().createCustomer();
+ customer2.setName("customer2");
+
+ res.getContents().add(customer2);
+ transaction.setSavepoint();
+ res.getContents().remove(customer2);
+ transaction.rollback();
+ assertEquals(false, res.getContents().contains(customer2));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_298561_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_298561_Test.java
index 3489cd3951..c7ea6a070f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_298561_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_298561_Test.java
@@ -1,223 +1,223 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.ObjectNotFoundException;
-
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * See bug 298561
- *
- * @author Eike Stepper
- */
-public class Bugzilla_298561_Test extends AbstractCDOTest
-{
- private static String RESOURCENAME = "/r1";
-
- public void testNew() throws CommitException
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- session.getPackageRegistry().putEPackage(getModel4Package());
-
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
-
- // Create referencee and store it
- ContainedElementNoOpposite referencee = getModel4Factory().createContainedElementNoOpposite();
- r1.getContents().add(referencee);
- tx.commit();
-
- // Create referencer, don't store it -- keep it as NEW
- RefSingleNonContainedNPL referencer = getModel4Factory().createRefSingleNonContainedNPL();
- r1.getContents().add(referencer);
- referencer.setElement(referencee);
- assertEquals(CDOState.NEW, CDOUtil.getCDOObject(referencer).cdoState());
-
- // Delete the referencee in 2nd session
- doSecondSession();
-
- // Refresh
- session.refresh();
-
- //
- try
- {
- EReference ref = getModel4Package().getRefSingleNonContainedNPL_Element();
- boolean isSet = referencer.eIsSet(ref);
- if (isSet)
- {
- assertNull(referencer.getElement());
- }
- }
- catch (ObjectNotFoundException e)
- {
- fail("Should not have thrown ObjectNotFoundException");
- }
-
- tx.close();
- session.close();
- }
-
- public void testDirty() throws CommitException
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- session.getPackageRegistry().putEPackage(getModel4Package());
-
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
-
- // Create referencee and referencer (but no reference yet), and store them
- ContainedElementNoOpposite referencee = getModel4Factory().createContainedElementNoOpposite();
- r1.getContents().add(referencee);
- RefSingleNonContainedNPL referencer = getModel4Factory().createRefSingleNonContainedNPL();
- r1.getContents().add(referencer);
- tx.commit();
-
- // Create the reference, making the referencer dirty
- referencer.setElement(referencee);
- assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(referencer).cdoState());
-
- // Delete the referencee in 2nd session
- doSecondSession();
-
- // Refresh
- session.refresh();
-
- try
- {
- boolean isSet = referencer.eIsSet(getModel4Package().getRefSingleNonContainedNPL_Element());
- if (isSet)
- {
- assertNull(referencer.getElement());
- }
- }
- catch (ObjectNotFoundException e)
- {
- fail("Should not have thrown ObjectNotFoundException");
- }
-
- tx.close();
- session.close();
- }
-
- public void testNewMulti() throws CommitException
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- session.getPackageRegistry().putEPackage(getModel4Package());
-
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
-
- // Create referencee and store it
- ContainedElementNoOpposite referencee = getModel4Factory().createContainedElementNoOpposite();
- r1.getContents().add(referencee);
- tx.commit();
-
- // Create referencer, don't store it -- keep it as NEW
- RefMultiNonContainedNPL referencer = getModel4Factory().createRefMultiNonContainedNPL();
- r1.getContents().add(referencer);
- referencer.getElements().add(referencee);
- assertEquals(CDOState.NEW, CDOUtil.getCDOObject(referencer).cdoState());
-
- // Delete the referencee in 2nd session
- doSecondSession();
-
- // Refresh
- session.refresh();
-
- //
- try
- {
- boolean isSet = referencer.eIsSet(getModel4Package().getRefMultiNonContainedNPL_Elements());
- if (isSet && referencer.getElements().size() > 0)
- {
- assertNull(referencer.getElements().get(0));
- }
- }
- catch (ObjectNotFoundException e)
- {
- fail("Should not have thrown ObjectNotFoundException");
- }
-
- tx.close();
- session.close();
- }
-
- public void testDirtyMulti() throws CommitException
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- session.getPackageRegistry().putEPackage(getModel4Package());
-
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
-
- // Create referencee and referencer (but no reference yet), and store them
- ContainedElementNoOpposite referencee = getModel4Factory().createContainedElementNoOpposite();
- r1.getContents().add(referencee);
- RefMultiNonContainedNPL referencer = getModel4Factory().createRefMultiNonContainedNPL();
- r1.getContents().add(referencer);
- tx.commit();
-
- // Create the reference, making the referencer dirty
- referencer.getElements().add(referencee);
- assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(referencer).cdoState());
-
- // Delete the referencee in 2nd session
- doSecondSession();
-
- // Refresh
- session.refresh();
-
- //
- try
- {
- boolean isSet = referencer.eIsSet(getModel4Package().getRefMultiNonContainedNPL_Elements());
- if (isSet && referencer.getElements().size() > 0)
- {
- assertNull(referencer.getElements().get(0));
- }
- }
- catch (ObjectNotFoundException e)
- {
- fail("Should not have thrown ObjectNotFoundException");
- }
-
- tx.close();
- session.close();
- }
-
- private void doSecondSession() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getResource(getResourcePath(RESOURCENAME));
- ContainedElementNoOpposite referencee = (ContainedElementNoOpposite)r1.getContents().get(0);
- EcoreUtil.delete(referencee);
- tx.commit();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * See bug 298561
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_298561_Test extends AbstractCDOTest
+{
+ private static String RESOURCENAME = "/r1";
+
+ public void testNew() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ session.getPackageRegistry().putEPackage(getModel4Package());
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
+
+ // Create referencee and store it
+ ContainedElementNoOpposite referencee = getModel4Factory().createContainedElementNoOpposite();
+ r1.getContents().add(referencee);
+ tx.commit();
+
+ // Create referencer, don't store it -- keep it as NEW
+ RefSingleNonContainedNPL referencer = getModel4Factory().createRefSingleNonContainedNPL();
+ r1.getContents().add(referencer);
+ referencer.setElement(referencee);
+ assertEquals(CDOState.NEW, CDOUtil.getCDOObject(referencer).cdoState());
+
+ // Delete the referencee in 2nd session
+ doSecondSession();
+
+ // Refresh
+ session.refresh();
+
+ //
+ try
+ {
+ EReference ref = getModel4Package().getRefSingleNonContainedNPL_Element();
+ boolean isSet = referencer.eIsSet(ref);
+ if (isSet)
+ {
+ assertNull(referencer.getElement());
+ }
+ }
+ catch (ObjectNotFoundException e)
+ {
+ fail("Should not have thrown ObjectNotFoundException");
+ }
+
+ tx.close();
+ session.close();
+ }
+
+ public void testDirty() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ session.getPackageRegistry().putEPackage(getModel4Package());
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
+
+ // Create referencee and referencer (but no reference yet), and store them
+ ContainedElementNoOpposite referencee = getModel4Factory().createContainedElementNoOpposite();
+ r1.getContents().add(referencee);
+ RefSingleNonContainedNPL referencer = getModel4Factory().createRefSingleNonContainedNPL();
+ r1.getContents().add(referencer);
+ tx.commit();
+
+ // Create the reference, making the referencer dirty
+ referencer.setElement(referencee);
+ assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(referencer).cdoState());
+
+ // Delete the referencee in 2nd session
+ doSecondSession();
+
+ // Refresh
+ session.refresh();
+
+ try
+ {
+ boolean isSet = referencer.eIsSet(getModel4Package().getRefSingleNonContainedNPL_Element());
+ if (isSet)
+ {
+ assertNull(referencer.getElement());
+ }
+ }
+ catch (ObjectNotFoundException e)
+ {
+ fail("Should not have thrown ObjectNotFoundException");
+ }
+
+ tx.close();
+ session.close();
+ }
+
+ public void testNewMulti() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ session.getPackageRegistry().putEPackage(getModel4Package());
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
+
+ // Create referencee and store it
+ ContainedElementNoOpposite referencee = getModel4Factory().createContainedElementNoOpposite();
+ r1.getContents().add(referencee);
+ tx.commit();
+
+ // Create referencer, don't store it -- keep it as NEW
+ RefMultiNonContainedNPL referencer = getModel4Factory().createRefMultiNonContainedNPL();
+ r1.getContents().add(referencer);
+ referencer.getElements().add(referencee);
+ assertEquals(CDOState.NEW, CDOUtil.getCDOObject(referencer).cdoState());
+
+ // Delete the referencee in 2nd session
+ doSecondSession();
+
+ // Refresh
+ session.refresh();
+
+ //
+ try
+ {
+ boolean isSet = referencer.eIsSet(getModel4Package().getRefMultiNonContainedNPL_Elements());
+ if (isSet && referencer.getElements().size() > 0)
+ {
+ assertNull(referencer.getElements().get(0));
+ }
+ }
+ catch (ObjectNotFoundException e)
+ {
+ fail("Should not have thrown ObjectNotFoundException");
+ }
+
+ tx.close();
+ session.close();
+ }
+
+ public void testDirtyMulti() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ session.getPackageRegistry().putEPackage(getModel4Package());
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath(RESOURCENAME));
+
+ // Create referencee and referencer (but no reference yet), and store them
+ ContainedElementNoOpposite referencee = getModel4Factory().createContainedElementNoOpposite();
+ r1.getContents().add(referencee);
+ RefMultiNonContainedNPL referencer = getModel4Factory().createRefMultiNonContainedNPL();
+ r1.getContents().add(referencer);
+ tx.commit();
+
+ // Create the reference, making the referencer dirty
+ referencer.getElements().add(referencee);
+ assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(referencer).cdoState());
+
+ // Delete the referencee in 2nd session
+ doSecondSession();
+
+ // Refresh
+ session.refresh();
+
+ //
+ try
+ {
+ boolean isSet = referencer.eIsSet(getModel4Package().getRefMultiNonContainedNPL_Elements());
+ if (isSet && referencer.getElements().size() > 0)
+ {
+ assertNull(referencer.getElements().get(0));
+ }
+ }
+ catch (ObjectNotFoundException e)
+ {
+ fail("Should not have thrown ObjectNotFoundException");
+ }
+
+ tx.close();
+ session.close();
+ }
+
+ private void doSecondSession() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getResource(getResourcePath(RESOURCENAME));
+ ContainedElementNoOpposite referencee = (ContainedElementNoOpposite)r1.getContents().get(0);
+ EcoreUtil.delete(referencee);
+ tx.commit();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_299190_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_299190_Test.java
index 8ec5ea56b9..5e501346e5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_299190_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_299190_Test.java
@@ -1,151 +1,151 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
-import org.eclipse.emf.cdo.tests.model4.ImplContainedElementNPL;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_299190_Test extends AbstractCDOTest
-{
- private static long uniqueCounter = System.currentTimeMillis();
-
- private model4Factory factory;
-
- private CDOResource resource1;
-
- private CDOTransaction transaction;
-
- private CDOSession session;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- String path1 = getResourcePath("/resources/folder1/" + uniqueCounter);
- ++uniqueCounter;
-
- init(path1);
- commit();
- }
-
- private void purgeCaches()
- {
- // according to Eike's comment at Bug 249681, client caches are
- // ignored, if a new session is opened.
- // server caches are wiped by the clearCache call.
- String path1 = resource1.getPath();
-
- transaction.close();
- session.close();
-
- clearCache(getRepository().getRevisionManager());
- init(path1);
- }
-
- private void init(String path1)
- {
- factory = getModel4Factory();
-
- session = openSession();
- session.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
- session.getPackageRegistry().putEPackage(getModel4Package());
-
- transaction = session.openTransaction();
-
- resource1 = transaction.getOrCreateResource(path1);
- }
-
- private void commit() throws CommitException
- {
- transaction.commit();
- }
-
- public void testGenRefSingleContainedUnidirectionalCDO() throws CommitException
- {
- GenRefSingleContained container = factory.createGenRefSingleContained();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("GenRefSingleContainedUnidirectional-Element-0");
- resource1.getContents().add(container);
- container.setElement(element0);
- resource1.getContents().add(element0); // here the element should be removed from the container
-
- check1(container, element0, resource1);
-
- commit();
- purgeCaches();
-
- container = (GenRefSingleContained)resource1.getContents().get(0);
- element0 = (ImplContainedElementNPL)container.getElement();
-
- // check after load
- check2(container, element0, resource1);
- }
-
- public void testGenRefSingleContainedUnidirectionalResourceFirstCDO() throws CommitException
- {
- GenRefSingleContained container = factory.createGenRefSingleContained();
- ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
- element0.setName("GenRefSingleContainedUnidirectional-Element-0");
-
- resource1.getContents().add(container);
- container.setElement(element0);
-
- check3(resource1, container, element0);
-
- commit();
- purgeCaches();
-
- // now only one Object should be contained in the resource because element is only referenced be container
- assertEquals(1, resource1.getContents().size());
-
- container = (GenRefSingleContained)resource1.getContents().get(0);
- element0 = (ImplContainedElementNPL)container.getElement();
-
- check3(resource1, container, element0);
- }
-
- private void check1(GenRefSingleContained container, ImplContainedElementNPL element0, Resource res)
- {
- assertNull(container.getElement()); // element should be null here
- assertEquals(res, container.eResource());
- assertEquals(res, element0.eResource());
- assertNotSame(container, element0.eContainer());
- assertNull(element0.eContainer());
- assertEquals(2, res.getContents().size());
- }
-
- private void check2(GenRefSingleContained container, ImplContainedElementNPL element0, Resource res)
- {
- assertNull(element0); // element should be null here
- assertEquals(res, container.eResource());
- assertEquals(2, res.getContents().size());
- }
-
- private void check3(Resource resource1, GenRefSingleContained container, ImplContainedElementNPL element0)
- {
- assertNotNull(container.getElement()); // element should be null here
- assertEquals(resource1, container.eResource());
- assertEquals(container, element0.eContainer());
- assertNotSame(resource1, element0.eContainer());
- assertEquals(1, resource1.getContents().size());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.GenRefSingleContained;
+import org.eclipse.emf.cdo.tests.model4.ImplContainedElementNPL;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_299190_Test extends AbstractCDOTest
+{
+ private static long uniqueCounter = System.currentTimeMillis();
+
+ private model4Factory factory;
+
+ private CDOResource resource1;
+
+ private CDOTransaction transaction;
+
+ private CDOSession session;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ String path1 = getResourcePath("/resources/folder1/" + uniqueCounter);
+ ++uniqueCounter;
+
+ init(path1);
+ commit();
+ }
+
+ private void purgeCaches()
+ {
+ // according to Eike's comment at Bug 249681, client caches are
+ // ignored, if a new session is opened.
+ // server caches are wiped by the clearCache call.
+ String path1 = resource1.getPath();
+
+ transaction.close();
+ session.close();
+
+ clearCache(getRepository().getRevisionManager());
+ init(path1);
+ }
+
+ private void init(String path1)
+ {
+ factory = getModel4Factory();
+
+ session = openSession();
+ session.getPackageRegistry().putEPackage(getModel4InterfacesPackage());
+ session.getPackageRegistry().putEPackage(getModel4Package());
+
+ transaction = session.openTransaction();
+
+ resource1 = transaction.getOrCreateResource(path1);
+ }
+
+ private void commit() throws CommitException
+ {
+ transaction.commit();
+ }
+
+ public void testGenRefSingleContainedUnidirectionalCDO() throws CommitException
+ {
+ GenRefSingleContained container = factory.createGenRefSingleContained();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("GenRefSingleContainedUnidirectional-Element-0");
+ resource1.getContents().add(container);
+ container.setElement(element0);
+ resource1.getContents().add(element0); // here the element should be removed from the container
+
+ check1(container, element0, resource1);
+
+ commit();
+ purgeCaches();
+
+ container = (GenRefSingleContained)resource1.getContents().get(0);
+ element0 = (ImplContainedElementNPL)container.getElement();
+
+ // check after load
+ check2(container, element0, resource1);
+ }
+
+ public void testGenRefSingleContainedUnidirectionalResourceFirstCDO() throws CommitException
+ {
+ GenRefSingleContained container = factory.createGenRefSingleContained();
+ ImplContainedElementNPL element0 = factory.createImplContainedElementNPL();
+ element0.setName("GenRefSingleContainedUnidirectional-Element-0");
+
+ resource1.getContents().add(container);
+ container.setElement(element0);
+
+ check3(resource1, container, element0);
+
+ commit();
+ purgeCaches();
+
+ // now only one Object should be contained in the resource because element is only referenced be container
+ assertEquals(1, resource1.getContents().size());
+
+ container = (GenRefSingleContained)resource1.getContents().get(0);
+ element0 = (ImplContainedElementNPL)container.getElement();
+
+ check3(resource1, container, element0);
+ }
+
+ private void check1(GenRefSingleContained container, ImplContainedElementNPL element0, Resource res)
+ {
+ assertNull(container.getElement()); // element should be null here
+ assertEquals(res, container.eResource());
+ assertEquals(res, element0.eResource());
+ assertNotSame(container, element0.eContainer());
+ assertNull(element0.eContainer());
+ assertEquals(2, res.getContents().size());
+ }
+
+ private void check2(GenRefSingleContained container, ImplContainedElementNPL element0, Resource res)
+ {
+ assertNull(element0); // element should be null here
+ assertEquals(res, container.eResource());
+ assertEquals(2, res.getContents().size());
+ }
+
+ private void check3(Resource resource1, GenRefSingleContained container, ImplContainedElementNPL element0)
+ {
+ assertNotNull(container.getElement()); // element should be null here
+ assertEquals(resource1, container.eResource());
+ assertEquals(container, element0.eContainer());
+ assertNotSame(resource1, element0.eContainer());
+ assertEquals(1, resource1.getContents().size());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302233_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302233_Test.java
index c5dab0dc29..be43428870 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302233_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302233_Test.java
@@ -1,112 +1,112 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * unset of CDO does not work correctly
- * <p>
- * See bug 302233
- *
- * @author Martin Fluegge
- */
-public class Bugzilla_302233_Test extends AbstractCDOTest
-{
- public void testUnset() throws Exception
- {
- Order order = getModel1Factory().createPurchaseOrder();
- EStructuralFeature feature = getModel1Package().getOrder_OrderDetails();
- assertEquals(false, order.eIsSet(feature));
-
- order.eUnset(feature);
-
- for (int i = 0; i < 10; i++)
- {
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
- }
-
- order.eUnset(feature);
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(getModel1Package());
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(order);
-
- for (int i = 0; i < 10; i++)
- {
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- order.getOrderDetails().add(orderDetail);
- }
-
- transaction.commit();
-
- order.eUnset(feature);
- assertEquals(false, order.eIsSet(getModel1Package().getOrder_OrderDetails()));
-
- session.close();
- }
-
- public void testUnset2() throws Exception
- {
- EReference feature = getModel1Package().getCompany_Categories();
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(company);
- transaction.commit();
-
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
- company.getCategories().add(getModel1Factory().createCategory());
-
- company.eUnset(feature);
- assertEquals(false, company.eIsSet(feature));
-
- transaction.commit();
- session.close();
- }
-
- public void testRemove() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
-
- resource.getContents().remove(3);
- resource.getContents().remove(2);
- resource.getContents().remove(1);
- resource.getContents().remove(0);
-
- transaction.commit();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * unset of CDO does not work correctly
+ * <p>
+ * See bug 302233
+ *
+ * @author Martin Fluegge
+ */
+public class Bugzilla_302233_Test extends AbstractCDOTest
+{
+ public void testUnset() throws Exception
+ {
+ Order order = getModel1Factory().createPurchaseOrder();
+ EStructuralFeature feature = getModel1Package().getOrder_OrderDetails();
+ assertEquals(false, order.eIsSet(feature));
+
+ order.eUnset(feature);
+
+ for (int i = 0; i < 10; i++)
+ {
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+ }
+
+ order.eUnset(feature);
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(getModel1Package());
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(order);
+
+ for (int i = 0; i < 10; i++)
+ {
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ order.getOrderDetails().add(orderDetail);
+ }
+
+ transaction.commit();
+
+ order.eUnset(feature);
+ assertEquals(false, order.eIsSet(getModel1Package().getOrder_OrderDetails()));
+
+ session.close();
+ }
+
+ public void testUnset2() throws Exception
+ {
+ EReference feature = getModel1Package().getCompany_Categories();
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(company);
+ transaction.commit();
+
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+ company.getCategories().add(getModel1Factory().createCategory());
+
+ company.eUnset(feature);
+ assertEquals(false, company.eIsSet(feature));
+
+ transaction.commit();
+ session.close();
+ }
+
+ public void testRemove() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+
+ resource.getContents().remove(3);
+ resource.getContents().remove(2);
+ resource.getContents().remove(1);
+ resource.getContents().remove(0);
+
+ transaction.commit();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302414_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302414_Test.java
index 23b85df1dd..ad654b2bd3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302414_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_302414_Test.java
@@ -1,99 +1,99 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import java.util.List;
-
-/**
- * Bug 302414, bug 316713 - ArrayIndexOutOfBoundsException in CDOListFeatureDeltaImpl
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_302414_Test extends AbstractCDOTest
-{
- public void test1() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
-
- Company company = getModel1Factory().createCompany();
- r1.getContents().add(company);
- tx.commit();
-
- List<PurchaseOrder> list = company.getPurchaseOrders();
-
- PurchaseOrder foo = getModel1Factory().createPurchaseOrder();
- list.add(foo);
- list.remove(foo);
-
- PurchaseOrder bar = getModel1Factory().createPurchaseOrder();
- list.add(bar);
-
- for (int i = 0; i < 10; i++)
- {
- company.getPurchaseOrders().add(getModel1Factory().createPurchaseOrder());
- }
-
- try
- {
- list.remove(bar);
- }
- catch (ArrayIndexOutOfBoundsException e)
- {
- e.printStackTrace();
- fail("Should not have thrown " + e.getClass().getName());
- }
-
- tx.close();
- session.close();
- }
-
- public void test2() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
-
- Company company = getModel1Factory().createCompany();
- r1.getContents().add(company);
- tx.commit();
-
- List<PurchaseOrder> list = company.getPurchaseOrders();
-
- try
- {
- for (int i = 0; i < 20; i++)
- {
- PurchaseOrder foo1 = getModel1Factory().createPurchaseOrder();
- PurchaseOrder foo2 = getModel1Factory().createPurchaseOrder();
- list.add(foo1);
- list.add(foo2);
- list.remove(foo1);
- }
- }
- catch (ArrayIndexOutOfBoundsException e)
- {
- fail("Should not have thrown " + e.getClass().getName());
- }
-
- tx.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import java.util.List;
+
+/**
+ * Bug 302414, bug 316713 - ArrayIndexOutOfBoundsException in CDOListFeatureDeltaImpl
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_302414_Test extends AbstractCDOTest
+{
+ public void test1() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ Company company = getModel1Factory().createCompany();
+ r1.getContents().add(company);
+ tx.commit();
+
+ List<PurchaseOrder> list = company.getPurchaseOrders();
+
+ PurchaseOrder foo = getModel1Factory().createPurchaseOrder();
+ list.add(foo);
+ list.remove(foo);
+
+ PurchaseOrder bar = getModel1Factory().createPurchaseOrder();
+ list.add(bar);
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getPurchaseOrders().add(getModel1Factory().createPurchaseOrder());
+ }
+
+ try
+ {
+ list.remove(bar);
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ e.printStackTrace();
+ fail("Should not have thrown " + e.getClass().getName());
+ }
+
+ tx.close();
+ session.close();
+ }
+
+ public void test2() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ Company company = getModel1Factory().createCompany();
+ r1.getContents().add(company);
+ tx.commit();
+
+ List<PurchaseOrder> list = company.getPurchaseOrders();
+
+ try
+ {
+ for (int i = 0; i < 20; i++)
+ {
+ PurchaseOrder foo1 = getModel1Factory().createPurchaseOrder();
+ PurchaseOrder foo2 = getModel1Factory().createPurchaseOrder();
+ list.add(foo1);
+ list.add(foo2);
+ list.remove(foo1);
+ }
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ fail("Should not have thrown " + e.getClass().getName());
+ }
+
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303466_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303466_Test.java
index 817aba319a..9140ecc0bf 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303466_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303466_Test.java
@@ -1,150 +1,150 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.util.TestEMFUtil;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.signal.RemoteException;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * CDO not robust when using dynamic packages
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_303466_Test extends AbstractCDOTest
-{
- @CleanRepositoriesBefore
- public void test_missingDependency() throws Exception
- {
- CDOSession session = openSession();
-
- ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
- EPackage derivedPkg = TestEMFUtil.loadEcore("../org.eclipse.emf.cdo.tests/model/derived.ecore");
- Resource resource = derivedPkg.eResource();
- resourceSet.getResources().add(resource);
- resource.load(null);
-
- session.getPackageRegistry().putEPackage(derivedPkg);
- assertEquals(4, session.getPackageRegistry().size());
-
- EClass derivedClass = (EClass)derivedPkg.getEClassifier("DerivedClass");
- EObject derived = derivedPkg.getEFactoryInstance().create(derivedClass);
-
- // Verify that the feature inherited from the base class is missing
- assertNull(derivedClass.getEStructuralFeature("couter"));
-
- CDOTransaction tx = session.openTransaction();
- CDOResource resource2 = tx.createResource(getResourcePath("/resource1"));
- resource2.getContents().add(derived);
-
- try
- {
- tx.commit();
- fail("Should have thrown an exception because of the missing base package");
- }
- catch (CommitException e)
- {
- if (e.getCause() instanceof IllegalStateException)
- {
- // Good
- }
- else if (e.getCause() instanceof RemoteException)
- {
- fail("Problem should have been detected on the client side");
- }
- else
- {
- throw e;
- }
- }
- finally
- {
- tx.close();
- session.close();
- }
- }
-
- public void test_badUris() throws IOException
- {
- CDOSession session = openSession();
-
- ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
-
- EPackage basePkg = TestEMFUtil.loadEcore("../org.eclipse.emf.cdo.tests/model/base.ecore");
- Resource resource1 = basePkg.eResource();
- resourceSet.getResources().add(resource1);
- resourceSet.getPackageRegistry().put(basePkg.getNsURI(), basePkg);
-
- EPackage derivedPkg = TestEMFUtil.loadEcore("../org.eclipse.emf.cdo.tests/model/derived.ecore");
- Resource resource2 = derivedPkg.eResource();
- resourceSet.getResources().add(resource2);
- resourceSet.getPackageRegistry().put(basePkg.getNsURI(), derivedPkg);
-
- Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
- URI modelUri3 = URI.createFileURI("base.ecore");
- uriMap.put(modelUri3, resource1.getURI());
-
- EMFUtil.safeResolveAll(resourceSet);
-
- session.getPackageRegistry().putEPackage(basePkg);
- session.getPackageRegistry().putEPackage(derivedPkg);
-
- EClass derivedClass = (EClass)derivedPkg.getEClassifier("DerivedClass");
- EObject derived = derivedPkg.getEFactoryInstance().create(derivedClass);
-
- // Verify that the feature inherited from the base class is NOT missing on the client side
- assertNotNull(derivedClass.getEStructuralFeature("couter"));
-
- CDOTransaction tx = session.openTransaction();
- CDOResource resource3 = tx.createResource(getResourcePath("/resource1"));
- resource3.getContents().add(derived);
-
- try
- {
- tx.commit();
- fail("Should have thrown an exception because of the file URIs in the dependent package");
- }
- catch (CommitException e)
- {
- if (e.getCause() instanceof IllegalStateException)
- {
- // Good
- }
- else if (e.getCause() instanceof RemoteException)
- {
- fail("Problem should have been detected on the client side");
- }
- else
- {
- fail("Should have thrown an " + IllegalStateException.class.getName());
- }
- }
-
- tx.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.util.TestEMFUtil;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.signal.RemoteException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * CDO not robust when using dynamic packages
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_303466_Test extends AbstractCDOTest
+{
+ @CleanRepositoriesBefore
+ public void test_missingDependency() throws Exception
+ {
+ CDOSession session = openSession();
+
+ ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
+ EPackage derivedPkg = TestEMFUtil.loadEcore("../org.eclipse.emf.cdo.tests/model/derived.ecore");
+ Resource resource = derivedPkg.eResource();
+ resourceSet.getResources().add(resource);
+ resource.load(null);
+
+ session.getPackageRegistry().putEPackage(derivedPkg);
+ assertEquals(4, session.getPackageRegistry().size());
+
+ EClass derivedClass = (EClass)derivedPkg.getEClassifier("DerivedClass");
+ EObject derived = derivedPkg.getEFactoryInstance().create(derivedClass);
+
+ // Verify that the feature inherited from the base class is missing
+ assertNull(derivedClass.getEStructuralFeature("couter"));
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource2 = tx.createResource(getResourcePath("/resource1"));
+ resource2.getContents().add(derived);
+
+ try
+ {
+ tx.commit();
+ fail("Should have thrown an exception because of the missing base package");
+ }
+ catch (CommitException e)
+ {
+ if (e.getCause() instanceof IllegalStateException)
+ {
+ // Good
+ }
+ else if (e.getCause() instanceof RemoteException)
+ {
+ fail("Problem should have been detected on the client side");
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ finally
+ {
+ tx.close();
+ session.close();
+ }
+ }
+
+ public void test_badUris() throws IOException
+ {
+ CDOSession session = openSession();
+
+ ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
+
+ EPackage basePkg = TestEMFUtil.loadEcore("../org.eclipse.emf.cdo.tests/model/base.ecore");
+ Resource resource1 = basePkg.eResource();
+ resourceSet.getResources().add(resource1);
+ resourceSet.getPackageRegistry().put(basePkg.getNsURI(), basePkg);
+
+ EPackage derivedPkg = TestEMFUtil.loadEcore("../org.eclipse.emf.cdo.tests/model/derived.ecore");
+ Resource resource2 = derivedPkg.eResource();
+ resourceSet.getResources().add(resource2);
+ resourceSet.getPackageRegistry().put(basePkg.getNsURI(), derivedPkg);
+
+ Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
+ URI modelUri3 = URI.createFileURI("base.ecore");
+ uriMap.put(modelUri3, resource1.getURI());
+
+ EMFUtil.safeResolveAll(resourceSet);
+
+ session.getPackageRegistry().putEPackage(basePkg);
+ session.getPackageRegistry().putEPackage(derivedPkg);
+
+ EClass derivedClass = (EClass)derivedPkg.getEClassifier("DerivedClass");
+ EObject derived = derivedPkg.getEFactoryInstance().create(derivedClass);
+
+ // Verify that the feature inherited from the base class is NOT missing on the client side
+ assertNotNull(derivedClass.getEStructuralFeature("couter"));
+
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource3 = tx.createResource(getResourcePath("/resource1"));
+ resource3.getContents().add(derived);
+
+ try
+ {
+ tx.commit();
+ fail("Should have thrown an exception because of the file URIs in the dependent package");
+ }
+ catch (CommitException e)
+ {
+ if (e.getCause() instanceof IllegalStateException)
+ {
+ // Good
+ }
+ else if (e.getCause() instanceof RemoteException)
+ {
+ fail("Problem should have been detected on the client side");
+ }
+ else
+ {
+ fail("Should have thrown an " + IllegalStateException.class.getName());
+ }
+ }
+
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303807_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303807_Test.java
index e6232c5e10..de46a07757 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303807_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_303807_Test.java
@@ -1,47 +1,47 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * InvalidObjectException when switching branch
- * <p>
- * See bug 303807
- *
- * @author Victor Roldan Betancort
- */
-@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
-public class Bugzilla_303807_Test extends AbstractCDOTest
-{
- public void testBugzilla_303807() throws Exception
- {
- CDOSession session = openSession();
-
- // Commit to main branch a new resource
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOTransaction transaction = session.openTransaction(mainBranch);
- transaction.createResource(getResourcePath("/test1"));
- transaction.commit();
-
- // Switch transaction to a new branch
- CDOBranch newBranch = mainBranch.createBranch("foobar");
- transaction.setBranch(newBranch);
-
- transaction.getRootResource().getContents().size();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * InvalidObjectException when switching branch
+ * <p>
+ * See bug 303807
+ *
+ * @author Victor Roldan Betancort
+ */
+@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+public class Bugzilla_303807_Test extends AbstractCDOTest
+{
+ public void testBugzilla_303807() throws Exception
+ {
+ CDOSession session = openSession();
+
+ // Commit to main branch a new resource
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOTransaction transaction = session.openTransaction(mainBranch);
+ transaction.createResource(getResourcePath("/test1"));
+ transaction.commit();
+
+ // Switch transaction to a new branch
+ CDOBranch newBranch = mainBranch.createBranch("foobar");
+ transaction.setBranch(newBranch);
+
+ transaction.getRootResource().getContents().size();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_305527_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_305527_Test.java
index e0e4affbb2..bd9e978ec1 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_305527_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_305527_Test.java
@@ -1,71 +1,71 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.mango.MangoValue;
-import org.eclipse.emf.cdo.tests.mango.MangoValueList;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-/**
- * @author Martin Fluegge
- * @since 4.0
- */
-public class Bugzilla_305527_Test extends AbstractCDOTest
-{
- @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
- public void testAvoidReferencingDifferentViews() throws CommitException
- {
- final CDOSession session = openSession();
- long commitTime;
-
- {
- MangoValue mangoValue = getMangoFactory().createMangoValue();
- mangoValue.setName("1");
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1")); //$NON-NLS-1$
- resource.getContents().add(mangoValue);
- commitTime = transaction.commit().getTimeStamp();
-
- mangoValue.setName("2");
- transaction.commit();
- transaction.close();
- }
-
- CDOView audit = session.openView(commitTime);
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- MangoValue mangoValue = (MangoValue)auditResource.getContents().get(0);
- assertEquals("1", mangoValue.getName());
-
- MangoValueList mangoList = getMangoFactory().createMangoValueList();
- mangoList.getValues().add(mangoValue);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/res1")); //$NON-NLS-1$
-
- try
- {
- resource.getContents().add(mangoList);
- fail("IllegalArgumentException expected");
- }
- catch (IllegalArgumentException expected)
- {
- // SUCCESS
- expected.printStackTrace();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.mango.MangoValue;
+import org.eclipse.emf.cdo.tests.mango.MangoValueList;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * @author Martin Fluegge
+ * @since 4.0
+ */
+public class Bugzilla_305527_Test extends AbstractCDOTest
+{
+ @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+ public void testAvoidReferencingDifferentViews() throws CommitException
+ {
+ final CDOSession session = openSession();
+ long commitTime;
+
+ {
+ MangoValue mangoValue = getMangoFactory().createMangoValue();
+ mangoValue.setName("1");
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1")); //$NON-NLS-1$
+ resource.getContents().add(mangoValue);
+ commitTime = transaction.commit().getTimeStamp();
+
+ mangoValue.setName("2");
+ transaction.commit();
+ transaction.close();
+ }
+
+ CDOView audit = session.openView(commitTime);
+ CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
+ MangoValue mangoValue = (MangoValue)auditResource.getContents().get(0);
+ assertEquals("1", mangoValue.getName());
+
+ MangoValueList mangoList = getMangoFactory().createMangoValueList();
+ mangoList.getValues().add(mangoValue);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/res1")); //$NON-NLS-1$
+
+ try
+ {
+ resource.getContents().add(mangoList);
+ fail("IllegalArgumentException expected");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // SUCCESS
+ expected.printStackTrace();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306710_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306710_Test.java
index f0000904a2..cda83c219d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306710_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306710_Test.java
@@ -1,187 +1,187 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-
-/**
- * IndexOutOfBoundsException in buildNotification.
- * <p>
- * See bug 306710
- */
-public class Bugzilla_306710_Test extends AbstractCDOTest
-{
- public void testBugzilla_306710_remove() throws Exception
- {
- final NotifyCounter counter = new NotifyCounter();
-
- // setup connection1.
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
- CDOResource resource1 = transaction1.createResource(getResourcePath("/test1"));
-
- // add initial model.
- Company company1 = getModel1Factory().createCompany();
- resource1.getContents().add(company1);
- Category category1a = getModel1Factory().createCategory();
- company1.getCategories().add(category1a);
- transaction1.commit();
-
- // sleep(100);
-
- // setup connection2.
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/test1"));
-
- // add adapter to company2 to have sendDeltaNotification being called.
- Company company2 = (Company)resource2.getContents().get(0);
- company2.eAdapters().add(new AdapterImpl()
- {
- @Override
- public void notifyChanged(Notification msg)
- {
- if (msg.getEventType() == Notification.ADD)
- {
- counter.incAdds();
- }
- else if (msg.getEventType() == Notification.REMOVE)
- {
- counter.incRemoves();
- }
- }
- });
-
- // add and remove an object from category list of company to have the CDONotificationBuilder call remove with an
- // index not known to the oldRevision.
- Category category1b = getModel1Factory().createCategory();
- company1.getCategories().add(0, category1b);
- company1.getCategories().remove(1);
-
- // commit the changes.
- transaction1.commit();
-
- // wait for the invalidation to arrive on transaction2.
- transaction2.waitForUpdate(transaction1.getLastCommitTime(), DEFAULT_TIMEOUT);
-
- // cleanup.
- session1.close();
- session2.close();
-
- // check if the notifications arrived (which is not the case because of the exception).
- assertEquals(1, counter.getAdds());
- assertEquals(1, counter.getRemoves());
- }
-
- /**
- * @since 4.0
- */
- public void testBugzilla_306710_addRemove() throws Exception
- {
- final NotifyCounter counter = new NotifyCounter();
-
- // setup connection1.
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
- CDOResource resource1 = transaction1.createResource(getResourcePath("/test1"));
-
- // add initial model.
- Company company1 = getModel1Factory().createCompany();
- resource1.getContents().add(company1);
- transaction1.commit();
-
- // sleep(100);
-
- // setup connection2.
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
- transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/test1"));
-
- // add adapter to company2 to have sendDeltaNotification being called.
- Company company2 = (Company)resource2.getContents().get(0);
- company2.eAdapters().add(new AdapterImpl()
- {
- @Override
- public void notifyChanged(Notification msg)
- {
- if (msg.getEventType() == Notification.ADD)
- {
- counter.incAdds();
- }
- else if (msg.getEventType() == Notification.REMOVE)
- {
- counter.incRemoves();
- }
- }
- });
-
- // add and remove an object from category list of company to have the CDONotificationBuilder call remove with an
- // index not known to the oldRevision.
- Category category1a = getModel1Factory().createCategory();
- company1.getCategories().add(0, category1a);
- company1.getCategories().remove(0);
-
- // commit the changes.
- transaction1.commit();
-
- // wait for the invalidation to arrive on transaction2.
- transaction2.waitForUpdate(transaction1.getLastCommitTime(), DEFAULT_TIMEOUT);
-
- // cleanup.
- session1.close();
- session2.close();
-
- // check if the notifications arrived (which is not the case because of the exception).
- assertEquals(0, counter.getAdds());
- assertEquals(0, counter.getRemoves());
- }
-
- /**
- * Helper class to count the notifications.
- */
- public static class NotifyCounter
- {
- int adds;
-
- int removes;
-
- public int getAdds()
- {
- return adds;
- }
-
- public int getRemoves()
- {
- return removes;
- }
-
- public void incAdds()
- {
- adds++;
- }
-
- public void incRemoves()
- {
- removes++;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+
+/**
+ * IndexOutOfBoundsException in buildNotification.
+ * <p>
+ * See bug 306710
+ */
+public class Bugzilla_306710_Test extends AbstractCDOTest
+{
+ public void testBugzilla_306710_remove() throws Exception
+ {
+ final NotifyCounter counter = new NotifyCounter();
+
+ // setup connection1.
+ CDOSession session1 = openSession();
+ CDOTransaction transaction1 = session1.openTransaction();
+ CDOResource resource1 = transaction1.createResource(getResourcePath("/test1"));
+
+ // add initial model.
+ Company company1 = getModel1Factory().createCompany();
+ resource1.getContents().add(company1);
+ Category category1a = getModel1Factory().createCategory();
+ company1.getCategories().add(category1a);
+ transaction1.commit();
+
+ // sleep(100);
+
+ // setup connection2.
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/test1"));
+
+ // add adapter to company2 to have sendDeltaNotification being called.
+ Company company2 = (Company)resource2.getContents().get(0);
+ company2.eAdapters().add(new AdapterImpl()
+ {
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ if (msg.getEventType() == Notification.ADD)
+ {
+ counter.incAdds();
+ }
+ else if (msg.getEventType() == Notification.REMOVE)
+ {
+ counter.incRemoves();
+ }
+ }
+ });
+
+ // add and remove an object from category list of company to have the CDONotificationBuilder call remove with an
+ // index not known to the oldRevision.
+ Category category1b = getModel1Factory().createCategory();
+ company1.getCategories().add(0, category1b);
+ company1.getCategories().remove(1);
+
+ // commit the changes.
+ transaction1.commit();
+
+ // wait for the invalidation to arrive on transaction2.
+ transaction2.waitForUpdate(transaction1.getLastCommitTime(), DEFAULT_TIMEOUT);
+
+ // cleanup.
+ session1.close();
+ session2.close();
+
+ // check if the notifications arrived (which is not the case because of the exception).
+ assertEquals(1, counter.getAdds());
+ assertEquals(1, counter.getRemoves());
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void testBugzilla_306710_addRemove() throws Exception
+ {
+ final NotifyCounter counter = new NotifyCounter();
+
+ // setup connection1.
+ CDOSession session1 = openSession();
+ CDOTransaction transaction1 = session1.openTransaction();
+ CDOResource resource1 = transaction1.createResource(getResourcePath("/test1"));
+
+ // add initial model.
+ Company company1 = getModel1Factory().createCompany();
+ resource1.getContents().add(company1);
+ transaction1.commit();
+
+ // sleep(100);
+
+ // setup connection2.
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("/test1"));
+
+ // add adapter to company2 to have sendDeltaNotification being called.
+ Company company2 = (Company)resource2.getContents().get(0);
+ company2.eAdapters().add(new AdapterImpl()
+ {
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ if (msg.getEventType() == Notification.ADD)
+ {
+ counter.incAdds();
+ }
+ else if (msg.getEventType() == Notification.REMOVE)
+ {
+ counter.incRemoves();
+ }
+ }
+ });
+
+ // add and remove an object from category list of company to have the CDONotificationBuilder call remove with an
+ // index not known to the oldRevision.
+ Category category1a = getModel1Factory().createCategory();
+ company1.getCategories().add(0, category1a);
+ company1.getCategories().remove(0);
+
+ // commit the changes.
+ transaction1.commit();
+
+ // wait for the invalidation to arrive on transaction2.
+ transaction2.waitForUpdate(transaction1.getLastCommitTime(), DEFAULT_TIMEOUT);
+
+ // cleanup.
+ session1.close();
+ session2.close();
+
+ // check if the notifications arrived (which is not the case because of the exception).
+ assertEquals(0, counter.getAdds());
+ assertEquals(0, counter.getRemoves());
+ }
+
+ /**
+ * Helper class to count the notifications.
+ */
+ public static class NotifyCounter
+ {
+ int adds;
+
+ int removes;
+
+ public int getAdds()
+ {
+ return adds;
+ }
+
+ public int getRemoves()
+ {
+ return removes;
+ }
+
+ public void incAdds()
+ {
+ adds++;
+ }
+
+ public void incRemoves()
+ {
+ removes++;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306998_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306998_Test.java
index 898a2fa39e..514f1a7993 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306998_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_306998_Test.java
@@ -1,115 +1,115 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.legacy.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_306998_Test extends AbstractCDOTest
-{
- @CleanRepositoriesBefore
- public void testValidEENumLiteral() throws CommitException
- {
- EPackage pkg = EMFUtil.createEPackage("pkg", "pkg", "http://cdo.eclipse.org/Bugzilla_306998_Test_1.ecore");
- EClass cls = EMFUtil.createEClass(pkg, "cls", false, false);
- EAttribute att = EMFUtil.createEAttribute(cls, "att", Model1Package.eINSTANCE.getVAT());
- att.setDefaultValueLiteral("vat7");
-
- CDOUtil.prepareDynamicEPackage(pkg);
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test"));
-
- EObject obj = EcoreUtil.create(cls);
-
- res.getContents().add(obj);
- tx.commit();
- tx.close();
- session.close();
- }
- clearCache(getRepository().getRevisionManager());
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView view = session.openView();
- CDOResource res = view.getResource(getResourcePath("/test"));
-
- EObject obj = res.getContents().get(0);
- assertEquals(7, ((VAT)obj.eGet(att)).getValue());
-
- view.close();
- session.close();
- }
- }
-
- // does not affect MemStore!
- @Skips("MEM")
- @CleanRepositoriesBefore
- public void testInalidEENumLiteral() throws CommitException
- {
- EPackage pkg = EMFUtil.createEPackage("pkg", "pkg", "http://cdo.eclipse.org/Bugzilla_306998_Test_1.ecore");
- EClass cls = EMFUtil.createEClass(pkg, "cls", false, false);
- EAttribute att = EMFUtil.createEAttribute(cls, "att", Model1Package.eINSTANCE.getVAT());
- att.setDefaultValueLiteral("vat8");
- att.setDefaultValue(Model1Package.eINSTANCE.getVAT().getEEnumLiteral("vat8"));
-
- CDOUtil.prepareDynamicEPackage(pkg);
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test"));
-
- EObject obj = EcoreUtil.create(cls);
-
- res.getContents().add(obj);
- tx.commit();
- tx.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView view = session.openView();
- CDOResource res = view.getResource(getResourcePath("/test"));
-
- EObject obj = res.getContents().get(0);
- assertEquals(0, ((VAT)obj.eGet(att)).getValue());
-
- view.close();
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.legacy.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_306998_Test extends AbstractCDOTest
+{
+ @CleanRepositoriesBefore
+ public void testValidEENumLiteral() throws CommitException
+ {
+ EPackage pkg = EMFUtil.createEPackage("pkg", "pkg", "http://cdo.eclipse.org/Bugzilla_306998_Test_1.ecore");
+ EClass cls = EMFUtil.createEClass(pkg, "cls", false, false);
+ EAttribute att = EMFUtil.createEAttribute(cls, "att", Model1Package.eINSTANCE.getVAT());
+ att.setDefaultValueLiteral("vat7");
+
+ CDOUtil.prepareDynamicEPackage(pkg);
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test"));
+
+ EObject obj = EcoreUtil.create(cls);
+
+ res.getContents().add(obj);
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+ clearCache(getRepository().getRevisionManager());
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView view = session.openView();
+ CDOResource res = view.getResource(getResourcePath("/test"));
+
+ EObject obj = res.getContents().get(0);
+ assertEquals(7, ((VAT)obj.eGet(att)).getValue());
+
+ view.close();
+ session.close();
+ }
+ }
+
+ // does not affect MemStore!
+ @Skips("MEM")
+ @CleanRepositoriesBefore
+ public void testInalidEENumLiteral() throws CommitException
+ {
+ EPackage pkg = EMFUtil.createEPackage("pkg", "pkg", "http://cdo.eclipse.org/Bugzilla_306998_Test_1.ecore");
+ EClass cls = EMFUtil.createEClass(pkg, "cls", false, false);
+ EAttribute att = EMFUtil.createEAttribute(cls, "att", Model1Package.eINSTANCE.getVAT());
+ att.setDefaultValueLiteral("vat8");
+ att.setDefaultValue(Model1Package.eINSTANCE.getVAT().getEEnumLiteral("vat8"));
+
+ CDOUtil.prepareDynamicEPackage(pkg);
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test"));
+
+ EObject obj = EcoreUtil.create(cls);
+
+ res.getContents().add(obj);
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView view = session.openView();
+ CDOResource res = view.getResource(getResourcePath("/test"));
+
+ EObject obj = res.getContents().get(0);
+ assertEquals(0, ((VAT)obj.eGet(att)).getValue());
+
+ view.close();
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_308895_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_308895_Test.java
index 7212d77140..cdc3841b71 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_308895_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_308895_Test.java
@@ -1,245 +1,245 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * @author Stefan Winkler
- */
-public class Bugzilla_308895_Test extends AbstractCDOTest
-{
- private EPackage pkg;
-
- private EClass cls;
-
- private EAttribute att;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- pkg = EMFUtil.createEPackage("customTest", "ct", "http://cdo.emf.eclipse.org/customTest.ecore");
- EDataType custom = EcoreFactory.eINSTANCE.createEDataType();
- custom.setInstanceClass(CustomType.class);
- custom.setName("CustomType");
-
- pkg.getEClassifiers().add(custom);
-
- cls = EMFUtil.createEClass(pkg, "Foobar", false, false);
- att = EMFUtil.createEAttribute(cls, "att", custom);
-
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- protected EAttribute getAtt()
- {
- return att;
- }
-
- public void testCustomRegular() throws CommitException
- {
- EObject obj = EcoreUtil.create(cls);
- obj.eSet(att, new CustomType(23, 42));
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test"));
- res.getContents().add(obj);
- tx.commit();
- tx.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView v = session.openView();
- CDOResource res = v.getResource(getResourcePath("/test"));
- EObject persistent = res.getContents().get(0);
-
- CustomType pCustom = (CustomType)persistent.eGet(att);
- assertEquals(23, pCustom.getA());
- assertEquals(42, pCustom.getB());
-
- v.close();
- session.close();
- }
- }
-
- public void testCustomDefaultLiteral() throws CommitException
- {
- // valid default literal
- att.setDefaultValueLiteral("1;2");
-
- EObject obj = EcoreUtil.create(cls);
- obj.eUnset(att);
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test"));
- res.getContents().add(obj);
- tx.commit();
- tx.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView v = session.openView();
- CDOResource res = v.getResource(getResourcePath("/test"));
- EObject persistent = res.getContents().get(0);
-
- CustomType pCustom = (CustomType)persistent.eGet(att);
- assertEquals(1, pCustom.getA());
- assertEquals(2, pCustom.getB());
-
- v.close();
- session.close();
- }
- }
-
- public void testCustomDefaultDefault() throws CommitException
- {
- // no default literal is set
- EObject obj = EcoreUtil.create(cls);
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test"));
- res.getContents().add(obj);
- tx.commit();
- tx.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView v = session.openView();
- CDOResource res = v.getResource(getResourcePath("/test"));
- EObject persistent = res.getContents().get(0);
-
- CustomType pCustom = (CustomType)persistent.eGet(att);
- assertNull(pCustom);
-
- v.close();
- session.close();
- }
- }
-
- public void testCustomDefaultInvalidLiteral() throws CommitException
- {
- // invalid default literal
- att.setDefaultValueLiteral("1;2;3");
-
- EObject obj = EcoreUtil.create(cls);
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test"));
- res.getContents().add(obj);
- tx.commit();
- tx.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView v = session.openView();
- CDOResource res = v.getResource(getResourcePath("/test"));
- EObject persistent = res.getContents().get(0);
-
- CustomType pCustom = (CustomType)persistent.eGet(att);
- assertNull(pCustom);
-
- v.close();
- session.close();
- }
- }
-
- public static class CustomType
- {
- private int a = 0;
-
- private int b = 0;
-
- public CustomType(int _a, int _b)
- {
- a = _a;
- b = _b;
- }
-
- public CustomType(String literal)
- {
- String[] values = literal.split(";");
- if (values.length != 2)
- {
- throw new RuntimeException("Error: only 2 values allowed");
- }
- else
- {
- a = Integer.valueOf(values[0]);
- b = Integer.valueOf(values[1]);
- }
- }
-
- @Override
- public String toString()
- {
- return a + ";" + b;
- }
-
- public int getA()
- {
- return a;
- }
-
- public int getB()
- {
- return b;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_308895_Test extends AbstractCDOTest
+{
+ private EPackage pkg;
+
+ private EClass cls;
+
+ private EAttribute att;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ pkg = EMFUtil.createEPackage("customTest", "ct", "http://cdo.emf.eclipse.org/customTest.ecore");
+ EDataType custom = EcoreFactory.eINSTANCE.createEDataType();
+ custom.setInstanceClass(CustomType.class);
+ custom.setName("CustomType");
+
+ pkg.getEClassifiers().add(custom);
+
+ cls = EMFUtil.createEClass(pkg, "Foobar", false, false);
+ att = EMFUtil.createEAttribute(cls, "att", custom);
+
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ protected EAttribute getAtt()
+ {
+ return att;
+ }
+
+ public void testCustomRegular() throws CommitException
+ {
+ EObject obj = EcoreUtil.create(cls);
+ obj.eSet(att, new CustomType(23, 42));
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test"));
+ res.getContents().add(obj);
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView v = session.openView();
+ CDOResource res = v.getResource(getResourcePath("/test"));
+ EObject persistent = res.getContents().get(0);
+
+ CustomType pCustom = (CustomType)persistent.eGet(att);
+ assertEquals(23, pCustom.getA());
+ assertEquals(42, pCustom.getB());
+
+ v.close();
+ session.close();
+ }
+ }
+
+ public void testCustomDefaultLiteral() throws CommitException
+ {
+ // valid default literal
+ att.setDefaultValueLiteral("1;2");
+
+ EObject obj = EcoreUtil.create(cls);
+ obj.eUnset(att);
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test"));
+ res.getContents().add(obj);
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView v = session.openView();
+ CDOResource res = v.getResource(getResourcePath("/test"));
+ EObject persistent = res.getContents().get(0);
+
+ CustomType pCustom = (CustomType)persistent.eGet(att);
+ assertEquals(1, pCustom.getA());
+ assertEquals(2, pCustom.getB());
+
+ v.close();
+ session.close();
+ }
+ }
+
+ public void testCustomDefaultDefault() throws CommitException
+ {
+ // no default literal is set
+ EObject obj = EcoreUtil.create(cls);
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test"));
+ res.getContents().add(obj);
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView v = session.openView();
+ CDOResource res = v.getResource(getResourcePath("/test"));
+ EObject persistent = res.getContents().get(0);
+
+ CustomType pCustom = (CustomType)persistent.eGet(att);
+ assertNull(pCustom);
+
+ v.close();
+ session.close();
+ }
+ }
+
+ public void testCustomDefaultInvalidLiteral() throws CommitException
+ {
+ // invalid default literal
+ att.setDefaultValueLiteral("1;2;3");
+
+ EObject obj = EcoreUtil.create(cls);
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test"));
+ res.getContents().add(obj);
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView v = session.openView();
+ CDOResource res = v.getResource(getResourcePath("/test"));
+ EObject persistent = res.getContents().get(0);
+
+ CustomType pCustom = (CustomType)persistent.eGet(att);
+ assertNull(pCustom);
+
+ v.close();
+ session.close();
+ }
+ }
+
+ public static class CustomType
+ {
+ private int a = 0;
+
+ private int b = 0;
+
+ public CustomType(int _a, int _b)
+ {
+ a = _a;
+ b = _b;
+ }
+
+ public CustomType(String literal)
+ {
+ String[] values = literal.split(";");
+ if (values.length != 2)
+ {
+ throw new RuntimeException("Error: only 2 values allowed");
+ }
+ else
+ {
+ a = Integer.valueOf(values[0]);
+ b = Integer.valueOf(values[1]);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return a + ";" + b;
+ }
+
+ public int getA()
+ {
+ return a;
+ }
+
+ public int getB()
+ {
+ return b;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_310574_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_310574_Test.java
index 3053f15535..49993af30e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_310574_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_310574_Test.java
@@ -1,1366 +1,1366 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository.WriteAccessHandler;
-import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
-import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.emf.common.util.EList;
-
-import java.util.Random;
-
-/**
- * CDOAddFeatureDelta with null value.
- * <p>
- * See bug 310574
- *
- * @author Eike Stepper
- */
-@CleanRepositoriesBefore
-public class Bugzilla_310574_Test extends AbstractCDOTest
-{
- @SuppressWarnings("unused")
- private final WriteAccessHandler printHandler = new WriteAccessHandler()
- {
- public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor) throws RuntimeException
- {
- InternalCDORevisionDelta[] deltas = commitContext.getDirtyObjectDeltas();
- for (InternalCDORevisionDelta delta : deltas)
- {
- if (delta.getEClass() == getModel1Package().getCustomer())
- {
- System.out.println(delta);
- }
- }
- }
-
- public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext, OMMonitor monitor)
- {
- }
- };
-
- private SalesOrder[] createSalesOrders(int number)
- {
- SalesOrder orders[] = new SalesOrder[number];
- for (int i = 0; i < number; i++)
- {
- orders[i] = getModel1Factory().createSalesOrder();
- orders[i].setId(i);
- }
-
- return orders;
- }
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- // Adds our handler.
- // getRepository().addHandler(printHandler);
- }
-
- public void testRemoveFromContainerThenFromReferenceList() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
- Company company = getModel1Factory().createCompany();
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(7);
- int[] positions;
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- resource.getContents().add(company);
-
- company.getSalesOrders().clear();
- customer.getSalesOrders().clear();
-
- for (int i = 0; i < order.length; i++)
- {
- company.getSalesOrders().add(order[i]);
- customer.getSalesOrders().add(order[i]);
- }
-
- transaction.commit();
-
- company.getSalesOrders().remove(5);
- company.getSalesOrders().remove(3);
-
- customer.getSalesOrders().remove(5);
- customer.getSalesOrders().remove(3);
-
- positions = new int[customer.getSalesOrders().size()];
- for (int i = 0; i < customer.getSalesOrders().size(); i++)
- {
- positions[i] = customer.getSalesOrders().get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (SalesOrder o : orders)
- {
- System.out.println("b: " + o.getId());
- }
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- /**
- * @since 4.0
- */
- public void testAddAndRemoveWithNull() throws Exception
- {
- // setup connection1.
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- // add initial model.
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- // add and remove an object from category list of company.
- Category category = getModel1Factory().createCategory();
- company.getCategories().add(0, category);
- company.getCategories().remove(0);
-
- // Inspect the transaction.
- CDORevisionDelta delta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(company).cdoID());
- for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas())
- {
- if (featureDelta instanceof CDOListFeatureDelta)
- {
- CDOListFeatureDelta listFeatureDelta = (CDOListFeatureDelta)featureDelta;
- for (CDOFeatureDelta featureDelta2 : listFeatureDelta.getListChanges())
- {
- if (featureDelta2 instanceof CDOAddFeatureDelta)
- {
- CDOAddFeatureDelta addFeatureDelta = (CDOAddFeatureDelta)featureDelta2;
- assertNotSame(CDOID.NULL, addFeatureDelta.getValue());
- }
- }
- }
- }
-
- // ignore the changes.
- transaction.rollback();
-
- // cleanup.
- session.close();
- }
-
- /**
- * @since 4.0
- */
- public void testOptimizeAddAndRemove() throws Exception
- {
- // setup connection1.
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
-
- // add initial model.
- Company company = getModel1Factory().createCompany();
- resource1.getContents().add(company);
- transaction.commit();
-
- // add and remove an object from category list of company.
- Category category = getModel1Factory().createCategory();
-
- // add and remove the same object repeatedly.
- for (int i = 0; i < 100; i++)
- {
- company.getCategories().add(0, category);
- company.getCategories().remove(0);
- }
-
- // Inspect the transaction.
- CDORevisionDelta delta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(company).cdoID());
- for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas())
- {
- if (featureDelta instanceof CDOListFeatureDelta)
- {
- CDOListFeatureDelta listFeatureDelta = (CDOListFeatureDelta)featureDelta;
- assertEquals(0, listFeatureDelta.getListChanges().size());
- }
- }
-
- // ignore the changes.
- transaction.rollback();
-
- // cleanup.
- session.close();
- }
-
- /**
- * @since 4.0
- */
- public void testOptimizeInterleavedAddMoveAndRemove() throws Exception
- {
- // setup connection1.
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- // add initial model.
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.commit();
-
- // add and remove an object from category list of company.
- Category aCategory = getModel1Factory().createCategory();
- Category bCategory = getModel1Factory().createCategory();
-
- // add and remove the same object repeatedly.
- for (int i = 0; i < 100; i++)
- {
- company.getCategories().add(aCategory);
- company.getCategories().add(bCategory);
- company.getCategories().move(0, 1);
- company.getCategories().remove(aCategory);
- company.getCategories().remove(bCategory);
- }
-
- // Inspect the transaction.
- CDORevisionDelta delta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(company).cdoID());
- for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas())
- {
- if (featureDelta instanceof CDOListFeatureDelta)
- {
- CDOListFeatureDelta listFeatureDelta = (CDOListFeatureDelta)featureDelta;
- assertEquals(0, listFeatureDelta.getListChanges().size());
- }
- }
-
- // ignore the changes.
- transaction.rollback();
-
- // cleanup.
- session.close();
- }
-
- public void testAddAndModifyAndRemoveFromPersistedList() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
- String resourcePath = "/test1";
- CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
- res.getContents().add(getModel1Factory().createCompany());
- transaction1.commit();
-
- Supplier supplier = getModel1Factory().createSupplier();
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- res.getContents().add(supplier);
- res.getContents().add(purchaseOrder);
- supplier.getPurchaseOrders().add(purchaseOrder);
- transaction1.commit();
-
- // This remove will generate a CDOSetFeatureDelta that will be added to a CDOListFeatureDelta. Why?
- res.getContents().remove(purchaseOrder);
- supplier.getPurchaseOrders().remove(purchaseOrder);
- purchaseOrder.setSupplier(null);
- transaction1.commit();
- }
-
- public void testListChanges07() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(5);
- int[] positions = new int[5];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- orders.add(order[2]);
-
- transaction.commit();
-
- orders.add(0, order[0]);
- orders.move(1, 0);
- orders.add(0, order[1]);
- orders.remove(1);
- orders.add(1, order[2]);
- orders.remove(2);
- orders.move(1, 0);
- orders.move(0, 1);
- orders.remove(1);
-
- for (int i = 0; i < orders.size(); i++)
- {
- positions[i] = orders.get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testListChanges06() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(5);
- int[] positions = new int[5];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- orders.add(0, order[0]);
- orders.add(0, order[1]);
- orders.add(0, order[2]);
- orders.add(2, order[3]);
- orders.remove(3);
- orders.move(2, 0);
- orders.add(1, order[0]);
- orders.move(2, 1);
- orders.move(3, 0);
- orders.remove(0);
-
- for (int i = 0; i < orders.size(); i++)
- {
- positions[i] = orders.get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testListChanges05() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(5);
- int[] positions = new int[5];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- orders.add(0, order[0]);
- orders.add(0, order[1]);
- orders.move(1, 0);
- orders.add(1, order[2]);
- orders.add(0, order[3]);
- orders.move(1, 3);
- orders.move(2, 3);
- orders.add(1, order[4]);
- orders.remove(4);
-
- for (int i = 0; i < orders.size(); i++)
- {
- positions[i] = orders.get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testListChanges04() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(4);
- int[] positions = new int[4];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- orders.add(0, order[0]);
- orders.add(0, order[1]);
- orders.add(0, order[2]);
- orders.move(1, 2);
- orders.move(1, 2);
- orders.remove(2);
-
- for (int i = 0; i < orders.size(); i++)
- {
- positions[i] = orders.get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testListChanges03() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(4);
- int[] positions = new int[4];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- orders.add(0, order[0]);
- orders.add(0, order[1]);
- orders.add(0, order[2]);
- orders.move(0, 1);
- orders.remove(1);
-
- for (int i = 0; i < orders.size(); i++)
- {
- positions[i] = orders.get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testListChanges02() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(4);
- int[] positions = new int[4];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- orders.add(0, order[0]);
- orders.add(0, order[1]);
- orders.move(0, 1);
- orders.add(0, order[2]);
- orders.move(2, 0);
- orders.remove(1);
- orders.remove(0);
-
- for (int i = 0; i < orders.size(); i++)
- {
- positions[i] = orders.get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testListChanges01() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(4);
- int[] positions = new int[4];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- orders.add(0, order[0]);
- orders.add(0, order[1]);
- orders.add(0, order[2]);
- orders.move(2, 0);
- orders.remove(0);
- orders.remove(0);
-
- for (int i = 0; i < orders.size(); i++)
- {
- positions[i] = orders.get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testAddMoveMoveRemove() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(4);
- int[] positions = new int[4];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- orders.add(0, order[0]);
- orders.add(0, order[1]);
- orders.add(1, order[2]);
- orders.add(2, order[3]);
- orders.remove(0);
- orders.add(2, order[1]);
- orders.remove(3);
-
- for (int i = 0; i < orders.size(); i++)
- {
- positions[i] = orders.get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testMultipleMove() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(5);
- int[] positions = new int[5];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- orders.add(order[0]);
- // 0
- orders.add(order[1]);
- // 0,1
- orders.add(order[2]);
- // 0,1,2
- orders.move(2, 0);
- // 1,2,0
- orders.move(1, 2);
- // 1,0,2
- orders.move(0, 2);
- // 2,1,0
- orders.remove(1);
- // 2,0
-
- for (int i = 0; i < orders.size(); i++)
- {
- positions[i] = orders.get(i).getId();
- }
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- // assertEquals(4, orders.size());
-
- for (int i = 0; i < orders.size(); i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testRemoveAdd() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(4);
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
- for (int i = 0; i < order.length; i++)
- {
- orders.add(order[i]);
- }
-
- transaction.commit();
-
- orders.remove(order[2]);
- orders.add(order[2]);
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- assertEquals(4, orders.size());
-
- int[] array = { 0, 1, 3, 2 };
- for (int i = 0; i < array.length; i++)
- {
- assertEquals(array[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testAddRemoveWithAdditionalMoves() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder[] order = createSalesOrders(4);
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
- orders.add(order[0]); // 0
- orders.add(order[1]); // 0,1
- orders.add(order[2]); // 0,1,2
- orders.add(order[3]); // 0,1,2,3
- orders.remove(order[1]); // 0,2,3
- // We should have [order3, order0, order2] after the next move.
- orders.move(0, 2); // 3,0,2
- orders.add(1, order[1]); // 3,1,0,2
- orders.remove(order[1]); // 3,0,2
-
- transaction.commit();
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- assertEquals(3, orders.size());
-
- int[] array = { 3, 0, 2 };
- for (int i = 0; i < array.length; i++)
- {
- assertEquals(array[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testAddRemoveWithAdditionalAdds() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder[] order = createSalesOrders(3);
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- customer.getSalesOrders().add(order[0]);
- customer.getSalesOrders().add(order[1]);
- customer.getSalesOrders().remove(order[0]);
- customer.getSalesOrders().add(order[2]);
-
- transaction.commit();
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- assertEquals(2, orders.size());
-
- int[] array = { 1, 2 };
- for (int i = 0; i < array.length; i++)
- {
- assertEquals(array[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- public void testOptimizeAddRemove() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order = createSalesOrders(1)[0];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- resource.getContents().add(order);
-
- for (int i = 0; i < 100; i++)
- {
- customer.getSalesOrders().add(order);
- customer.getSalesOrders().remove(order);
- }
-
- transaction.commit();
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- assertEquals(0, orders.size());
-
- transaction.close();
- session.close();
- }
- }
-
- public void testOptimizeInterleavedAddRemove() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder[] order = createSalesOrders(2);
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- for (int i = 0; i < 100; i++)
- {
- customer.getSalesOrders().add(order[0]);
- customer.getSalesOrders().add(order[1]);
- customer.getSalesOrders().remove(order[0]);
- customer.getSalesOrders().remove(order[1]);
- }
-
- transaction.commit();
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- assertEquals(0, orders.size());
-
- transaction.close();
- session.close();
- }
- }
-
- public void testOptimizeMove() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- SalesOrder order[] = createSalesOrders(4);
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
- for (int i = 0; i < order.length; i++)
- {
- orders.add(order[i]);
- }
-
- // 0,1,2,3
- orders.move(0, 2);
- // 2,0,1,3
- orders.remove(0);
- // 0,1,3
- orders.remove(0);
- // 1,3
-
- transaction.commit();
-
- session.close();
- }
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- assertEquals(2, orders.size());
-
- int[] array = { 1, 3 };
- for (int i = 0; i < array.length; i++)
- {
- assertEquals(array[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-
- /**
- * Use this test to generate random list changes. It will loop until and exception is thrown. So DO NOT ENABLE it
- * except if you are working on this bug.
- */
- public void _testRandomAddRemoveMove() throws Exception
- {
- tearDown();
- while (true)
- {
- setUp();
- generateRandomAddRemoveMove();
- tearDown();
- }
- }
-
- private void generateRandomAddRemoveMove() throws Exception
- {
- // Creates a customer and commits.
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
-
- // Creates a new order and adds/removes it several times before committing.
- int orderSize = 10;
- SalesOrder order[] = createSalesOrders(orderSize);
- int[] positions = new int[orderSize];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(customer);
- transaction.commit();
-
- for (int i = 0; i < order.length; i++)
- {
- resource.getContents().add(order[i]);
- }
-
- EList<SalesOrder> orders = customer.getSalesOrders();
-
- // Random but not too much.
- long time = System.currentTimeMillis();
- System.out.println("Seed: " + time);
- Random rnd = new Random(time);
-
- // Pre-feed the list.
- System.out.print("Original list: [ ");
- for (int i = 0; i < orderSize; i++)
- {
- if (rnd.nextBoolean())
- {
- System.out.print(i + " ");
- orders.add(order[i]);
- }
- }
-
- System.out.println("]");
- transaction.commit();
-
- for (int i = 0; i < 30; i++)
- {
- // Add/Remove
- if (rnd.nextBoolean())
- {
- // Add
- if (rnd.nextBoolean())
- {
- boolean success = false;
- for (int j = 0; j < order.length; j++)
- {
- if (!orders.contains(order[j]))
- {
- int index = rnd.nextInt(orders.size() == 0 ? 1 : orders.size());
- System.out.println("ADD " + order[j].getId() + " at " + index);
- orders.add(index, order[j]);
- success = true;
- break;
- }
- }
- if (!success)
- {
- int nextInt = rnd.nextInt(orderSize);
- System.out.println("REMOVE " + nextInt);
- orders.remove(nextInt);
- }
- }
- // Remove
- else
- {
- if (orders.size() > 0)
- {
- int nextInt = rnd.nextInt(orders.size());
- System.out.println("REMOVE " + nextInt);
- orders.remove(nextInt);
- }
- else
- { // Not super random but who cares?
- int index = rnd.nextInt(orders.size() == 0 ? 1 : orders.size());
- System.out.println("ADD " + order[0].getId() + " at " + index);
- orders.add(index, order[0]);
- }
- }
- }
- // Move
- else
- {
- int size = orders.size();
- if (size > 1)
- {
- int to = rnd.nextInt(size);
- int from = rnd.nextInt(size);
- System.out.println("MOVE " + from + " => " + to);
- orders.move(to, from);
- }
- }
- }
-
- // System.out.println("==========");
-
- // And the result is...
- for (int i = 0; i < positions.length; i++)
- {
- positions[i] = i < orders.size() ? orders.get(i).getId() : -1;
- // System.out.println(i + " => " + positions[i]);
- }
-
- transaction.commit();
-
- session.close();
- }
-
- System.out.println("==========");
-
- // Checks that the other transaction got the right invalidation.
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Customer testCustomer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> orders = testCustomer.getSalesOrders();
-
- for (int i = 0; i < positions.length && positions[i] != -1; i++)
- {
- System.out.println(positions[i] + " => " + orders.get(i).getId());
- }
-
- for (int i = 0; i < positions.length && positions[i] != -1; i++)
- {
- assertEquals(positions[i], orders.get(i).getId());
- }
-
- transaction.close();
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository.WriteAccessHandler;
+import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.emf.common.util.EList;
+
+import java.util.Random;
+
+/**
+ * CDOAddFeatureDelta with null value.
+ * <p>
+ * See bug 310574
+ *
+ * @author Eike Stepper
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_310574_Test extends AbstractCDOTest
+{
+ @SuppressWarnings("unused")
+ private final WriteAccessHandler printHandler = new WriteAccessHandler()
+ {
+ public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor) throws RuntimeException
+ {
+ InternalCDORevisionDelta[] deltas = commitContext.getDirtyObjectDeltas();
+ for (InternalCDORevisionDelta delta : deltas)
+ {
+ if (delta.getEClass() == getModel1Package().getCustomer())
+ {
+ System.out.println(delta);
+ }
+ }
+ }
+
+ public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext, OMMonitor monitor)
+ {
+ }
+ };
+
+ private SalesOrder[] createSalesOrders(int number)
+ {
+ SalesOrder orders[] = new SalesOrder[number];
+ for (int i = 0; i < number; i++)
+ {
+ orders[i] = getModel1Factory().createSalesOrder();
+ orders[i].setId(i);
+ }
+
+ return orders;
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ // Adds our handler.
+ // getRepository().addHandler(printHandler);
+ }
+
+ public void testRemoveFromContainerThenFromReferenceList() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+ Company company = getModel1Factory().createCompany();
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(7);
+ int[] positions;
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ resource.getContents().add(company);
+
+ company.getSalesOrders().clear();
+ customer.getSalesOrders().clear();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ company.getSalesOrders().add(order[i]);
+ customer.getSalesOrders().add(order[i]);
+ }
+
+ transaction.commit();
+
+ company.getSalesOrders().remove(5);
+ company.getSalesOrders().remove(3);
+
+ customer.getSalesOrders().remove(5);
+ customer.getSalesOrders().remove(3);
+
+ positions = new int[customer.getSalesOrders().size()];
+ for (int i = 0; i < customer.getSalesOrders().size(); i++)
+ {
+ positions[i] = customer.getSalesOrders().get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (SalesOrder o : orders)
+ {
+ System.out.println("b: " + o.getId());
+ }
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void testAddAndRemoveWithNull() throws Exception
+ {
+ // setup connection1.
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ // add initial model.
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // add and remove an object from category list of company.
+ Category category = getModel1Factory().createCategory();
+ company.getCategories().add(0, category);
+ company.getCategories().remove(0);
+
+ // Inspect the transaction.
+ CDORevisionDelta delta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(company).cdoID());
+ for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas())
+ {
+ if (featureDelta instanceof CDOListFeatureDelta)
+ {
+ CDOListFeatureDelta listFeatureDelta = (CDOListFeatureDelta)featureDelta;
+ for (CDOFeatureDelta featureDelta2 : listFeatureDelta.getListChanges())
+ {
+ if (featureDelta2 instanceof CDOAddFeatureDelta)
+ {
+ CDOAddFeatureDelta addFeatureDelta = (CDOAddFeatureDelta)featureDelta2;
+ assertNotSame(CDOID.NULL, addFeatureDelta.getValue());
+ }
+ }
+ }
+ }
+
+ // ignore the changes.
+ transaction.rollback();
+
+ // cleanup.
+ session.close();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void testOptimizeAddAndRemove() throws Exception
+ {
+ // setup connection1.
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+
+ // add initial model.
+ Company company = getModel1Factory().createCompany();
+ resource1.getContents().add(company);
+ transaction.commit();
+
+ // add and remove an object from category list of company.
+ Category category = getModel1Factory().createCategory();
+
+ // add and remove the same object repeatedly.
+ for (int i = 0; i < 100; i++)
+ {
+ company.getCategories().add(0, category);
+ company.getCategories().remove(0);
+ }
+
+ // Inspect the transaction.
+ CDORevisionDelta delta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(company).cdoID());
+ for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas())
+ {
+ if (featureDelta instanceof CDOListFeatureDelta)
+ {
+ CDOListFeatureDelta listFeatureDelta = (CDOListFeatureDelta)featureDelta;
+ assertEquals(0, listFeatureDelta.getListChanges().size());
+ }
+ }
+
+ // ignore the changes.
+ transaction.rollback();
+
+ // cleanup.
+ session.close();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void testOptimizeInterleavedAddMoveAndRemove() throws Exception
+ {
+ // setup connection1.
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ // add initial model.
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // add and remove an object from category list of company.
+ Category aCategory = getModel1Factory().createCategory();
+ Category bCategory = getModel1Factory().createCategory();
+
+ // add and remove the same object repeatedly.
+ for (int i = 0; i < 100; i++)
+ {
+ company.getCategories().add(aCategory);
+ company.getCategories().add(bCategory);
+ company.getCategories().move(0, 1);
+ company.getCategories().remove(aCategory);
+ company.getCategories().remove(bCategory);
+ }
+
+ // Inspect the transaction.
+ CDORevisionDelta delta = transaction.getRevisionDeltas().get(CDOUtil.getCDOObject(company).cdoID());
+ for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas())
+ {
+ if (featureDelta instanceof CDOListFeatureDelta)
+ {
+ CDOListFeatureDelta listFeatureDelta = (CDOListFeatureDelta)featureDelta;
+ assertEquals(0, listFeatureDelta.getListChanges().size());
+ }
+ }
+
+ // ignore the changes.
+ transaction.rollback();
+
+ // cleanup.
+ session.close();
+ }
+
+ public void testAddAndModifyAndRemoveFromPersistedList() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+ String resourcePath = "/test1";
+ CDOResource res = transaction1.createResource(getResourcePath(resourcePath));
+ res.getContents().add(getModel1Factory().createCompany());
+ transaction1.commit();
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ res.getContents().add(supplier);
+ res.getContents().add(purchaseOrder);
+ supplier.getPurchaseOrders().add(purchaseOrder);
+ transaction1.commit();
+
+ // This remove will generate a CDOSetFeatureDelta that will be added to a CDOListFeatureDelta. Why?
+ res.getContents().remove(purchaseOrder);
+ supplier.getPurchaseOrders().remove(purchaseOrder);
+ purchaseOrder.setSupplier(null);
+ transaction1.commit();
+ }
+
+ public void testListChanges07() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(5);
+ int[] positions = new int[5];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ orders.add(order[2]);
+
+ transaction.commit();
+
+ orders.add(0, order[0]);
+ orders.move(1, 0);
+ orders.add(0, order[1]);
+ orders.remove(1);
+ orders.add(1, order[2]);
+ orders.remove(2);
+ orders.move(1, 0);
+ orders.move(0, 1);
+ orders.remove(1);
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ positions[i] = orders.get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testListChanges06() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(5);
+ int[] positions = new int[5];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ orders.add(0, order[0]);
+ orders.add(0, order[1]);
+ orders.add(0, order[2]);
+ orders.add(2, order[3]);
+ orders.remove(3);
+ orders.move(2, 0);
+ orders.add(1, order[0]);
+ orders.move(2, 1);
+ orders.move(3, 0);
+ orders.remove(0);
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ positions[i] = orders.get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testListChanges05() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(5);
+ int[] positions = new int[5];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ orders.add(0, order[0]);
+ orders.add(0, order[1]);
+ orders.move(1, 0);
+ orders.add(1, order[2]);
+ orders.add(0, order[3]);
+ orders.move(1, 3);
+ orders.move(2, 3);
+ orders.add(1, order[4]);
+ orders.remove(4);
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ positions[i] = orders.get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testListChanges04() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(4);
+ int[] positions = new int[4];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ orders.add(0, order[0]);
+ orders.add(0, order[1]);
+ orders.add(0, order[2]);
+ orders.move(1, 2);
+ orders.move(1, 2);
+ orders.remove(2);
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ positions[i] = orders.get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testListChanges03() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(4);
+ int[] positions = new int[4];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ orders.add(0, order[0]);
+ orders.add(0, order[1]);
+ orders.add(0, order[2]);
+ orders.move(0, 1);
+ orders.remove(1);
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ positions[i] = orders.get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testListChanges02() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(4);
+ int[] positions = new int[4];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ orders.add(0, order[0]);
+ orders.add(0, order[1]);
+ orders.move(0, 1);
+ orders.add(0, order[2]);
+ orders.move(2, 0);
+ orders.remove(1);
+ orders.remove(0);
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ positions[i] = orders.get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testListChanges01() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(4);
+ int[] positions = new int[4];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ orders.add(0, order[0]);
+ orders.add(0, order[1]);
+ orders.add(0, order[2]);
+ orders.move(2, 0);
+ orders.remove(0);
+ orders.remove(0);
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ positions[i] = orders.get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testAddMoveMoveRemove() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(4);
+ int[] positions = new int[4];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ orders.add(0, order[0]);
+ orders.add(0, order[1]);
+ orders.add(1, order[2]);
+ orders.add(2, order[3]);
+ orders.remove(0);
+ orders.add(2, order[1]);
+ orders.remove(3);
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ positions[i] = orders.get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testMultipleMove() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(5);
+ int[] positions = new int[5];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ orders.add(order[0]);
+ // 0
+ orders.add(order[1]);
+ // 0,1
+ orders.add(order[2]);
+ // 0,1,2
+ orders.move(2, 0);
+ // 1,2,0
+ orders.move(1, 2);
+ // 1,0,2
+ orders.move(0, 2);
+ // 2,1,0
+ orders.remove(1);
+ // 2,0
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ positions[i] = orders.get(i).getId();
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ // assertEquals(4, orders.size());
+
+ for (int i = 0; i < orders.size(); i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testRemoveAdd() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(4);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+ for (int i = 0; i < order.length; i++)
+ {
+ orders.add(order[i]);
+ }
+
+ transaction.commit();
+
+ orders.remove(order[2]);
+ orders.add(order[2]);
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ assertEquals(4, orders.size());
+
+ int[] array = { 0, 1, 3, 2 };
+ for (int i = 0; i < array.length; i++)
+ {
+ assertEquals(array[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testAddRemoveWithAdditionalMoves() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder[] order = createSalesOrders(4);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+ orders.add(order[0]); // 0
+ orders.add(order[1]); // 0,1
+ orders.add(order[2]); // 0,1,2
+ orders.add(order[3]); // 0,1,2,3
+ orders.remove(order[1]); // 0,2,3
+ // We should have [order3, order0, order2] after the next move.
+ orders.move(0, 2); // 3,0,2
+ orders.add(1, order[1]); // 3,1,0,2
+ orders.remove(order[1]); // 3,0,2
+
+ transaction.commit();
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ assertEquals(3, orders.size());
+
+ int[] array = { 3, 0, 2 };
+ for (int i = 0; i < array.length; i++)
+ {
+ assertEquals(array[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testAddRemoveWithAdditionalAdds() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder[] order = createSalesOrders(3);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ customer.getSalesOrders().add(order[0]);
+ customer.getSalesOrders().add(order[1]);
+ customer.getSalesOrders().remove(order[0]);
+ customer.getSalesOrders().add(order[2]);
+
+ transaction.commit();
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ assertEquals(2, orders.size());
+
+ int[] array = { 1, 2 };
+ for (int i = 0; i < array.length; i++)
+ {
+ assertEquals(array[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testOptimizeAddRemove() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order = createSalesOrders(1)[0];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ resource.getContents().add(order);
+
+ for (int i = 0; i < 100; i++)
+ {
+ customer.getSalesOrders().add(order);
+ customer.getSalesOrders().remove(order);
+ }
+
+ transaction.commit();
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ assertEquals(0, orders.size());
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testOptimizeInterleavedAddRemove() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder[] order = createSalesOrders(2);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ for (int i = 0; i < 100; i++)
+ {
+ customer.getSalesOrders().add(order[0]);
+ customer.getSalesOrders().add(order[1]);
+ customer.getSalesOrders().remove(order[0]);
+ customer.getSalesOrders().remove(order[1]);
+ }
+
+ transaction.commit();
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ assertEquals(0, orders.size());
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testOptimizeMove() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ SalesOrder order[] = createSalesOrders(4);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+ for (int i = 0; i < order.length; i++)
+ {
+ orders.add(order[i]);
+ }
+
+ // 0,1,2,3
+ orders.move(0, 2);
+ // 2,0,1,3
+ orders.remove(0);
+ // 0,1,3
+ orders.remove(0);
+ // 1,3
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ assertEquals(2, orders.size());
+
+ int[] array = { 1, 3 };
+ for (int i = 0; i < array.length; i++)
+ {
+ assertEquals(array[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+
+ /**
+ * Use this test to generate random list changes. It will loop until and exception is thrown. So DO NOT ENABLE it
+ * except if you are working on this bug.
+ */
+ public void _testRandomAddRemoveMove() throws Exception
+ {
+ tearDown();
+ while (true)
+ {
+ setUp();
+ generateRandomAddRemoveMove();
+ tearDown();
+ }
+ }
+
+ private void generateRandomAddRemoveMove() throws Exception
+ {
+ // Creates a customer and commits.
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ // Creates a new order and adds/removes it several times before committing.
+ int orderSize = 10;
+ SalesOrder order[] = createSalesOrders(orderSize);
+ int[] positions = new int[orderSize];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ for (int i = 0; i < order.length; i++)
+ {
+ resource.getContents().add(order[i]);
+ }
+
+ EList<SalesOrder> orders = customer.getSalesOrders();
+
+ // Random but not too much.
+ long time = System.currentTimeMillis();
+ System.out.println("Seed: " + time);
+ Random rnd = new Random(time);
+
+ // Pre-feed the list.
+ System.out.print("Original list: [ ");
+ for (int i = 0; i < orderSize; i++)
+ {
+ if (rnd.nextBoolean())
+ {
+ System.out.print(i + " ");
+ orders.add(order[i]);
+ }
+ }
+
+ System.out.println("]");
+ transaction.commit();
+
+ for (int i = 0; i < 30; i++)
+ {
+ // Add/Remove
+ if (rnd.nextBoolean())
+ {
+ // Add
+ if (rnd.nextBoolean())
+ {
+ boolean success = false;
+ for (int j = 0; j < order.length; j++)
+ {
+ if (!orders.contains(order[j]))
+ {
+ int index = rnd.nextInt(orders.size() == 0 ? 1 : orders.size());
+ System.out.println("ADD " + order[j].getId() + " at " + index);
+ orders.add(index, order[j]);
+ success = true;
+ break;
+ }
+ }
+ if (!success)
+ {
+ int nextInt = rnd.nextInt(orderSize);
+ System.out.println("REMOVE " + nextInt);
+ orders.remove(nextInt);
+ }
+ }
+ // Remove
+ else
+ {
+ if (orders.size() > 0)
+ {
+ int nextInt = rnd.nextInt(orders.size());
+ System.out.println("REMOVE " + nextInt);
+ orders.remove(nextInt);
+ }
+ else
+ { // Not super random but who cares?
+ int index = rnd.nextInt(orders.size() == 0 ? 1 : orders.size());
+ System.out.println("ADD " + order[0].getId() + " at " + index);
+ orders.add(index, order[0]);
+ }
+ }
+ }
+ // Move
+ else
+ {
+ int size = orders.size();
+ if (size > 1)
+ {
+ int to = rnd.nextInt(size);
+ int from = rnd.nextInt(size);
+ System.out.println("MOVE " + from + " => " + to);
+ orders.move(to, from);
+ }
+ }
+ }
+
+ // System.out.println("==========");
+
+ // And the result is...
+ for (int i = 0; i < positions.length; i++)
+ {
+ positions[i] = i < orders.size() ? orders.get(i).getId() : -1;
+ // System.out.println(i + " => " + positions[i]);
+ }
+
+ transaction.commit();
+
+ session.close();
+ }
+
+ System.out.println("==========");
+
+ // Checks that the other transaction got the right invalidation.
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Customer testCustomer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> orders = testCustomer.getSalesOrders();
+
+ for (int i = 0; i < positions.length && positions[i] != -1; i++)
+ {
+ System.out.println(positions[i] + " => " + orders.get(i).getId());
+ }
+
+ for (int i = 0; i < positions.length && positions[i] != -1; i++)
+ {
+ assertEquals(positions[i], orders.get(i).getId());
+ }
+
+ transaction.close();
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313326_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313326_Test.java
index e3abb9f060..42fcc96373 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313326_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313326_Test.java
@@ -1,72 +1,72 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContained;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-/**
- * NullPointerException in CDONotificationBuilder during Branch Merge
- * <p>
- * See bug 313326
- */
-public class Bugzilla_313326_Test extends AbstractCDOTest
-{
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- @CleanRepositoriesBefore
- public void testNotificationBuilderBranch() throws Exception
- {
- // setup transaction.
- final CDOSession session = openSession();
- final CDOTransaction tr1 = session.openTransaction();
- tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- // init model with a container.
- final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
- RefSingleContained container = getModel4Factory().createRefSingleContained();
- container.setElement(getModel4Factory().createSingleContainedElement());
-
- // attach adapter to get notifications.
- container.eAdapters().add(new TestAdapter());
- resource.getContents().add(container);
- tr1.commit();
-
- // create another branch
- final CDOBranch mainBranch = tr1.getBranch();
- final CDOBranch otherBranch = mainBranch.createBranch("other");
- final CDOTransaction tr2 = session.openTransaction(otherBranch);
-
- // get container in other branch and remove containment.
- RefSingleContained otherContainer = tr2.getObject(container);
- assertNotNull(otherContainer);
- otherContainer.setElement(null);
- tr2.commit();
-
- // sleep to have the merger see the changes.
- sleep(500);
- // tr1.waitForUpdate(tr2.getLastCommitTime(), DEFAULT_TIMEOUT);
-
- // merge the other branch to main.
- tr1.merge(tr2.getBranch().getHead(), new DefaultCDOMerger.PerFeature());
-
- tr1.commit();
- assertEquals(false, tr1.isDirty());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContained;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+/**
+ * NullPointerException in CDONotificationBuilder during Branch Merge
+ * <p>
+ * See bug 313326
+ */
+public class Bugzilla_313326_Test extends AbstractCDOTest
+{
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ @CleanRepositoriesBefore
+ public void testNotificationBuilderBranch() throws Exception
+ {
+ // setup transaction.
+ final CDOSession session = openSession();
+ final CDOTransaction tr1 = session.openTransaction();
+ tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ // init model with a container.
+ final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
+ RefSingleContained container = getModel4Factory().createRefSingleContained();
+ container.setElement(getModel4Factory().createSingleContainedElement());
+
+ // attach adapter to get notifications.
+ container.eAdapters().add(new TestAdapter());
+ resource.getContents().add(container);
+ tr1.commit();
+
+ // create another branch
+ final CDOBranch mainBranch = tr1.getBranch();
+ final CDOBranch otherBranch = mainBranch.createBranch("other");
+ final CDOTransaction tr2 = session.openTransaction(otherBranch);
+
+ // get container in other branch and remove containment.
+ RefSingleContained otherContainer = tr2.getObject(container);
+ assertNotNull(otherContainer);
+ otherContainer.setElement(null);
+ tr2.commit();
+
+ // sleep to have the merger see the changes.
+ sleep(500);
+ // tr1.waitForUpdate(tr2.getLastCommitTime(), DEFAULT_TIMEOUT);
+
+ // merge the other branch to main.
+ tr1.merge(tr2.getBranch().getHead(), new DefaultCDOMerger.PerFeature());
+
+ tr1.commit();
+ assertEquals(false, tr1.isDirty());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313913_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313913_Test.java
index df6016f2e3..b321823fbf 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313913_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_313913_Test.java
@@ -1,77 +1,77 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model2.Task;
-import org.eclipse.emf.cdo.tests.model2.TaskContainer;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * IndexOutOfBoundsException on View Invalidation.
- * <p>
- * See bug 313913
- */
-public class Bugzilla_313913_Test extends AbstractCDOTest
-{
- public void testAccessOldValue() throws Exception
- {
- final CDOSession session = openSession();
- final CDOTransaction transaction = session.openTransaction();
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- TaskContainer container = getModel2Factory().createTaskContainer();
-
- for (int i = 0; i < 2; i++)
- {
- Task task = getModel2Factory().createTask();
- container.getTasks().add(task);
- }
-
- final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
- resourceA.getContents().add(container);
- transaction.commit();
-
- CDOView view = session.openView();
- view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- view.getObject(container).eAdapters().add(new TestAdapter());
-
- CDOView view2 = session.openView();
- view2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- view2.getObject(container).eAdapters().add(new TestAdapter());
-
- CDOView view3 = session.openView();
- view3.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- view3.getObject(container).eAdapters().add(new TestAdapter());
-
- List<Task> tasks = new ArrayList<Task>(container.getTasks());
- container.getTasks().removeAll(tasks);
-
- container.getTasks().add(getModel2Factory().createTask());
- transaction.commit();
-
- sleep(100);
-
- System.out.println(container.getTasks().toString());
- System.out.println(view.getObject(container).getTasks().toString());
- // this will fail...
- System.out.println(view2.getObject(container).getTasks().toString());
-
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model2.Task;
+import org.eclipse.emf.cdo.tests.model2.TaskContainer;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * IndexOutOfBoundsException on View Invalidation.
+ * <p>
+ * See bug 313913
+ */
+public class Bugzilla_313913_Test extends AbstractCDOTest
+{
+ public void testAccessOldValue() throws Exception
+ {
+ final CDOSession session = openSession();
+ final CDOTransaction transaction = session.openTransaction();
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ TaskContainer container = getModel2Factory().createTaskContainer();
+
+ for (int i = 0; i < 2; i++)
+ {
+ Task task = getModel2Factory().createTask();
+ container.getTasks().add(task);
+ }
+
+ final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));
+ resourceA.getContents().add(container);
+ transaction.commit();
+
+ CDOView view = session.openView();
+ view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ view.getObject(container).eAdapters().add(new TestAdapter());
+
+ CDOView view2 = session.openView();
+ view2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ view2.getObject(container).eAdapters().add(new TestAdapter());
+
+ CDOView view3 = session.openView();
+ view3.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ view3.getObject(container).eAdapters().add(new TestAdapter());
+
+ List<Task> tasks = new ArrayList<Task>(container.getTasks());
+ container.getTasks().removeAll(tasks);
+
+ container.getTasks().add(getModel2Factory().createTask());
+ transaction.commit();
+
+ sleep(100);
+
+ System.out.println(container.getTasks().toString());
+ System.out.println(view.getObject(container).getTasks().toString());
+ // this will fail...
+ System.out.println(view2.getObject(container).getTasks().toString());
+
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_314186_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_314186_Test.java
index 44a3eebaf7..3460e66a9d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_314186_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_314186_Test.java
@@ -1,58 +1,58 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.mango.MangoValue;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_314186_Test extends AbstractCDOTest
-{
- public void testEMFCompliance() throws Exception
- {
- CDOSession session = openSession();
- ResourceSet resourceSet = new ResourceSetImpl();
-
- CDOTransaction transaction = session.openTransaction(resourceSet);
- CDOResource resource = transaction.createResource(getResourcePath("/resource"));
-
- resource.eAdapters().add(new AdapterImpl()
- {
- @Override
- public void notifyChanged(Notification notification)
- {
- if (notification.getFeature() != null
- && notification.getFeature().equals(EresourcePackage.eINSTANCE.getCDOResource_ResourceSet()))
- {
- assertEquals(Resource.RESOURCE__RESOURCE_SET, notification.getFeatureID(Resource.class));
- }
- }
- });
-
- MangoValue mangoValue = getMangoFactory().createMangoValue();
- resource.getContents().add(mangoValue);
-
- transaction.commit();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.EresourcePackage;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.mango.MangoValue;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_314186_Test extends AbstractCDOTest
+{
+ public void testEMFCompliance() throws Exception
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+ CDOResource resource = transaction.createResource(getResourcePath("/resource"));
+
+ resource.eAdapters().add(new AdapterImpl()
+ {
+ @Override
+ public void notifyChanged(Notification notification)
+ {
+ if (notification.getFeature() != null
+ && notification.getFeature().equals(EresourcePackage.eINSTANCE.getCDOResource_ResourceSet()))
+ {
+ assertEquals(Resource.RESOURCE__RESOURCE_SET, notification.getFeatureID(Resource.class));
+ }
+ }
+ });
+
+ MangoValue mangoValue = getMangoFactory().createMangoValue();
+ resource.getContents().add(mangoValue);
+
+ transaction.commit();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_315043_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_315043_Test.java
index 6fefaea7e6..a36b26d3de 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_315043_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_315043_Test.java
@@ -1,134 +1,134 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_315043_Test extends AbstractCDOTest
-{
- @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
- @CleanRepositoriesBefore
- public void testReloadingRevisions() throws Exception
- {
- final String RESOURCE_NAME = "resource";
-
- Set<CDOID> ids = new HashSet<CDOID>();
- long timeStampOfHoleCommit;
-
- CDOSession initialSession = openSession();
- {
- // create model history
- CDOTransaction openTransaction = initialSession.openTransaction();
- CDOResource resource = openTransaction.getOrCreateResource(getResourcePath(RESOURCE_NAME));
-
- // creating initial commit
- Company createdCompany = getModel1Factory().createCompany();
- createdCompany.setName("CompanyTesting");
- createdCompany.setCity("City");
- createdCompany.setStreet("Street");
-
- resource.getContents().add(createdCompany);
-
- openTransaction.commit();
-
- // collect id's
- for (TreeIterator<EObject> allContents = resource.getAllContents(); allContents.hasNext();)
- {
- CDOObject next = CDOUtil.getCDOObject(allContents.next());
- ids.add(next.cdoID());
- }
-
- // making holes - detaching
- List<EObject> contents = new ArrayList<EObject>(resource.getContents());
- for (int i = 0; i < contents.size(); i++)
- {
- EcoreUtil.delete(contents.get(i), true);
- }
-
- timeStampOfHoleCommit = openTransaction.commit().getTimeStamp();
- }
-
- // check when locally cached elements are availabe
- checkRevisionsOnGivenSession(ids, timeStampOfHoleCommit, 2, initialSession);
-
- // turn of revision download by timestamp
- checkRevisionsOnGivenSession(ids, -1, 2, initialSession);
- initialSession.close();
-
- checkRevisions(ids, timeStampOfHoleCommit, 2);
-
- // turn of revision download by timestamp
- checkRevisions(ids, -1, 2);
-
- // clear caches
- clearCache(getRepository().getRevisionManager());
- checkRevisions(ids, timeStampOfHoleCommit, 2);
-
- // turn of revision download by timestamp
- clearCache(getRepository().getRevisionManager());
- checkRevisions(ids, -1, 2);
- }
-
- private void checkRevisions(Set<CDOID> ids, long timeStampOfHoleCommit, int version)
- {
- CDOSession session = openSession();
- checkRevisionsOnGivenSession(ids, timeStampOfHoleCommit, version, session);
- session.close();
- }
-
- private void checkRevisionsOnGivenSession(Set<CDOID> ids, long timeStampOfHoleCommit, int version, CDOSession session)
- {
- CDORevisionManager revisionManager = session.getRevisionManager();
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- CDOBranchPoint branchPoint = mainBranch.getPoint(timeStampOfHoleCommit);
- CDOBranchVersion branchVersion = mainBranch.getVersion(version);
-
- for (Iterator<CDOID> it = ids.iterator(); it.hasNext();)
- {
- CDOID next = it.next();
- if (timeStampOfHoleCommit != -1)
- {
- CDORevision revision = revisionManager.getRevision(next, branchPoint, CDORevision.DEPTH_NONE, 0, true);
- assertNull(revision);
- }
-
- CDORevision revision = revisionManager.getRevisionByVersion(next, branchVersion, CDORevision.DEPTH_NONE, true);
- assertInstanceOf(DetachedCDORevision.class, revision);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_315043_Test extends AbstractCDOTest
+{
+ @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+ @CleanRepositoriesBefore
+ public void testReloadingRevisions() throws Exception
+ {
+ final String RESOURCE_NAME = "resource";
+
+ Set<CDOID> ids = new HashSet<CDOID>();
+ long timeStampOfHoleCommit;
+
+ CDOSession initialSession = openSession();
+ {
+ // create model history
+ CDOTransaction openTransaction = initialSession.openTransaction();
+ CDOResource resource = openTransaction.getOrCreateResource(getResourcePath(RESOURCE_NAME));
+
+ // creating initial commit
+ Company createdCompany = getModel1Factory().createCompany();
+ createdCompany.setName("CompanyTesting");
+ createdCompany.setCity("City");
+ createdCompany.setStreet("Street");
+
+ resource.getContents().add(createdCompany);
+
+ openTransaction.commit();
+
+ // collect id's
+ for (TreeIterator<EObject> allContents = resource.getAllContents(); allContents.hasNext();)
+ {
+ CDOObject next = CDOUtil.getCDOObject(allContents.next());
+ ids.add(next.cdoID());
+ }
+
+ // making holes - detaching
+ List<EObject> contents = new ArrayList<EObject>(resource.getContents());
+ for (int i = 0; i < contents.size(); i++)
+ {
+ EcoreUtil.delete(contents.get(i), true);
+ }
+
+ timeStampOfHoleCommit = openTransaction.commit().getTimeStamp();
+ }
+
+ // check when locally cached elements are availabe
+ checkRevisionsOnGivenSession(ids, timeStampOfHoleCommit, 2, initialSession);
+
+ // turn of revision download by timestamp
+ checkRevisionsOnGivenSession(ids, -1, 2, initialSession);
+ initialSession.close();
+
+ checkRevisions(ids, timeStampOfHoleCommit, 2);
+
+ // turn of revision download by timestamp
+ checkRevisions(ids, -1, 2);
+
+ // clear caches
+ clearCache(getRepository().getRevisionManager());
+ checkRevisions(ids, timeStampOfHoleCommit, 2);
+
+ // turn of revision download by timestamp
+ clearCache(getRepository().getRevisionManager());
+ checkRevisions(ids, -1, 2);
+ }
+
+ private void checkRevisions(Set<CDOID> ids, long timeStampOfHoleCommit, int version)
+ {
+ CDOSession session = openSession();
+ checkRevisionsOnGivenSession(ids, timeStampOfHoleCommit, version, session);
+ session.close();
+ }
+
+ private void checkRevisionsOnGivenSession(Set<CDOID> ids, long timeStampOfHoleCommit, int version, CDOSession session)
+ {
+ CDORevisionManager revisionManager = session.getRevisionManager();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOBranchPoint branchPoint = mainBranch.getPoint(timeStampOfHoleCommit);
+ CDOBranchVersion branchVersion = mainBranch.getVersion(version);
+
+ for (Iterator<CDOID> it = ids.iterator(); it.hasNext();)
+ {
+ CDOID next = it.next();
+ if (timeStampOfHoleCommit != -1)
+ {
+ CDORevision revision = revisionManager.getRevision(next, branchPoint, CDORevision.DEPTH_NONE, 0, true);
+ assertNull(revision);
+ }
+
+ CDORevision revision = revisionManager.getRevisionByVersion(next, branchVersion, CDORevision.DEPTH_NONE, true);
+ assertInstanceOf(DetachedCDORevision.class, revision);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316145_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316145_Test.java
index f77de401ce..2dd623eb1e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316145_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316145_Test.java
@@ -1,80 +1,80 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.net4j.CDONet4jSession;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.Iterator;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_316145_Test extends AbstractCDOTest
-{
- private static final String RESOURCE_NAME = "resource";
-
- private CDOID id;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
-
- // create model history
- CDONet4jSession session = (CDONet4jSession)openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath(RESOURCE_NAME));
-
- // creating initial commit
- Company company = getModel1Factory().createCompany();
- company.setName("Company");
- company.setCity("City");
- company.setStreet("Street");
- resource.getContents().add(company);
-
- transaction.commit();
-
- id = CDOUtil.getCDOObject(company).cdoID();
-
- session.close();
-
- IRepository repository = getScenario().getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
- clearCache(repository.getRevisionManager());
- }
-
- public void testRevisionInListNull()
- {
- CDONet4jSession session = (CDONet4jSession)openSession();
- CDOTransaction transaction = session.openTransaction();
- CDORevision revision = session.getRevisionManager().getRevision(id, transaction, 0, 0, true);
- msg(revision);
-
- CDOObject object = transaction.getObject(id);
- for (Iterator<EObject> it = object.eAllContents(); it.hasNext();)
- {
- it.next();
- }
-
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.Iterator;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_316145_Test extends AbstractCDOTest
+{
+ private static final String RESOURCE_NAME = "resource";
+
+ private CDOID id;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+
+ // create model history
+ CDONet4jSession session = (CDONet4jSession)openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath(RESOURCE_NAME));
+
+ // creating initial commit
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company");
+ company.setCity("City");
+ company.setStreet("Street");
+ resource.getContents().add(company);
+
+ transaction.commit();
+
+ id = CDOUtil.getCDOObject(company).cdoID();
+
+ session.close();
+
+ IRepository repository = getScenario().getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
+ clearCache(repository.getRevisionManager());
+ }
+
+ public void testRevisionInListNull()
+ {
+ CDONet4jSession session = (CDONet4jSession)openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDORevision revision = session.getRevisionManager().getRevision(id, transaction, 0, 0, true);
+ msg(revision);
+
+ CDOObject object = transaction.getObject(id);
+ for (Iterator<EObject> it = object.eAllContents(); it.hasNext();)
+ {
+ it.next();
+ }
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316273_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316273_Test.java
index 4548b38992..d92942ffab 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316273_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316273_Test.java
@@ -1,83 +1,83 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * Problem with CDOStore.contains()
- * <p>
- * See bug 316273
- *
- * @author Eike Stepper
- */
-public class Bugzilla_316273_Test extends AbstractCDOTest
-{
- public void testXRef_Single() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
- resource.getContents().add(customer);
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(4711);
- salesOrder.setCustomer(customer);
- resource.getContents().add(salesOrder);
-
- transaction.commit();
-
- resource.getContents().remove(customer);
- salesOrder.setCustomer(null);
-
- transaction.commit();
- }
-
- public void testXRef_Many() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- Product1 product1 = getModel1Factory().createProduct1();
- product1.setName("product1");
- resource.getContents().add(product1);
-
- OrderDetail orderDetail1 = getModel1Factory().createOrderDetail();
- orderDetail1.setProduct(product1);
- resource.getContents().add(orderDetail1);
-
- OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
- orderDetail2.setProduct(product1);
- resource.getContents().add(orderDetail2);
-
- OrderDetail orderDetail3 = getModel1Factory().createOrderDetail();
- orderDetail3.setProduct(product1);
- resource.getContents().add(orderDetail3);
-
- transaction.commit();
-
- resource.getContents().remove(orderDetail2);
- product1.getOrderDetails().remove(orderDetail2);
-
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * Problem with CDOStore.contains()
+ * <p>
+ * See bug 316273
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_316273_Test extends AbstractCDOTest
+{
+ public void testXRef_Single() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+ resource.getContents().add(customer);
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(4711);
+ salesOrder.setCustomer(customer);
+ resource.getContents().add(salesOrder);
+
+ transaction.commit();
+
+ resource.getContents().remove(customer);
+ salesOrder.setCustomer(null);
+
+ transaction.commit();
+ }
+
+ public void testXRef_Many() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ Product1 product1 = getModel1Factory().createProduct1();
+ product1.setName("product1");
+ resource.getContents().add(product1);
+
+ OrderDetail orderDetail1 = getModel1Factory().createOrderDetail();
+ orderDetail1.setProduct(product1);
+ resource.getContents().add(orderDetail1);
+
+ OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
+ orderDetail2.setProduct(product1);
+ resource.getContents().add(orderDetail2);
+
+ OrderDetail orderDetail3 = getModel1Factory().createOrderDetail();
+ orderDetail3.setProduct(product1);
+ resource.getContents().add(orderDetail3);
+
+ transaction.commit();
+
+ resource.getContents().remove(orderDetail2);
+ product1.getOrderDetails().remove(orderDetail2);
+
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316434_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316434_Test.java
index 20361ff175..e0c08e3ff2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316434_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316434_Test.java
@@ -1,77 +1,77 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObjectReference;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.ReferentialIntegrityException;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-public class Bugzilla_316434_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
- return map;
- }
-
- public void testInitial() throws Exception
- {
- skipStoreWithoutQueryXRefs();
-
- {
- ContainedElementNoOpposite target = getModel4Factory().createContainedElementNoOpposite();
- RefSingleNonContainedNPL source = getModel4Factory().createRefSingleNonContainedNPL();
- source.setElement(target);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- resource.getContents().add(target);
- resource.getContents().add(source);
-
- transaction.commit();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
- resource.getContents().remove(0);
-
- try
- {
- transaction.commit();
- fail("ReferentialIntegrityException expected");
- }
- catch (ReferentialIntegrityException expected)
- {
- List<CDOObjectReference> xRefs = expected.getXRefs();
- assertEquals(1, xRefs.size());
- // SUCCESS
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObjectReference;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.ReferentialIntegrityException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public class Bugzilla_316434_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ public void testInitial() throws Exception
+ {
+ skipStoreWithoutQueryXRefs();
+
+ {
+ ContainedElementNoOpposite target = getModel4Factory().createContainedElementNoOpposite();
+ RefSingleNonContainedNPL source = getModel4Factory().createRefSingleNonContainedNPL();
+ source.setElement(target);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ resource.getContents().add(target);
+ resource.getContents().add(source);
+
+ transaction.commit();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+ resource.getContents().remove(0);
+
+ try
+ {
+ transaction.commit();
+ fail("ReferentialIntegrityException expected");
+ }
+ catch (ReferentialIntegrityException expected)
+ {
+ List<CDOObjectReference> xRefs = expected.getXRefs();
+ assertEquals(1, xRefs.size());
+ // SUCCESS
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316444_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316444_Test.java
index cab930e8b0..ec1f6bc606 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316444_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316444_Test.java
@@ -1,637 +1,637 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.internal.server.Repository;
-import org.eclipse.emf.cdo.internal.server.TransactionCommitContext;
-import org.eclipse.emf.cdo.net4j.CDONet4jSession;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalTransaction;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
-import org.eclipse.emf.cdo.tests.model3.NodeA;
-import org.eclipse.emf.cdo.tests.model3.NodeB;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Martin Fluegge
- * @since 4.0
- */
-public class Bugzilla_316444_Test extends AbstractCDOTest
-{
- private static final String REPOSITORY_NAME = "repo1";
-
- private static final String RESOURCE_PATH = "/my/resource";
-
- public int idSessionA;
-
- public int idSessionB;
-
- private int idInitSession;
-
- private Object monitor = new Object();
-
- private CountDownLatch latch = new CountDownLatch(2);
-
- private boolean finishedSessionA = false;
-
- private List<Exception> exceptions = new ArrayList<Exception>();
-
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
- return map;
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- createRepository();
- super.doSetUp();
- }
-
- private void createRepository()
- {
- Repository repository = new Repository.Default()
- {
- @Override
- public InternalCommitContext createCommitContext(InternalTransaction transaction)
- {
- return new TransactionCommitContext(transaction)
- {
- @Override
- protected void lockObjects() throws InterruptedException
- {
- int sessionID = getTransaction().getSession().getSessionID();
- if (sessionID == idSessionB)
- {
- synchronized (monitor)
- {
- // Only wait if Session A has not passed the lockObjects
- if (!finishedSessionA)
- {
- msg("Session B is waiting for Session A");
- monitor.wait(DEFAULT_TIMEOUT);
- msg("Session B stopped waiting");
- }
- else
- {
- msg("Session B - no need to wait. A has already passed lockObjects()");
- }
- }
- }
-
- msg("Passing lockObjects() " + getTransaction().getSession());
-
- try
- {
- super.lockObjects();
- }
- catch (RuntimeException ex)
- {
- latch.countDown();
- throw ex;
- }
- catch (Exception ex)
- {
- latch.countDown();
- throw WrappedException.wrap(ex);
- }
-
- msg("Passed lockObjects() " + getTransaction().getSession());
-
- if (sessionID == idSessionA)
- {
- synchronized (monitor)
- {
- finishedSessionA = true;
- monitor.notifyAll();
- msg("Session A notified others not to wait anymore.");
- }
- }
-
- // Do nothing for inital session. Otherwise the test will block too early
- if (sessionID != idInitSession)
- {
- latch.countDown();
-
- try
- {
- assertEquals(true, latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
- }
- catch (InterruptedException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- }
- };
- }
- };
-
- Map<String, String> props = getRepositoryProperties();
- ((InternalRepository)repository).setProperties(props);
-
- repository.setName(REPOSITORY_NAME);
-
- Map<String, Object> map = getTestProperties();
- map.put(RepositoryConfig.PROP_TEST_REPOSITORY, repository);
- }
-
- @CleanRepositoriesBefore
- public void testMovingSubtree() throws Exception
- {
- exceptions.clear();
-
- {
- CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
- idInitSession = session.getSessionID();
- CDOTransaction transaction = session.openTransaction();
-
- Resource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
-
- // -------------- create graph begin ------------------------
- NodeB root = createSimpleNode("root");
-
- NodeB A = createSimpleNode("A");
- NodeB B = createSimpleNode("B");
- NodeB C = createSimpleNode("C");
- NodeB D = createSimpleNode("D");
- NodeB E = createSimpleNode("E");
-
- root.getChildren().add(A);
- root.getChildren().add(D);
-
- A.getChildren().add(B);
- B.getChildren().add(C);
-
- D.getChildren().add(E);
-
- resource.getContents().add(root);
- transaction.commit();
-
- // -------- check for consistency -----------
-
- checkInitialGraph(root, A, B, C, D, E);
-
- transaction.close();
- session.close();
- }
-
- // if (!(isConfig(MEM) || isConfig(MEM_AUDITS) || isConfig(MEM_BRANCHES) || isConfig(MEM_OFFLINE)))
- // {
- // // do not restart the repository on MEM store
- // restartRepository();
- // }
-
- {
- // Just an additional check to make sure that the graph is stored correctly even after repository restart
- CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
- idInitSession = session.getSessionID();
- CDOTransaction transaction = session.openTransaction();
- Resource resource = transaction.getResource(getResourcePath(RESOURCE_PATH), true);
-
- NodeB root = (NodeB)resource.getContents().get(0);
- assertEquals("root", root.getName());
-
- NodeB A = getElementFromGraphNodeB(root, "A");
- NodeB B = getElementFromGraphNodeB(root, "B");
- NodeB C = getElementFromGraphNodeB(root, "C");
- NodeB D = getElementFromGraphNodeB(root, "D");
- NodeB E = getElementFromGraphNodeB(root, "E");
-
- assertNotNull(A);
- assertNotNull(B);
- assertNotNull(C);
- assertNotNull(D);
- assertNotNull(E);
-
- checkInitialGraph(root, A, B, C, D, E);
- }
-
- {
- CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
- idInitSession = session.getSessionID();
-
- // ----- start threads -----
- ThreadA threadA = new ThreadA(RESOURCE_PATH);
- ThreadB threadB = new ThreadB(RESOURCE_PATH);
-
- threadA.start();
- sleepIfNeeded();
- threadB.start();
-
- threadA.done.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- threadB.done.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- // threadA.join(DEFAULT_TIMEOUT);
- // threadB.join(DEFAULT_TIMEOUT);
-
- if (exceptions.size() > 0)
- {
- Exception exception = exceptions.get(0);
- if (exception instanceof ThreadBShouldHaveThrownAnExceptionException)
- {
- fail(exception.getMessage());
- }
- else
- {
- throw exception;
- }
- }
-
- session.close();
- msg("finished");
- }
- }
-
- public void testLockParentWithEAttributeChange() throws Exception
- {
- String resourcePath = RESOURCE_PATH + "1";
- {
- CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
- idInitSession = session.getSessionID();
- CDOTransaction transaction = session.openTransaction();
-
- Resource resource = transaction.createResource(getResourcePath(resourcePath));
-
- // -------------- create graph begin ------------------------
- NodeB root = createSimpleNode("root");
-
- NodeB A = createSimpleNode("A");
- NodeB B = createSimpleNode("B");
- NodeB C = createSimpleNode("C");
- NodeB D = createSimpleNode("D");
- NodeB E = createSimpleNode("E");
-
- root.getChildren().add(A);
- root.getChildren().add(D);
-
- A.getChildren().add(B);
- B.getChildren().add(C);
-
- D.getChildren().add(E);
-
- resource.getContents().add(root);
- transaction.commit();
-
- // -------- check for consistency -----------
-
- checkInitialGraph(root, A, B, C, D, E);
-
- transaction.close();
- session.close();
- }
-
- // restartRepository();
-
- {
- CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
- idInitSession = session.getSessionID();
-
- // ----- start threads -----
- ThreadX threadX = new ThreadX(resourcePath);
- ThreadA threadA = new ThreadA(resourcePath);
-
- threadA.start();
- sleepIfNeeded();
- threadX.start();
-
- threadA.done.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- threadX.done.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- // threadX.join(DEFAULT_TIMEOUT);
- // threadA.join(DEFAULT_TIMEOUT);
-
- if (exceptions.size() > 0)
- {
- throw exceptions.get(0);
- }
- }
- }
-
- private void sleepIfNeeded()
- {
- if (isConfig(LEGACY))
- {
- // sleep in legacy while Bug 318816 is not solved
- sleep(1000);
- }
- }
-
- private void checkInitialGraph(NodeB root, NodeB A, NodeB B, NodeB C, NodeB D, NodeB E)
- {
- assertEquals("A", A.getName());
- assertEquals("B", B.getName());
- assertEquals("C", C.getName());
- assertEquals("D", D.getName());
- assertEquals("E", E.getName());
-
- assertEquals(root, A.getParent());
- assertEquals(root, A.eContainer());
-
- assertEquals(root, D.getParent());
- assertEquals(root, D.eContainer());
-
- assertEquals(A, B.getParent());
- assertEquals(A, B.eContainer());
-
- assertEquals(B, C.getParent());
- assertEquals(B, C.eContainer());
-
- assertEquals(D, E.getParent());
- assertEquals(D, E.eContainer());
- }
-
- private abstract class AbstactTestThread extends Thread
- {
- public CountDownLatch done = new CountDownLatch(1);
-
- protected final String resourcePath;
-
- public AbstactTestThread(String resourcePath)
- {
- this.resourcePath = resourcePath;
- }
-
- @Override
- public final void run()
- {
- try
- {
- doRun();
- }
- finally
- {
- done.countDown();
- }
- }
-
- protected abstract void doRun();
- }
-
- /**
- * @author Martin Fluegge
- */
- private class ThreadA extends AbstactTestThread
- {
- private CDONet4jSession session;
-
- public ThreadA(String resourcePath)
- {
- super(resourcePath);
- setName("ThreadA");
-
- msg("Starting Thread A");
- session = (CDONet4jSession)openSession(REPOSITORY_NAME);
- idSessionA = session.getSessionID();
- }
-
- @Override
- protected void doRun()
- {
- try
- {
- msg("Started Thread A " + session);
- CDOTransaction transaction = session.openTransaction();
- Resource resource = transaction.getResource(getResourcePath(resourcePath), true);
-
- NodeB root = (NodeB)resource.getContents().get(0);
- assertEquals("root", root.getName());
-
- NodeB B = getElementFromGraphNodeB(root, "B");
- NodeB E = getElementFromGraphNodeB(root, "E");
-
- assertEquals("B", B.getName());
- assertEquals("E", E.getName());
-
- E.getChildren().add(B);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- exceptions.add(ex);
- }
-
- session.close();
- msg("Finished Thread A " + session);
- }
- catch (Exception e)
- {
- exceptions.add(e);
- }
- }
- }
-
- /**
- * @author Martin Fluegge
- */
- private class ThreadB extends AbstactTestThread
- {
- private CDONet4jSession session;
-
- public ThreadB(String resourcePath)
- {
- super(resourcePath);
- setName("ThreadB");
-
- msg("Starting Thread B");
- session = (CDONet4jSession)openSession(REPOSITORY_NAME);
- idSessionB = session.getSessionID();
- }
-
- @Override
- protected void doRun()
- {
- try
- {
- msg("Started Thread B " + session);
- CDOTransaction transaction = session.openTransaction();
-
- Resource resource = transaction.getResource(getResourcePath(resourcePath), true);
-
- NodeB root = (NodeB)resource.getContents().get(0);
- assertEquals("root", root.getName());
- NodeB C = getElementFromGraphNodeB(root, "C");
- NodeB D = getElementFromGraphNodeB(root, "D");
-
- assertEquals("C", C.getName());
- assertEquals("D", D.getName());
-
- C.getChildren().add(D);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- try
- {
- String message = ex.getMessage();
- if (message == null || !message.contains("ContainmentCycleDetectedException"))
- {
- throw ex;
- }
-
- msg("Finished (Passed) Thread B " + session);
- return;
- }
- catch (Exception exx)
- {
- throw new RuntimeException(exx);
- }
- }
-
- exceptions.add(new ThreadBShouldHaveThrownAnExceptionException("Thread B should have thrown an exception"));
- session.close();
- }
- catch (Exception e)
- {
- exceptions.add(e);
- msg("Finished Thread B " + session);
- }
- }
- }
-
- /**
- * @author Martin Fluegge
- */
- private class ThreadX extends AbstactTestThread
- {
- private CDONet4jSession session;
-
- public ThreadX(String resourcePath)
- {
- super(resourcePath);
- setName("ThreadX");
-
- msg("Starting Thread X");
- session = (CDONet4jSession)openSession(REPOSITORY_NAME);
- idSessionB = session.getSessionID();
- }
-
- @Override
- protected void doRun()
- {
- try
- {
- msg("Started Thread X" + session);
- CDOTransaction transaction = session.openTransaction();
- Resource resource = transaction.getResource(getResourcePath(resourcePath), true);
-
- NodeB root = (NodeB)resource.getContents().get(0);
- assertEquals("root", root.getName());
-
- NodeB D = getElementFromGraphNodeB(root, "D");
-
- assertEquals("D", D.getName());
- D.setName("DD");
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- exceptions.add(ex);
- }
-
- session.close();
- msg("Finished Thread X");
- }
- catch (Exception e)
- {
- exceptions.add(e);
- }
- }
- }
-
- private NodeB createSimpleNode(String name)
- {
- NodeB y = getModel3Factory().createNodeB();
- y.setName(name);
- return y;
- }
-
- private NodeB getElementFromGraphNodeB(NodeB node, String name)
- {
- if (node.getName().equals(name))
- {
- return node;
- }
-
- for (NodeB child : node.getChildren())
- {
- NodeB elementFromGraph = getElementFromGraphNodeB(child, name);
- if (elementFromGraph != null)
- {
- return elementFromGraph;
- }
- }
-
- return null;
- }
-
- @SuppressWarnings("unused")
- private NodeA getElementFromGraphNodeA(NodeA node, String name)
- {
- if (node.getName().equals(name))
- {
- return node;
- }
-
- for (NodeA child : node.getChildren())
- {
- NodeA elementFromGraph = getElementFromGraphNodeA(child, name);
- if (elementFromGraph != null)
- {
- return elementFromGraph;
- }
- }
-
- return null;
- }
-
- /*
- * @SuppressWarnings("unused") private void restartRepository() { LifecycleUtil.deactivate(getRepository());
- * createRepository(); getRepository(); }
- */
-
- /**
- * @author Martin Fluegge
- */
- private static class ThreadBShouldHaveThrownAnExceptionException extends Exception
- {
- private static final long serialVersionUID = 1L;
-
- public ThreadBShouldHaveThrownAnExceptionException(String s)
- {
- super(s);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.internal.server.Repository;
+import org.eclipse.emf.cdo.internal.server.TransactionCommitContext;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalTransaction;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.emf.cdo.tests.model3.NodeA;
+import org.eclipse.emf.cdo.tests.model3.NodeB;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Martin Fluegge
+ * @since 4.0
+ */
+public class Bugzilla_316444_Test extends AbstractCDOTest
+{
+ private static final String REPOSITORY_NAME = "repo1";
+
+ private static final String RESOURCE_PATH = "/my/resource";
+
+ public int idSessionA;
+
+ public int idSessionB;
+
+ private int idInitSession;
+
+ private Object monitor = new Object();
+
+ private CountDownLatch latch = new CountDownLatch(2);
+
+ private boolean finishedSessionA = false;
+
+ private List<Exception> exceptions = new ArrayList<Exception>();
+
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ createRepository();
+ super.doSetUp();
+ }
+
+ private void createRepository()
+ {
+ Repository repository = new Repository.Default()
+ {
+ @Override
+ public InternalCommitContext createCommitContext(InternalTransaction transaction)
+ {
+ return new TransactionCommitContext(transaction)
+ {
+ @Override
+ protected void lockObjects() throws InterruptedException
+ {
+ int sessionID = getTransaction().getSession().getSessionID();
+ if (sessionID == idSessionB)
+ {
+ synchronized (monitor)
+ {
+ // Only wait if Session A has not passed the lockObjects
+ if (!finishedSessionA)
+ {
+ msg("Session B is waiting for Session A");
+ monitor.wait(DEFAULT_TIMEOUT);
+ msg("Session B stopped waiting");
+ }
+ else
+ {
+ msg("Session B - no need to wait. A has already passed lockObjects()");
+ }
+ }
+ }
+
+ msg("Passing lockObjects() " + getTransaction().getSession());
+
+ try
+ {
+ super.lockObjects();
+ }
+ catch (RuntimeException ex)
+ {
+ latch.countDown();
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ latch.countDown();
+ throw WrappedException.wrap(ex);
+ }
+
+ msg("Passed lockObjects() " + getTransaction().getSession());
+
+ if (sessionID == idSessionA)
+ {
+ synchronized (monitor)
+ {
+ finishedSessionA = true;
+ monitor.notifyAll();
+ msg("Session A notified others not to wait anymore.");
+ }
+ }
+
+ // Do nothing for inital session. Otherwise the test will block too early
+ if (sessionID != idInitSession)
+ {
+ latch.countDown();
+
+ try
+ {
+ assertEquals(true, latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
+ }
+ catch (InterruptedException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+ }
+ };
+ }
+ };
+
+ Map<String, String> props = getRepositoryProperties();
+ ((InternalRepository)repository).setProperties(props);
+
+ repository.setName(REPOSITORY_NAME);
+
+ Map<String, Object> map = getTestProperties();
+ map.put(RepositoryConfig.PROP_TEST_REPOSITORY, repository);
+ }
+
+ @CleanRepositoriesBefore
+ public void testMovingSubtree() throws Exception
+ {
+ exceptions.clear();
+
+ {
+ CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
+ idInitSession = session.getSessionID();
+ CDOTransaction transaction = session.openTransaction();
+
+ Resource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+
+ // -------------- create graph begin ------------------------
+ NodeB root = createSimpleNode("root");
+
+ NodeB A = createSimpleNode("A");
+ NodeB B = createSimpleNode("B");
+ NodeB C = createSimpleNode("C");
+ NodeB D = createSimpleNode("D");
+ NodeB E = createSimpleNode("E");
+
+ root.getChildren().add(A);
+ root.getChildren().add(D);
+
+ A.getChildren().add(B);
+ B.getChildren().add(C);
+
+ D.getChildren().add(E);
+
+ resource.getContents().add(root);
+ transaction.commit();
+
+ // -------- check for consistency -----------
+
+ checkInitialGraph(root, A, B, C, D, E);
+
+ transaction.close();
+ session.close();
+ }
+
+ // if (!(isConfig(MEM) || isConfig(MEM_AUDITS) || isConfig(MEM_BRANCHES) || isConfig(MEM_OFFLINE)))
+ // {
+ // // do not restart the repository on MEM store
+ // restartRepository();
+ // }
+
+ {
+ // Just an additional check to make sure that the graph is stored correctly even after repository restart
+ CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
+ idInitSession = session.getSessionID();
+ CDOTransaction transaction = session.openTransaction();
+ Resource resource = transaction.getResource(getResourcePath(RESOURCE_PATH), true);
+
+ NodeB root = (NodeB)resource.getContents().get(0);
+ assertEquals("root", root.getName());
+
+ NodeB A = getElementFromGraphNodeB(root, "A");
+ NodeB B = getElementFromGraphNodeB(root, "B");
+ NodeB C = getElementFromGraphNodeB(root, "C");
+ NodeB D = getElementFromGraphNodeB(root, "D");
+ NodeB E = getElementFromGraphNodeB(root, "E");
+
+ assertNotNull(A);
+ assertNotNull(B);
+ assertNotNull(C);
+ assertNotNull(D);
+ assertNotNull(E);
+
+ checkInitialGraph(root, A, B, C, D, E);
+ }
+
+ {
+ CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
+ idInitSession = session.getSessionID();
+
+ // ----- start threads -----
+ ThreadA threadA = new ThreadA(RESOURCE_PATH);
+ ThreadB threadB = new ThreadB(RESOURCE_PATH);
+
+ threadA.start();
+ sleepIfNeeded();
+ threadB.start();
+
+ threadA.done.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ threadB.done.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ // threadA.join(DEFAULT_TIMEOUT);
+ // threadB.join(DEFAULT_TIMEOUT);
+
+ if (exceptions.size() > 0)
+ {
+ Exception exception = exceptions.get(0);
+ if (exception instanceof ThreadBShouldHaveThrownAnExceptionException)
+ {
+ fail(exception.getMessage());
+ }
+ else
+ {
+ throw exception;
+ }
+ }
+
+ session.close();
+ msg("finished");
+ }
+ }
+
+ public void testLockParentWithEAttributeChange() throws Exception
+ {
+ String resourcePath = RESOURCE_PATH + "1";
+ {
+ CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
+ idInitSession = session.getSessionID();
+ CDOTransaction transaction = session.openTransaction();
+
+ Resource resource = transaction.createResource(getResourcePath(resourcePath));
+
+ // -------------- create graph begin ------------------------
+ NodeB root = createSimpleNode("root");
+
+ NodeB A = createSimpleNode("A");
+ NodeB B = createSimpleNode("B");
+ NodeB C = createSimpleNode("C");
+ NodeB D = createSimpleNode("D");
+ NodeB E = createSimpleNode("E");
+
+ root.getChildren().add(A);
+ root.getChildren().add(D);
+
+ A.getChildren().add(B);
+ B.getChildren().add(C);
+
+ D.getChildren().add(E);
+
+ resource.getContents().add(root);
+ transaction.commit();
+
+ // -------- check for consistency -----------
+
+ checkInitialGraph(root, A, B, C, D, E);
+
+ transaction.close();
+ session.close();
+ }
+
+ // restartRepository();
+
+ {
+ CDONet4jSession session = (CDONet4jSession)openSession(REPOSITORY_NAME);
+ idInitSession = session.getSessionID();
+
+ // ----- start threads -----
+ ThreadX threadX = new ThreadX(resourcePath);
+ ThreadA threadA = new ThreadA(resourcePath);
+
+ threadA.start();
+ sleepIfNeeded();
+ threadX.start();
+
+ threadA.done.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ threadX.done.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ // threadX.join(DEFAULT_TIMEOUT);
+ // threadA.join(DEFAULT_TIMEOUT);
+
+ if (exceptions.size() > 0)
+ {
+ throw exceptions.get(0);
+ }
+ }
+ }
+
+ private void sleepIfNeeded()
+ {
+ if (isConfig(LEGACY))
+ {
+ // sleep in legacy while Bug 318816 is not solved
+ sleep(1000);
+ }
+ }
+
+ private void checkInitialGraph(NodeB root, NodeB A, NodeB B, NodeB C, NodeB D, NodeB E)
+ {
+ assertEquals("A", A.getName());
+ assertEquals("B", B.getName());
+ assertEquals("C", C.getName());
+ assertEquals("D", D.getName());
+ assertEquals("E", E.getName());
+
+ assertEquals(root, A.getParent());
+ assertEquals(root, A.eContainer());
+
+ assertEquals(root, D.getParent());
+ assertEquals(root, D.eContainer());
+
+ assertEquals(A, B.getParent());
+ assertEquals(A, B.eContainer());
+
+ assertEquals(B, C.getParent());
+ assertEquals(B, C.eContainer());
+
+ assertEquals(D, E.getParent());
+ assertEquals(D, E.eContainer());
+ }
+
+ private abstract class AbstactTestThread extends Thread
+ {
+ public CountDownLatch done = new CountDownLatch(1);
+
+ protected final String resourcePath;
+
+ public AbstactTestThread(String resourcePath)
+ {
+ this.resourcePath = resourcePath;
+ }
+
+ @Override
+ public final void run()
+ {
+ try
+ {
+ doRun();
+ }
+ finally
+ {
+ done.countDown();
+ }
+ }
+
+ protected abstract void doRun();
+ }
+
+ /**
+ * @author Martin Fluegge
+ */
+ private class ThreadA extends AbstactTestThread
+ {
+ private CDONet4jSession session;
+
+ public ThreadA(String resourcePath)
+ {
+ super(resourcePath);
+ setName("ThreadA");
+
+ msg("Starting Thread A");
+ session = (CDONet4jSession)openSession(REPOSITORY_NAME);
+ idSessionA = session.getSessionID();
+ }
+
+ @Override
+ protected void doRun()
+ {
+ try
+ {
+ msg("Started Thread A " + session);
+ CDOTransaction transaction = session.openTransaction();
+ Resource resource = transaction.getResource(getResourcePath(resourcePath), true);
+
+ NodeB root = (NodeB)resource.getContents().get(0);
+ assertEquals("root", root.getName());
+
+ NodeB B = getElementFromGraphNodeB(root, "B");
+ NodeB E = getElementFromGraphNodeB(root, "E");
+
+ assertEquals("B", B.getName());
+ assertEquals("E", E.getName());
+
+ E.getChildren().add(B);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ exceptions.add(ex);
+ }
+
+ session.close();
+ msg("Finished Thread A " + session);
+ }
+ catch (Exception e)
+ {
+ exceptions.add(e);
+ }
+ }
+ }
+
+ /**
+ * @author Martin Fluegge
+ */
+ private class ThreadB extends AbstactTestThread
+ {
+ private CDONet4jSession session;
+
+ public ThreadB(String resourcePath)
+ {
+ super(resourcePath);
+ setName("ThreadB");
+
+ msg("Starting Thread B");
+ session = (CDONet4jSession)openSession(REPOSITORY_NAME);
+ idSessionB = session.getSessionID();
+ }
+
+ @Override
+ protected void doRun()
+ {
+ try
+ {
+ msg("Started Thread B " + session);
+ CDOTransaction transaction = session.openTransaction();
+
+ Resource resource = transaction.getResource(getResourcePath(resourcePath), true);
+
+ NodeB root = (NodeB)resource.getContents().get(0);
+ assertEquals("root", root.getName());
+ NodeB C = getElementFromGraphNodeB(root, "C");
+ NodeB D = getElementFromGraphNodeB(root, "D");
+
+ assertEquals("C", C.getName());
+ assertEquals("D", D.getName());
+
+ C.getChildren().add(D);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ try
+ {
+ String message = ex.getMessage();
+ if (message == null || !message.contains("ContainmentCycleDetectedException"))
+ {
+ throw ex;
+ }
+
+ msg("Finished (Passed) Thread B " + session);
+ return;
+ }
+ catch (Exception exx)
+ {
+ throw new RuntimeException(exx);
+ }
+ }
+
+ exceptions.add(new ThreadBShouldHaveThrownAnExceptionException("Thread B should have thrown an exception"));
+ session.close();
+ }
+ catch (Exception e)
+ {
+ exceptions.add(e);
+ msg("Finished Thread B " + session);
+ }
+ }
+ }
+
+ /**
+ * @author Martin Fluegge
+ */
+ private class ThreadX extends AbstactTestThread
+ {
+ private CDONet4jSession session;
+
+ public ThreadX(String resourcePath)
+ {
+ super(resourcePath);
+ setName("ThreadX");
+
+ msg("Starting Thread X");
+ session = (CDONet4jSession)openSession(REPOSITORY_NAME);
+ idSessionB = session.getSessionID();
+ }
+
+ @Override
+ protected void doRun()
+ {
+ try
+ {
+ msg("Started Thread X" + session);
+ CDOTransaction transaction = session.openTransaction();
+ Resource resource = transaction.getResource(getResourcePath(resourcePath), true);
+
+ NodeB root = (NodeB)resource.getContents().get(0);
+ assertEquals("root", root.getName());
+
+ NodeB D = getElementFromGraphNodeB(root, "D");
+
+ assertEquals("D", D.getName());
+ D.setName("DD");
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ exceptions.add(ex);
+ }
+
+ session.close();
+ msg("Finished Thread X");
+ }
+ catch (Exception e)
+ {
+ exceptions.add(e);
+ }
+ }
+ }
+
+ private NodeB createSimpleNode(String name)
+ {
+ NodeB y = getModel3Factory().createNodeB();
+ y.setName(name);
+ return y;
+ }
+
+ private NodeB getElementFromGraphNodeB(NodeB node, String name)
+ {
+ if (node.getName().equals(name))
+ {
+ return node;
+ }
+
+ for (NodeB child : node.getChildren())
+ {
+ NodeB elementFromGraph = getElementFromGraphNodeB(child, name);
+ if (elementFromGraph != null)
+ {
+ return elementFromGraph;
+ }
+ }
+
+ return null;
+ }
+
+ @SuppressWarnings("unused")
+ private NodeA getElementFromGraphNodeA(NodeA node, String name)
+ {
+ if (node.getName().equals(name))
+ {
+ return node;
+ }
+
+ for (NodeA child : node.getChildren())
+ {
+ NodeA elementFromGraph = getElementFromGraphNodeA(child, name);
+ if (elementFromGraph != null)
+ {
+ return elementFromGraph;
+ }
+ }
+
+ return null;
+ }
+
+ /*
+ * @SuppressWarnings("unused") private void restartRepository() { LifecycleUtil.deactivate(getRepository());
+ * createRepository(); getRepository(); }
+ */
+
+ /**
+ * @author Martin Fluegge
+ */
+ private static class ThreadBShouldHaveThrownAnExceptionException extends Exception
+ {
+ private static final long serialVersionUID = 1L;
+
+ public ThreadBShouldHaveThrownAnExceptionException(String s)
+ {
+ super(s);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316887_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316887_Test.java
index fa8383bcec..5b4e4edd96 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316887_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_316887_Test.java
@@ -1,136 +1,136 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model2.Task;
-import org.eclipse.emf.cdo.tests.model2.TaskContainer;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Databinding & CDO Notifications.
- * <p>
- * See bug 316887
- *
- * @author Cyril Jaquier
- * @since 4.0
- */
-public class Bugzilla_316887_Test extends AbstractCDOTest
-{
- /**
- * @deprecated AbstractObjectConflictResolver is deprecated
- */
- @Deprecated
- public void testResolveConflictWithAdjustedNotifcations() throws Exception
- {
- // setup transaction.
- final CDOSession session = openSession();
- final CDOTransaction tr1 = session.openTransaction();
-
- final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
- TaskContainer container = getModel2Factory().createTaskContainer();
- resource.getContents().add(container);
-
- for (int i = 0; i < 7; i++)
- {
- Task task = getModel2Factory().createTask();
- task.setDescription(Integer.toString(i));
- container.getTasks().add(task);
- }
-
- tr1.commit();
-
- sleep(500);
-
- final CDOTransaction tr2 = session.openTransaction();
-
- // Adds a conflict resolver.
- tr2.options().addConflictResolver(new org.eclipse.emf.spi.cdo.AbstractObjectConflictResolver()
- {
- @Deprecated
- @Override
- protected void resolveConflict(CDOObject conflict, CDORevision oldRemoteRevision, CDORevisionDelta localDelta,
- CDORevisionDelta remoteDelta, List<CDORevisionDelta> allRemoteDeltas)
- {
- CDOStateMachine.INSTANCE.rollback((InternalCDOObject)conflict);
-
- // Adjusts the local delta
- CDOListFeatureDelta list = (CDOListFeatureDelta)localDelta.getFeatureDeltas().get(0);
- CDORemoveFeatureDelta remove = (CDORemoveFeatureDelta)list.getListChanges().get(0);
- ((WithIndex)remove).adjustAfterRemoval(0);
-
- changeObject(conflict, localDelta);
-
- // Adjusts the "notifications"
- CDORevisionDelta delta = allRemoteDeltas.get(0);
- list = (CDOListFeatureDelta)delta.getFeatureDeltas().get(0);
- CDOMoveFeatureDelta move = (CDOMoveFeatureDelta)list.getListChanges().get(0);
- ((WithIndex)move).adjustAfterRemoval(0);
- }
- });
-
- TaskContainer otherContainer = tr2.getObject(container);
- assertNotNull(otherContainer);
-
- //
- TestAdapter adapter = new TestAdapter();
- otherContainer.eAdapters().add(adapter);
-
- // Move in transaction 1.
- container.getTasks().move(6, 0);
-
- // Remove in transaction 2.
- otherContainer.getTasks().remove(2);
-
- tr1.commit();
-
- sleep(500);
-
- assertEquals(2, adapter.getNotifications().length);
- assertEquals(Notification.REMOVE, adapter.getNotifications()[0].getEventType());
- assertEquals(Notification.MOVE, adapter.getNotifications()[1].getEventType());
- assertEquals(5, adapter.getNotifications()[1].getPosition());
-
- tr2.commit();
-
- sleep(500);
-
- // At this point, both transactions must have an similar list.
- assertEquals(container.getTasks().size(), otherContainer.getTasks().size());
-
- Iterator<Task> i1 = container.getTasks().iterator();
- Iterator<Task> i2 = otherContainer.getTasks().iterator();
- while (i1.hasNext())
- {
- Task task1 = i1.next();
- Task task2 = i2.next();
- assertEquals(task1.getDescription(), task2.getDescription());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model2.Task;
+import org.eclipse.emf.cdo.tests.model2.TaskContainer;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Databinding & CDO Notifications.
+ * <p>
+ * See bug 316887
+ *
+ * @author Cyril Jaquier
+ * @since 4.0
+ */
+public class Bugzilla_316887_Test extends AbstractCDOTest
+{
+ /**
+ * @deprecated AbstractObjectConflictResolver is deprecated
+ */
+ @Deprecated
+ public void testResolveConflictWithAdjustedNotifcations() throws Exception
+ {
+ // setup transaction.
+ final CDOSession session = openSession();
+ final CDOTransaction tr1 = session.openTransaction();
+
+ final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
+ TaskContainer container = getModel2Factory().createTaskContainer();
+ resource.getContents().add(container);
+
+ for (int i = 0; i < 7; i++)
+ {
+ Task task = getModel2Factory().createTask();
+ task.setDescription(Integer.toString(i));
+ container.getTasks().add(task);
+ }
+
+ tr1.commit();
+
+ sleep(500);
+
+ final CDOTransaction tr2 = session.openTransaction();
+
+ // Adds a conflict resolver.
+ tr2.options().addConflictResolver(new org.eclipse.emf.spi.cdo.AbstractObjectConflictResolver()
+ {
+ @Deprecated
+ @Override
+ protected void resolveConflict(CDOObject conflict, CDORevision oldRemoteRevision, CDORevisionDelta localDelta,
+ CDORevisionDelta remoteDelta, List<CDORevisionDelta> allRemoteDeltas)
+ {
+ CDOStateMachine.INSTANCE.rollback((InternalCDOObject)conflict);
+
+ // Adjusts the local delta
+ CDOListFeatureDelta list = (CDOListFeatureDelta)localDelta.getFeatureDeltas().get(0);
+ CDORemoveFeatureDelta remove = (CDORemoveFeatureDelta)list.getListChanges().get(0);
+ ((WithIndex)remove).adjustAfterRemoval(0);
+
+ changeObject(conflict, localDelta);
+
+ // Adjusts the "notifications"
+ CDORevisionDelta delta = allRemoteDeltas.get(0);
+ list = (CDOListFeatureDelta)delta.getFeatureDeltas().get(0);
+ CDOMoveFeatureDelta move = (CDOMoveFeatureDelta)list.getListChanges().get(0);
+ ((WithIndex)move).adjustAfterRemoval(0);
+ }
+ });
+
+ TaskContainer otherContainer = tr2.getObject(container);
+ assertNotNull(otherContainer);
+
+ //
+ TestAdapter adapter = new TestAdapter();
+ otherContainer.eAdapters().add(adapter);
+
+ // Move in transaction 1.
+ container.getTasks().move(6, 0);
+
+ // Remove in transaction 2.
+ otherContainer.getTasks().remove(2);
+
+ tr1.commit();
+
+ sleep(500);
+
+ assertEquals(2, adapter.getNotifications().length);
+ assertEquals(Notification.REMOVE, adapter.getNotifications()[0].getEventType());
+ assertEquals(Notification.MOVE, adapter.getNotifications()[1].getEventType());
+ assertEquals(5, adapter.getNotifications()[1].getPosition());
+
+ tr2.commit();
+
+ sleep(500);
+
+ // At this point, both transactions must have an similar list.
+ assertEquals(container.getTasks().size(), otherContainer.getTasks().size());
+
+ Iterator<Task> i1 = container.getTasks().iterator();
+ Iterator<Task> i2 = otherContainer.getTasks().iterator();
+ while (i1.hasNext())
+ {
+ Task task1 = i1.next();
+ Task task2 = i2.next();
+ assertEquals(task1.getDescription(), task2.getDescription());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318518_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318518_Test.java
index ae16c31048..8b30c10e0b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318518_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318518_Test.java
@@ -1,96 +1,96 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model2.Task;
-import org.eclipse.emf.cdo.tests.model2.TaskContainer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Martin Fluegge
- * @since 4.0
- */
-public class Bugzilla_318518_Test extends AbstractCDOTest
-{
- private List<Exception> exceptions = new ArrayList<Exception>();
-
- /**
- * @deprecated AbstractObjectConflictResolver is deprecated
- */
- @Deprecated
- public void testCorrectNumberOfFeatureDeltas() throws Exception
- {
- // setup transaction.
- final CDOSession session = openSession();
- final CDOTransaction tr1 = session.openTransaction();
-
- final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
- TaskContainer container = getModel2Factory().createTaskContainer();
- resource.getContents().add(container);
-
- for (int i = 0; i < 2; i++)
- {
- Task task = getModel2Factory().createTask();
- task.setDescription(Integer.toString(i));
- container.getTasks().add(task);
- }
- tr1.commit();
-
- sleep(500);
-
- final CDOTransaction tr2 = session.openTransaction();
-
- tr2.options().addConflictResolver(new org.eclipse.emf.spi.cdo.AbstractObjectConflictResolver()
- {
- @Override
- protected void resolveConflict(CDOObject conflict, CDORevision oldRevision, CDORevisionDelta localDelta,
- CDORevisionDelta remoteDelta, List<CDORevisionDelta> deltas)
- {
- CDOListFeatureDelta list = (CDOListFeatureDelta)localDelta.getFeatureDeltas().get(0);
-
- int size = list.getListChanges().size();
- if (size != 1)
- {
- exceptions.add(new Exception("Size of list changes should be 1 but is " + size));
- return;
- }
- }
- });
-
- TaskContainer otherContainer = tr2.getObject(container);
- assertNotNull(otherContainer);
-
- // Just do something and commit
- container.getTasks().move(1, 0);
-
- // Remove in transaction 2.
- otherContainer.getTasks().remove(1);
-
- tr1.commit();
-
- sleep(1000);
-
- if (exceptions.size() > 0)
- {
- throw exceptions.get(0);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model2.Task;
+import org.eclipse.emf.cdo.tests.model2.TaskContainer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ * @since 4.0
+ */
+public class Bugzilla_318518_Test extends AbstractCDOTest
+{
+ private List<Exception> exceptions = new ArrayList<Exception>();
+
+ /**
+ * @deprecated AbstractObjectConflictResolver is deprecated
+ */
+ @Deprecated
+ public void testCorrectNumberOfFeatureDeltas() throws Exception
+ {
+ // setup transaction.
+ final CDOSession session = openSession();
+ final CDOTransaction tr1 = session.openTransaction();
+
+ final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
+ TaskContainer container = getModel2Factory().createTaskContainer();
+ resource.getContents().add(container);
+
+ for (int i = 0; i < 2; i++)
+ {
+ Task task = getModel2Factory().createTask();
+ task.setDescription(Integer.toString(i));
+ container.getTasks().add(task);
+ }
+ tr1.commit();
+
+ sleep(500);
+
+ final CDOTransaction tr2 = session.openTransaction();
+
+ tr2.options().addConflictResolver(new org.eclipse.emf.spi.cdo.AbstractObjectConflictResolver()
+ {
+ @Override
+ protected void resolveConflict(CDOObject conflict, CDORevision oldRevision, CDORevisionDelta localDelta,
+ CDORevisionDelta remoteDelta, List<CDORevisionDelta> deltas)
+ {
+ CDOListFeatureDelta list = (CDOListFeatureDelta)localDelta.getFeatureDeltas().get(0);
+
+ int size = list.getListChanges().size();
+ if (size != 1)
+ {
+ exceptions.add(new Exception("Size of list changes should be 1 but is " + size));
+ return;
+ }
+ }
+ });
+
+ TaskContainer otherContainer = tr2.getObject(container);
+ assertNotNull(otherContainer);
+
+ // Just do something and commit
+ container.getTasks().move(1, 0);
+
+ // Remove in transaction 2.
+ otherContainer.getTasks().remove(1);
+
+ tr1.commit();
+
+ sleep(1000);
+
+ if (exceptions.size() > 0)
+ {
+ throw exceptions.get(0);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318844_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318844_Test.java
index 8a322d94ac..33804811c6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318844_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318844_Test.java
@@ -1,79 +1,79 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import java.util.Date;
-
-/**
- * Bug 318844 - CDONotificationBuilder cannot handle mixed OID's/CDOObjects when processing CDOClearFeatureDelta</p>
- * http://bugs.eclipse.org/318844</p>
- *
- * @author Caspar De Groot
- * @since 4.0
- */
-public class Bugzilla_318844_Test extends AbstractCDOTest
-{
- public void test() throws CommitException
- {
- final CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
-
- PurchaseOrder po1 = getModel1Factory().createPurchaseOrder();
- po1.setDate(new Date());
- r1.getContents().add(po1);
-
- tx.commit();
-
- // Create a new supplier but don't commit it
- Supplier supplier = getModel1Factory().createSupplier();
- r1.getContents().add(supplier);
-
- // Create a reference to po1 but don't commit it
- supplier.getPurchaseOrders().add(po1);
-
- // Add an adapter so that notification mechanism will be invoked
- r1.eAdapters().add(new TestAdapter());
-
- // Remove po2 in another session
- doSecondSession();
-
- // The following call wthrows a CCE if bug 318844 is not fixed
- session.refresh();
-
- tx.close();
- session.close();
- }
-
- private void doSecondSession() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getResource(getResourcePath("/r1")); //$NON-NLS-1$
-
- // Detach the purchaseOrder
- r1.getContents().remove(0);
-
- tx.commit();
- tx.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import java.util.Date;
+
+/**
+ * Bug 318844 - CDONotificationBuilder cannot handle mixed OID's/CDOObjects when processing CDOClearFeatureDelta</p>
+ * http://bugs.eclipse.org/318844</p>
+ *
+ * @author Caspar De Groot
+ * @since 4.0
+ */
+public class Bugzilla_318844_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ final CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ PurchaseOrder po1 = getModel1Factory().createPurchaseOrder();
+ po1.setDate(new Date());
+ r1.getContents().add(po1);
+
+ tx.commit();
+
+ // Create a new supplier but don't commit it
+ Supplier supplier = getModel1Factory().createSupplier();
+ r1.getContents().add(supplier);
+
+ // Create a reference to po1 but don't commit it
+ supplier.getPurchaseOrders().add(po1);
+
+ // Add an adapter so that notification mechanism will be invoked
+ r1.eAdapters().add(new TestAdapter());
+
+ // Remove po2 in another session
+ doSecondSession();
+
+ // The following call wthrows a CCE if bug 318844 is not fixed
+ session.refresh();
+
+ tx.close();
+ session.close();
+ }
+
+ private void doSecondSession() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ // Detach the purchaseOrder
+ r1.getContents().remove(0);
+
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318876_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318876_Test.java
index ab6353f6a5..957010a66e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318876_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318876_Test.java
@@ -1,83 +1,83 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.Date;
-
-/**
- * Bugzilla 318876 - Mechanism for avoiding dangling refs can introduce spurious conflicts</p>
- * http://bugs.eclipse.org/318876</p>
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_318876_Test extends AbstractCDOTest
-{
- public void test() throws CommitException
- {
- final CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
-
- PurchaseOrder po1 = getModel1Factory().createPurchaseOrder();
- po1.setDate(new Date());
- r1.getContents().add(po1);
-
- Supplier supplier = getModel1Factory().createSupplier();
- supplier.getPurchaseOrders().add(po1);
- r1.getContents().add(supplier);
-
- tx.commit();
-
- // Remove po2 in another session
- doSecondSession();
-
- // Make the supplier dirty so that it will be scanned for dangling refs
- // during processing of the refresh results
- supplier.setName("Supplier");
-
- session.refresh();
-
- CDOState state = CDOUtil.getCDOObject(po1).cdoState();
- System.out.println("--> purchaseOrder state (should be INVALID) = " + state);
- assertEquals(CDOState.INVALID, state);
-
- tx.close();
- session.close();
- }
-
- private void doSecondSession() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getResource(getResourcePath("/r1")); //$NON-NLS-1$
-
- // Detach the po
- PurchaseOrder po = (PurchaseOrder)r1.getContents().get(0);
- EcoreUtil.delete(po);
-
- tx.commit();
- tx.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.Date;
+
+/**
+ * Bugzilla 318876 - Mechanism for avoiding dangling refs can introduce spurious conflicts</p>
+ * http://bugs.eclipse.org/318876</p>
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_318876_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ final CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ PurchaseOrder po1 = getModel1Factory().createPurchaseOrder();
+ po1.setDate(new Date());
+ r1.getContents().add(po1);
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.getPurchaseOrders().add(po1);
+ r1.getContents().add(supplier);
+
+ tx.commit();
+
+ // Remove po2 in another session
+ doSecondSession();
+
+ // Make the supplier dirty so that it will be scanned for dangling refs
+ // during processing of the refresh results
+ supplier.setName("Supplier");
+
+ session.refresh();
+
+ CDOState state = CDOUtil.getCDOObject(po1).cdoState();
+ System.out.println("--> purchaseOrder state (should be INVALID) = " + state);
+ assertEquals(CDOState.INVALID, state);
+
+ tx.close();
+ session.close();
+ }
+
+ private void doSecondSession() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ // Detach the po
+ PurchaseOrder po = (PurchaseOrder)r1.getContents().get(0);
+ EcoreUtil.delete(po);
+
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318919_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318919_Test.java
index 4fd73ef95d..21c107ead1 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318919_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318919_Test.java
@@ -1,166 +1,166 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.util.TestRevisionManager;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.Iterator;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_318919_Test extends AbstractCDOTest
-{
- private static int counter;
-
- private Category createCategoryTree(int depth)
- {
- if (depth == 0)
- {
- return null;
- }
-
- Category category = getModel1Factory().createCategory();
- for (int i = 0; i < 2; i++)
- {
- Category child = createCategoryTree(depth - 1);
- if (child != null)
- {
- category.getCategories().add(child);
- }
- }
-
- for (int i = 0; i < 3; i++)
- {
- Product1 child = getModel1Factory().createProduct1();
- // generate a unique id
- String id = "test " + depth + "_" + i + "_" + ++counter;
- child.setName(id);
- category.getProducts().add(child);
- }
-
- return category;
- }
-
- private int countObjects(EObject tree)
- {
- int count = 1;
- for (Iterator<?> it = tree.eAllContents(); it.hasNext();)
- {
- it.next();
- ++count;
- }
-
- return count;
- }
-
- public void testPrefetchResource_PROXY() throws Exception
- {
- int expected;
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- Category tree = createCategoryTree(3);
- expected = countObjects(tree);
- resource.getContents().add(tree);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- TestRevisionManager revisionManager = (TestRevisionManager)session.getRevisionManager();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/res1"));
- assertProxy(resource);
-
- revisionManager.resetAdditionalCounter();
- resource.cdoPrefetch(CDORevision.DEPTH_INFINITE);
- assertEquals(expected, revisionManager.getAdditionalCounter());
- }
-
- public void testPrefetchResource_CLEAN() throws Exception
- {
- int expected;
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- Category tree = createCategoryTree(3);
- expected = countObjects(tree);
- resource.getContents().add(tree);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- TestRevisionManager revisionManager = (TestRevisionManager)session.getRevisionManager();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/res1"));
- resource.getContents().get(0);
- assertClean(resource, transaction);
-
- revisionManager.resetAdditionalCounter();
- resource.cdoPrefetch(CDORevision.DEPTH_INFINITE);
- assertEquals(expected, revisionManager.getAdditionalCounter());
- }
-
- public void testPrefetchObject() throws Exception
- {
- int expected;
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- Category tree = createCategoryTree(3);
- expected = countObjects(tree);
- resource.getContents().add(tree);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- TestRevisionManager revisionManager = (TestRevisionManager)session.getRevisionManager();
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/res1"));
- Category category = (Category)resource.getContents().get(0);
- category.getName(); // Not really needed
- --expected; // Tree root is not "additional"
- assertClean(category, transaction);
-
- revisionManager.resetAdditionalCounter();
- CDOUtil.getCDOObject(category).cdoPrefetch(CDORevision.DEPTH_INFINITE);
- assertEquals(expected, revisionManager.getAdditionalCounter());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.util.TestRevisionManager;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.Iterator;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_318919_Test extends AbstractCDOTest
+{
+ private static int counter;
+
+ private Category createCategoryTree(int depth)
+ {
+ if (depth == 0)
+ {
+ return null;
+ }
+
+ Category category = getModel1Factory().createCategory();
+ for (int i = 0; i < 2; i++)
+ {
+ Category child = createCategoryTree(depth - 1);
+ if (child != null)
+ {
+ category.getCategories().add(child);
+ }
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ Product1 child = getModel1Factory().createProduct1();
+ // generate a unique id
+ String id = "test " + depth + "_" + i + "_" + ++counter;
+ child.setName(id);
+ category.getProducts().add(child);
+ }
+
+ return category;
+ }
+
+ private int countObjects(EObject tree)
+ {
+ int count = 1;
+ for (Iterator<?> it = tree.eAllContents(); it.hasNext();)
+ {
+ it.next();
+ ++count;
+ }
+
+ return count;
+ }
+
+ public void testPrefetchResource_PROXY() throws Exception
+ {
+ int expected;
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ Category tree = createCategoryTree(3);
+ expected = countObjects(tree);
+ resource.getContents().add(tree);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ TestRevisionManager revisionManager = (TestRevisionManager)session.getRevisionManager();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/res1"));
+ assertProxy(resource);
+
+ revisionManager.resetAdditionalCounter();
+ resource.cdoPrefetch(CDORevision.DEPTH_INFINITE);
+ assertEquals(expected, revisionManager.getAdditionalCounter());
+ }
+
+ public void testPrefetchResource_CLEAN() throws Exception
+ {
+ int expected;
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ Category tree = createCategoryTree(3);
+ expected = countObjects(tree);
+ resource.getContents().add(tree);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ TestRevisionManager revisionManager = (TestRevisionManager)session.getRevisionManager();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/res1"));
+ resource.getContents().get(0);
+ assertClean(resource, transaction);
+
+ revisionManager.resetAdditionalCounter();
+ resource.cdoPrefetch(CDORevision.DEPTH_INFINITE);
+ assertEquals(expected, revisionManager.getAdditionalCounter());
+ }
+
+ public void testPrefetchObject() throws Exception
+ {
+ int expected;
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ Category tree = createCategoryTree(3);
+ expected = countObjects(tree);
+ resource.getContents().add(tree);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ TestRevisionManager revisionManager = (TestRevisionManager)session.getRevisionManager();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/res1"));
+ Category category = (Category)resource.getContents().get(0);
+ category.getName(); // Not really needed
+ --expected; // Tree root is not "additional"
+ assertClean(category, transaction);
+
+ revisionManager.resetAdditionalCounter();
+ CDOUtil.getCDOObject(category).cdoPrefetch(CDORevision.DEPTH_INFINITE);
+ assertEquals(expected, revisionManager.getAdditionalCounter());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318998_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318998_Test.java
index 6a439e50d6..4a3dc31daa 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318998_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_318998_Test.java
@@ -1,100 +1,100 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.RefMultiContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_318998_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
- return map;
- }
-
- public void testQueryXRefSingle() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating test data");
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
- RefSingleContainedNPL container = getModel4Factory().createRefSingleContainedNPL();
- RefSingleNonContainedNPL nonContainer = getModel4Factory().createRefSingleNonContainedNPL();
- ContainedElementNoOpposite contained = getModel4Factory().createContainedElementNoOpposite();
- container.setElement(contained);
- nonContainer.setElement(contained);
-
- resource.getContents().add(container);
- resource.getContents().add(nonContainer);
-
- transaction.commit();
-
- container.setElement(null);
-
- try
- {
- transaction.commit();
- fail("Exception expected");
- }
- catch (Exception e)
- {
- msg("catched expected ex: " + e.getMessage());
- }
- }
-
- public void testQueryXRefMany() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating test data");
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
- RefMultiContainedNPL container = getModel4Factory().createRefMultiContainedNPL();
- RefMultiNonContainedNPL nonContainer = getModel4Factory().createRefMultiNonContainedNPL();
- ContainedElementNoOpposite contained = getModel4Factory().createContainedElementNoOpposite();
- container.getElements().add(contained);
- nonContainer.getElements().add(contained);
-
- resource.getContents().add(container);
- resource.getContents().add(nonContainer);
-
- transaction.commit();
-
- container.getElements().remove(0);
-
- try
- {
- transaction.commit();
- fail("Exception expected");
- }
- catch (Exception e)
- {
- msg("Caught expected exception: " + e.getMessage());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.RefMultiContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_318998_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ public void testQueryXRefSingle() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating test data");
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+ RefSingleContainedNPL container = getModel4Factory().createRefSingleContainedNPL();
+ RefSingleNonContainedNPL nonContainer = getModel4Factory().createRefSingleNonContainedNPL();
+ ContainedElementNoOpposite contained = getModel4Factory().createContainedElementNoOpposite();
+ container.setElement(contained);
+ nonContainer.setElement(contained);
+
+ resource.getContents().add(container);
+ resource.getContents().add(nonContainer);
+
+ transaction.commit();
+
+ container.setElement(null);
+
+ try
+ {
+ transaction.commit();
+ fail("Exception expected");
+ }
+ catch (Exception e)
+ {
+ msg("catched expected ex: " + e.getMessage());
+ }
+ }
+
+ public void testQueryXRefMany() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating test data");
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+ RefMultiContainedNPL container = getModel4Factory().createRefMultiContainedNPL();
+ RefMultiNonContainedNPL nonContainer = getModel4Factory().createRefMultiNonContainedNPL();
+ ContainedElementNoOpposite contained = getModel4Factory().createContainedElementNoOpposite();
+ container.getElements().add(contained);
+ nonContainer.getElements().add(contained);
+
+ resource.getContents().add(container);
+ resource.getContents().add(nonContainer);
+
+ transaction.commit();
+
+ container.getElements().remove(0);
+
+ try
+ {
+ transaction.commit();
+ fail("Exception expected");
+ }
+ catch (Exception e)
+ {
+ msg("Caught expected exception: " + e.getMessage());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java
index 723ba304a5..df01870bc7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java
@@ -1,407 +1,407 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository.WriteAccessHandler;
-import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
-import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model3.NodeA;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.emf.edit.command.DragAndDropCommand;
-
-import java.text.MessageFormat;
-
-/**
- * Moving nodes in a tree structure (simulate a {@link DragAndDropCommand}) may result in an inconsistent tree.
- * <p>
- * See bug 319836
- *
- * @author Cyril Jaquier
- */
-public class Bugzilla_319836_Test extends AbstractCDOTest
-{
- private static final boolean SHOW_BUG = true;
-
- public void testNodeMovesInTreeCreatesCycle() throws Exception
- {
- {
- // Setup an initial session and a transaction.
- CDOSession session = openSession();
- CDOTransaction tr1 = session.openTransaction();
- CDOResource resource = tr1.createResource(getResourcePath("/test1"));
-
- NodeA n1 = getModel3Factory().createNodeA();
- NodeA n2 = getModel3Factory().createNodeA();
- NodeA n3 = getModel3Factory().createNodeA();
-
- resource.getContents().add(n1);
-
- // Create a deep tree.
- //
- // n1
- // `- n2
- // ___`- n3
- n1.getChildren().add(n2);
- n2.getChildren().add(n3);
-
- tr1.commit();
- setNames(n1, n2, n3);
- tr1.commit();
- addCommitContextTracer();
-
- // First move.
- //
- // n1
- // |- n2
- // `- n3
- if (SHOW_BUG)
- {
- n2.getChildren().remove(n3);
- }
-
- n1.getChildren().add(n3);
-
- // Second move.
- //
- // n1
- // `- n3
- // ___`- n2
-
- // Something bad will happen during the execution of the next line. Set a breakpoint in
- // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new HashMap<CDOID,CDOObject>()
- // {...}.put(CDOID, CDOObject) and see how the previous REMOVE is eaten.
- if (SHOW_BUG)
- {
- n1.getChildren().remove(n2);
- }
-
- n3.getChildren().add(n2);
-
- // Problem is with n2; the removal of its child has been lost
- CDOID n2ID = CDOUtil.getCDOObject(n2).cdoID();
- CDORevisionDelta revDelta = tr1.getRevisionDeltas().get(n2ID);
- assertEquals(2, revDelta.getFeatureDeltas().size());
-
- tr1.commit();
-
- // Checks the tree.
- assertEquals(1, n1.getChildren().size());
- assertEquals(0, n2.getChildren().size());
- assertEquals(1, n3.getChildren().size());
- }
-
- {
- // Setup a new session. The bug only does not seem to occur if we use the same session.
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- NodeA n1 = (NodeA)resource.getContents().get(0);
-
- // Checks the tree.
- assertEquals(1, n1.getChildren().size());
- NodeA n3 = n1.getChildren().get(0);
- assertEquals(1, n3.getChildren().size());
- NodeA n2 = n3.getChildren().get(0);
- // Oups... n2 has a child!? And even worst... it's n3 :'( Houston, we have a problem...
- assertEquals(0, n2.getChildren().size());
- }
- }
-
- public void testNodeMovesInTreeDuplicatesNode() throws Exception
- {
- {
- // Setup an initial session and a transaction.
- CDOSession session = openSession();
- CDOTransaction tr1 = session.openTransaction();
- CDOResource resource = tr1.createResource(getResourcePath("/test1"));
-
- NodeA n1 = getModel3Factory().createNodeA();
- NodeA n2 = getModel3Factory().createNodeA();
- NodeA n3 = getModel3Factory().createNodeA();
- NodeA n4 = getModel3Factory().createNodeA();
-
- resource.getContents().add(n1);
-
- // Create a deep tree.
- //
- // n1
- // `- n2
- // ___`- n3
- // ______`- n4
- n1.getChildren().add(n2);
- n2.getChildren().add(n3);
- n3.getChildren().add(n4);
-
- tr1.commit();
- setNames(n1, n2, n3);
- tr1.commit();
- addCommitContextTracer();
-
- // First move.
- //
- // n1
- // `- n2
- // ___|- n3
- // ___`- n4
- if (SHOW_BUG)
- {
- n3.getChildren().remove(n4);
- }
-
- n2.getChildren().add(n4);
-
- // Second move.
- //
- // n1
- // |- n2
- // |__`- n4
- // `- n3
-
- // Something bad will happen during the execution of the next line. Set a breakpoint in
- // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new HashMap<CDOID,CDOObject>()
- // {...}.put(CDOID, CDOObject) and see how the previous REMOVE is eaten.
- if (SHOW_BUG)
- {
- n2.getChildren().remove(n3);
- }
-
- n1.getChildren().add(n3);
-
- tr1.commit();
-
- // Checks the tree.
- assertEquals(2, n1.getChildren().size());
- assertEquals(1, n2.getChildren().size());
- assertEquals(0, n3.getChildren().size());
- assertEquals(0, n4.getChildren().size());
- }
-
- {
- // Setup a new session. The bug only does not seem to occur if we use the same session.
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- NodeA n1 = (NodeA)resource.getContents().get(0);
-
- // Checks the tree.
- assertEquals(2, n1.getChildren().size());
- NodeA n2 = n1.getChildren().get(0);
- assertEquals(1, n2.getChildren().size());
- NodeA n4 = n2.getChildren().get(0);
- assertEquals(0, n4.getChildren().size());
- NodeA n3 = n1.getChildren().get(1);
- // Oups... n3 has a child!?
- assertEquals(0, n3.getChildren().size());
- }
- }
-
- public void testNodeMovesInTreeEatsNode() throws Exception
- {
- {
- // Setup an initial session and a transaction.
- CDOSession session = openSession();
- CDOTransaction tr1 = session.openTransaction();
- CDOResource resource = tr1.createResource(getResourcePath("/test1"));
-
- NodeA n1 = getModel3Factory().createNodeA();
- NodeA n2 = getModel3Factory().createNodeA();
- NodeA n3 = getModel3Factory().createNodeA();
- NodeA n4 = getModel3Factory().createNodeA();
-
- resource.getContents().add(n1);
-
- // Create a flat tree.
- //
- // n1
- // |- n2
- // |- n3
- // `- n4
- n1.getChildren().add(n2);
- n1.getChildren().add(n3);
- n1.getChildren().add(n4);
-
- tr1.commit();
- setNames(n1, n2, n3);
- tr1.commit();
- addCommitContextTracer();
-
- // First move.
- //
- // n1
- // |- n2
- // `- n3
- // ___`- n4
- if (SHOW_BUG)
- {
- n1.getChildren().remove(n4);
- }
-
- n3.getChildren().add(n4);
-
- // Second move.
- //
- // n1
- // `- n2
- // ___`- n3
- // ______`- n4
-
- // Something bad will happen during the execution of the next line. Set a breakpoint in
- // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new HashMap<CDOID,CDOObject>()
- // {...}.put(CDOID, CDOObject) and see how the previous ADD is eaten.
- if (SHOW_BUG)
- {
- n1.getChildren().remove(n3);
- }
-
- n2.getChildren().add(n3);
-
- tr1.commit();
-
- // Checks the tree.
- assertEquals(1, n1.getChildren().size());
- assertEquals(n2, n1.getChildren().get(0));
- assertEquals(1, n2.getChildren().size());
- assertEquals(n3, n2.getChildren().get(0));
- assertEquals(1, n3.getChildren().size());
- assertEquals(n4, n3.getChildren().get(0));
- assertEquals(0, n4.getChildren().size());
- }
-
- {
- // Setup a new session. The bug only does not seem to occur if we use the same session.
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/test1"));
-
- NodeA n1 = (NodeA)resource.getContents().get(0);
-
- // Checks the tree.
- assertEquals(1, n1.getChildren().size());
- NodeA n2 = n1.getChildren().get(0);
- assertEquals(1, n2.getChildren().size());
- NodeA n3 = n2.getChildren().get(0);
- // Oups... Where is n4!?
- assertEquals(1, n3.getChildren().size());
- NodeA n4 = n3.getChildren().get(0);
- assertEquals(0, n4.getChildren().size());
- }
- }
-
- private void setNames(NodeA... nodes)
- {
- for (NodeA node : nodes)
- {
- String id = CDOUtil.getCDOObject(node).cdoID().toString();
- msg("Node: " + id);
- node.setName(id);
- }
- }
-
- private void addCommitContextTracer()
- {
- getRepository().addHandler(new WriteAccessHandler()
- {
- public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor) throws RuntimeException
- {
- msg(toPrettyString("\t", commitContext.getDirtyObjectDeltas()));
- }
-
- public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor)
- {
- }
-
- /**
- * Prints the {@link InternalCDORevisionDelta}s in a more friendly way than {@link #toString()}.
- *
- * @param spacer
- * the spacer used to increment the output
- * @return {@link String}
- */
- private String toPrettyString(String spacer, InternalCDORevisionDelta[] dirtyObjects)
- {
- StringBuilder sb = new StringBuilder();
-
- // Delta.
- sb.append(spacer).append("Delta revision(s):\n");
- for (InternalCDORevisionDelta item : dirtyObjects)
- {
- String m = MessageFormat.format("{0}@{1}:{2}v{3}", item.getEClass().getName(), item.getID(), item.getBranch()
- .getID(), item.getVersion());
- sb.append(spacer).append(spacer).append(m).append("\n");
- // Feature deltas.
- for (CDOFeatureDelta delta : item.getFeatureDeltas())
- {
- printFeatureDelta(sb, delta, spacer, 3);
- }
- }
-
- return sb.toString();
- }
-
- /**
- * Pretty prints {@link CDOFeatureDelta}, recursing into {@link CDOListFeatureDelta}.
- *
- * @param sb
- * {@link StringBuilder} where the output is written
- * @param delta
- * {@link CDOFeatureDelta}
- * @param spacer
- * the spacer used to increment the output
- * @param numberOfSpacer
- * the minimal number of spacer in front of a line
- */
- private void printFeatureDelta(StringBuilder sb, CDOFeatureDelta delta, String spacer, int numberOfSpacer)
- {
- if (delta instanceof CDOListFeatureDelta)
- {
- CDOListFeatureDelta list = (CDOListFeatureDelta)delta;
- for (int i = 0; i < numberOfSpacer; i++)
- {
- sb.append(spacer);
- }
-
- sb.append("CDOListFeatureDelta").append("\n");
- for (CDOFeatureDelta c : list.getListChanges())
- {
- sb.append(spacer);
- printFeatureDelta(sb, c, spacer, numberOfSpacer);
- }
- }
- else
- {
- for (int i = 0; i < numberOfSpacer; i++)
- {
- sb.append(spacer);
- }
-
- sb.append(delta).append("\n");
- }
- }
- });
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository.WriteAccessHandler;
+import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model3.NodeA;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.emf.edit.command.DragAndDropCommand;
+
+import java.text.MessageFormat;
+
+/**
+ * Moving nodes in a tree structure (simulate a {@link DragAndDropCommand}) may result in an inconsistent tree.
+ * <p>
+ * See bug 319836
+ *
+ * @author Cyril Jaquier
+ */
+public class Bugzilla_319836_Test extends AbstractCDOTest
+{
+ private static final boolean SHOW_BUG = true;
+
+ public void testNodeMovesInTreeCreatesCycle() throws Exception
+ {
+ {
+ // Setup an initial session and a transaction.
+ CDOSession session = openSession();
+ CDOTransaction tr1 = session.openTransaction();
+ CDOResource resource = tr1.createResource(getResourcePath("/test1"));
+
+ NodeA n1 = getModel3Factory().createNodeA();
+ NodeA n2 = getModel3Factory().createNodeA();
+ NodeA n3 = getModel3Factory().createNodeA();
+
+ resource.getContents().add(n1);
+
+ // Create a deep tree.
+ //
+ // n1
+ // `- n2
+ // ___`- n3
+ n1.getChildren().add(n2);
+ n2.getChildren().add(n3);
+
+ tr1.commit();
+ setNames(n1, n2, n3);
+ tr1.commit();
+ addCommitContextTracer();
+
+ // First move.
+ //
+ // n1
+ // |- n2
+ // `- n3
+ if (SHOW_BUG)
+ {
+ n2.getChildren().remove(n3);
+ }
+
+ n1.getChildren().add(n3);
+
+ // Second move.
+ //
+ // n1
+ // `- n3
+ // ___`- n2
+
+ // Something bad will happen during the execution of the next line. Set a breakpoint in
+ // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new HashMap<CDOID,CDOObject>()
+ // {...}.put(CDOID, CDOObject) and see how the previous REMOVE is eaten.
+ if (SHOW_BUG)
+ {
+ n1.getChildren().remove(n2);
+ }
+
+ n3.getChildren().add(n2);
+
+ // Problem is with n2; the removal of its child has been lost
+ CDOID n2ID = CDOUtil.getCDOObject(n2).cdoID();
+ CDORevisionDelta revDelta = tr1.getRevisionDeltas().get(n2ID);
+ assertEquals(2, revDelta.getFeatureDeltas().size());
+
+ tr1.commit();
+
+ // Checks the tree.
+ assertEquals(1, n1.getChildren().size());
+ assertEquals(0, n2.getChildren().size());
+ assertEquals(1, n3.getChildren().size());
+ }
+
+ {
+ // Setup a new session. The bug only does not seem to occur if we use the same session.
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ NodeA n1 = (NodeA)resource.getContents().get(0);
+
+ // Checks the tree.
+ assertEquals(1, n1.getChildren().size());
+ NodeA n3 = n1.getChildren().get(0);
+ assertEquals(1, n3.getChildren().size());
+ NodeA n2 = n3.getChildren().get(0);
+ // Oups... n2 has a child!? And even worst... it's n3 :'( Houston, we have a problem...
+ assertEquals(0, n2.getChildren().size());
+ }
+ }
+
+ public void testNodeMovesInTreeDuplicatesNode() throws Exception
+ {
+ {
+ // Setup an initial session and a transaction.
+ CDOSession session = openSession();
+ CDOTransaction tr1 = session.openTransaction();
+ CDOResource resource = tr1.createResource(getResourcePath("/test1"));
+
+ NodeA n1 = getModel3Factory().createNodeA();
+ NodeA n2 = getModel3Factory().createNodeA();
+ NodeA n3 = getModel3Factory().createNodeA();
+ NodeA n4 = getModel3Factory().createNodeA();
+
+ resource.getContents().add(n1);
+
+ // Create a deep tree.
+ //
+ // n1
+ // `- n2
+ // ___`- n3
+ // ______`- n4
+ n1.getChildren().add(n2);
+ n2.getChildren().add(n3);
+ n3.getChildren().add(n4);
+
+ tr1.commit();
+ setNames(n1, n2, n3);
+ tr1.commit();
+ addCommitContextTracer();
+
+ // First move.
+ //
+ // n1
+ // `- n2
+ // ___|- n3
+ // ___`- n4
+ if (SHOW_BUG)
+ {
+ n3.getChildren().remove(n4);
+ }
+
+ n2.getChildren().add(n4);
+
+ // Second move.
+ //
+ // n1
+ // |- n2
+ // |__`- n4
+ // `- n3
+
+ // Something bad will happen during the execution of the next line. Set a breakpoint in
+ // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new HashMap<CDOID,CDOObject>()
+ // {...}.put(CDOID, CDOObject) and see how the previous REMOVE is eaten.
+ if (SHOW_BUG)
+ {
+ n2.getChildren().remove(n3);
+ }
+
+ n1.getChildren().add(n3);
+
+ tr1.commit();
+
+ // Checks the tree.
+ assertEquals(2, n1.getChildren().size());
+ assertEquals(1, n2.getChildren().size());
+ assertEquals(0, n3.getChildren().size());
+ assertEquals(0, n4.getChildren().size());
+ }
+
+ {
+ // Setup a new session. The bug only does not seem to occur if we use the same session.
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ NodeA n1 = (NodeA)resource.getContents().get(0);
+
+ // Checks the tree.
+ assertEquals(2, n1.getChildren().size());
+ NodeA n2 = n1.getChildren().get(0);
+ assertEquals(1, n2.getChildren().size());
+ NodeA n4 = n2.getChildren().get(0);
+ assertEquals(0, n4.getChildren().size());
+ NodeA n3 = n1.getChildren().get(1);
+ // Oups... n3 has a child!?
+ assertEquals(0, n3.getChildren().size());
+ }
+ }
+
+ public void testNodeMovesInTreeEatsNode() throws Exception
+ {
+ {
+ // Setup an initial session and a transaction.
+ CDOSession session = openSession();
+ CDOTransaction tr1 = session.openTransaction();
+ CDOResource resource = tr1.createResource(getResourcePath("/test1"));
+
+ NodeA n1 = getModel3Factory().createNodeA();
+ NodeA n2 = getModel3Factory().createNodeA();
+ NodeA n3 = getModel3Factory().createNodeA();
+ NodeA n4 = getModel3Factory().createNodeA();
+
+ resource.getContents().add(n1);
+
+ // Create a flat tree.
+ //
+ // n1
+ // |- n2
+ // |- n3
+ // `- n4
+ n1.getChildren().add(n2);
+ n1.getChildren().add(n3);
+ n1.getChildren().add(n4);
+
+ tr1.commit();
+ setNames(n1, n2, n3);
+ tr1.commit();
+ addCommitContextTracer();
+
+ // First move.
+ //
+ // n1
+ // |- n2
+ // `- n3
+ // ___`- n4
+ if (SHOW_BUG)
+ {
+ n1.getChildren().remove(n4);
+ }
+
+ n3.getChildren().add(n4);
+
+ // Second move.
+ //
+ // n1
+ // `- n2
+ // ___`- n3
+ // ______`- n4
+
+ // Something bad will happen during the execution of the next line. Set a breakpoint in
+ // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new HashMap<CDOID,CDOObject>()
+ // {...}.put(CDOID, CDOObject) and see how the previous ADD is eaten.
+ if (SHOW_BUG)
+ {
+ n1.getChildren().remove(n3);
+ }
+
+ n2.getChildren().add(n3);
+
+ tr1.commit();
+
+ // Checks the tree.
+ assertEquals(1, n1.getChildren().size());
+ assertEquals(n2, n1.getChildren().get(0));
+ assertEquals(1, n2.getChildren().size());
+ assertEquals(n3, n2.getChildren().get(0));
+ assertEquals(1, n3.getChildren().size());
+ assertEquals(n4, n3.getChildren().get(0));
+ assertEquals(0, n4.getChildren().size());
+ }
+
+ {
+ // Setup a new session. The bug only does not seem to occur if we use the same session.
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/test1"));
+
+ NodeA n1 = (NodeA)resource.getContents().get(0);
+
+ // Checks the tree.
+ assertEquals(1, n1.getChildren().size());
+ NodeA n2 = n1.getChildren().get(0);
+ assertEquals(1, n2.getChildren().size());
+ NodeA n3 = n2.getChildren().get(0);
+ // Oups... Where is n4!?
+ assertEquals(1, n3.getChildren().size());
+ NodeA n4 = n3.getChildren().get(0);
+ assertEquals(0, n4.getChildren().size());
+ }
+ }
+
+ private void setNames(NodeA... nodes)
+ {
+ for (NodeA node : nodes)
+ {
+ String id = CDOUtil.getCDOObject(node).cdoID().toString();
+ msg("Node: " + id);
+ node.setName(id);
+ }
+ }
+
+ private void addCommitContextTracer()
+ {
+ getRepository().addHandler(new WriteAccessHandler()
+ {
+ public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor) throws RuntimeException
+ {
+ msg(toPrettyString("\t", commitContext.getDirtyObjectDeltas()));
+ }
+
+ public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor)
+ {
+ }
+
+ /**
+ * Prints the {@link InternalCDORevisionDelta}s in a more friendly way than {@link #toString()}.
+ *
+ * @param spacer
+ * the spacer used to increment the output
+ * @return {@link String}
+ */
+ private String toPrettyString(String spacer, InternalCDORevisionDelta[] dirtyObjects)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // Delta.
+ sb.append(spacer).append("Delta revision(s):\n");
+ for (InternalCDORevisionDelta item : dirtyObjects)
+ {
+ String m = MessageFormat.format("{0}@{1}:{2}v{3}", item.getEClass().getName(), item.getID(), item.getBranch()
+ .getID(), item.getVersion());
+ sb.append(spacer).append(spacer).append(m).append("\n");
+ // Feature deltas.
+ for (CDOFeatureDelta delta : item.getFeatureDeltas())
+ {
+ printFeatureDelta(sb, delta, spacer, 3);
+ }
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Pretty prints {@link CDOFeatureDelta}, recursing into {@link CDOListFeatureDelta}.
+ *
+ * @param sb
+ * {@link StringBuilder} where the output is written
+ * @param delta
+ * {@link CDOFeatureDelta}
+ * @param spacer
+ * the spacer used to increment the output
+ * @param numberOfSpacer
+ * the minimal number of spacer in front of a line
+ */
+ private void printFeatureDelta(StringBuilder sb, CDOFeatureDelta delta, String spacer, int numberOfSpacer)
+ {
+ if (delta instanceof CDOListFeatureDelta)
+ {
+ CDOListFeatureDelta list = (CDOListFeatureDelta)delta;
+ for (int i = 0; i < numberOfSpacer; i++)
+ {
+ sb.append(spacer);
+ }
+
+ sb.append("CDOListFeatureDelta").append("\n");
+ for (CDOFeatureDelta c : list.getListChanges())
+ {
+ sb.append(spacer);
+ printFeatureDelta(sb, c, spacer, numberOfSpacer);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < numberOfSpacer; i++)
+ {
+ sb.append(spacer);
+ }
+
+ sb.append(delta).append("\n");
+ }
+ }
+ });
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320690_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320690_Test.java
index 09adf29ba3..f519772941 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320690_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320690_Test.java
@@ -1,176 +1,176 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model3.NodeA;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_320690_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
- return map;
- }
-
- public void testLockRefTargets() throws Exception
- {
- skipStoreWithoutQueryXRefs();
-
- CDOSession session1 = openSession();
- session1.options().setPassiveUpdateEnabled(false);
- CDOTransaction transaction1 = session1.openTransaction();
-
- msg("Creating test data");
- CDOResource resource1 = transaction1.createResource(getResourcePath("/test"));
- RefSingleNonContainedNPL nonContainer1 = getModel4Factory().createRefSingleNonContainedNPL();
- RefSingleContainedNPL container1 = getModel4Factory().createRefSingleContainedNPL();
- ContainedElementNoOpposite contained1 = getModel4Factory().createContainedElementNoOpposite();
- container1.setElement(contained1);
-
- resource1.getContents().add(container1);
- resource1.getContents().add(nonContainer1);
- transaction1.commit();
- dumpAllRevisions(getRepository().getStore());
-
- CDOSession session2 = openSession();
- session2.options().setPassiveUpdateEnabled(false);
- CDOTransaction transaction2 = session2.openTransaction();
- RefSingleNonContainedNPL nonContainer2 = transaction2.getObject(nonContainer1);
- ContainedElementNoOpposite contained2 = transaction2.getObject(contained1);
-
- nonContainer2.setElement(contained2);
-
- // Transaction 1
- container1.setElement(null);
- transaction1.commit();
- dumpAllRevisions(getRepository().getStore());
-
- try
- {
- // This commit should throw an exception because contained_2 is already detached on the repository.
- transaction2.commit();
- dumpAllRevisions(getRepository().getStore());
-
- fail("Exception expected");
- }
- catch (Exception ex)
- {
- msg("Caught expected exception: " + ex.getMessage());
- }
-
- dumpAllRevisions(getRepository().getStore());
- }
-
- public void testDeleteTarget() throws Exception
- {
- NodeA a = getModel3Factory().createNodeA();
- NodeA b = getModel3Factory().createNodeA();
- NodeA c = getModel3Factory().createNodeA();
-
- a.getChildren().add(c);
- b.getOtherNodes().add(c);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- resource.getContents().add(a);
- resource.getContents().add(b);
- transaction.commit();
-
- a.getChildren().remove(c);
-
- try
- {
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException ex)
- {
- // SUCCESS
- }
- }
-
- public void testDeleteTargetAndReferenceAtOnce() throws Exception
- {
- skipStoreWithoutQueryXRefs();
- NodeA a = getModel3Factory().createNodeA();
- NodeA b = getModel3Factory().createNodeA();
- NodeA c = getModel3Factory().createNodeA();
-
- a.getChildren().add(c);
- b.getOtherNodes().add(c);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- resource.getContents().add(a);
- resource.getContents().add(b);
- transaction.commit();
- dumpAllRevisions(getRepository().getStore());
-
- a.getChildren().remove(c);
- b.getOtherNodes().remove(c);
-
- // Must not fail:
- transaction.commit();
- }
-
- public void testDeleteTargetRemoveAndAddReference() throws Exception
- {
- NodeA a = getModel3Factory().createNodeA();
- NodeA b = getModel3Factory().createNodeA();
- NodeA c = getModel3Factory().createNodeA();
-
- a.getChildren().add(c);
- b.getOtherNodes().add(c);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- resource.getContents().add(a);
- resource.getContents().add(b);
- transaction.commit();
- dumpAllRevisions(getRepository().getStore());
-
- a.getChildren().remove(c);
- b.getOtherNodes().remove(c);
- b.getOtherNodes().add(c);
-
- try
- {
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException ex)
- {
- // SUCCESS
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model3.NodeA;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_320690_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ public void testLockRefTargets() throws Exception
+ {
+ skipStoreWithoutQueryXRefs();
+
+ CDOSession session1 = openSession();
+ session1.options().setPassiveUpdateEnabled(false);
+ CDOTransaction transaction1 = session1.openTransaction();
+
+ msg("Creating test data");
+ CDOResource resource1 = transaction1.createResource(getResourcePath("/test"));
+ RefSingleNonContainedNPL nonContainer1 = getModel4Factory().createRefSingleNonContainedNPL();
+ RefSingleContainedNPL container1 = getModel4Factory().createRefSingleContainedNPL();
+ ContainedElementNoOpposite contained1 = getModel4Factory().createContainedElementNoOpposite();
+ container1.setElement(contained1);
+
+ resource1.getContents().add(container1);
+ resource1.getContents().add(nonContainer1);
+ transaction1.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ CDOSession session2 = openSession();
+ session2.options().setPassiveUpdateEnabled(false);
+ CDOTransaction transaction2 = session2.openTransaction();
+ RefSingleNonContainedNPL nonContainer2 = transaction2.getObject(nonContainer1);
+ ContainedElementNoOpposite contained2 = transaction2.getObject(contained1);
+
+ nonContainer2.setElement(contained2);
+
+ // Transaction 1
+ container1.setElement(null);
+ transaction1.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ try
+ {
+ // This commit should throw an exception because contained_2 is already detached on the repository.
+ transaction2.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ fail("Exception expected");
+ }
+ catch (Exception ex)
+ {
+ msg("Caught expected exception: " + ex.getMessage());
+ }
+
+ dumpAllRevisions(getRepository().getStore());
+ }
+
+ public void testDeleteTarget() throws Exception
+ {
+ NodeA a = getModel3Factory().createNodeA();
+ NodeA b = getModel3Factory().createNodeA();
+ NodeA c = getModel3Factory().createNodeA();
+
+ a.getChildren().add(c);
+ b.getOtherNodes().add(c);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ resource.getContents().add(a);
+ resource.getContents().add(b);
+ transaction.commit();
+
+ a.getChildren().remove(c);
+
+ try
+ {
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException ex)
+ {
+ // SUCCESS
+ }
+ }
+
+ public void testDeleteTargetAndReferenceAtOnce() throws Exception
+ {
+ skipStoreWithoutQueryXRefs();
+ NodeA a = getModel3Factory().createNodeA();
+ NodeA b = getModel3Factory().createNodeA();
+ NodeA c = getModel3Factory().createNodeA();
+
+ a.getChildren().add(c);
+ b.getOtherNodes().add(c);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ resource.getContents().add(a);
+ resource.getContents().add(b);
+ transaction.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ a.getChildren().remove(c);
+ b.getOtherNodes().remove(c);
+
+ // Must not fail:
+ transaction.commit();
+ }
+
+ public void testDeleteTargetRemoveAndAddReference() throws Exception
+ {
+ NodeA a = getModel3Factory().createNodeA();
+ NodeA b = getModel3Factory().createNodeA();
+ NodeA c = getModel3Factory().createNodeA();
+
+ a.getChildren().add(c);
+ b.getOtherNodes().add(c);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ resource.getContents().add(a);
+ resource.getContents().add(b);
+ transaction.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ a.getChildren().remove(c);
+ b.getOtherNodes().remove(c);
+ b.getOtherNodes().add(c);
+
+ try
+ {
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException ex)
+ {
+ // SUCCESS
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320837_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320837_Test.java
index db286725ee..458eba01ab 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320837_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_320837_Test.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_320837_Test extends AbstractCDOTest
-{
- public void testLoadContainedBeforeContainer() throws Exception
- {
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
-
- CDOResource resource1 = transaction1.createResource(getResourcePath("/test"));
- RefSingleContainedNPL container1 = getModel4Factory().createRefSingleContainedNPL();
- ContainedElementNoOpposite contained1 = getModel4Factory().createContainedElementNoOpposite();
- container1.setElement(contained1);
-
- resource1.getContents().add(container1);
- transaction1.commit();
-
- CDOSession session2 = openSession();
- CDOTransaction transaction2 = session2.openTransaction();
-
- // Revieving the object should not result in an exception
- transaction2.getObject(contained1);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_320837_Test extends AbstractCDOTest
+{
+ public void testLoadContainedBeforeContainer() throws Exception
+ {
+ CDOSession session1 = openSession();
+ CDOTransaction transaction1 = session1.openTransaction();
+
+ CDOResource resource1 = transaction1.createResource(getResourcePath("/test"));
+ RefSingleContainedNPL container1 = getModel4Factory().createRefSingleContainedNPL();
+ ContainedElementNoOpposite contained1 = getModel4Factory().createContainedElementNoOpposite();
+ container1.setElement(contained1);
+
+ resource1.getContents().add(container1);
+ transaction1.commit();
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+
+ // Revieving the object should not result in an exception
+ transaction2.getObject(contained1);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321699_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321699_Test.java
index 3d5e944c73..fa1aa02e35 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321699_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321699_Test.java
@@ -1,58 +1,58 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-/**
- * Bug 321699 - CDOViewImpl.getObject(CDOID, boolean) can return wrong object for temporary IDs.
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_321699_Test extends AbstractCDOTest
-{
- public void test() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("/r1"));
- msg("Pre-commit ID of resource = " + resource.cdoID());
-
- CDOObject fetchedObject = tx.getObject(resource.cdoID());
- assertSame(resource, fetchedObject);
-
- tx.commit();
-
- msg("Post-commit ID of resource = " + resource.cdoID());
-
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- CDOID customerID = CDOUtil.getCDOObject(customer).cdoID();
- msg("Pre-commit ID of customer = " + customerID);
-
- fetchedObject = tx.getObject(customerID);
-
- msg("Object fetched for customerID = " + fetchedObject);
-
- assertSame(CDOUtil.getEObject(customer), CDOUtil.getEObject(fetchedObject));
-
- tx.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+/**
+ * Bug 321699 - CDOViewImpl.getObject(CDOID, boolean) can return wrong object for temporary IDs.
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_321699_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("/r1"));
+ msg("Pre-commit ID of resource = " + resource.cdoID());
+
+ CDOObject fetchedObject = tx.getObject(resource.cdoID());
+ assertSame(resource, fetchedObject);
+
+ tx.commit();
+
+ msg("Post-commit ID of resource = " + resource.cdoID());
+
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ CDOID customerID = CDOUtil.getCDOObject(customer).cdoID();
+ msg("Pre-commit ID of customer = " + customerID);
+
+ fetchedObject = tx.getObject(customerID);
+
+ msg("Object fetched for customerID = " + fetchedObject);
+
+ assertSame(CDOUtil.getEObject(customer), CDOUtil.getEObject(fetchedObject));
+
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java
index e59d0b3de8..11428935ee 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java
@@ -1,76 +1,76 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Address;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_321986_Test extends AbstractCDOTest
-{
- public void testRollback() throws CommitException
- {
- CDOSession session1 = openSession();
- CDOTransaction tx1 = session1.openTransaction();
-
- CDOResource resource1 = tx1.createResource(getResourcePath("test"));
- Address address = getModel1Factory().createAddress();
- resource1.getContents().add(address);
- tx1.commit();
-
- CDOObject cdoAddress = CDOUtil.getCDOObject(address);
- cdoAddress.cdoWriteLock().lock();
-
- msg("Address: " + cdoAddress.cdoID());
-
- CDOSession session2 = openSession();
- CDOTransaction tx2 = session2.openTransaction();
- CDOResource resource2 = tx2.getResource(getResourcePath("test"));
- resource2.getContents().clear();
- try
- {
- // We must fail here, because object was locked
- tx2.commit();
- fail("Commit should have failed");
- }
- catch (CommitException e)
- {
- // Good
- }
-
- // Remove in the 1st transaction
- EcoreUtil.delete(address);
- tx1.commit();
-
- try
- {
- tx2.rollback();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- fail("Exception on rollbak:" + ex.getMessage());
- }
-
- session2.close();
- session1.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Address;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_321986_Test extends AbstractCDOTest
+{
+ public void testRollback() throws CommitException
+ {
+ CDOSession session1 = openSession();
+ CDOTransaction tx1 = session1.openTransaction();
+
+ CDOResource resource1 = tx1.createResource(getResourcePath("test"));
+ Address address = getModel1Factory().createAddress();
+ resource1.getContents().add(address);
+ tx1.commit();
+
+ CDOObject cdoAddress = CDOUtil.getCDOObject(address);
+ cdoAddress.cdoWriteLock().lock();
+
+ msg("Address: " + cdoAddress.cdoID());
+
+ CDOSession session2 = openSession();
+ CDOTransaction tx2 = session2.openTransaction();
+ CDOResource resource2 = tx2.getResource(getResourcePath("test"));
+ resource2.getContents().clear();
+ try
+ {
+ // We must fail here, because object was locked
+ tx2.commit();
+ fail("Commit should have failed");
+ }
+ catch (CommitException e)
+ {
+ // Good
+ }
+
+ // Remove in the 1st transaction
+ EcoreUtil.delete(address);
+ tx1.commit();
+
+ try
+ {
+ tx2.rollback();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ fail("Exception on rollbak:" + ex.getMessage());
+ }
+
+ session2.close();
+ session1.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322754_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322754_Test.java
index ed2a539bb8..3e21f79ea4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322754_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322754_Test.java
@@ -1,88 +1,88 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.DanglingReferenceException;
-
-/**
- * Bug 322754 - NullPointerException after deleting a resource
- *
- * @author Eike Stepper
- */
-public class Bugzilla_322754_Test extends AbstractCDOTest
-{
- public void testResourceDelete() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/r1"));
-
- msg("Fill and commit a resource");
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.commit();
-
- msg("Delete and commit the resource");
- resource.delete(null);
- transaction.commit();
- }
-
- public void testResourceDeleteWithDanglingReferences() throws Exception
- {
- Product1 product = getModel1Factory().createProduct1();
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- product.setName("product1");
- orderDetail.setProduct(product);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("/r1"));
- resource1.getContents().add(product);
-
- CDOResource resource2 = transaction.createResource(getResourcePath("/r2"));
- resource2.getContents().add(orderDetail);
-
- transaction.commit();
-
- msg("Delete and commit the resource");
- resource1.delete(null);
-
- try
- {
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- assertInstanceOf(DanglingReferenceException.class, expected.getCause());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.DanglingReferenceException;
+
+/**
+ * Bug 322754 - NullPointerException after deleting a resource
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_322754_Test extends AbstractCDOTest
+{
+ public void testResourceDelete() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/r1"));
+
+ msg("Fill and commit a resource");
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.commit();
+
+ msg("Delete and commit the resource");
+ resource.delete(null);
+ transaction.commit();
+ }
+
+ public void testResourceDeleteWithDanglingReferences() throws Exception
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ product.setName("product1");
+ orderDetail.setProduct(product);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("/r1"));
+ resource1.getContents().add(product);
+
+ CDOResource resource2 = transaction.createResource(getResourcePath("/r2"));
+ resource2.getContents().add(orderDetail);
+
+ transaction.commit();
+
+ msg("Delete and commit the resource");
+ resource1.delete(null);
+
+ try
+ {
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ assertInstanceOf(DanglingReferenceException.class, expected.getCause());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322804_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322804_Test.java
index c94b13de35..3f5e69c6da 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322804_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_322804_Test.java
@@ -1,43 +1,43 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model5.GenListOfIntArray;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * Bug 322804 - ClassCastException adding an object to an EList with objects of a custom data type
- *
- * @author Eike Stepper
- */
-public class Bugzilla_322804_Test extends AbstractCDOTest
-{
- public void testAddElementToCustomTypedList() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/r1"));
-
- msg("Fill and commit a resource");
- GenListOfIntArray object = getModel5Factory().createGenListOfIntArray();
- resource.getContents().add(object);
- transaction.commit();
-
- msg("Add int[] elements");
- object.getElements().add(new int[] { 1, 2, 3, 4, 5 });
- object.getElements().add(new int[] { 10, 20, 30, 40, 50 });
- transaction.commit();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model5.GenListOfIntArray;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * Bug 322804 - ClassCastException adding an object to an EList with objects of a custom data type
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_322804_Test extends AbstractCDOTest
+{
+ public void testAddElementToCustomTypedList() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/r1"));
+
+ msg("Fill and commit a resource");
+ GenListOfIntArray object = getModel5Factory().createGenListOfIntArray();
+ resource.getContents().add(object);
+ transaction.commit();
+
+ msg("Add int[] elements");
+ object.getElements().add(new int[] { 1, 2, 3, 4, 5 });
+ object.getElements().add(new int[] { 10, 20, 30, 40, 50 });
+ transaction.commit();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323930_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323930_Test.java
index 775779fcfe..d40745e42d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323930_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323930_Test.java
@@ -1,265 +1,265 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model3.NodeA;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_323930_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
- return map;
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- skipStoreWithoutQueryXRefs();
- }
-
- public void testChangeIndexesInTargetList() throws Exception
- {
- NodeA a = getModel3Factory().createNodeA();
- NodeA b = getModel3Factory().createNodeA();
- NodeA c = getModel3Factory().createNodeA();
-
- NodeA x = getModel3Factory().createNodeA();
- NodeA y = getModel3Factory().createNodeA();
- NodeA z = getModel3Factory().createNodeA();
-
- a.getOtherNodes().add(x);
- a.getOtherNodes().add(y);
- a.getOtherNodes().add(z);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- resource.getContents().add(a);
- resource.getContents().add(b);
- resource.getContents().add(c);
- resource.getContents().add(x);
- resource.getContents().add(y);
- resource.getContents().add(z);
- transaction.commit();
- dumpAllRevisions(getRepository().getStore());
-
- resource.getContents().remove(b);
- resource.getContents().remove(c);
- resource.getContents().remove(z);
- a.getOtherNodes().remove(z);
-
- // Must not fail:
- transaction.commit();
- }
-
- public void testChangeIndexesInSourceList() throws Exception
- {
- NodeA a = getModel3Factory().createNodeA();
- NodeA b = getModel3Factory().createNodeA();
- NodeA c = getModel3Factory().createNodeA();
-
- NodeA x = getModel3Factory().createNodeA();
- NodeA y = getModel3Factory().createNodeA();
- NodeA z = getModel3Factory().createNodeA();
-
- a.getOtherNodes().add(x);
- a.getOtherNodes().add(y);
- a.getOtherNodes().add(z);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- resource.getContents().add(a);
- resource.getContents().add(b);
- resource.getContents().add(c);
- resource.getContents().add(x);
- resource.getContents().add(y);
- resource.getContents().add(z);
- transaction.commit();
- dumpAllRevisions(getRepository().getStore());
-
- a.getOtherNodes().add(0, b);
- a.getOtherNodes().add(1, c);
- a.getOtherNodes().remove(z); // Remove xref from index 4
- resource.getContents().remove(z);
-
- // Must not fail:
- transaction.commit();
- }
-
- public void testRemoveXRefByReplace() throws Exception
- {
- NodeA a = getModel3Factory().createNodeA();
- NodeA b = getModel3Factory().createNodeA();
- NodeA c = getModel3Factory().createNodeA();
-
- NodeA x = getModel3Factory().createNodeA();
- NodeA y = getModel3Factory().createNodeA();
- NodeA z = getModel3Factory().createNodeA();
-
- a.getOtherNodes().add(x);
- a.getOtherNodes().add(y);
- a.getOtherNodes().add(z);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- resource.getContents().add(a);
- resource.getContents().add(b);
- resource.getContents().add(c);
- resource.getContents().add(x);
- resource.getContents().add(y);
- resource.getContents().add(z);
- transaction.commit();
- dumpAllRevisions(getRepository().getStore());
-
- a.getOtherNodes().set(2, b); // Replace z with b
- resource.getContents().remove(z);
-
- // Must not fail:
- transaction.commit();
- }
-
- public void testRemoveXRefByReplace_PrecedingAdd() throws Exception
- {
- NodeA a = getModel3Factory().createNodeA();
- NodeA b = getModel3Factory().createNodeA();
- NodeA c = getModel3Factory().createNodeA();
-
- NodeA x = getModel3Factory().createNodeA();
- NodeA y = getModel3Factory().createNodeA();
- NodeA z = getModel3Factory().createNodeA();
-
- a.getOtherNodes().add(x);
- a.getOtherNodes().add(y);
- a.getOtherNodes().add(z);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- resource.getContents().add(a);
- resource.getContents().add(b);
- resource.getContents().add(c);
- resource.getContents().add(x);
- resource.getContents().add(y);
- resource.getContents().add(z);
- transaction.commit();
- dumpAllRevisions(getRepository().getStore());
-
- a.getOtherNodes().add(0, b);
- a.getOtherNodes().set(3, c); // Replace z with c
- resource.getContents().remove(z);
-
- // Must not fail:
- transaction.commit();
- }
-
- public void testAddXRefByReplace() throws Exception
- {
- NodeA a = getModel3Factory().createNodeA();
- NodeA b = getModel3Factory().createNodeA();
- NodeA c = getModel3Factory().createNodeA();
-
- NodeA x = getModel3Factory().createNodeA();
- NodeA y = getModel3Factory().createNodeA();
- NodeA z = getModel3Factory().createNodeA();
-
- a.getOtherNodes().add(x);
- a.getOtherNodes().add(y);
- a.getOtherNodes().add(b);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- resource.getContents().add(a);
- resource.getContents().add(b);
- resource.getContents().add(c);
- resource.getContents().add(x);
- resource.getContents().add(y);
- resource.getContents().add(z);
- transaction.commit();
- dumpAllRevisions(getRepository().getStore());
-
- a.getOtherNodes().set(2, z); // Replace b with z
- resource.getContents().remove(z);
-
- try
- {
- transaction.commit();
- fail("Exception expected");
- }
- catch (Exception expected)
- {
- // SUCCESS
- }
- }
-
- public void testAddXRefByReplace_PrecedingAdd() throws Exception
- {
- NodeA a = getModel3Factory().createNodeA();
- NodeA b = getModel3Factory().createNodeA();
- NodeA c = getModel3Factory().createNodeA();
-
- NodeA x = getModel3Factory().createNodeA();
- NodeA y = getModel3Factory().createNodeA();
- NodeA z = getModel3Factory().createNodeA();
-
- a.getOtherNodes().add(x);
- a.getOtherNodes().add(y);
- a.getOtherNodes().add(b);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- resource.getContents().add(a);
- resource.getContents().add(b);
- resource.getContents().add(c);
- resource.getContents().add(x);
- resource.getContents().add(y);
- resource.getContents().add(z);
- transaction.commit();
- dumpAllRevisions(getRepository().getStore());
-
- a.getOtherNodes().add(0, c);
- a.getOtherNodes().set(3, z); // Replace b with z
- resource.getContents().remove(z);
-
- try
- {
- transaction.commit();
- fail("Exception expected");
- }
- catch (Exception expected)
- {
- // SUCCESS
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model3.NodeA;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_323930_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ skipStoreWithoutQueryXRefs();
+ }
+
+ public void testChangeIndexesInTargetList() throws Exception
+ {
+ NodeA a = getModel3Factory().createNodeA();
+ NodeA b = getModel3Factory().createNodeA();
+ NodeA c = getModel3Factory().createNodeA();
+
+ NodeA x = getModel3Factory().createNodeA();
+ NodeA y = getModel3Factory().createNodeA();
+ NodeA z = getModel3Factory().createNodeA();
+
+ a.getOtherNodes().add(x);
+ a.getOtherNodes().add(y);
+ a.getOtherNodes().add(z);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ resource.getContents().add(a);
+ resource.getContents().add(b);
+ resource.getContents().add(c);
+ resource.getContents().add(x);
+ resource.getContents().add(y);
+ resource.getContents().add(z);
+ transaction.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ resource.getContents().remove(b);
+ resource.getContents().remove(c);
+ resource.getContents().remove(z);
+ a.getOtherNodes().remove(z);
+
+ // Must not fail:
+ transaction.commit();
+ }
+
+ public void testChangeIndexesInSourceList() throws Exception
+ {
+ NodeA a = getModel3Factory().createNodeA();
+ NodeA b = getModel3Factory().createNodeA();
+ NodeA c = getModel3Factory().createNodeA();
+
+ NodeA x = getModel3Factory().createNodeA();
+ NodeA y = getModel3Factory().createNodeA();
+ NodeA z = getModel3Factory().createNodeA();
+
+ a.getOtherNodes().add(x);
+ a.getOtherNodes().add(y);
+ a.getOtherNodes().add(z);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ resource.getContents().add(a);
+ resource.getContents().add(b);
+ resource.getContents().add(c);
+ resource.getContents().add(x);
+ resource.getContents().add(y);
+ resource.getContents().add(z);
+ transaction.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ a.getOtherNodes().add(0, b);
+ a.getOtherNodes().add(1, c);
+ a.getOtherNodes().remove(z); // Remove xref from index 4
+ resource.getContents().remove(z);
+
+ // Must not fail:
+ transaction.commit();
+ }
+
+ public void testRemoveXRefByReplace() throws Exception
+ {
+ NodeA a = getModel3Factory().createNodeA();
+ NodeA b = getModel3Factory().createNodeA();
+ NodeA c = getModel3Factory().createNodeA();
+
+ NodeA x = getModel3Factory().createNodeA();
+ NodeA y = getModel3Factory().createNodeA();
+ NodeA z = getModel3Factory().createNodeA();
+
+ a.getOtherNodes().add(x);
+ a.getOtherNodes().add(y);
+ a.getOtherNodes().add(z);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ resource.getContents().add(a);
+ resource.getContents().add(b);
+ resource.getContents().add(c);
+ resource.getContents().add(x);
+ resource.getContents().add(y);
+ resource.getContents().add(z);
+ transaction.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ a.getOtherNodes().set(2, b); // Replace z with b
+ resource.getContents().remove(z);
+
+ // Must not fail:
+ transaction.commit();
+ }
+
+ public void testRemoveXRefByReplace_PrecedingAdd() throws Exception
+ {
+ NodeA a = getModel3Factory().createNodeA();
+ NodeA b = getModel3Factory().createNodeA();
+ NodeA c = getModel3Factory().createNodeA();
+
+ NodeA x = getModel3Factory().createNodeA();
+ NodeA y = getModel3Factory().createNodeA();
+ NodeA z = getModel3Factory().createNodeA();
+
+ a.getOtherNodes().add(x);
+ a.getOtherNodes().add(y);
+ a.getOtherNodes().add(z);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ resource.getContents().add(a);
+ resource.getContents().add(b);
+ resource.getContents().add(c);
+ resource.getContents().add(x);
+ resource.getContents().add(y);
+ resource.getContents().add(z);
+ transaction.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ a.getOtherNodes().add(0, b);
+ a.getOtherNodes().set(3, c); // Replace z with c
+ resource.getContents().remove(z);
+
+ // Must not fail:
+ transaction.commit();
+ }
+
+ public void testAddXRefByReplace() throws Exception
+ {
+ NodeA a = getModel3Factory().createNodeA();
+ NodeA b = getModel3Factory().createNodeA();
+ NodeA c = getModel3Factory().createNodeA();
+
+ NodeA x = getModel3Factory().createNodeA();
+ NodeA y = getModel3Factory().createNodeA();
+ NodeA z = getModel3Factory().createNodeA();
+
+ a.getOtherNodes().add(x);
+ a.getOtherNodes().add(y);
+ a.getOtherNodes().add(b);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ resource.getContents().add(a);
+ resource.getContents().add(b);
+ resource.getContents().add(c);
+ resource.getContents().add(x);
+ resource.getContents().add(y);
+ resource.getContents().add(z);
+ transaction.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ a.getOtherNodes().set(2, z); // Replace b with z
+ resource.getContents().remove(z);
+
+ try
+ {
+ transaction.commit();
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ public void testAddXRefByReplace_PrecedingAdd() throws Exception
+ {
+ NodeA a = getModel3Factory().createNodeA();
+ NodeA b = getModel3Factory().createNodeA();
+ NodeA c = getModel3Factory().createNodeA();
+
+ NodeA x = getModel3Factory().createNodeA();
+ NodeA y = getModel3Factory().createNodeA();
+ NodeA z = getModel3Factory().createNodeA();
+
+ a.getOtherNodes().add(x);
+ a.getOtherNodes().add(y);
+ a.getOtherNodes().add(b);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ resource.getContents().add(a);
+ resource.getContents().add(b);
+ resource.getContents().add(c);
+ resource.getContents().add(x);
+ resource.getContents().add(y);
+ resource.getContents().add(z);
+ transaction.commit();
+ dumpAllRevisions(getRepository().getStore());
+
+ a.getOtherNodes().add(0, c);
+ a.getOtherNodes().set(3, z); // Replace b with z
+ resource.getContents().remove(z);
+
+ try
+ {
+ transaction.commit();
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // SUCCESS
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323958_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323958_Test.java
index 910f1dc28c..9855275405 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323958_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_323958_Test.java
@@ -1,89 +1,89 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOCommitContext;
-import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_323958_Test extends AbstractCDOTest
-{
- public void testModificationFromTransactionHandler() throws Exception
- {
- {
- final Company company = getModel1Factory().createCompany();
- company.setName("X");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(new CDODefaultTransactionHandler()
- {
- @Override
- public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- company.setName("Y");
- }
- });
-
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
- resource.getContents().add(company);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test"));
-
- Company company = (Company)resource.getContents().get(0);
- assertEquals("Y", company.getName());
- }
-
- public void testAdditionFromTransactionHandler() throws Exception
- {
- {
- final Company company = getModel1Factory().createCompany();
- company.setName("X");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.addTransactionHandler(new CDODefaultTransactionHandler()
- {
- @Override
- public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- company.getCategories().add(getModel1Factory().createCategory());
- }
- });
-
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
- resource.getContents().add(company);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test"));
-
- Company company = (Company)resource.getContents().get(0);
- assertEquals(1, company.getCategories().size());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOCommitContext;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_323958_Test extends AbstractCDOTest
+{
+ public void testModificationFromTransactionHandler() throws Exception
+ {
+ {
+ final Company company = getModel1Factory().createCompany();
+ company.setName("X");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler()
+ {
+ @Override
+ public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ company.setName("Y");
+ }
+ });
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+ resource.getContents().add(company);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test"));
+
+ Company company = (Company)resource.getContents().get(0);
+ assertEquals("Y", company.getName());
+ }
+
+ public void testAdditionFromTransactionHandler() throws Exception
+ {
+ {
+ final Company company = getModel1Factory().createCompany();
+ company.setName("X");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler()
+ {
+ @Override
+ public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ company.getCategories().add(getModel1Factory().createCategory());
+ }
+ });
+
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+ resource.getContents().add(company);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test"));
+
+ Company company = (Company)resource.getContents().get(0);
+ assertEquals(1, company.getCategories().size());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324084_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324084_Test.java
index 74887fd09d..73bd6bf895 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324084_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324084_Test.java
@@ -1,119 +1,119 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContained;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-import java.util.Map;
-
-/**
- * CommitException with XRef on new objects after branch merge.
- * <p>
- * See bug 324084
- *
- * @author Pascal Lehmann
- */
-@CleanRepositoriesBefore
-public class Bugzilla_324084_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
- return map;
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testXRefMergeSingleValueTest() throws Exception
- {
- // setup transaction.
- final CDOSession session = openSession();
- final CDOTransaction tr1 = session.openTransaction();
- tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
- RefSingleContained container = getModel4Factory().createRefSingleContained();
- resource.getContents().add(container);
-
- tr1.commit();
- sleep(1000);
-
- final CDOBranch otherBranch = tr1.getBranch().createBranch("other");
- final CDOTransaction tr2 = session.openTransaction(otherBranch);
-
- RefSingleContained otherContainer = tr2.getObject(container);
- assertNotNull(otherContainer);
-
- // set a new element.
- otherContainer.setElement(getModel4Factory().createSingleContainedElement());
-
- tr2.commit();
-
- // sleep to have the merger see the changes.
- sleep(1000);
-
- // merge the other branch to main.
- tr1.merge(tr2.getBranch().getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
-
- tr1.commit();
- assertEquals(false, tr1.isDirty());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testXRefMergeManyValueTest() throws Exception
- {
- // setup transaction.
- final CDOSession session = openSession();
- final CDOTransaction tr1 = session.openTransaction();
- tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
- RefMultiContained container = getModel4Factory().createRefMultiContained();
- resource.getContents().add(container);
-
- tr1.commit();
- sleep(1000);
-
- final CDOBranch otherBranch = tr1.getBranch().createBranch("other");
- final CDOTransaction tr2 = session.openTransaction(otherBranch);
-
- RefMultiContained otherContainer = tr2.getObject(container);
- assertNotNull(otherContainer);
-
- // add a new element on other branch at index 0.
- otherContainer.getElements().add(0, getModel4Factory().createMultiContainedElement());
-
- tr2.commit();
-
- // sleep to have the merger see the changes.
- sleep(1000);
-
- // merge the other branch to main.
- tr1.merge(tr2.getBranch().getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
-
- tr1.commit();
- assertEquals(false, tr1.isDirty());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContained;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+import java.util.Map;
+
+/**
+ * CommitException with XRef on new objects after branch merge.
+ * <p>
+ * See bug 324084
+ *
+ * @author Pascal Lehmann
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_324084_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testXRefMergeSingleValueTest() throws Exception
+ {
+ // setup transaction.
+ final CDOSession session = openSession();
+ final CDOTransaction tr1 = session.openTransaction();
+ tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
+ RefSingleContained container = getModel4Factory().createRefSingleContained();
+ resource.getContents().add(container);
+
+ tr1.commit();
+ sleep(1000);
+
+ final CDOBranch otherBranch = tr1.getBranch().createBranch("other");
+ final CDOTransaction tr2 = session.openTransaction(otherBranch);
+
+ RefSingleContained otherContainer = tr2.getObject(container);
+ assertNotNull(otherContainer);
+
+ // set a new element.
+ otherContainer.setElement(getModel4Factory().createSingleContainedElement());
+
+ tr2.commit();
+
+ // sleep to have the merger see the changes.
+ sleep(1000);
+
+ // merge the other branch to main.
+ tr1.merge(tr2.getBranch().getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+
+ tr1.commit();
+ assertEquals(false, tr1.isDirty());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testXRefMergeManyValueTest() throws Exception
+ {
+ // setup transaction.
+ final CDOSession session = openSession();
+ final CDOTransaction tr1 = session.openTransaction();
+ tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
+ RefMultiContained container = getModel4Factory().createRefMultiContained();
+ resource.getContents().add(container);
+
+ tr1.commit();
+ sleep(1000);
+
+ final CDOBranch otherBranch = tr1.getBranch().createBranch("other");
+ final CDOTransaction tr2 = session.openTransaction(otherBranch);
+
+ RefMultiContained otherContainer = tr2.getObject(container);
+ assertNotNull(otherContainer);
+
+ // add a new element on other branch at index 0.
+ otherContainer.getElements().add(0, getModel4Factory().createMultiContainedElement());
+
+ tr2.commit();
+
+ // sleep to have the merger see the changes.
+ sleep(1000);
+
+ // merge the other branch to main.
+ tr1.merge(tr2.getBranch().getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+
+ tr1.commit();
+ assertEquals(false, tr1.isDirty());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324585_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324585_Test.java
index 33b2fba0f8..15ef446b54 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324585_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324585_Test.java
@@ -1,68 +1,68 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_324585_Test extends AbstractCDOTest
-{
- /**
- * To see the problem it may be necessary to limit the stack size with e.g. -Xss256k
- */
- public void testUpdate() throws CommitException
- {
- // user 1
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
- CDOResource resource1 = transaction1.createResource(getResourcePath("test"));
-
- Category category1 = getModel1Factory().createCategory();
- resource1.getContents().add(category1);
- resource1.getContents().add(category1);
- transaction1.commit();
-
- // user 2
- CDOSession session2 = openSession();
- session2.options().setPassiveUpdateEnabled(false);
- CDOTransaction transaction2 = session2.openTransaction();
- CDOResource resource2 = transaction2.getResource(getResourcePath("test"));
-
- EObject category2 = resource2.getContents().get(0);
- category2.eAdapters().add(new AdapterImpl());
-
- // user1
- EList<Product1> products = category1.getProducts();
- for (int i = 0; i < 10000; i++)
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Product" + i);
- products.add(product);
- }
-
- transaction1.commit();
-
- // user2
- session2.refresh();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_324585_Test extends AbstractCDOTest
+{
+ /**
+ * To see the problem it may be necessary to limit the stack size with e.g. -Xss256k
+ */
+ public void testUpdate() throws CommitException
+ {
+ // user 1
+ CDOSession session1 = openSession();
+ CDOTransaction transaction1 = session1.openTransaction();
+ CDOResource resource1 = transaction1.createResource(getResourcePath("test"));
+
+ Category category1 = getModel1Factory().createCategory();
+ resource1.getContents().add(category1);
+ resource1.getContents().add(category1);
+ transaction1.commit();
+
+ // user 2
+ CDOSession session2 = openSession();
+ session2.options().setPassiveUpdateEnabled(false);
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource resource2 = transaction2.getResource(getResourcePath("test"));
+
+ EObject category2 = resource2.getContents().get(0);
+ category2.eAdapters().add(new AdapterImpl());
+
+ // user1
+ EList<Product1> products = category1.getProducts();
+ for (int i = 0; i < 10000; i++)
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Product" + i);
+ products.add(product);
+ }
+
+ transaction1.commit();
+
+ // user2
+ session2.refresh();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324635_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324635_Test.java
index 3bb3e353c5..652a8494fa 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324635_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324635_Test.java
@@ -1,91 +1,91 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model4.MultiContainedElement;
-import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-/**
- * "Attempt to modify historical revision"-Exception after branch merge.
- * <p>
- * See bug 324635.
- *
- * @author Pascal Lehmann
- */
-public class Bugzilla_324635_Test extends AbstractCDOTest
-{
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testTargetGoalDeltaVersion() throws Exception
- {
- // setup 2 transactions.
- final CDOSession session1 = openSession();
- final CDOTransaction s1Tr1 = session1.openTransaction();
- s1Tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- final CDOTransaction s1Tr2 = session1.openTransaction();
- s1Tr2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- // create resource, container and 2 elements using transaction 1.
- final CDOResource resource = s1Tr1.createResource(getResourcePath("/test1"));
- RefMultiContained container = getModel4Factory().createRefMultiContained();
- resource.getContents().add(container);
- MultiContainedElement element1 = getModel4Factory().createMultiContainedElement();
- container.getElements().add(element1);
- MultiContainedElement element2 = getModel4Factory().createMultiContainedElement();
- container.getElements().add(element2);
-
- commitAndSync(s1Tr1, s1Tr2);
-
- // access container on transaction 2 to have it updated with a RevisionDelta.
- RefMultiContained container2 = s1Tr2.getObject(container);
-
- // setup another branch.
- final CDOBranch otherBranch = s1Tr1.getBranch().createBranch("other");
- final CDOTransaction s1Tr3 = session1.openTransaction(otherBranch);
-
- RefMultiContained otherContainer = s1Tr3.getObject(container);
- assertNotSame(null, otherContainer);
- assertEquals(true, otherContainer.getElements().size() > 0);
-
- // remove an element on the other branch.
- otherContainer.getElements().remove(0);
-
- commitAndSync(s1Tr3, s1Tr1);
-
- // merge the other branch to main (this creates the targetGoalDelta for the RevisionDelta).
- s1Tr1.merge(s1Tr3.getBranch().getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
-
- commitAndSync(s1Tr1, s1Tr2);
-
- // check the change on tr2 and do another change.
- assertEquals(false, s1Tr1.isDirty());
- container2.getElements().remove(0);
-
- commitAndSync(s1Tr2, s1Tr1); // <--- this commit will throw the following exception:
- // java.util.ConcurrentModificationException:
- // Attempt by Transaction[2:2] to modify historical revision: RefMultiContained@OID4:0v1
- assertEquals(false, s1Tr1.isDirty());
-
- // check revision versions.
- assertEquals(CDOUtil.getCDOObject(container).cdoRevision().getVersion(), CDOUtil.getCDOObject(container2)
- .cdoRevision().getVersion());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model4.MultiContainedElement;
+import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+/**
+ * "Attempt to modify historical revision"-Exception after branch merge.
+ * <p>
+ * See bug 324635.
+ *
+ * @author Pascal Lehmann
+ */
+public class Bugzilla_324635_Test extends AbstractCDOTest
+{
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testTargetGoalDeltaVersion() throws Exception
+ {
+ // setup 2 transactions.
+ final CDOSession session1 = openSession();
+ final CDOTransaction s1Tr1 = session1.openTransaction();
+ s1Tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+ final CDOTransaction s1Tr2 = session1.openTransaction();
+ s1Tr2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ // create resource, container and 2 elements using transaction 1.
+ final CDOResource resource = s1Tr1.createResource(getResourcePath("/test1"));
+ RefMultiContained container = getModel4Factory().createRefMultiContained();
+ resource.getContents().add(container);
+ MultiContainedElement element1 = getModel4Factory().createMultiContainedElement();
+ container.getElements().add(element1);
+ MultiContainedElement element2 = getModel4Factory().createMultiContainedElement();
+ container.getElements().add(element2);
+
+ commitAndSync(s1Tr1, s1Tr2);
+
+ // access container on transaction 2 to have it updated with a RevisionDelta.
+ RefMultiContained container2 = s1Tr2.getObject(container);
+
+ // setup another branch.
+ final CDOBranch otherBranch = s1Tr1.getBranch().createBranch("other");
+ final CDOTransaction s1Tr3 = session1.openTransaction(otherBranch);
+
+ RefMultiContained otherContainer = s1Tr3.getObject(container);
+ assertNotSame(null, otherContainer);
+ assertEquals(true, otherContainer.getElements().size() > 0);
+
+ // remove an element on the other branch.
+ otherContainer.getElements().remove(0);
+
+ commitAndSync(s1Tr3, s1Tr1);
+
+ // merge the other branch to main (this creates the targetGoalDelta for the RevisionDelta).
+ s1Tr1.merge(s1Tr3.getBranch().getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+
+ commitAndSync(s1Tr1, s1Tr2);
+
+ // check the change on tr2 and do another change.
+ assertEquals(false, s1Tr1.isDirty());
+ container2.getElements().remove(0);
+
+ commitAndSync(s1Tr2, s1Tr1); // <--- this commit will throw the following exception:
+ // java.util.ConcurrentModificationException:
+ // Attempt by Transaction[2:2] to modify historical revision: RefMultiContained@OID4:0v1
+ assertEquals(false, s1Tr1.isDirty());
+
+ // check revision versions.
+ assertEquals(CDOUtil.getCDOObject(container).cdoRevision().getVersion(), CDOUtil.getCDOObject(container2)
+ .cdoRevision().getVersion());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324756_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324756_Test.java
index fdbd2ac7ce..f917abfa3f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324756_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_324756_Test.java
@@ -1,138 +1,138 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.MultiContainedElement;
-import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-/**
- * NPE in TransactionCommitContext with re-attached object on branch.
- * <p>
- * See bug 324756
- *
- * @author Pascal Lehmann
- */
-public class Bugzilla_324756_Test extends AbstractCDOTest
-{
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testReattachBranchVersion() throws Exception
- {
- // setup transaction.
- final CDOSession session1 = openSession();
- final CDOTransaction s1Tr1 = session1.openTransaction();
- s1Tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- // create resource, container using transaction 1.
- final CDOResource resource = s1Tr1.createResource(getResourcePath("/test1"));
- RefMultiContained container = getModel4Factory().createRefMultiContained();
- resource.getContents().add(container);
-
- s1Tr1.commit();
-
- // do a couple of changes to have the version increase.
- MultiContainedElement element1 = getModel4Factory().createMultiContainedElement();
- container.getElements().add(element1);
-
- s1Tr1.commit();
-
- container.getElements().remove(0);
-
- s1Tr1.commit();
-
- // setup another branch.
- final CDOBranch otherBranch = s1Tr1.getBranch().createBranch("other");
- final CDOTransaction s1Tr3 = session1.openTransaction(otherBranch);
-
- CDOResource branchResource = s1Tr3.getObject(resource);
- assertNotSame(null, branchResource);
-
- // detach container on branch.
- RefMultiContained otherContainer = (RefMultiContained)branchResource.getContents().remove(0);
- assertNotSame(null, otherContainer);
-
- // re-attach container.
-
- branchResource.getContents().add(otherContainer);
-
- s1Tr3.commit(); // <--- This will store the revision with the wrong version.
-
- // do a change to create a RevisionDelta with wrong version.
- MultiContainedElement element2 = getModel4Factory().createMultiContainedElement();
- otherContainer.getElements().add(element2);
-
- s1Tr3.commit(); // <--- This will throw the exception:
- // java.lang.NullPointerException at
- // org.eclipse.emf.cdo.internal.server.TransactionCommitContext.isContainerLocked(TransactionCommitContext.java:712)
-
- assertEquals(false, s1Tr3.isDirty());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- public void testReattachBranchVersion2() throws Exception
- {
- // setup transaction.
- final CDOSession session1 = openSession();
- final CDOTransaction s1Tr1 = session1.openTransaction();
- s1Tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- // create resource, element using transaction 1.
- final CDOResource resource = s1Tr1.createResource(getResourcePath("/test1"));
- ContainedElementNoOpposite element = getModel4Factory().createContainedElementNoOpposite();
- element.setName("Version1");
- resource.getContents().add(element);
-
- s1Tr1.commit();
-
- // do a couple of changes to have the version increase.
- element.setName("Version2");
-
- s1Tr1.commit();
-
- element.setName("Version3");
-
- s1Tr1.commit();
-
- // setup another branch.
- final CDOBranch otherBranch = s1Tr1.getBranch().createBranch("other");
- final CDOTransaction s1Tr3 = session1.openTransaction(otherBranch);
-
- CDOResource branchResource = s1Tr3.getObject(resource);
- assertNotSame(null, branchResource);
-
- // detach container on branch.
- ContainedElementNoOpposite otherElement = (ContainedElementNoOpposite)branchResource.getContents().remove(0);
- assertNotSame(null, otherElement);
-
- // re-attach container.
-
- branchResource.getContents().add(otherElement);
-
- s1Tr3.commit(); // <--- This will store the revision with the wrong version.
-
- // do a change to create a RevisionDelta with wrong version.
- otherElement.setName("BranchVersion2");
-
- s1Tr3.commit(); // <--- This will throw the exception:
- // java.lang.IllegalStateException: Origin revision not found for
- // CDORevisionDelta[ContainedElementNoOpposite@OID2:1v4 --> [CDOFeatureDelta[name, SET, value=BranchVersion2]]]
-
- assertEquals(false, s1Tr3.isDirty());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.MultiContainedElement;
+import org.eclipse.emf.cdo.tests.model4.RefMultiContained;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+/**
+ * NPE in TransactionCommitContext with re-attached object on branch.
+ * <p>
+ * See bug 324756
+ *
+ * @author Pascal Lehmann
+ */
+public class Bugzilla_324756_Test extends AbstractCDOTest
+{
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testReattachBranchVersion() throws Exception
+ {
+ // setup transaction.
+ final CDOSession session1 = openSession();
+ final CDOTransaction s1Tr1 = session1.openTransaction();
+ s1Tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ // create resource, container using transaction 1.
+ final CDOResource resource = s1Tr1.createResource(getResourcePath("/test1"));
+ RefMultiContained container = getModel4Factory().createRefMultiContained();
+ resource.getContents().add(container);
+
+ s1Tr1.commit();
+
+ // do a couple of changes to have the version increase.
+ MultiContainedElement element1 = getModel4Factory().createMultiContainedElement();
+ container.getElements().add(element1);
+
+ s1Tr1.commit();
+
+ container.getElements().remove(0);
+
+ s1Tr1.commit();
+
+ // setup another branch.
+ final CDOBranch otherBranch = s1Tr1.getBranch().createBranch("other");
+ final CDOTransaction s1Tr3 = session1.openTransaction(otherBranch);
+
+ CDOResource branchResource = s1Tr3.getObject(resource);
+ assertNotSame(null, branchResource);
+
+ // detach container on branch.
+ RefMultiContained otherContainer = (RefMultiContained)branchResource.getContents().remove(0);
+ assertNotSame(null, otherContainer);
+
+ // re-attach container.
+
+ branchResource.getContents().add(otherContainer);
+
+ s1Tr3.commit(); // <--- This will store the revision with the wrong version.
+
+ // do a change to create a RevisionDelta with wrong version.
+ MultiContainedElement element2 = getModel4Factory().createMultiContainedElement();
+ otherContainer.getElements().add(element2);
+
+ s1Tr3.commit(); // <--- This will throw the exception:
+ // java.lang.NullPointerException at
+ // org.eclipse.emf.cdo.internal.server.TransactionCommitContext.isContainerLocked(TransactionCommitContext.java:712)
+
+ assertEquals(false, s1Tr3.isDirty());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testReattachBranchVersion2() throws Exception
+ {
+ // setup transaction.
+ final CDOSession session1 = openSession();
+ final CDOTransaction s1Tr1 = session1.openTransaction();
+ s1Tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ // create resource, element using transaction 1.
+ final CDOResource resource = s1Tr1.createResource(getResourcePath("/test1"));
+ ContainedElementNoOpposite element = getModel4Factory().createContainedElementNoOpposite();
+ element.setName("Version1");
+ resource.getContents().add(element);
+
+ s1Tr1.commit();
+
+ // do a couple of changes to have the version increase.
+ element.setName("Version2");
+
+ s1Tr1.commit();
+
+ element.setName("Version3");
+
+ s1Tr1.commit();
+
+ // setup another branch.
+ final CDOBranch otherBranch = s1Tr1.getBranch().createBranch("other");
+ final CDOTransaction s1Tr3 = session1.openTransaction(otherBranch);
+
+ CDOResource branchResource = s1Tr3.getObject(resource);
+ assertNotSame(null, branchResource);
+
+ // detach container on branch.
+ ContainedElementNoOpposite otherElement = (ContainedElementNoOpposite)branchResource.getContents().remove(0);
+ assertNotSame(null, otherElement);
+
+ // re-attach container.
+
+ branchResource.getContents().add(otherElement);
+
+ s1Tr3.commit(); // <--- This will store the revision with the wrong version.
+
+ // do a change to create a RevisionDelta with wrong version.
+ otherElement.setName("BranchVersion2");
+
+ s1Tr3.commit(); // <--- This will throw the exception:
+ // java.lang.IllegalStateException: Origin revision not found for
+ // CDORevisionDelta[ContainedElementNoOpposite@OID2:1v4 --> [CDOFeatureDelta[name, SET, value=BranchVersion2]]]
+
+ assertEquals(false, s1Tr3.isDirty());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325603_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325603_Test.java
index 7c34450bdc..d37202601d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325603_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325603_Test.java
@@ -1,49 +1,49 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_325603_Test extends AbstractCDOTest
-{
- public void testModifyResource() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/r1"));
-
- resource.eAdapters().add(new AdapterImpl()
- {
- @Override
- public void notifyChanged(Notification notification)
- {
- if (notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED)
- {
- assertInstanceOf(Boolean.class, notification.getOldValue());
- notification.getOldBooleanValue();
- // passed if we do not get an exception here
- }
- }
- });
-
- resource.setModified(true);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_325603_Test extends AbstractCDOTest
+{
+ public void testModifyResource() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/r1"));
+
+ resource.eAdapters().add(new AdapterImpl()
+ {
+ @Override
+ public void notifyChanged(Notification notification)
+ {
+ if (notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED)
+ {
+ assertInstanceOf(Boolean.class, notification.getOldValue());
+ notification.getOldBooleanValue();
+ // passed if we do not get an exception here
+ }
+ }
+ });
+
+ resource.setModified(true);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325866_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325866_Test.java
index 9082b1a498..84c3dd588e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325866_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325866_Test.java
@@ -1,99 +1,99 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model4.GenRefMultiContained;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-import java.util.Map;
-
-/**
- * IllegalStateException when committing a reattached containment of a detached container after branch merge with XRef
- * enabled.
- * <p>
- * See bug 325866
- *
- * @author Pascal Lehmann
- */
-public class Bugzilla_325866_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
- return map;
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- @CleanRepositoriesBefore
- public void testXRefReattachBranch() throws Exception
- {
- // setup transaction.
- final CDOSession session1 = openSession();
- final CDOTransaction s1Tr1 = session1.openTransaction();
- s1Tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- // create resource, and container tree using transaction 1.
- final CDOResource resource = s1Tr1.createResource(getResourcePath("/test1"));
- GenRefMultiContained container1 = getModel4Factory().createGenRefMultiContained();
- GenRefMultiContained container2 = getModel4Factory().createGenRefMultiContained();
- GenRefMultiContained container3 = getModel4Factory().createGenRefMultiContained();
- resource.getContents().add(container1);
- container1.getElements().add(container2);
- container2.getElements().add(container3);
-
- s1Tr1.commit();
- sleep(1000L);
-
- // setup another branch.
- final CDOBranch otherBranch = s1Tr1.getBranch().createBranch("other");
- final CDOTransaction s1Tr3 = session1.openTransaction(otherBranch);
-
- CDOResource branchResource = s1Tr3.getObject(resource);
- assertNotSame(null, branchResource);
-
- GenRefMultiContained otherContainer1 = (GenRefMultiContained)branchResource.getContents().get(0);
- assertNotSame(null, otherContainer1);
-
- GenRefMultiContained otherContainer2 = (GenRefMultiContained)otherContainer1.getElements().get(0);
- assertNotSame(null, otherContainer2);
-
- GenRefMultiContained otherContainer3 = (GenRefMultiContained)otherContainer2.getElements().get(0);
- assertNotSame(null, otherContainer3);
-
- // detach the middle container on branch.
- otherContainer1.getElements().remove(otherContainer2);
-
- // re-attach detached's child container.
- otherContainer1.getElements().add(otherContainer3);
-
- s1Tr3.commit();
- assertEquals(false, s1Tr3.isDirty());
-
- // merge the other branch to main.
- sleep(1000L);
- s1Tr1.merge(s1Tr3.getBranch().getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
-
- s1Tr1.commit();
- assertEquals(false, s1Tr1.isDirty());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model4.GenRefMultiContained;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+import java.util.Map;
+
+/**
+ * IllegalStateException when committing a reattached containment of a detached container after branch merge with XRef
+ * enabled.
+ * <p>
+ * See bug 325866
+ *
+ * @author Pascal Lehmann
+ */
+public class Bugzilla_325866_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ @CleanRepositoriesBefore
+ public void testXRefReattachBranch() throws Exception
+ {
+ // setup transaction.
+ final CDOSession session1 = openSession();
+ final CDOTransaction s1Tr1 = session1.openTransaction();
+ s1Tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ // create resource, and container tree using transaction 1.
+ final CDOResource resource = s1Tr1.createResource(getResourcePath("/test1"));
+ GenRefMultiContained container1 = getModel4Factory().createGenRefMultiContained();
+ GenRefMultiContained container2 = getModel4Factory().createGenRefMultiContained();
+ GenRefMultiContained container3 = getModel4Factory().createGenRefMultiContained();
+ resource.getContents().add(container1);
+ container1.getElements().add(container2);
+ container2.getElements().add(container3);
+
+ s1Tr1.commit();
+ sleep(1000L);
+
+ // setup another branch.
+ final CDOBranch otherBranch = s1Tr1.getBranch().createBranch("other");
+ final CDOTransaction s1Tr3 = session1.openTransaction(otherBranch);
+
+ CDOResource branchResource = s1Tr3.getObject(resource);
+ assertNotSame(null, branchResource);
+
+ GenRefMultiContained otherContainer1 = (GenRefMultiContained)branchResource.getContents().get(0);
+ assertNotSame(null, otherContainer1);
+
+ GenRefMultiContained otherContainer2 = (GenRefMultiContained)otherContainer1.getElements().get(0);
+ assertNotSame(null, otherContainer2);
+
+ GenRefMultiContained otherContainer3 = (GenRefMultiContained)otherContainer2.getElements().get(0);
+ assertNotSame(null, otherContainer3);
+
+ // detach the middle container on branch.
+ otherContainer1.getElements().remove(otherContainer2);
+
+ // re-attach detached's child container.
+ otherContainer1.getElements().add(otherContainer3);
+
+ s1Tr3.commit();
+ assertEquals(false, s1Tr3.isDirty());
+
+ // merge the other branch to main.
+ sleep(1000L);
+ s1Tr1.merge(s1Tr3.getBranch().getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+
+ s1Tr1.commit();
+ assertEquals(false, s1Tr1.isDirty());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326518_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326518_Test.java
index eccfee88fd..cc22b75522 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326518_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326518_Test.java
@@ -1,143 +1,143 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.GenRefMultiContained;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-import java.util.Map;
-
-/**
- * List index problem during merge can cause a StaleReference in database even with XRef checking enabled.
- * <p>
- * See bug 326518
- *
- * @author Pascal Lehmann
- */
-public class Bugzilla_326518_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
- return map;
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- @CleanRepositoriesBefore
- public void testIndexBranchMerge() throws Exception
- {
- // setup transaction.
- final CDOSession session = openSession();
- final CDOTransaction transaction1 = session.openTransaction();
- transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- // create resource, and container using transaction 1.
- final CDOResource resource = transaction1.createResource(getResourcePath("/test1"));
- GenRefMultiContained container = getModel4Factory().createGenRefMultiContained();
- resource.getContents().add(container);
- ContainedElementNoOpposite element1 = getModel4Factory().createContainedElementNoOpposite();
- ContainedElementNoOpposite element2 = getModel4Factory().createContainedElementNoOpposite();
- container.getElements().add(element1);
- container.getElements().add(element2);
-
- transaction1.commit();
- sleep(1000L);
-
- // setup another branch.
- final CDOBranch branch2 = transaction1.getBranch().createBranch("branch2");
- final CDOTransaction transaction2 = session.openTransaction(branch2);
-
- CDOResource branchResource = transaction2.getObject(resource);
- assertNotSame(null, branchResource);
- GenRefMultiContained otherContainer = (GenRefMultiContained)branchResource.getContents().get(0);
- assertNotSame(null, otherContainer);
-
- // detach the first element on branch.
- otherContainer.getElements().remove(0);
- // add a new element on branch at index0.
- otherContainer.getElements().add(0, getModel4Factory().createContainedElementNoOpposite());
-
- transaction2.commit();
- assertEquals(false, transaction2.isDirty());
-
- // detach the second element on main.
- container.getElements().remove(1);
- // add a new element on main at index0.
- container.getElements().add(0, getModel4Factory().createContainedElementNoOpposite());
-
- transaction1.commit();
- assertEquals(false, transaction1.isDirty());
-
- // merge the other branch to main.
- sleep(1000L);
- CDOChangeSetData changes = transaction1.merge(transaction2.getBranch().getHead(),
- new DefaultCDOMerger.PerFeature.ManyValued());
-
- printChangeSetData(changes);
-
- try
- {
- transaction1.commit();
- }
- catch (CommitException expected)
- {
- fail("No CommitException expected");
- }
-
- // access the container's elements.
- for (Object object : container.getElements()) // <-- will cause an ObjectNotFoundException.
- {
- System.out.println(object);
- }
- }
-
- public static void printChangeSetData(CDOChangeSetData changes)
- {
- StringBuilder sb = new StringBuilder();
- sb.append("## ChangeSet:\n");
- sb.append(" * New objects: ").append(changes.getNewObjects().size()).append("\n");
- for (CDOIDAndVersion idVersion : changes.getNewObjects())
- {
- sb.append(" - ").append(idVersion).append("\n");
- }
-
- sb.append(" * Changed objects: ").append(changes.getChangedObjects().size()).append("\n");
- for (CDORevisionKey revKey : changes.getChangedObjects())
- {
- sb.append(" - ").append(revKey).append("\n");
- }
-
- sb.append(" * Detached objects: ").append(changes.getNewObjects().size()).append("\n");
- for (CDOIDAndVersion idVersion : changes.getNewObjects())
- {
- sb.append(" - ").append(idVersion).append("\n");
- }
-
- System.out.println(sb);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.GenRefMultiContained;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+import java.util.Map;
+
+/**
+ * List index problem during merge can cause a StaleReference in database even with XRef checking enabled.
+ * <p>
+ * See bug 326518
+ *
+ * @author Pascal Lehmann
+ */
+public class Bugzilla_326518_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ @CleanRepositoriesBefore
+ public void testIndexBranchMerge() throws Exception
+ {
+ // setup transaction.
+ final CDOSession session = openSession();
+ final CDOTransaction transaction1 = session.openTransaction();
+ transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ // create resource, and container using transaction 1.
+ final CDOResource resource = transaction1.createResource(getResourcePath("/test1"));
+ GenRefMultiContained container = getModel4Factory().createGenRefMultiContained();
+ resource.getContents().add(container);
+ ContainedElementNoOpposite element1 = getModel4Factory().createContainedElementNoOpposite();
+ ContainedElementNoOpposite element2 = getModel4Factory().createContainedElementNoOpposite();
+ container.getElements().add(element1);
+ container.getElements().add(element2);
+
+ transaction1.commit();
+ sleep(1000L);
+
+ // setup another branch.
+ final CDOBranch branch2 = transaction1.getBranch().createBranch("branch2");
+ final CDOTransaction transaction2 = session.openTransaction(branch2);
+
+ CDOResource branchResource = transaction2.getObject(resource);
+ assertNotSame(null, branchResource);
+ GenRefMultiContained otherContainer = (GenRefMultiContained)branchResource.getContents().get(0);
+ assertNotSame(null, otherContainer);
+
+ // detach the first element on branch.
+ otherContainer.getElements().remove(0);
+ // add a new element on branch at index0.
+ otherContainer.getElements().add(0, getModel4Factory().createContainedElementNoOpposite());
+
+ transaction2.commit();
+ assertEquals(false, transaction2.isDirty());
+
+ // detach the second element on main.
+ container.getElements().remove(1);
+ // add a new element on main at index0.
+ container.getElements().add(0, getModel4Factory().createContainedElementNoOpposite());
+
+ transaction1.commit();
+ assertEquals(false, transaction1.isDirty());
+
+ // merge the other branch to main.
+ sleep(1000L);
+ CDOChangeSetData changes = transaction1.merge(transaction2.getBranch().getHead(),
+ new DefaultCDOMerger.PerFeature.ManyValued());
+
+ printChangeSetData(changes);
+
+ try
+ {
+ transaction1.commit();
+ }
+ catch (CommitException expected)
+ {
+ fail("No CommitException expected");
+ }
+
+ // access the container's elements.
+ for (Object object : container.getElements()) // <-- will cause an ObjectNotFoundException.
+ {
+ System.out.println(object);
+ }
+ }
+
+ public static void printChangeSetData(CDOChangeSetData changes)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("## ChangeSet:\n");
+ sb.append(" * New objects: ").append(changes.getNewObjects().size()).append("\n");
+ for (CDOIDAndVersion idVersion : changes.getNewObjects())
+ {
+ sb.append(" - ").append(idVersion).append("\n");
+ }
+
+ sb.append(" * Changed objects: ").append(changes.getChangedObjects().size()).append("\n");
+ for (CDORevisionKey revKey : changes.getChangedObjects())
+ {
+ sb.append(" - ").append(revKey).append("\n");
+ }
+
+ sb.append(" * Detached objects: ").append(changes.getNewObjects().size()).append("\n");
+ for (CDOIDAndVersion idVersion : changes.getNewObjects())
+ {
+ sb.append(" - ").append(idVersion).append("\n");
+ }
+
+ System.out.println(sb);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326743_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326743_Test.java
index 2b8f2c125f..f8b83de08a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326743_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326743_Test.java
@@ -1,99 +1,99 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * @author Stefan Winkler
- */
-public class Bugzilla_326743_Test extends AbstractCDOTest
-{
- private EPackage pkg;
-
- private EClass cls;
-
- private EAttribute att;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- pkg = EMFUtil.createEPackage("customTest", "ct", "http://cdo.emf.eclipse.org/customTest.ecore");
-
- EDataType customPrimitive = EcoreFactory.eINSTANCE.createEDataType();
- customPrimitive.setInstanceTypeName("boolean");
- customPrimitive.setName("CustomPrimitiveType");
-
- // added type annotation for teneo test case
- final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
- eAnnotation.setSource("teneo.jpa");
- final String typeAnnotation = "@Type(type=\"org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOCustomTypeUserType\")";
- eAnnotation.getDetails().put("value", typeAnnotation);
- customPrimitive.getEAnnotations().add(eAnnotation);
-
- pkg.getEClassifiers().add(customPrimitive);
-
- cls = EMFUtil.createEClass(pkg, "Foobar", false, false);
- att = EMFUtil.createEAttribute(cls, "attPrimitive", customPrimitive);
-
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- public void testDefaultValue() throws CommitException
- {
- EObject obj = EcoreUtil.create(cls);
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test"));
- res.getContents().add(obj);
- tx.commit();
- tx.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView v = session.openView();
- CDOResource res = v.getResource(getResourcePath("/test"));
- EObject persistent = res.getContents().get(0);
-
- boolean pCustom = (Boolean)persistent.eGet(att);
- assertEquals(false, pCustom);
-
- v.close();
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_326743_Test extends AbstractCDOTest
+{
+ private EPackage pkg;
+
+ private EClass cls;
+
+ private EAttribute att;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ pkg = EMFUtil.createEPackage("customTest", "ct", "http://cdo.emf.eclipse.org/customTest.ecore");
+
+ EDataType customPrimitive = EcoreFactory.eINSTANCE.createEDataType();
+ customPrimitive.setInstanceTypeName("boolean");
+ customPrimitive.setName("CustomPrimitiveType");
+
+ // added type annotation for teneo test case
+ final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ eAnnotation.setSource("teneo.jpa");
+ final String typeAnnotation = "@Type(type=\"org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOCustomTypeUserType\")";
+ eAnnotation.getDetails().put("value", typeAnnotation);
+ customPrimitive.getEAnnotations().add(eAnnotation);
+
+ pkg.getEClassifiers().add(customPrimitive);
+
+ cls = EMFUtil.createEClass(pkg, "Foobar", false, false);
+ att = EMFUtil.createEAttribute(cls, "attPrimitive", customPrimitive);
+
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ public void testDefaultValue() throws CommitException
+ {
+ EObject obj = EcoreUtil.create(cls);
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test"));
+ res.getContents().add(obj);
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView v = session.openView();
+ CDOResource res = v.getResource(getResourcePath("/test"));
+ EObject persistent = res.getContents().get(0);
+
+ boolean pCustom = (Boolean)persistent.eGet(att);
+ assertEquals(false, pCustom);
+
+ v.close();
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java
index 1685d50887..d115d3faf3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java
@@ -1,300 +1,300 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.mem.MEMStoreUtil;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
-import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.tests.util.TestSessionConfiguration;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.emf.cdo.workspace.CDOWorkspace;
-import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase;
-import org.eclipse.emf.cdo.workspace.CDOWorkspaceConfiguration;
-import org.eclipse.emf.cdo.workspace.CDOWorkspaceUtil;
-
-import org.eclipse.net4j.jvm.JVMUtil;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * See bug 327604.
- *
- * @author Martin Fluegge
- */
-@Requires(IRepositoryConfig.CAPABILITY_AUDITING)
-public class Bugzilla_327604_Test extends AbstractCDOTest
-{
- private static final String RESOURCE = "/test1";
-
- private static final int PRODUCTS = 1;
-
- private static final int CUSTOMERS = 1;
-
- private static final int SALES_ORDERS_PER_CUSTOMER = 1;
-
- private static final int SALES_ORDERS = CUSTOMERS * SALES_ORDERS_PER_CUSTOMER;
-
- private static final int ORDER_DETAILS = SALES_ORDERS * PRODUCTS;
-
- private List<CDOWorkspace> workspaces = new ArrayList<CDOWorkspace>();
-
- private CDOTransaction transaction;
-
- private List<Product1> products;
-
- private List<Customer> customers;
-
- private List<SalesOrder> salesOrders;
-
- private List<OrderDetail> orderDetails;
-
- private int totalObjects;
-
- private IStore localStore;
-
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> map = super.getTestProperties();
- map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "false");
- return map;
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- disableConsole();
- super.doSetUp();
- skipTest(!getRepository().getStore().getObjectIDTypes().equals(MEMStore.OBJECT_ID_TYPES));
-
- CDOSession session = openSession();
- transaction = session.openTransaction();
-
- products = new ArrayList<Product1>();
- customers = new ArrayList<Customer>();
- orderDetails = new ArrayList<OrderDetail>();
- salesOrders = new ArrayList<SalesOrder>();
-
- createTestSet(transaction);
- assertEquals(PRODUCTS, products.size());
- assertEquals(CUSTOMERS, customers.size());
- assertEquals(SALES_ORDERS, salesOrders.size());
- assertEquals(ORDER_DETAILS, orderDetails.size());
-
- JVMUtil.prepareContainer(getClientContainer());
- localStore = createLocalStore();
-
- CDOUtil.setLegacyModeDefault(true);
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- disableConsole();
- CDOUtil.setLegacyModeDefault(false);
- for (CDOWorkspace workspace : workspaces)
- {
- IOUtil.closeSilent(workspace);
- }
-
- workspaces.clear();
- super.doTearDown();
- }
-
- @CleanRepositoriesBefore
- public void testReadObjects() throws Exception
- {
- skipStoreWithoutHandleRevisions();
-
- InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
-
- CDOView view = workspace.openView();
- CDOResource resource = view.getResource(getResourcePath(RESOURCE));
- assertEquals(totalObjects, dumpObjects(null, resource));
- }
-
- protected IStore createLocalStore()
- {
- return MEMStoreUtil.createMEMStore();
- }
-
- protected InternalCDOWorkspace checkout(String branchPath, long timeStamp)
- {
- disableConsole();
- CDOSessionConfigurationFactory remote = new RemoteSessionConfigurationFactory();
-
- File folder = createTempFolder("cdo-");
- CDOWorkspaceBase base = CDOWorkspaceUtil.createFolderWorkspaceBase(folder);
- IOUtil.ERR().println("CDOWorkspaceBaseline: " + folder.getAbsolutePath());
-
- CDOWorkspaceConfiguration config = CDOWorkspaceUtil.createWorkspaceConfiguration();
- config.setStore(localStore);
- config.setBase(base);
- config.setRemote(remote);
- config.setBranchPath(branchPath);
- config.setTimeStamp(timeStamp);
- config.setIDGenerationLocation(getRepository().getIDGenerationLocation());
-
- InternalCDOWorkspace workspace = (InternalCDOWorkspace)config.checkout();
- workspaces.add(workspace);
-
- InternalRepository localRepository = workspace.getLocalRepository();
- registerRepository(localRepository);
- LifecycleUtil.activate(localRepository);
-
- return workspace;
- }
-
- private int dumpObjects(String prefix, EObject object)
- {
- System.out.println("Object: " + object);
- if (prefix != null)
- {
- IOUtil.OUT().println(prefix + object);
- }
-
- int sum = 1;
- for (EObject content : object.eContents())
- {
- sum += dumpObjects(prefix != null ? prefix + " " : null, content);
- }
-
- return sum;
- }
-
- private CDOResource createTestSet(CDOTransaction transaction) throws CommitException
- {
- disableConsole();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE));
- fillResource(resource);
-
- totalObjects = 1;
- for (Iterator<EObject> it = resource.eAllContents(); it.hasNext();)
- {
- it.next();
- ++totalObjects;
- }
-
- transaction.commit();
- enableConsole();
- return resource;
- }
-
- private void fillResource(CDOResource resource)
- {
- for (int i = 0; i < PRODUCTS; i++)
- {
- Product1 product = createProduct(i);
- products.add(product);
- resource.getContents().add(product);
- }
-
- int id = 100;
- for (int i = 0; i < CUSTOMERS; i++)
- {
- Customer customer = createCustomer(i);
- customers.add(customer);
- resource.getContents().add(customer);
-
- for (int k = 0; k < SALES_ORDERS_PER_CUSTOMER; k++)
- {
- SalesOrder salesOrder = createSalesOrder(id++, customer);
- salesOrders.add(salesOrder);
- resource.getContents().add(salesOrder);
-
- for (Product1 product : products)
- {
- OrderDetail orderDetail = createOrderDetail(product, 55.123f);
- orderDetails.add(orderDetail);
- salesOrder.getOrderDetails().add(orderDetail);
- }
- }
- }
- }
-
- private Product1 createProduct(int index)
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Product No" + index);
- product.setDescription("Description " + index);
- product.setVat(VAT.VAT15);
- return product;
- }
-
- private Customer createCustomer(int i)
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setCity("City " + i);
- customer.setName("" + i);
- customer.setStreet("Street " + i);
- return customer;
- }
-
- private SalesOrder createSalesOrder(int id, Customer customer)
- {
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(id);
- salesOrder.setCustomer(customer);
- return salesOrder;
- }
-
- private OrderDetail createOrderDetail(Product1 product, float price)
- {
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setPrice(price);
- orderDetail.setProduct(product);
- return orderDetail;
- }
-
- /**
- * @author Eike Stepper
- */
- private final class RemoteSessionConfigurationFactory implements CDOSessionConfigurationFactory
- {
- public CDOSessionConfiguration createSessionConfiguration()
- {
- return new TestSessionConfiguration()
- {
- public CDOSession openSession()
- {
- return Bugzilla_327604_Test.this.openSession();
- }
- };
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.mem.MEMStoreUtil;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
+import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.tests.util.TestSessionConfiguration;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.workspace.CDOWorkspace;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceConfiguration;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceUtil;
+
+import org.eclipse.net4j.jvm.JVMUtil;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * See bug 327604.
+ *
+ * @author Martin Fluegge
+ */
+@Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+public class Bugzilla_327604_Test extends AbstractCDOTest
+{
+ private static final String RESOURCE = "/test1";
+
+ private static final int PRODUCTS = 1;
+
+ private static final int CUSTOMERS = 1;
+
+ private static final int SALES_ORDERS_PER_CUSTOMER = 1;
+
+ private static final int SALES_ORDERS = CUSTOMERS * SALES_ORDERS_PER_CUSTOMER;
+
+ private static final int ORDER_DETAILS = SALES_ORDERS * PRODUCTS;
+
+ private List<CDOWorkspace> workspaces = new ArrayList<CDOWorkspace>();
+
+ private CDOTransaction transaction;
+
+ private List<Product1> products;
+
+ private List<Customer> customers;
+
+ private List<SalesOrder> salesOrders;
+
+ private List<OrderDetail> orderDetails;
+
+ private int totalObjects;
+
+ private IStore localStore;
+
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "false");
+ return map;
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ disableConsole();
+ super.doSetUp();
+ skipTest(!getRepository().getStore().getObjectIDTypes().equals(MEMStore.OBJECT_ID_TYPES));
+
+ CDOSession session = openSession();
+ transaction = session.openTransaction();
+
+ products = new ArrayList<Product1>();
+ customers = new ArrayList<Customer>();
+ orderDetails = new ArrayList<OrderDetail>();
+ salesOrders = new ArrayList<SalesOrder>();
+
+ createTestSet(transaction);
+ assertEquals(PRODUCTS, products.size());
+ assertEquals(CUSTOMERS, customers.size());
+ assertEquals(SALES_ORDERS, salesOrders.size());
+ assertEquals(ORDER_DETAILS, orderDetails.size());
+
+ JVMUtil.prepareContainer(getClientContainer());
+ localStore = createLocalStore();
+
+ CDOUtil.setLegacyModeDefault(true);
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ disableConsole();
+ CDOUtil.setLegacyModeDefault(false);
+ for (CDOWorkspace workspace : workspaces)
+ {
+ IOUtil.closeSilent(workspace);
+ }
+
+ workspaces.clear();
+ super.doTearDown();
+ }
+
+ @CleanRepositoriesBefore
+ public void testReadObjects() throws Exception
+ {
+ skipStoreWithoutHandleRevisions();
+
+ InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
+
+ CDOView view = workspace.openView();
+ CDOResource resource = view.getResource(getResourcePath(RESOURCE));
+ assertEquals(totalObjects, dumpObjects(null, resource));
+ }
+
+ protected IStore createLocalStore()
+ {
+ return MEMStoreUtil.createMEMStore();
+ }
+
+ protected InternalCDOWorkspace checkout(String branchPath, long timeStamp)
+ {
+ disableConsole();
+ CDOSessionConfigurationFactory remote = new RemoteSessionConfigurationFactory();
+
+ File folder = createTempFolder("cdo-");
+ CDOWorkspaceBase base = CDOWorkspaceUtil.createFolderWorkspaceBase(folder);
+ IOUtil.ERR().println("CDOWorkspaceBaseline: " + folder.getAbsolutePath());
+
+ CDOWorkspaceConfiguration config = CDOWorkspaceUtil.createWorkspaceConfiguration();
+ config.setStore(localStore);
+ config.setBase(base);
+ config.setRemote(remote);
+ config.setBranchPath(branchPath);
+ config.setTimeStamp(timeStamp);
+ config.setIDGenerationLocation(getRepository().getIDGenerationLocation());
+
+ InternalCDOWorkspace workspace = (InternalCDOWorkspace)config.checkout();
+ workspaces.add(workspace);
+
+ InternalRepository localRepository = workspace.getLocalRepository();
+ registerRepository(localRepository);
+ LifecycleUtil.activate(localRepository);
+
+ return workspace;
+ }
+
+ private int dumpObjects(String prefix, EObject object)
+ {
+ System.out.println("Object: " + object);
+ if (prefix != null)
+ {
+ IOUtil.OUT().println(prefix + object);
+ }
+
+ int sum = 1;
+ for (EObject content : object.eContents())
+ {
+ sum += dumpObjects(prefix != null ? prefix + " " : null, content);
+ }
+
+ return sum;
+ }
+
+ private CDOResource createTestSet(CDOTransaction transaction) throws CommitException
+ {
+ disableConsole();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE));
+ fillResource(resource);
+
+ totalObjects = 1;
+ for (Iterator<EObject> it = resource.eAllContents(); it.hasNext();)
+ {
+ it.next();
+ ++totalObjects;
+ }
+
+ transaction.commit();
+ enableConsole();
+ return resource;
+ }
+
+ private void fillResource(CDOResource resource)
+ {
+ for (int i = 0; i < PRODUCTS; i++)
+ {
+ Product1 product = createProduct(i);
+ products.add(product);
+ resource.getContents().add(product);
+ }
+
+ int id = 100;
+ for (int i = 0; i < CUSTOMERS; i++)
+ {
+ Customer customer = createCustomer(i);
+ customers.add(customer);
+ resource.getContents().add(customer);
+
+ for (int k = 0; k < SALES_ORDERS_PER_CUSTOMER; k++)
+ {
+ SalesOrder salesOrder = createSalesOrder(id++, customer);
+ salesOrders.add(salesOrder);
+ resource.getContents().add(salesOrder);
+
+ for (Product1 product : products)
+ {
+ OrderDetail orderDetail = createOrderDetail(product, 55.123f);
+ orderDetails.add(orderDetail);
+ salesOrder.getOrderDetails().add(orderDetail);
+ }
+ }
+ }
+ }
+
+ private Product1 createProduct(int index)
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Product No" + index);
+ product.setDescription("Description " + index);
+ product.setVat(VAT.VAT15);
+ return product;
+ }
+
+ private Customer createCustomer(int i)
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setCity("City " + i);
+ customer.setName("" + i);
+ customer.setStreet("Street " + i);
+ return customer;
+ }
+
+ private SalesOrder createSalesOrder(int id, Customer customer)
+ {
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(id);
+ salesOrder.setCustomer(customer);
+ return salesOrder;
+ }
+
+ private OrderDetail createOrderDetail(Product1 product, float price)
+ {
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setPrice(price);
+ orderDetail.setProduct(product);
+ return orderDetail;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class RemoteSessionConfigurationFactory implements CDOSessionConfigurationFactory
+ {
+ public CDOSessionConfiguration createSessionConfiguration()
+ {
+ return new TestSessionConfiguration()
+ {
+ public CDOSession openSession()
+ {
+ return Bugzilla_327604_Test.this.openSession();
+ }
+ };
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_328790_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_328790_Test.java
index 8068badc19..1bbb809496 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_328790_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_328790_Test.java
@@ -1,88 +1,88 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-
-/**
- * Bug 328790 - CDOResource.isLoaded returns false after adding/clearing contents of new resource
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_328790_Test extends AbstractCDOTest
-{
- public void test_newThenAdd1() throws CommitException
- {
- CDOSession session = openSession();
- ResourceSet resourceSet = new ResourceSetImpl();
- CDOTransaction tx = session.openTransaction(resourceSet);
-
- Resource resource = resourceSet.createResource(URI.createURI("cdo://myUri"));
- EObject object = getModel1Factory().createAddress();
- resource.getContents().add(object);
-
- assertEquals(true, resource.isLoaded());
-
- tx.commit();
-
- assertEquals(true, resource.isLoaded());
-
- tx.close();
- session.close();
- }
-
- public void test_newThenAdd2() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
-
- CDOResource resource = tx.createResource(getResourcePath("/myUri"));
- EObject object = getModel1Factory().createAddress();
- resource.getContents().add(object);
-
- assertEquals(true, resource.isLoaded());
-
- tx.commit();
-
- assertEquals(true, resource.isLoaded());
-
- tx.close();
- session.close();
- }
-
- public void test_newThenClear() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
-
- CDOResource resource = tx.createResource(getResourcePath("/myUri"));
- resource.getContents().clear();
-
- assertEquals(true, resource.isLoaded());
-
- tx.commit();
-
- assertEquals(true, resource.isLoaded());
-
- tx.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+/**
+ * Bug 328790 - CDOResource.isLoaded returns false after adding/clearing contents of new resource
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_328790_Test extends AbstractCDOTest
+{
+ public void test_newThenAdd1() throws CommitException
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction tx = session.openTransaction(resourceSet);
+
+ Resource resource = resourceSet.createResource(URI.createURI("cdo://myUri"));
+ EObject object = getModel1Factory().createAddress();
+ resource.getContents().add(object);
+
+ assertEquals(true, resource.isLoaded());
+
+ tx.commit();
+
+ assertEquals(true, resource.isLoaded());
+
+ tx.close();
+ session.close();
+ }
+
+ public void test_newThenAdd2() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+
+ CDOResource resource = tx.createResource(getResourcePath("/myUri"));
+ EObject object = getModel1Factory().createAddress();
+ resource.getContents().add(object);
+
+ assertEquals(true, resource.isLoaded());
+
+ tx.commit();
+
+ assertEquals(true, resource.isLoaded());
+
+ tx.close();
+ session.close();
+ }
+
+ public void test_newThenClear() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+
+ CDOResource resource = tx.createResource(getResourcePath("/myUri"));
+ resource.getContents().clear();
+
+ assertEquals(true, resource.isLoaded());
+
+ tx.commit();
+
+ assertEquals(true, resource.isLoaded());
+
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329254_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329254_Test.java
index ed639819b1..4d931a1dce 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329254_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329254_Test.java
@@ -1,399 +1,399 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.server.Repository;
-import org.eclipse.emf.cdo.internal.server.TransactionCommitContext;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalTransaction;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * LastCommitTimeStamp updated even when a serverSide Error occurred.
- * <p>
- * See bug 329254.
- *
- * @author Pascal Lehmann
- * @since 4.0
- */
-public class Bugzilla_329254_Test extends AbstractCDOTest
-{
- private static final String REPOSITORY_NAME = "repo1";
-
- private boolean modelInitialized;
-
- private CountDownLatch enterLatch = new CountDownLatch(1);
-
- private CountDownLatch leaveLatch = new CountDownLatch(1);
-
- private int sessionId2;
-
- @Override
- protected void doSetUp() throws Exception
- {
- modelInitialized = false;
- createRepository();
- super.doSetUp();
- }
-
- private void createRepository()
- {
- Repository repository = new Repository.Default()
- {
- @Override
- public InternalCommitContext createCommitContext(InternalTransaction transaction)
- {
- return new TransactionCommitContext(transaction)
- {
- @Override
- protected void adjustForCommit()
- {
- // ignore all calls before model has been initialized.
- if (modelInitialized)
- {
- IOUtil.OUT().println("AdjustForCommit entered: " + this);
- if (getTransaction().getSession().getSessionID() == sessionId2)
- {
- // grant the other session access to enter and
- // block until it has left again.
- enterLatch.countDown();
- try
- {
- leaveLatch.await();
- }
- catch (InterruptedException ex)
- {
- ex.printStackTrace();
- }
- }
-
- super.adjustForCommit();
- IOUtil.OUT().println("AdjustForCommit left: " + this);
- }
- else
- {
- super.adjustForCommit();
- }
- }
- };
- }
- };
-
- Map<String, String> props = getRepositoryProperties();
- ((InternalRepository)repository).setProperties(props);
-
- repository.setName(REPOSITORY_NAME);
-
- Map<String, Object> map = getTestProperties();
- map.put(RepositoryConfig.PROP_TEST_REPOSITORY, repository);
- }
-
- public void testCommitTimeStampUpdateOnError() throws Exception
- {
- disableConsole();
-
- CDOSession session1 = openSession(REPOSITORY_NAME);
- CDOSession session2 = openSession(REPOSITORY_NAME);
-
- session1.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
- session2.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
-
- sessionId2 = session2.getSessionID();
-
- CDOTransaction transaction10 = session1.openTransaction();
- final CDOTransaction transaction11async = session1.openTransaction();
- final CDOTransaction transaction21async = session2.openTransaction();
- CDOTransaction transaction12 = session1.openTransaction();
- CDOTransaction transaction22 = session2.openTransaction();
-
- // Create initial model.
- CDOResource resource = transaction10.createResource(getResourcePath("/test"));
- final Company company10 = getModel1Factory().createCompany();
- company10.setName("company");
- resource.getContents().add(company10);
- commitAndSync(transaction10, transaction11async, transaction21async);
-
- Thread thread11 = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- // Do concurrent changes on company to produce an error.
- Company company11 = transaction11async.getObject(company10);
- company11.setCity("city");
- transaction11async.commit();
- }
- catch (Exception ex)
- {
- IOUtil.OUT().println("Simulated problem in thread 11: " + ex.getClass().getName());
- }
- }
- };
-
- Thread thread21 = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- // Do concurrent changes on company to produce an error.
- Company company21 = transaction21async.getObject(company10);
- company21.setStreet("street");
- transaction21async.commit();
- }
- catch (Exception ex)
- {
- IOUtil.OUT().println("Simulated problem in thread 21: " + ex.getClass().getName());
- }
- }
- };
-
- thread11.start();
- thread21.start();
-
- thread11.join();
- thread21.join();
-
- transaction22.waitForUpdate(transaction11async.getLastCommitTime(), DEFAULT_TIMEOUT);
- transaction22.waitForUpdate(transaction21async.getLastCommitTime(), DEFAULT_TIMEOUT);
-
- // Do another commit.
- Company company4 = transaction22.getObject(company10);
- company4.setName("company2");
- commitAndSync(transaction22, transaction10, transaction12);
-
- // Check if update arrived.
- assertEquals(company4.getName(), company10.getName());
-
- // Check committing on the other session too.
- Company company5 = transaction12.getObject(company10);
- company5.setName("company3");
- commitAndSync(transaction12, transaction22);
-
- // Check if update arrived.
- assertEquals(company5.getName(), company4.getName());
- }
-
- @CleanRepositoriesBefore
- public void testCommitTimeStampUpdateLongRunningCommitSameType() throws Exception
- {
- disableConsole();
-
- CDOSession session1 = openSession(REPOSITORY_NAME);
- CDOSession session2 = openSession(REPOSITORY_NAME);
- session1.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
- sessionId2 = session2.getSessionID();
-
- CDOTransaction transaction1 = session1.openTransaction();
- final CDOTransaction transaction2 = session2.openTransaction();
- final CDOTransaction transaction3 = session1.openTransaction();
-
- // create initial model.
- CDOResource resource = transaction1.createResource(getResourcePath("/test"));
- Company company1a = getModel1Factory().createCompany();
- company1a.setName("companyA");
- resource.getContents().add(company1a);
- Company company1b = getModel1Factory().createCompany();
- company1b.setName("companyB");
- resource.getContents().add(company1b);
- commitAndSync(transaction1, transaction2, transaction3);
-
- modelInitialized = true;
-
- // do concurrent changes on different objects, same type.
- Company company2a = transaction2.getObject(company1a);
- company2a.setName("companyA2");
-
- Company company3b = transaction3.getObject(company1b);
- company3b.setName("companyB2");
-
- Thread commitThread1 = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- try
- {
- // wait until session 2 has entered write.
- enterLatch.await();
- }
- catch (InterruptedException ex)
- {
- ex.printStackTrace();
- }
-
- transaction3.commit();
- }
- catch (CommitException ex)
- {
- ex.printStackTrace();
- }
- finally
- {
- // let session 2 continue.
- leaveLatch.countDown();
- }
- }
- };
-
- Thread commitThread2 = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- transaction2.commit();
- }
- catch (CommitException ex)
- {
- ex.printStackTrace();
- }
- }
- };
-
- commitThread1.start();
- commitThread2.start();
-
- commitThread1.join();
- commitThread2.join();
-
- transaction1.waitForUpdate(transaction3.getLastCommitTime(), DEFAULT_TIMEOUT);
- transaction1.waitForUpdate(transaction2.getLastCommitTime(), DEFAULT_TIMEOUT);
-
- // do another commit.
- CDOTransaction transaction4 = session2.openTransaction();
- Company company4a = transaction4.getObject(company1a);
- company4a.setName("companyA3");
- commitAndSync(transaction4, transaction1);
-
- // check if update arrived.
- assertEquals(company4a.getName(), company1a.getName());
- }
-
- @CleanRepositoriesBefore
- public void testCommitTimeStampUpdateLongRunningCommitDifferentType() throws Exception
- {
- disableConsole();
-
- CDOSession session1 = openSession(REPOSITORY_NAME);
- CDOSession session2 = openSession(REPOSITORY_NAME);
- session1.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
- sessionId2 = session2.getSessionID();
-
- CDOTransaction transaction1 = session1.openTransaction();
- final CDOTransaction transaction2 = session2.openTransaction();
- final CDOTransaction transaction3 = session1.openTransaction();
-
- // create initial model.
- CDOResource resource = transaction1.createResource(getResourcePath("/test"));
- Company company1 = getModel1Factory().createCompany();
- company1.setName("company1");
- resource.getContents().add(company1);
- Category cat1 = getModel1Factory().createCategory();
- cat1.setName("category1");
- company1.getCategories().add(cat1);
- commitAndSync(transaction1, transaction2, transaction3);
-
- modelInitialized = true;
-
- // do concurrent changes on different objects, different type.
- Company company2 = transaction2.getObject(company1);
- company2.setName("company2");
-
- Category cat3 = transaction3.getObject(cat1);
- cat3.setName("category3");
-
- Thread commitThread1 = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- try
- {
- // wait until session 2 has entered write.
- enterLatch.await();
- }
- catch (InterruptedException ex)
- {
- ex.printStackTrace();
- }
-
- transaction3.commit();
- }
- catch (CommitException ex)
- {
- ex.printStackTrace();
- }
- finally
- {
- // let session 2 continue.
- leaveLatch.countDown();
- }
- }
- };
-
- Thread commitThread2 = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- transaction2.commit();
- }
- catch (CommitException ex)
- {
- ex.printStackTrace();
- }
- }
- };
-
- commitThread1.start();
- commitThread2.start();
-
- commitThread1.join();
- commitThread2.join();
-
- transaction1.waitForUpdate(transaction3.getLastCommitTime(), DEFAULT_TIMEOUT);
- transaction1.waitForUpdate(transaction2.getLastCommitTime(), DEFAULT_TIMEOUT);
-
- // do another commit.
- CDOTransaction transaction4 = session2.openTransaction();
- Company company4 = transaction4.getObject(company1);
- company4.setName("company3");
- commitAndSync(transaction4, transaction1);
-
- // check if update arrived.
- assertEquals(company4.getName(), company1.getName());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.server.Repository;
+import org.eclipse.emf.cdo.internal.server.TransactionCommitContext;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalTransaction;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * LastCommitTimeStamp updated even when a serverSide Error occurred.
+ * <p>
+ * See bug 329254.
+ *
+ * @author Pascal Lehmann
+ * @since 4.0
+ */
+public class Bugzilla_329254_Test extends AbstractCDOTest
+{
+ private static final String REPOSITORY_NAME = "repo1";
+
+ private boolean modelInitialized;
+
+ private CountDownLatch enterLatch = new CountDownLatch(1);
+
+ private CountDownLatch leaveLatch = new CountDownLatch(1);
+
+ private int sessionId2;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ modelInitialized = false;
+ createRepository();
+ super.doSetUp();
+ }
+
+ private void createRepository()
+ {
+ Repository repository = new Repository.Default()
+ {
+ @Override
+ public InternalCommitContext createCommitContext(InternalTransaction transaction)
+ {
+ return new TransactionCommitContext(transaction)
+ {
+ @Override
+ protected void adjustForCommit()
+ {
+ // ignore all calls before model has been initialized.
+ if (modelInitialized)
+ {
+ IOUtil.OUT().println("AdjustForCommit entered: " + this);
+ if (getTransaction().getSession().getSessionID() == sessionId2)
+ {
+ // grant the other session access to enter and
+ // block until it has left again.
+ enterLatch.countDown();
+ try
+ {
+ leaveLatch.await();
+ }
+ catch (InterruptedException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ super.adjustForCommit();
+ IOUtil.OUT().println("AdjustForCommit left: " + this);
+ }
+ else
+ {
+ super.adjustForCommit();
+ }
+ }
+ };
+ }
+ };
+
+ Map<String, String> props = getRepositoryProperties();
+ ((InternalRepository)repository).setProperties(props);
+
+ repository.setName(REPOSITORY_NAME);
+
+ Map<String, Object> map = getTestProperties();
+ map.put(RepositoryConfig.PROP_TEST_REPOSITORY, repository);
+ }
+
+ public void testCommitTimeStampUpdateOnError() throws Exception
+ {
+ disableConsole();
+
+ CDOSession session1 = openSession(REPOSITORY_NAME);
+ CDOSession session2 = openSession(REPOSITORY_NAME);
+
+ session1.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+ session2.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+
+ sessionId2 = session2.getSessionID();
+
+ CDOTransaction transaction10 = session1.openTransaction();
+ final CDOTransaction transaction11async = session1.openTransaction();
+ final CDOTransaction transaction21async = session2.openTransaction();
+ CDOTransaction transaction12 = session1.openTransaction();
+ CDOTransaction transaction22 = session2.openTransaction();
+
+ // Create initial model.
+ CDOResource resource = transaction10.createResource(getResourcePath("/test"));
+ final Company company10 = getModel1Factory().createCompany();
+ company10.setName("company");
+ resource.getContents().add(company10);
+ commitAndSync(transaction10, transaction11async, transaction21async);
+
+ Thread thread11 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ // Do concurrent changes on company to produce an error.
+ Company company11 = transaction11async.getObject(company10);
+ company11.setCity("city");
+ transaction11async.commit();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.OUT().println("Simulated problem in thread 11: " + ex.getClass().getName());
+ }
+ }
+ };
+
+ Thread thread21 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ // Do concurrent changes on company to produce an error.
+ Company company21 = transaction21async.getObject(company10);
+ company21.setStreet("street");
+ transaction21async.commit();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.OUT().println("Simulated problem in thread 21: " + ex.getClass().getName());
+ }
+ }
+ };
+
+ thread11.start();
+ thread21.start();
+
+ thread11.join();
+ thread21.join();
+
+ transaction22.waitForUpdate(transaction11async.getLastCommitTime(), DEFAULT_TIMEOUT);
+ transaction22.waitForUpdate(transaction21async.getLastCommitTime(), DEFAULT_TIMEOUT);
+
+ // Do another commit.
+ Company company4 = transaction22.getObject(company10);
+ company4.setName("company2");
+ commitAndSync(transaction22, transaction10, transaction12);
+
+ // Check if update arrived.
+ assertEquals(company4.getName(), company10.getName());
+
+ // Check committing on the other session too.
+ Company company5 = transaction12.getObject(company10);
+ company5.setName("company3");
+ commitAndSync(transaction12, transaction22);
+
+ // Check if update arrived.
+ assertEquals(company5.getName(), company4.getName());
+ }
+
+ @CleanRepositoriesBefore
+ public void testCommitTimeStampUpdateLongRunningCommitSameType() throws Exception
+ {
+ disableConsole();
+
+ CDOSession session1 = openSession(REPOSITORY_NAME);
+ CDOSession session2 = openSession(REPOSITORY_NAME);
+ session1.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+ sessionId2 = session2.getSessionID();
+
+ CDOTransaction transaction1 = session1.openTransaction();
+ final CDOTransaction transaction2 = session2.openTransaction();
+ final CDOTransaction transaction3 = session1.openTransaction();
+
+ // create initial model.
+ CDOResource resource = transaction1.createResource(getResourcePath("/test"));
+ Company company1a = getModel1Factory().createCompany();
+ company1a.setName("companyA");
+ resource.getContents().add(company1a);
+ Company company1b = getModel1Factory().createCompany();
+ company1b.setName("companyB");
+ resource.getContents().add(company1b);
+ commitAndSync(transaction1, transaction2, transaction3);
+
+ modelInitialized = true;
+
+ // do concurrent changes on different objects, same type.
+ Company company2a = transaction2.getObject(company1a);
+ company2a.setName("companyA2");
+
+ Company company3b = transaction3.getObject(company1b);
+ company3b.setName("companyB2");
+
+ Thread commitThread1 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ try
+ {
+ // wait until session 2 has entered write.
+ enterLatch.await();
+ }
+ catch (InterruptedException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ transaction3.commit();
+ }
+ catch (CommitException ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ // let session 2 continue.
+ leaveLatch.countDown();
+ }
+ }
+ };
+
+ Thread commitThread2 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ transaction2.commit();
+ }
+ catch (CommitException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ };
+
+ commitThread1.start();
+ commitThread2.start();
+
+ commitThread1.join();
+ commitThread2.join();
+
+ transaction1.waitForUpdate(transaction3.getLastCommitTime(), DEFAULT_TIMEOUT);
+ transaction1.waitForUpdate(transaction2.getLastCommitTime(), DEFAULT_TIMEOUT);
+
+ // do another commit.
+ CDOTransaction transaction4 = session2.openTransaction();
+ Company company4a = transaction4.getObject(company1a);
+ company4a.setName("companyA3");
+ commitAndSync(transaction4, transaction1);
+
+ // check if update arrived.
+ assertEquals(company4a.getName(), company1a.getName());
+ }
+
+ @CleanRepositoriesBefore
+ public void testCommitTimeStampUpdateLongRunningCommitDifferentType() throws Exception
+ {
+ disableConsole();
+
+ CDOSession session1 = openSession(REPOSITORY_NAME);
+ CDOSession session2 = openSession(REPOSITORY_NAME);
+ session1.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+ sessionId2 = session2.getSessionID();
+
+ CDOTransaction transaction1 = session1.openTransaction();
+ final CDOTransaction transaction2 = session2.openTransaction();
+ final CDOTransaction transaction3 = session1.openTransaction();
+
+ // create initial model.
+ CDOResource resource = transaction1.createResource(getResourcePath("/test"));
+ Company company1 = getModel1Factory().createCompany();
+ company1.setName("company1");
+ resource.getContents().add(company1);
+ Category cat1 = getModel1Factory().createCategory();
+ cat1.setName("category1");
+ company1.getCategories().add(cat1);
+ commitAndSync(transaction1, transaction2, transaction3);
+
+ modelInitialized = true;
+
+ // do concurrent changes on different objects, different type.
+ Company company2 = transaction2.getObject(company1);
+ company2.setName("company2");
+
+ Category cat3 = transaction3.getObject(cat1);
+ cat3.setName("category3");
+
+ Thread commitThread1 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ try
+ {
+ // wait until session 2 has entered write.
+ enterLatch.await();
+ }
+ catch (InterruptedException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ transaction3.commit();
+ }
+ catch (CommitException ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ // let session 2 continue.
+ leaveLatch.countDown();
+ }
+ }
+ };
+
+ Thread commitThread2 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ transaction2.commit();
+ }
+ catch (CommitException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ };
+
+ commitThread1.start();
+ commitThread2.start();
+
+ commitThread1.join();
+ commitThread2.join();
+
+ transaction1.waitForUpdate(transaction3.getLastCommitTime(), DEFAULT_TIMEOUT);
+ transaction1.waitForUpdate(transaction2.getLastCommitTime(), DEFAULT_TIMEOUT);
+
+ // do another commit.
+ CDOTransaction transaction4 = session2.openTransaction();
+ Company company4 = transaction4.getObject(company1);
+ company4.setName("company3");
+ commitAndSync(transaction4, transaction1);
+
+ // check if update arrived.
+ assertEquals(company4.getName(), company1.getName());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329752_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329752_Test.java
index b9e12f4293..9473391e52 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329752_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329752_Test.java
@@ -1,60 +1,60 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.tests.model2.EnumListHolder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_329752_Test extends AbstractCDOTest
-{
- public void testLoadContainedBeforeContainer() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- EnumListHolder enumListHolder = getModel2Factory().createEnumListHolder();
- EList<VAT> enumList = enumListHolder.getEnumList();
- enumList.add(VAT.VAT0);
- enumList.add(VAT.VAT15);
-
- String path = "/test";
- Resource resource = transaction.createResource(getResourcePath(path));
- resource.getContents().add(enumListHolder);
-
- transaction.commit();
-
- CDOTransaction transaction2 = session.openTransaction();
- CDOResource resource2 = transaction2.getResource(getResourcePath(path));
-
- EnumListHolder enumListHolder2 = (EnumListHolder)resource2.getContents().get(0);
-
- EList<VAT> enumList2 = enumListHolder2.getEnumList();
- assertEquals(2, enumList2.size());
- assertEquals(VAT.VAT0, enumList2.get(0));
- assertEquals(VAT.VAT15, enumList2.get(1));
-
- enumList2.add(VAT.VAT7);
- assertEquals(3, enumList2.size());
- transaction2.rollback();
-
- assertEquals(2, enumList2.size());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.tests.model2.EnumListHolder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_329752_Test extends AbstractCDOTest
+{
+ public void testLoadContainedBeforeContainer() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ EnumListHolder enumListHolder = getModel2Factory().createEnumListHolder();
+ EList<VAT> enumList = enumListHolder.getEnumList();
+ enumList.add(VAT.VAT0);
+ enumList.add(VAT.VAT15);
+
+ String path = "/test";
+ Resource resource = transaction.createResource(getResourcePath(path));
+ resource.getContents().add(enumListHolder);
+
+ transaction.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ CDOResource resource2 = transaction2.getResource(getResourcePath(path));
+
+ EnumListHolder enumListHolder2 = (EnumListHolder)resource2.getContents().get(0);
+
+ EList<VAT> enumList2 = enumListHolder2.getEnumList();
+ assertEquals(2, enumList2.size());
+ assertEquals(VAT.VAT0, enumList2.get(0));
+ assertEquals(VAT.VAT15, enumList2.get(1));
+
+ enumList2.add(VAT.VAT7);
+ assertEquals(3, enumList2.size());
+ transaction2.rollback();
+
+ assertEquals(2, enumList2.size());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329753_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329753_Test.java
index 89286aae6b..4a3afaa225 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329753_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329753_Test.java
@@ -1,61 +1,61 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_329753_Test extends AbstractCDOTest
-{
- @Requires(IModelConfig.CAPABILITY_LEGACY)
- public void testIncreasingVersion() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
-
- Product1 product1 = getModel1Factory().createProduct1();
- orderDetail.setProduct(product1);
-
- String path = "/test";
- Resource resource = transaction.createResource(getResourcePath(path));
- resource.getContents().add(orderDetail);
- resource.getContents().add(product1);
-
- transaction.commit();
-
- CDOObject cdoObject = CDOUtil.getCDOObject(orderDetail);
- CDORevision cdoRevision1 = cdoObject.cdoRevision();
-
- int version1 = cdoRevision1.getVersion();
-
- orderDetail.setProduct(product1);
-
- transaction.commit();
-
- CDORevision cdoRevision2 = cdoObject.cdoRevision();
- int version2 = cdoRevision2.getVersion();
- assertEquals(version1, version2);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_329753_Test extends AbstractCDOTest
+{
+ @Requires(IModelConfig.CAPABILITY_LEGACY)
+ public void testIncreasingVersion() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+
+ Product1 product1 = getModel1Factory().createProduct1();
+ orderDetail.setProduct(product1);
+
+ String path = "/test";
+ Resource resource = transaction.createResource(getResourcePath(path));
+ resource.getContents().add(orderDetail);
+ resource.getContents().add(product1);
+
+ transaction.commit();
+
+ CDOObject cdoObject = CDOUtil.getCDOObject(orderDetail);
+ CDORevision cdoRevision1 = cdoObject.cdoRevision();
+
+ int version1 = cdoRevision1.getVersion();
+
+ orderDetail.setProduct(product1);
+
+ transaction.commit();
+
+ CDORevision cdoRevision2 = cdoObject.cdoRevision();
+ int version2 = cdoRevision2.getVersion();
+ assertEquals(version1, version2);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329869_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329869_Test.java
index 2439bf021b..7593b68a9d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329869_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_329869_Test.java
@@ -1,57 +1,57 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.MultiNonContainedUnsettableElement;
-import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedUnsettable;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_329869_Test extends AbstractCDOTest
-{
- public void testDuplicateID() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- Resource resource = transaction.createResource(getResourcePath("/test"));
-
- RefMultiNonContainedUnsettable parent = getModel4Factory().createRefMultiNonContainedUnsettable();
- MultiNonContainedUnsettableElement child = getModel4Factory().createMultiNonContainedUnsettableElement();
-
- parent.getElements().add(child);
-
- resource.getContents().add(parent);
- resource.getContents().add(child);
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction2 = session.openTransaction();
- Resource resource2 = transaction2.getResource(getResourcePath("/test"));
-
- RefMultiNonContainedUnsettable parent = (RefMultiNonContainedUnsettable)resource2.getContents().get(0);
- MultiNonContainedUnsettableElement element = getModel4Factory().createMultiNonContainedUnsettableElement();
- element.setParent(parent);
- resource2.getContents().add(element);
- transaction2.commit();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.MultiNonContainedUnsettableElement;
+import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedUnsettable;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_329869_Test extends AbstractCDOTest
+{
+ public void testDuplicateID() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ Resource resource = transaction.createResource(getResourcePath("/test"));
+
+ RefMultiNonContainedUnsettable parent = getModel4Factory().createRefMultiNonContainedUnsettable();
+ MultiNonContainedUnsettableElement child = getModel4Factory().createMultiNonContainedUnsettableElement();
+
+ parent.getElements().add(child);
+
+ resource.getContents().add(parent);
+ resource.getContents().add(child);
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction2 = session.openTransaction();
+ Resource resource2 = transaction2.getResource(getResourcePath("/test"));
+
+ RefMultiNonContainedUnsettable parent = (RefMultiNonContainedUnsettable)resource2.getContents().get(0);
+ MultiNonContainedUnsettableElement element = getModel4Factory().createMultiNonContainedUnsettableElement();
+ element.setParent(parent);
+ resource2.getContents().add(element);
+ transaction2.commit();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java
index 7a7834bf82..9b1e621112 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java
@@ -1,80 +1,80 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Egidijus Vaisnora - initial API and implementation
- * Caspar De Groot - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Address;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-/**
- * Bug 330052 - Breakage related to sticky views
- *
- * @author Egidijus Vaisnora, Caspar De Groot
- */
-public class Bugzilla_330052_Test extends AbstractCDOTest
-{
- /**
- * Tests whether another view in the same session can retrieve the newly committed object
- */
- public void test_otherView() throws CommitException
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- CDOTransaction tx = session.openTransaction();
- CDOView view = session.openView();
-
- CDOResource resource = tx.createResource(getResourcePath("test"));
- Address address = getModel1Factory().createAddress();
- resource.getContents().add(address);
- tx.commit();
-
- CDOObject object = view.getObject(CDOUtil.getCDOObject(address).cdoID());
- assertNotNull(object);
- session.close();
- }
-
- /**
- * Tests whether an audit view in the same session fetches the correct historical version
- */
- @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
- public void test_auditView() throws CommitException
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("test"));
- Address address = getModel1Factory().createAddress();
- final String testName1 = "name1";
- address.setName(testName1);
- resource.getContents().add(address);
- long commitTime = transaction.commit().getTimeStamp();
-
- final String testName2 = "name2";
- address.setName(testName2);
- transaction.commit();
-
- CDOView view = session.openView(commitTime);
- Address historicalAddress = (Address)CDOUtil.getEObject(view.getObject(CDOUtil.getCDOObject(address).cdoID()));
-
- assertEquals(testName1, historicalAddress.getName());
-
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Egidijus Vaisnora - initial API and implementation
+ * Caspar De Groot - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Address;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * Bug 330052 - Breakage related to sticky views
+ *
+ * @author Egidijus Vaisnora, Caspar De Groot
+ */
+public class Bugzilla_330052_Test extends AbstractCDOTest
+{
+ /**
+ * Tests whether another view in the same session can retrieve the newly committed object
+ */
+ public void test_otherView() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction tx = session.openTransaction();
+ CDOView view = session.openView();
+
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+ Address address = getModel1Factory().createAddress();
+ resource.getContents().add(address);
+ tx.commit();
+
+ CDOObject object = view.getObject(CDOUtil.getCDOObject(address).cdoID());
+ assertNotNull(object);
+ session.close();
+ }
+
+ /**
+ * Tests whether an audit view in the same session fetches the correct historical version
+ */
+ @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
+ public void test_auditView() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+ Address address = getModel1Factory().createAddress();
+ final String testName1 = "name1";
+ address.setName(testName1);
+ resource.getContents().add(address);
+ long commitTime = transaction.commit().getTimeStamp();
+
+ final String testName2 = "name2";
+ address.setName(testName2);
+ transaction.commit();
+
+ CDOView view = session.openView(commitTime);
+ Address historicalAddress = (Address)CDOUtil.getEObject(view.getObject(CDOUtil.getCDOObject(address).cdoID()));
+
+ assertEquals(testName1, historicalAddress.getName());
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_331619_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_331619_Test.java
index b63953068a..9b948dd83c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_331619_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_331619_Test.java
@@ -1,140 +1,140 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObjectReference;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author Stefan Winkler
- */
-public class Bugzilla_331619_Test extends AbstractCDOTest
-{
- @SuppressWarnings("unchecked")
- public void testAbstractXRef() throws CommitException
- {
- skipStoreWithoutQueryXRefs();
-
- // set up model
- EPackage pkg = EMFUtil.createEPackage("test", "test", "http://www.eclipse.org/CDO/Tests/331619.ecore");
- EClass ref = EMFUtil.createEClass(pkg, "referencee", false, false);
- EAttribute refName = EMFUtil.createEAttribute(ref, "refname", EcorePackage.eINSTANCE.getEString());
-
- EClass abs = EMFUtil.createEClass(pkg, "abstractClass", true, false);
- EReference reference = EMFUtil.createEReference(abs, "reference", ref, false, true);
- reference.setContainment(false);
-
- EClass con = EMFUtil.createEClass(pkg, "concreteClass", false, false);
- con.getESuperTypes().add(abs);
- EAttribute conName = EMFUtil.createEAttribute(con, "conname", EcorePackage.eINSTANCE.getEString());
-
- CDOUtil.prepareDynamicEPackage(pkg);
-
- // write model
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource refres = tx.createResource(getResourcePath("/test/referenced"));
- CDOResource conres = tx.createResource(getResourcePath("/test/concrete"));
-
- EObject[] oRef = new EObject[6];
- for (int i = 0; i < 6; i++)
- {
- oRef[i] = EcoreUtil.create(ref);
- oRef[i].eSet(refName, "ref" + i);
- refres.getContents().add(oRef[i]);
- }
-
- EObject con1 = EcoreUtil.create(con);
- con1.eSet(conName, "con1");
- ((EList<EObject>)con1.eGet(reference)).add(oRef[1]);
- ((EList<EObject>)con1.eGet(reference)).add(oRef[5]);
- conres.getContents().add(con1);
-
- EObject con2 = EcoreUtil.create(con);
- con2.eSet(conName, "con2");
- ((EList<EObject>)con2.eGet(reference)).add(oRef[4]);
- ((EList<EObject>)con2.eGet(reference)).add(oRef[1]);
- conres.getContents().add(con2);
-
- tx.commit();
- tx.close();
- session.close();
- }
-
- // read model
- {
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource res = view.getResource(getResourcePath("/test/referenced"));
-
- EObject oRef = res.getContents().get(0);
- refName = (EAttribute)oRef.eClass().getEStructuralFeature("refname");
- assertEquals("ref0", oRef.eGet(refName));
- List<CDOObjectReference> results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
- assertEquals(0, results.size());
-
- oRef = res.getContents().get(1);
- assertEquals("ref1", oRef.eGet(refName));
- results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
- assertEquals(2, results.size());
-
- conName = (EAttribute)((EObject)results.get(0).getSourceObject()).eClass().getEStructuralFeature("conname");
- String conName1 = (String)results.get(0).getSourceObject().eGet(conName);
- String conName2 = (String)results.get(1).getSourceObject().eGet(conName);
-
- assertEquals(true, conName1.equals("con1") || conName1.equals("con2"));
- assertEquals(true, conName2.equals("con1") || conName2.equals("con2"));
- assertEquals(true, !conName1.equals(conName2));
-
- oRef = res.getContents().get(2);
- assertEquals("ref2", oRef.eGet(refName));
- results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
- assertEquals(0, results.size());
-
- oRef = res.getContents().get(3);
- assertEquals("ref3", oRef.eGet(refName));
- results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
- assertEquals(0, results.size());
-
- oRef = res.getContents().get(4);
- assertEquals("ref4", oRef.eGet(refName));
- results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
- assertEquals(1, results.size());
- assertEquals("con2", (String)results.get(0).getSourceObject().eGet(conName));
-
- oRef = res.getContents().get(5);
- assertEquals("ref5", oRef.eGet(refName));
- results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
- assertEquals(1, results.size());
- assertEquals("con1", (String)results.get(0).getSourceObject().eGet(conName));
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObjectReference;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_331619_Test extends AbstractCDOTest
+{
+ @SuppressWarnings("unchecked")
+ public void testAbstractXRef() throws CommitException
+ {
+ skipStoreWithoutQueryXRefs();
+
+ // set up model
+ EPackage pkg = EMFUtil.createEPackage("test", "test", "http://www.eclipse.org/CDO/Tests/331619.ecore");
+ EClass ref = EMFUtil.createEClass(pkg, "referencee", false, false);
+ EAttribute refName = EMFUtil.createEAttribute(ref, "refname", EcorePackage.eINSTANCE.getEString());
+
+ EClass abs = EMFUtil.createEClass(pkg, "abstractClass", true, false);
+ EReference reference = EMFUtil.createEReference(abs, "reference", ref, false, true);
+ reference.setContainment(false);
+
+ EClass con = EMFUtil.createEClass(pkg, "concreteClass", false, false);
+ con.getESuperTypes().add(abs);
+ EAttribute conName = EMFUtil.createEAttribute(con, "conname", EcorePackage.eINSTANCE.getEString());
+
+ CDOUtil.prepareDynamicEPackage(pkg);
+
+ // write model
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource refres = tx.createResource(getResourcePath("/test/referenced"));
+ CDOResource conres = tx.createResource(getResourcePath("/test/concrete"));
+
+ EObject[] oRef = new EObject[6];
+ for (int i = 0; i < 6; i++)
+ {
+ oRef[i] = EcoreUtil.create(ref);
+ oRef[i].eSet(refName, "ref" + i);
+ refres.getContents().add(oRef[i]);
+ }
+
+ EObject con1 = EcoreUtil.create(con);
+ con1.eSet(conName, "con1");
+ ((EList<EObject>)con1.eGet(reference)).add(oRef[1]);
+ ((EList<EObject>)con1.eGet(reference)).add(oRef[5]);
+ conres.getContents().add(con1);
+
+ EObject con2 = EcoreUtil.create(con);
+ con2.eSet(conName, "con2");
+ ((EList<EObject>)con2.eGet(reference)).add(oRef[4]);
+ ((EList<EObject>)con2.eGet(reference)).add(oRef[1]);
+ conres.getContents().add(con2);
+
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ // read model
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource res = view.getResource(getResourcePath("/test/referenced"));
+
+ EObject oRef = res.getContents().get(0);
+ refName = (EAttribute)oRef.eClass().getEStructuralFeature("refname");
+ assertEquals("ref0", oRef.eGet(refName));
+ List<CDOObjectReference> results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
+ assertEquals(0, results.size());
+
+ oRef = res.getContents().get(1);
+ assertEquals("ref1", oRef.eGet(refName));
+ results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
+ assertEquals(2, results.size());
+
+ conName = (EAttribute)((EObject)results.get(0).getSourceObject()).eClass().getEStructuralFeature("conname");
+ String conName1 = (String)results.get(0).getSourceObject().eGet(conName);
+ String conName2 = (String)results.get(1).getSourceObject().eGet(conName);
+
+ assertEquals(true, conName1.equals("con1") || conName1.equals("con2"));
+ assertEquals(true, conName2.equals("con1") || conName2.equals("con2"));
+ assertEquals(true, !conName1.equals(conName2));
+
+ oRef = res.getContents().get(2);
+ assertEquals("ref2", oRef.eGet(refName));
+ results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
+ assertEquals(0, results.size());
+
+ oRef = res.getContents().get(3);
+ assertEquals("ref3", oRef.eGet(refName));
+ results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
+ assertEquals(0, results.size());
+
+ oRef = res.getContents().get(4);
+ assertEquals("ref4", oRef.eGet(refName));
+ results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
+ assertEquals(1, results.size());
+ assertEquals("con2", (String)results.get(0).getSourceObject().eGet(conName));
+
+ oRef = res.getContents().get(5);
+ assertEquals("ref5", oRef.eGet(refName));
+ results = view.queryXRefs(Collections.singleton(CDOUtil.getCDOObject(oRef)));
+ assertEquals(1, results.size());
+ assertEquals("con1", (String)results.get(0).getSourceObject().eGet(conName));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333157_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333157_Test.java
index 08257ad567..49b9a9528f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333157_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333157_Test.java
@@ -1,52 +1,52 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-/**
- * @author Egidijus Vaisnora
- */
-public class Bugzilla_333157_Test extends AbstractCDOTest
-{
- public void testResourceFolderUpdate() throws CommitException
- {
- createResource(getResourcePath("/testFolder/t1"));
-
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- CDOView view = session.openView();
-
- // Testing if resource was created
- assertNotNull(view.getResource(getResourcePath("/testFolder/t1")));
-
- createResource(getResourcePath("/testFolder/t2"));
- session.refresh();
-
- // Getting created resource - "testFolder" is retrieved from local cache
- CDOResource t2 = view.getResource(getResourcePath("/testFolder/t2"));
- assertNotNull(t2);
- }
-
- private void createResource(String resourcePath) throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.createResource(resourcePath);
- transaction.commit();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_333157_Test extends AbstractCDOTest
+{
+ public void testResourceFolderUpdate() throws CommitException
+ {
+ createResource(getResourcePath("/testFolder/t1"));
+
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOView view = session.openView();
+
+ // Testing if resource was created
+ assertNotNull(view.getResource(getResourcePath("/testFolder/t1")));
+
+ createResource(getResourcePath("/testFolder/t2"));
+ session.refresh();
+
+ // Getting created resource - "testFolder" is retrieved from local cache
+ CDOResource t2 = view.getResource(getResourcePath("/testFolder/t2"));
+ assertNotNull(t2);
+ }
+
+ private void createResource(String resourcePath) throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.createResource(resourcePath);
+ transaction.commit();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333299_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333299_Test.java
index a75c904806..9b54348e0f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333299_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333299_Test.java
@@ -1,66 +1,66 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EcoreFactory;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_333299_Test extends AbstractCDOTest
-{
- @Requires(IModelConfig.CAPABILITY_LEGACY)
- public void testMoveEcoreElement() throws CommitException
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
-
- EClass eClass = EcoreFactory.eINSTANCE.createEClass();
- eClass.setName("clazz1");
- EReference eReference = EcoreFactory.eINSTANCE.createEReference();
- eReference.setName("eReference");
-
- eClass.getEReferences().add(eReference);
-
- resource.getContents().add(ePackage);
- ePackage.getEClassifiers().add(eClass);
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/res1"));
-
- EPackage ePackage = (EPackage)resource.getContents().get(0);
- ePackage.getEClassifiers().remove(0);
-
- transaction.commit();
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_333299_Test extends AbstractCDOTest
+{
+ @Requires(IModelConfig.CAPABILITY_LEGACY)
+ public void testMoveEcoreElement() throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+
+ EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
+
+ EClass eClass = EcoreFactory.eINSTANCE.createEClass();
+ eClass.setName("clazz1");
+ EReference eReference = EcoreFactory.eINSTANCE.createEReference();
+ eReference.setName("eReference");
+
+ eClass.getEReferences().add(eReference);
+
+ resource.getContents().add(ePackage);
+ ePackage.getEClassifiers().add(eClass);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/res1"));
+
+ EPackage ePackage = (EPackage)resource.getContents().get(0);
+ ePackage.getEClassifiers().remove(0);
+
+ transaction.commit();
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java
index cfae47454a..cd720cbcb0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java
@@ -1,120 +1,120 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Egidijus Vaishnora - initial API and implementation
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * @author Egidijus Vaishnora, Caspar De Groot
- */
-public class Bugzilla_333950_Test extends AbstractCDOTest
-{
- public void testOpposites() throws Exception
- {
- EPackage pkg1 = null;
- {
- // create ECore metamodel. Major aspect is to create two classes, which has linked opposite EReferences and one of
- // reference is not persistence
- pkg1 = EcoreFactory.eINSTANCE.createEPackage();
- pkg1.setNsURI("http://test.com/custom");
- pkg1.setName("test");
- pkg1.setNsPrefix("t");
-
- EClass customClassA = EcoreFactory.eINSTANCE.createEClass();
- customClassA.setName("A");
- pkg1.getEClassifiers().add(customClassA);
-
- EClass customClassB = EcoreFactory.eINSTANCE.createEClass();
- customClassB.setName("B");
- pkg1.getEClassifiers().add(customClassB);
-
- createOpposites(customClassA, customClassB);
- }
-
- {
- // create model and commit it
- CDOSession openSession = openSession();
- CDOTransaction openTransaction = openSession.openTransaction();
- CDOResource createResource = openTransaction.createResource(getResourcePath("test"));
-
- EClass classAClass = (EClass)pkg1.getEClassifier("A");
- EClass classBClass = (EClass)pkg1.getEClassifier("B");
-
- EObject instanceA = EcoreUtil.create(classAClass);
- EObject instanceB = EcoreUtil.create(classBClass);
- EStructuralFeature eStructuralFeatureA = classAClass.getEStructuralFeature("AB");
- EStructuralFeature eStructuralFeatureB = instanceB.eClass().getEStructuralFeature("_AB");
-
- instanceA.eSet(eStructuralFeatureA, instanceB);
-
- assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
-
- createResource.getContents().add(instanceA);
- createResource.getContents().add(instanceB);
-
- openTransaction.commit();
-
- assertEquals(true, eStructuralFeatureB.isTransient());
- assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
-
- System.out.println("---> instanceA: " + CDOUtil.getCDOObject(instanceA).cdoID());
- System.out.println("---> instanceB: " + CDOUtil.getCDOObject(instanceB).cdoID());
-
- openSession.close();
- }
-
- // open committed model and validate if transient opposite reference is available
- CDOSession openSession2 = openSession();
- CDOTransaction openTransaction2 = openSession2.openTransaction();
- CDOResource resource = openTransaction2.getResource(getResourcePath("test"));
- EObject eObjectA = resource.getContents().get(0);
- EObject eObjectB = resource.getContents().get(1);
-
- EStructuralFeature eStructuralFeatureA = eObjectA.eClass().getEStructuralFeature("AB");
- assertEquals(false, eStructuralFeatureA.isTransient());
- assertEquals(eObjectB, eObjectA.eGet(eStructuralFeatureA));
-
- EStructuralFeature eStructuralFeatureB = eObjectB.eClass().getEStructuralFeature("_AB");
- assertEquals(true, eStructuralFeatureB.isTransient());
- assertEquals(eObjectA, eObjectB.eGet(eStructuralFeatureB));
- }
-
- private void createOpposites(EClass A, EClass B)
- {
- EReference tmpRefA_B = EcoreFactory.eINSTANCE.createEReference();
- tmpRefA_B.setName(A.getName() + B.getName());
- A.getEStructuralFeatures().add(tmpRefA_B);
- tmpRefA_B.setEType(B);
-
- EReference tmpRefB_A = EcoreFactory.eINSTANCE.createEReference();
- tmpRefB_A.setTransient(true);
- tmpRefB_A.setName("_" + tmpRefA_B.getName());
- B.getEStructuralFeatures().add(tmpRefB_A);
- tmpRefB_A.setEType(A);
-
- tmpRefA_B.setEOpposite(tmpRefB_A);
- tmpRefB_A.setEOpposite(tmpRefA_B);
- assertSame(tmpRefA_B, tmpRefB_A.getEOpposite());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Egidijus Vaishnora - initial API and implementation
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * @author Egidijus Vaishnora, Caspar De Groot
+ */
+public class Bugzilla_333950_Test extends AbstractCDOTest
+{
+ public void testOpposites() throws Exception
+ {
+ EPackage pkg1 = null;
+ {
+ // create ECore metamodel. Major aspect is to create two classes, which has linked opposite EReferences and one of
+ // reference is not persistence
+ pkg1 = EcoreFactory.eINSTANCE.createEPackage();
+ pkg1.setNsURI("http://test.com/custom");
+ pkg1.setName("test");
+ pkg1.setNsPrefix("t");
+
+ EClass customClassA = EcoreFactory.eINSTANCE.createEClass();
+ customClassA.setName("A");
+ pkg1.getEClassifiers().add(customClassA);
+
+ EClass customClassB = EcoreFactory.eINSTANCE.createEClass();
+ customClassB.setName("B");
+ pkg1.getEClassifiers().add(customClassB);
+
+ createOpposites(customClassA, customClassB);
+ }
+
+ {
+ // create model and commit it
+ CDOSession openSession = openSession();
+ CDOTransaction openTransaction = openSession.openTransaction();
+ CDOResource createResource = openTransaction.createResource(getResourcePath("test"));
+
+ EClass classAClass = (EClass)pkg1.getEClassifier("A");
+ EClass classBClass = (EClass)pkg1.getEClassifier("B");
+
+ EObject instanceA = EcoreUtil.create(classAClass);
+ EObject instanceB = EcoreUtil.create(classBClass);
+ EStructuralFeature eStructuralFeatureA = classAClass.getEStructuralFeature("AB");
+ EStructuralFeature eStructuralFeatureB = instanceB.eClass().getEStructuralFeature("_AB");
+
+ instanceA.eSet(eStructuralFeatureA, instanceB);
+
+ assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
+
+ createResource.getContents().add(instanceA);
+ createResource.getContents().add(instanceB);
+
+ openTransaction.commit();
+
+ assertEquals(true, eStructuralFeatureB.isTransient());
+ assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
+
+ System.out.println("---> instanceA: " + CDOUtil.getCDOObject(instanceA).cdoID());
+ System.out.println("---> instanceB: " + CDOUtil.getCDOObject(instanceB).cdoID());
+
+ openSession.close();
+ }
+
+ // open committed model and validate if transient opposite reference is available
+ CDOSession openSession2 = openSession();
+ CDOTransaction openTransaction2 = openSession2.openTransaction();
+ CDOResource resource = openTransaction2.getResource(getResourcePath("test"));
+ EObject eObjectA = resource.getContents().get(0);
+ EObject eObjectB = resource.getContents().get(1);
+
+ EStructuralFeature eStructuralFeatureA = eObjectA.eClass().getEStructuralFeature("AB");
+ assertEquals(false, eStructuralFeatureA.isTransient());
+ assertEquals(eObjectB, eObjectA.eGet(eStructuralFeatureA));
+
+ EStructuralFeature eStructuralFeatureB = eObjectB.eClass().getEStructuralFeature("_AB");
+ assertEquals(true, eStructuralFeatureB.isTransient());
+ assertEquals(eObjectA, eObjectB.eGet(eStructuralFeatureB));
+ }
+
+ private void createOpposites(EClass A, EClass B)
+ {
+ EReference tmpRefA_B = EcoreFactory.eINSTANCE.createEReference();
+ tmpRefA_B.setName(A.getName() + B.getName());
+ A.getEStructuralFeatures().add(tmpRefA_B);
+ tmpRefA_B.setEType(B);
+
+ EReference tmpRefB_A = EcoreFactory.eINSTANCE.createEReference();
+ tmpRefB_A.setTransient(true);
+ tmpRefB_A.setName("_" + tmpRefA_B.getName());
+ B.getEStructuralFeatures().add(tmpRefB_A);
+ tmpRefB_A.setEType(A);
+
+ tmpRefA_B.setEOpposite(tmpRefB_A);
+ tmpRefB_A.setEOpposite(tmpRefA_B);
+ assertSame(tmpRefA_B, tmpRefB_A.getEOpposite());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java
index 0fe699e746..ab74a30c75 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java
@@ -1,114 +1,114 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Egidijus Vaishnora - initial API and implementation
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl;
-import org.eclipse.emf.internal.cdo.util.CommitIntegrityCheck;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
-
-/**
- * Bug 334608 - CommitIntegrityCheck erroneously checks non-persistent features
- *
- * @author Egidijus Vaishnora, Caspar De Groot
- */
-public class Bugzilla_334608_Test extends AbstractCDOTest
-{
- @CleanRepositoriesBefore
- public void testOpposites() throws Exception
- {
- EPackage pkg1 = null;
- {
- pkg1 = EcoreFactory.eINSTANCE.createEPackage();
- pkg1.setNsURI("http://test.com/custom");
- pkg1.setName("test");
- pkg1.setNsPrefix("t");
-
- EClass customClassA = EcoreFactory.eINSTANCE.createEClass();
- customClassA.setName("A");
- pkg1.getEClassifiers().add(customClassA);
-
- EClass customClassB = EcoreFactory.eINSTANCE.createEClass();
- customClassB.setName("B");
- pkg1.getEClassifiers().add(customClassB);
-
- createOpposites(customClassA, customClassB);
- }
-
- {
- // create model and commit it
- CDOSession openSession = openSession();
- CDOTransaction transaction = openSession.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test"));
-
- EClass classAClass = (EClass)pkg1.getEClassifier("A");
- EClass classBClass = (EClass)pkg1.getEClassifier("B");
-
- EObject instanceA = EcoreUtil.create(classAClass);
- EObject instanceB = EcoreUtil.create(classBClass);
- EStructuralFeature eStructuralFeatureA = classAClass.getEStructuralFeature("AB");
- EStructuralFeature eStructuralFeatureB = instanceB.eClass().getEStructuralFeature("_AB");
-
- instanceA.eSet(eStructuralFeatureA, instanceB);
-
- resource.getContents().add(instanceA);
- resource.getContents().add(instanceB);
-
- assertEquals(true, eStructuralFeatureB.isTransient());
- assertEquals(true, eStructuralFeatureA.isTransient());
- assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
- transaction.commit();
-
- resource.getContents().remove(instanceA);
- resource.getContents().remove(instanceB);
-
- InternalCDOCommitContext commitContext = ((CDOTransactionImpl)transaction).createCommitContext();
- CommitIntegrityCheck integrityCheck = new CommitIntegrityCheck(commitContext,
- CommitIntegrityCheck.Style.NO_EXCEPTION);
- integrityCheck.check();
-
- transaction.commit();
- openSession.close();
- }
- }
-
- private void createOpposites(EClass A, EClass B)
- {
- EReference tmpRefA_B = EcoreFactory.eINSTANCE.createEReference();
- tmpRefA_B.setTransient(true);
- tmpRefA_B.setName(A.getName() + B.getName());
- A.getEStructuralFeatures().add(tmpRefA_B);
- tmpRefA_B.setEType(B);
-
- EReference tmpRefB_A = EcoreFactory.eINSTANCE.createEReference();
- tmpRefB_A.setTransient(true);
- tmpRefB_A.setName("_" + tmpRefA_B.getName());
- B.getEStructuralFeatures().add(tmpRefB_A);
- tmpRefB_A.setEType(A);
-
- tmpRefA_B.setEOpposite(tmpRefB_A);
- tmpRefB_A.setEOpposite(tmpRefA_B);
- assertSame(tmpRefA_B, tmpRefB_A.getEOpposite());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Egidijus Vaishnora - initial API and implementation
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl;
+import org.eclipse.emf.internal.cdo.util.CommitIntegrityCheck;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
+
+/**
+ * Bug 334608 - CommitIntegrityCheck erroneously checks non-persistent features
+ *
+ * @author Egidijus Vaishnora, Caspar De Groot
+ */
+public class Bugzilla_334608_Test extends AbstractCDOTest
+{
+ @CleanRepositoriesBefore
+ public void testOpposites() throws Exception
+ {
+ EPackage pkg1 = null;
+ {
+ pkg1 = EcoreFactory.eINSTANCE.createEPackage();
+ pkg1.setNsURI("http://test.com/custom");
+ pkg1.setName("test");
+ pkg1.setNsPrefix("t");
+
+ EClass customClassA = EcoreFactory.eINSTANCE.createEClass();
+ customClassA.setName("A");
+ pkg1.getEClassifiers().add(customClassA);
+
+ EClass customClassB = EcoreFactory.eINSTANCE.createEClass();
+ customClassB.setName("B");
+ pkg1.getEClassifiers().add(customClassB);
+
+ createOpposites(customClassA, customClassB);
+ }
+
+ {
+ // create model and commit it
+ CDOSession openSession = openSession();
+ CDOTransaction transaction = openSession.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+
+ EClass classAClass = (EClass)pkg1.getEClassifier("A");
+ EClass classBClass = (EClass)pkg1.getEClassifier("B");
+
+ EObject instanceA = EcoreUtil.create(classAClass);
+ EObject instanceB = EcoreUtil.create(classBClass);
+ EStructuralFeature eStructuralFeatureA = classAClass.getEStructuralFeature("AB");
+ EStructuralFeature eStructuralFeatureB = instanceB.eClass().getEStructuralFeature("_AB");
+
+ instanceA.eSet(eStructuralFeatureA, instanceB);
+
+ resource.getContents().add(instanceA);
+ resource.getContents().add(instanceB);
+
+ assertEquals(true, eStructuralFeatureB.isTransient());
+ assertEquals(true, eStructuralFeatureA.isTransient());
+ assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
+ transaction.commit();
+
+ resource.getContents().remove(instanceA);
+ resource.getContents().remove(instanceB);
+
+ InternalCDOCommitContext commitContext = ((CDOTransactionImpl)transaction).createCommitContext();
+ CommitIntegrityCheck integrityCheck = new CommitIntegrityCheck(commitContext,
+ CommitIntegrityCheck.Style.NO_EXCEPTION);
+ integrityCheck.check();
+
+ transaction.commit();
+ openSession.close();
+ }
+ }
+
+ private void createOpposites(EClass A, EClass B)
+ {
+ EReference tmpRefA_B = EcoreFactory.eINSTANCE.createEReference();
+ tmpRefA_B.setTransient(true);
+ tmpRefA_B.setName(A.getName() + B.getName());
+ A.getEStructuralFeatures().add(tmpRefA_B);
+ tmpRefA_B.setEType(B);
+
+ EReference tmpRefB_A = EcoreFactory.eINSTANCE.createEReference();
+ tmpRefB_A.setTransient(true);
+ tmpRefB_A.setName("_" + tmpRefA_B.getName());
+ B.getEStructuralFeatures().add(tmpRefB_A);
+ tmpRefB_A.setEType(A);
+
+ tmpRefA_B.setEOpposite(tmpRefB_A);
+ tmpRefB_A.setEOpposite(tmpRefA_B);
+ assertSame(tmpRefA_B, tmpRefB_A.getEOpposite());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java
index 9f3866fa8e..c1e2880d83 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java
@@ -1,105 +1,105 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import java.util.Map.Entry;
-
-/**
- * Bug 334995 - CDOTransaction corrupted by persisted + new resource with same URI
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_334995_Test extends AbstractCDOTest
-{
- public void test() throws CommitException
- {
- CDOID[] resourceIDs = persistResources("/res1");
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- msg("New resource: " + resource);
- msg("newObjects:");
-
- for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
- {
- msg(" " + entry + ", state: " + entry.getValue().cdoState());
- assertNew(entry.getValue(), transaction);
- }
-
- // Fetch the persisted resource that has the same URI
- CDOResource resource1 = (CDOResource)transaction.getObject(resourceIDs[0]);
- msg("Persisted resource: " + resource1);
-
- msg("newObjects:");
- for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
- {
- msg(" " + entry + ", state: " + entry.getValue().cdoState());
- assertNew(entry.getValue(), transaction);
- }
-
- transaction.commit();
- }
- }
-
- public void testRename() throws CommitException
- {
- CDOID[] resourceIDs = persistResources("/res1", "/res2");
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.getResource(getResourcePath("/res1"));
- resource1.setPath("/res2");
-
- CDOResource resource2 = (CDOResource)transaction.getObject(resourceIDs[1]);
-
- resource1.getContents().add(getModel1Factory().createAddress());
- resource2.getContents().add(getModel1Factory().createAddress());
- transaction.commit();
-
- session.close();
- }
- }
-
- private CDOID[] persistResources(String... resourceNames) throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- int i = 0;
- CDOResource[] resources = new CDOResource[resourceNames.length];
- for (String resourceName : resourceNames)
- {
- resources[i++] = transaction.createResource(getResourcePath(resourceName));
- }
- transaction.commit();
-
- CDOID[] resourceIDs = new CDOID[resourceNames.length];
- for (i = 0; i < resources.length; i++)
- {
- resourceIDs[i] = resources[i].cdoID();
- }
-
- session.close();
- return resourceIDs;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import java.util.Map.Entry;
+
+/**
+ * Bug 334995 - CDOTransaction corrupted by persisted + new resource with same URI
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_334995_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ CDOID[] resourceIDs = persistResources("/res1");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ msg("New resource: " + resource);
+ msg("newObjects:");
+
+ for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
+ {
+ msg(" " + entry + ", state: " + entry.getValue().cdoState());
+ assertNew(entry.getValue(), transaction);
+ }
+
+ // Fetch the persisted resource that has the same URI
+ CDOResource resource1 = (CDOResource)transaction.getObject(resourceIDs[0]);
+ msg("Persisted resource: " + resource1);
+
+ msg("newObjects:");
+ for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
+ {
+ msg(" " + entry + ", state: " + entry.getValue().cdoState());
+ assertNew(entry.getValue(), transaction);
+ }
+
+ transaction.commit();
+ }
+ }
+
+ public void testRename() throws CommitException
+ {
+ CDOID[] resourceIDs = persistResources("/res1", "/res2");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.getResource(getResourcePath("/res1"));
+ resource1.setPath("/res2");
+
+ CDOResource resource2 = (CDOResource)transaction.getObject(resourceIDs[1]);
+
+ resource1.getContents().add(getModel1Factory().createAddress());
+ resource2.getContents().add(getModel1Factory().createAddress());
+ transaction.commit();
+
+ session.close();
+ }
+ }
+
+ private CDOID[] persistResources(String... resourceNames) throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ int i = 0;
+ CDOResource[] resources = new CDOResource[resourceNames.length];
+ for (String resourceName : resourceNames)
+ {
+ resources[i++] = transaction.createResource(getResourcePath(resourceName));
+ }
+ transaction.commit();
+
+ CDOID[] resourceIDs = new CDOID[resourceNames.length];
+ for (i = 0; i < resources.length; i++)
+ {
+ resourceIDs[i] = resources[i].cdoID();
+ }
+
+ session.close();
+ return resourceIDs;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335004_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335004_Test.java
index 7442e1477d..3dc2e576ff 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335004_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335004_Test.java
@@ -1,74 +1,74 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_335004_Test extends AbstractCDOTest
-{
- public void testDuplicatePackageInSystem() throws CommitException
- {
- String nsURI = getModel1Package().getNsURI();
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test"));
- resource.getContents().add(getModel1Factory().createAddress());
- transaction.commit();
- session.close();
- }
-
- assertNotNull(EPackage.Registry.INSTANCE.get(nsURI));
- Object oldPackage = EPackage.Registry.INSTANCE.remove(nsURI);
-
- try
- {
- assertNull(EPackage.Registry.INSTANCE.get(nsURI));
-
- CDOSession session = openSession();
- session.options().setGeneratedPackageEmulationEnabled(true);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("test")); // We are loading nsURI from the server
-
- EObject remoteObject = resource.getContents().get(0);
- EObject localObject = getModel1Factory().createAddress();
-
- try
- {
- resource.getContents().add(localObject);
- assertSame(remoteObject.eClass(), localObject.eClass());
- fail("IllegalStateException expected");
- }
- catch (IllegalStateException expected)
- {
- // Success
- }
- }
- finally
- {
- if (oldPackage != null)
- {
- EPackage.Registry.INSTANCE.put(nsURI, oldPackage);
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_335004_Test extends AbstractCDOTest
+{
+ public void testDuplicatePackageInSystem() throws CommitException
+ {
+ String nsURI = getModel1Package().getNsURI();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+ resource.getContents().add(getModel1Factory().createAddress());
+ transaction.commit();
+ session.close();
+ }
+
+ assertNotNull(EPackage.Registry.INSTANCE.get(nsURI));
+ Object oldPackage = EPackage.Registry.INSTANCE.remove(nsURI);
+
+ try
+ {
+ assertNull(EPackage.Registry.INSTANCE.get(nsURI));
+
+ CDOSession session = openSession();
+ session.options().setGeneratedPackageEmulationEnabled(true);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("test")); // We are loading nsURI from the server
+
+ EObject remoteObject = resource.getContents().get(0);
+ EObject localObject = getModel1Factory().createAddress();
+
+ try
+ {
+ resource.getContents().add(localObject);
+ assertSame(remoteObject.eClass(), localObject.eClass());
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ // Success
+ }
+ }
+ finally
+ {
+ if (oldPackage != null)
+ {
+ EPackage.Registry.INSTANCE.put(nsURI, oldPackage);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335675_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335675_Test.java
index deec7a217c..5059d0ce8d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335675_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335675_Test.java
@@ -1,179 +1,179 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_335675_Test extends AbstractCDOTest
-{
- @CleanRepositoriesBefore
- public void test0() throws Exception
- {
- EPackage pkg = null;
- EAttribute attr1 = null;
- EAttribute attr2 = null;
- EAttribute attr3 = null;
-
- final int TRANSIENT_VALUE = 2;
-
- EClass classA = null;
- {
- pkg = EcoreFactory.eINSTANCE.createEPackage();
- pkg.setNsURI("http://test.com/custom");
- pkg.setName("test");
- pkg.setNsPrefix("t");
-
- classA = EcoreFactory.eINSTANCE.createEClass();
- classA.setName("A");
-
- attr1 = createAttribute("attr1", EcorePackage.eINSTANCE.getEInt(), false);
- attr2 = createAttribute("attr2", EcorePackage.eINSTANCE.getEInt(), true);
- attr3 = createAttribute("attr3", EcorePackage.eINSTANCE.getEInt(), false);
-
- classA.getEStructuralFeatures().add(attr1);
- classA.getEStructuralFeatures().add(attr2);
- classA.getEStructuralFeatures().add(attr3);
-
- pkg.getEClassifiers().add(classA);
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test"));
-
- classA = (EClass)pkg.getEClassifier("A");
- EObject instanceA = EcoreUtil.create(classA);
- attr1 = (EAttribute)classA.getEStructuralFeature("attr1");
- attr2 = (EAttribute)classA.getEStructuralFeature("attr2");
- attr3 = (EAttribute)classA.getEStructuralFeature("attr3");
- instanceA.eSet(attr1, 1);
- instanceA.eSet(attr2, TRANSIENT_VALUE);
- instanceA.eSet(attr3, 3);
-
- resource.getContents().add(instanceA);
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("test"));
- CDOObject cdoObject = CDOUtil.getCDOObject(resource.getContents().get(0));
- classA = cdoObject.eClass();
- attr1 = (EAttribute)classA.getEStructuralFeature("attr1");
- attr2 = (EAttribute)classA.getEStructuralFeature("attr2");
- attr3 = (EAttribute)classA.getEStructuralFeature("attr3");
-
- BaseCDORevision rev = (BaseCDORevision)cdoObject.cdoRevision();
- // int attr1Val = (Integer)rev.getValue(attr1);
- // int attr3Val = (Integer)rev.getValue(attr3);
- try
- {
- int attr2Val = (Integer)rev.getValue(attr2);
- fail("Should have thrown an exception, but fetched value " + attr2Val);
- }
- catch (IllegalArgumentException ex)
- {
- // Good
- }
-
- session.close();
- }
- }
-
- public void test1() throws CommitException
- {
- EAttribute nameAttr = Model1Package.eINSTANCE.getProduct1_Name();
- assertEquals(false, nameAttr.isTransient());
-
- EAttribute descriptionAttr = Model1Package.eINSTANCE.getProduct1_Description();
- assertEquals(true, descriptionAttr.isTransient());
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test"));
-
- Product1 product = Model1Factory.eINSTANCE.createProduct1();
- product.setName("name");
- product.setDescription("description");
- product.setVat(VAT.VAT7);
- resource.getContents().add(product);
-
- PurchaseOrder order = Model1Factory.eINSTANCE.createPurchaseOrder();
- OrderDetail detail = Model1Factory.eINSTANCE.createOrderDetail();
- order.getOrderDetails().add(detail);
- resource.getContents().add(order);
-
- detail.setProduct(product);
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("test"));
- CDOObject cdoObject = CDOUtil.getCDOObject(resource.getContents().get(0));
-
- BaseCDORevision rev = (BaseCDORevision)cdoObject.cdoRevision();
- // String name = (String)rev.getValue(nameAttr);
- try
- {
- String desc = (String)rev.getValue(descriptionAttr);
- fail("Should have thrown an exception, but fetched value: " + desc);
- }
- catch (Exception ex)
- {
- // Good
- }
-
- session.close();
- }
- }
-
- private EAttribute createAttribute(String name, EDataType type, boolean tranzient)
- {
- EAttribute attr = EcoreFactory.eINSTANCE.createEAttribute();
- attr.setName(name);
- attr.setEType(type);
- attr.setTransient(tranzient);
- return attr;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_335675_Test extends AbstractCDOTest
+{
+ @CleanRepositoriesBefore
+ public void test0() throws Exception
+ {
+ EPackage pkg = null;
+ EAttribute attr1 = null;
+ EAttribute attr2 = null;
+ EAttribute attr3 = null;
+
+ final int TRANSIENT_VALUE = 2;
+
+ EClass classA = null;
+ {
+ pkg = EcoreFactory.eINSTANCE.createEPackage();
+ pkg.setNsURI("http://test.com/custom");
+ pkg.setName("test");
+ pkg.setNsPrefix("t");
+
+ classA = EcoreFactory.eINSTANCE.createEClass();
+ classA.setName("A");
+
+ attr1 = createAttribute("attr1", EcorePackage.eINSTANCE.getEInt(), false);
+ attr2 = createAttribute("attr2", EcorePackage.eINSTANCE.getEInt(), true);
+ attr3 = createAttribute("attr3", EcorePackage.eINSTANCE.getEInt(), false);
+
+ classA.getEStructuralFeatures().add(attr1);
+ classA.getEStructuralFeatures().add(attr2);
+ classA.getEStructuralFeatures().add(attr3);
+
+ pkg.getEClassifiers().add(classA);
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+
+ classA = (EClass)pkg.getEClassifier("A");
+ EObject instanceA = EcoreUtil.create(classA);
+ attr1 = (EAttribute)classA.getEStructuralFeature("attr1");
+ attr2 = (EAttribute)classA.getEStructuralFeature("attr2");
+ attr3 = (EAttribute)classA.getEStructuralFeature("attr3");
+ instanceA.eSet(attr1, 1);
+ instanceA.eSet(attr2, TRANSIENT_VALUE);
+ instanceA.eSet(attr3, 3);
+
+ resource.getContents().add(instanceA);
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
+ CDOObject cdoObject = CDOUtil.getCDOObject(resource.getContents().get(0));
+ classA = cdoObject.eClass();
+ attr1 = (EAttribute)classA.getEStructuralFeature("attr1");
+ attr2 = (EAttribute)classA.getEStructuralFeature("attr2");
+ attr3 = (EAttribute)classA.getEStructuralFeature("attr3");
+
+ BaseCDORevision rev = (BaseCDORevision)cdoObject.cdoRevision();
+ // int attr1Val = (Integer)rev.getValue(attr1);
+ // int attr3Val = (Integer)rev.getValue(attr3);
+ try
+ {
+ int attr2Val = (Integer)rev.getValue(attr2);
+ fail("Should have thrown an exception, but fetched value " + attr2Val);
+ }
+ catch (IllegalArgumentException ex)
+ {
+ // Good
+ }
+
+ session.close();
+ }
+ }
+
+ public void test1() throws CommitException
+ {
+ EAttribute nameAttr = Model1Package.eINSTANCE.getProduct1_Name();
+ assertEquals(false, nameAttr.isTransient());
+
+ EAttribute descriptionAttr = Model1Package.eINSTANCE.getProduct1_Description();
+ assertEquals(true, descriptionAttr.isTransient());
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+
+ Product1 product = Model1Factory.eINSTANCE.createProduct1();
+ product.setName("name");
+ product.setDescription("description");
+ product.setVat(VAT.VAT7);
+ resource.getContents().add(product);
+
+ PurchaseOrder order = Model1Factory.eINSTANCE.createPurchaseOrder();
+ OrderDetail detail = Model1Factory.eINSTANCE.createOrderDetail();
+ order.getOrderDetails().add(detail);
+ resource.getContents().add(order);
+
+ detail.setProduct(product);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
+ CDOObject cdoObject = CDOUtil.getCDOObject(resource.getContents().get(0));
+
+ BaseCDORevision rev = (BaseCDORevision)cdoObject.cdoRevision();
+ // String name = (String)rev.getValue(nameAttr);
+ try
+ {
+ String desc = (String)rev.getValue(descriptionAttr);
+ fail("Should have thrown an exception, but fetched value: " + desc);
+ }
+ catch (Exception ex)
+ {
+ // Good
+ }
+
+ session.close();
+ }
+ }
+
+ private EAttribute createAttribute(String name, EDataType type, boolean tranzient)
+ {
+ EAttribute attr = EcoreFactory.eINSTANCE.createEAttribute();
+ attr.setName(name);
+ attr.setEType(type);
+ attr.setTransient(tranzient);
+ return attr;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java
index 08cadc0d63..8272ea14b9 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java
@@ -1,184 +1,184 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.EMap;
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_335772_Test extends AbstractCDOTest
-{
- private Model1Factory factory;
-
- private Customer customer;
-
- private Product1 product1;
-
- private Product1 product2;
-
- private SalesOrder order1;
-
- private SalesOrder order2;
-
- private HashMap<Product1, SalesOrder> map;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- factory = getModel1Factory();
-
- customer = factory.createCustomer();
- product1 = factory.createProduct1();
- product1.setName("product1");
- product2 = factory.createProduct1();
- product2.setName("product2");
- order1 = factory.createSalesOrder();
- order1.setId(1);
- order2 = factory.createSalesOrder();
- order2.setId(2);
-
- map = new HashMap<Product1, SalesOrder>();
- map.put(product1, order1);
- customer.eSet(getModel1Package().getCustomer_OrderByProduct(), map);
-
- // delegateEList is not empty at this point
- customer.getOrderByProduct().get(0);
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- customer = null;
- factory = null;
- super.doTearDown();
- }
-
- public void testMapEntryReplacement() throws Exception
- {
- replaceMapEntry();
-
- // if delegateEList is empty at this point following line will throw IndexOutOfBoundsException
- customer.getOrderByProduct().get(0);
- }
-
- public void testMapEntryAddition() throws Exception
- {
- addMapEntry();
-
- // if delegateEList has only one element at this point following line will throw IndexOutOfBoundsException
- customer.getOrderByProduct().get(1);
- }
-
- public void testMapEntryReplacementPersistence() throws Exception
- {
- replaceMapEntry();
- assertEquals((Integer)2, persistAndRetrieveOrderIdForProduct1());
- }
-
- public void testMapEntryAdditionPersistence() throws Exception
- {
- addMapEntry();
- assertEquals((Integer)1, persistAndRetrieveOrderIdForProduct1());
- }
-
- private void replaceMapEntry()
- {
- map.put(product1, order2);
- assertEquals(1, map.size());
- customer.eSet(getModel1Package().getCustomer_OrderByProduct(), map);
- }
-
- private void addMapEntry()
- {
- map.put(product2, order2);
- assertEquals(2, map.size());
- customer.eSet(getModel1Package().getCustomer_OrderByProduct(), map);
- }
-
- private Integer persistAndRetrieveOrderIdForProduct1() throws CommitException
- {
- CDOSession session = openSession();
-
- try
- {
- CDOTransaction transaction = session.openTransaction();
- CDOResource customerResource;
-
- try
- {
- customerResource = transaction.getOrCreateResource(getResourcePath("/customer")); //$NON-NLS-1$
- EList<EObject> customerResourceContents = customerResource.getContents();
- customerResourceContents.clear();
- customerResourceContents.add(customer);
- customerResourceContents.add(product1);
- customerResourceContents.add(product2);
- customerResourceContents.add(order1);
- customerResourceContents.add(order2);
-
- transaction.commit();
- }
- finally
- {
- transaction.close();
- }
-
- transaction = session.openTransaction();
-
- try
- {
- customerResource = transaction.getResource(getResourcePath("/customer")); //$NON-NLS-1$
-
- Customer customer = (Customer)customerResource.getContents().get(0);
- EMap<Product1, SalesOrder> orderByProduct = customer.getOrderByProduct();
- orderByProduct.get(product1);
-
- CDOID product1CDOID = CDOUtil.getCDOObject(product1).cdoID();
-
- for (Map.Entry<Product1, SalesOrder> entry : orderByProduct.entrySet())
- {
- if (CDOUtil.getCDOObject(entry.getKey()).cdoID().equals(product1CDOID))
- {
- return entry.getValue().getId();
- }
- }
-
- return null;
- }
- finally
- {
- transaction.close();
- }
- }
- finally
- {
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_335772_Test extends AbstractCDOTest
+{
+ private Model1Factory factory;
+
+ private Customer customer;
+
+ private Product1 product1;
+
+ private Product1 product2;
+
+ private SalesOrder order1;
+
+ private SalesOrder order2;
+
+ private HashMap<Product1, SalesOrder> map;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ factory = getModel1Factory();
+
+ customer = factory.createCustomer();
+ product1 = factory.createProduct1();
+ product1.setName("product1");
+ product2 = factory.createProduct1();
+ product2.setName("product2");
+ order1 = factory.createSalesOrder();
+ order1.setId(1);
+ order2 = factory.createSalesOrder();
+ order2.setId(2);
+
+ map = new HashMap<Product1, SalesOrder>();
+ map.put(product1, order1);
+ customer.eSet(getModel1Package().getCustomer_OrderByProduct(), map);
+
+ // delegateEList is not empty at this point
+ customer.getOrderByProduct().get(0);
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ customer = null;
+ factory = null;
+ super.doTearDown();
+ }
+
+ public void testMapEntryReplacement() throws Exception
+ {
+ replaceMapEntry();
+
+ // if delegateEList is empty at this point following line will throw IndexOutOfBoundsException
+ customer.getOrderByProduct().get(0);
+ }
+
+ public void testMapEntryAddition() throws Exception
+ {
+ addMapEntry();
+
+ // if delegateEList has only one element at this point following line will throw IndexOutOfBoundsException
+ customer.getOrderByProduct().get(1);
+ }
+
+ public void testMapEntryReplacementPersistence() throws Exception
+ {
+ replaceMapEntry();
+ assertEquals((Integer)2, persistAndRetrieveOrderIdForProduct1());
+ }
+
+ public void testMapEntryAdditionPersistence() throws Exception
+ {
+ addMapEntry();
+ assertEquals((Integer)1, persistAndRetrieveOrderIdForProduct1());
+ }
+
+ private void replaceMapEntry()
+ {
+ map.put(product1, order2);
+ assertEquals(1, map.size());
+ customer.eSet(getModel1Package().getCustomer_OrderByProduct(), map);
+ }
+
+ private void addMapEntry()
+ {
+ map.put(product2, order2);
+ assertEquals(2, map.size());
+ customer.eSet(getModel1Package().getCustomer_OrderByProduct(), map);
+ }
+
+ private Integer persistAndRetrieveOrderIdForProduct1() throws CommitException
+ {
+ CDOSession session = openSession();
+
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource customerResource;
+
+ try
+ {
+ customerResource = transaction.getOrCreateResource(getResourcePath("/customer")); //$NON-NLS-1$
+ EList<EObject> customerResourceContents = customerResource.getContents();
+ customerResourceContents.clear();
+ customerResourceContents.add(customer);
+ customerResourceContents.add(product1);
+ customerResourceContents.add(product2);
+ customerResourceContents.add(order1);
+ customerResourceContents.add(order2);
+
+ transaction.commit();
+ }
+ finally
+ {
+ transaction.close();
+ }
+
+ transaction = session.openTransaction();
+
+ try
+ {
+ customerResource = transaction.getResource(getResourcePath("/customer")); //$NON-NLS-1$
+
+ Customer customer = (Customer)customerResource.getContents().get(0);
+ EMap<Product1, SalesOrder> orderByProduct = customer.getOrderByProduct();
+ orderByProduct.get(product1);
+
+ CDOID product1CDOID = CDOUtil.getCDOObject(product1).cdoID();
+
+ for (Map.Entry<Product1, SalesOrder> entry : orderByProduct.entrySet())
+ {
+ if (CDOUtil.getCDOObject(entry.getKey()).cdoID().equals(product1CDOID))
+ {
+ return entry.getValue().getId();
+ }
+ }
+
+ return null;
+ }
+ finally
+ {
+ transaction.close();
+ }
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336314_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336314_Test.java
index 81cd3c33f7..06fd7701dc 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336314_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336314_Test.java
@@ -1,107 +1,107 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Bug 336314 - Partial commits choke on CDOMoveFeatureDeltas
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_336314_Test extends AbstractCDOTest
-{
- public void test1() throws CommitException
- {
- test(new MoveIt()
- {
- public void move(SalesOrder order, OrderDetail detail)
- {
- order.getOrderDetails().remove(detail);
- order.getOrderDetails().add(detail);
- }
- });
- }
-
- public void test2() throws CommitException
- {
- test(new MoveIt()
- {
- public void move(SalesOrder order, OrderDetail detail)
- {
- order.getOrderDetails().move(0, 1);
- }
- });
- }
-
- private static interface MoveIt
- {
- void move(SalesOrder order, OrderDetail detail);
- }
-
- private void test(MoveIt moveIt) throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
-
- assertEquals(true, getModel1Package().getOrder_OrderDetails().isOrdered());
-
- Model1Factory mf = getModel1Factory();
- CDOResource resource = tx.createResource(getResourcePath("test"));
-
- OrderDetail detailY = mf.createOrderDetail();
- detailY.setPrice(1.0f);
-
- OrderDetail detailZ = mf.createOrderDetail();
- detailY.setPrice(2.0f);
-
- SalesOrder orderX = mf.createSalesOrder();
- orderX.getOrderDetails().add(detailY);
- orderX.getOrderDetails().add(detailZ);
-
- resource.getContents().add(orderX);
-
- // We need another object to make the later commit partial
- Product1 product = mf.createProduct1();
- product.setName("abc");
- resource.getContents().add(product);
-
- tx.commit();
-
- // Remove then add back, so as to change ordering
- moveIt.move(orderX, detailY);
-
- // Partial commit
- Set<EObject> committables = new HashSet<EObject>(1);
- committables.add(orderX);
- tx.setCommittables(committables);
-
- // Make other object dirty too, so that commit becomes 'partial'
- product.setName("def");
-
- tx.commit();
-
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Bug 336314 - Partial commits choke on CDOMoveFeatureDeltas
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_336314_Test extends AbstractCDOTest
+{
+ public void test1() throws CommitException
+ {
+ test(new MoveIt()
+ {
+ public void move(SalesOrder order, OrderDetail detail)
+ {
+ order.getOrderDetails().remove(detail);
+ order.getOrderDetails().add(detail);
+ }
+ });
+ }
+
+ public void test2() throws CommitException
+ {
+ test(new MoveIt()
+ {
+ public void move(SalesOrder order, OrderDetail detail)
+ {
+ order.getOrderDetails().move(0, 1);
+ }
+ });
+ }
+
+ private static interface MoveIt
+ {
+ void move(SalesOrder order, OrderDetail detail);
+ }
+
+ private void test(MoveIt moveIt) throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+
+ assertEquals(true, getModel1Package().getOrder_OrderDetails().isOrdered());
+
+ Model1Factory mf = getModel1Factory();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ OrderDetail detailY = mf.createOrderDetail();
+ detailY.setPrice(1.0f);
+
+ OrderDetail detailZ = mf.createOrderDetail();
+ detailY.setPrice(2.0f);
+
+ SalesOrder orderX = mf.createSalesOrder();
+ orderX.getOrderDetails().add(detailY);
+ orderX.getOrderDetails().add(detailZ);
+
+ resource.getContents().add(orderX);
+
+ // We need another object to make the later commit partial
+ Product1 product = mf.createProduct1();
+ product.setName("abc");
+ resource.getContents().add(product);
+
+ tx.commit();
+
+ // Remove then add back, so as to change ordering
+ moveIt.move(orderX, detailY);
+
+ // Partial commit
+ Set<EObject> committables = new HashSet<EObject>(1);
+ committables.add(orderX);
+ tx.setCommittables(committables);
+
+ // Make other object dirty too, so that commit becomes 'partial'
+ product.setName("def");
+
+ tx.commit();
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336382_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336382_Test.java
index db94342e88..10fc347565 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336382_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336382_Test.java
@@ -1,60 +1,60 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOMerger;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-/**
- * @author Stefan Winkler
- */
-public class Bugzilla_336382_Test extends AbstractCDOTest
-{
- @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void testPromoteToBranch() throws Exception
- {
- CDOSession session = openSession();
-
- CDOBranch mainBranch = session.getBranchManager().getMainBranch();
- long timestamp = mainBranch.getBase().getTimeStamp();
- CDOBranch sourceBranch = mainBranch.createBranch("branch1", timestamp);
-
- {
- CDOTransaction tx = session.openTransaction(sourceBranch);
- CDOResource res = tx.createResource(getResourcePath("/test"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Foo");
- company.setStreet("Bar");
- company.setCity("somewhere");
- res.getContents().add(company);
- tx.commit();
- }
-
- CDOBranch targetBranch = mainBranch.createBranch("branch2", timestamp);
-
- CDOTransaction transaction = session.openTransaction(targetBranch);
-
- CDOMerger merger = new DefaultCDOMerger.PerFeature.ManyValued();
- transaction.merge(sourceBranch.getHead(), merger);
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOMerger;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_336382_Test extends AbstractCDOTest
+{
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void testPromoteToBranch() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ long timestamp = mainBranch.getBase().getTimeStamp();
+ CDOBranch sourceBranch = mainBranch.createBranch("branch1", timestamp);
+
+ {
+ CDOTransaction tx = session.openTransaction(sourceBranch);
+ CDOResource res = tx.createResource(getResourcePath("/test"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Foo");
+ company.setStreet("Bar");
+ company.setCity("somewhere");
+ res.getContents().add(company);
+ tx.commit();
+ }
+
+ CDOBranch targetBranch = mainBranch.createBranch("branch2", timestamp);
+
+ CDOTransaction transaction = session.openTransaction(targetBranch);
+
+ CDOMerger merger = new DefaultCDOMerger.PerFeature.ManyValued();
+ transaction.merge(sourceBranch.getHead(), merger);
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336590_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336590_Test.java
index ef1d351f73..9e115ab3cf 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336590_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336590_Test.java
@@ -1,149 +1,149 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOConflictResolver2;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.util.collection.Pair;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_336590_Test extends AbstractCDOTest
-{
- private CDOID removedID;
-
- public void test() throws CommitException
- {
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
-
- CDOTransaction tx = session.openTransaction();
- tx.options().addConflictResolver(new TestResolver());
-
- CDOResource resource = tx.createResource(getResourcePath("test"));
- Model1Factory f = getModel1Factory();
- SalesOrder order = f.createSalesOrder();
- for (int i = 0; i < 3; i++)
- {
- order.getOrderDetails().add(f.createOrderDetail());
- }
-
- resource.getContents().add(order);
- tx.commit();
-
- for (int i = 0; i < 3; i++)
- {
- order.getOrderDetails().add(f.createOrderDetail());
- }
-
- OrderDetail newDetail = f.createOrderDetail();
- order.getOrderDetails().add(newDetail);
- System.out.println("---> New object: " + newDetail);
-
- doRemovalInOtherSession();
- session.refresh();
-
- session.close();
- }
-
- private void doRemovalInOtherSession() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.getResource(getResourcePath("test"));
-
- SalesOrder order = (SalesOrder)resource.getContents().get(0);
- OrderDetail removedDetail = order.getOrderDetails().get(0);
- removedID = CDOUtil.getCDOObject(removedDetail).cdoID();
- order.getOrderDetails().remove(0);
-
- tx.commit();
- session.close();
- }
-
- /**
- * @author Caspar De Groot
- */
- private class TestResolver implements CDOConflictResolver2
- {
- private CDOTransaction tx;
-
- public CDOTransaction getTransaction()
- {
- return tx;
- }
-
- public void setTransaction(CDOTransaction transaction)
- {
- tx = transaction;
- }
-
- public void resolveConflicts(Set<CDOObject> conflicts)
- {
- throw new UnsupportedOperationException();
- }
-
- public void resolveConflicts(Map<CDOObject, Pair<CDORevision, CDORevisionDelta>> conflicts,
- List<CDORevisionDelta> allRemoteDeltas)
- {
- assertEquals(1, allRemoteDeltas.size());
-
- List<CDOFeatureDelta> fDeltas = allRemoteDeltas.get(0).getFeatureDeltas();
- assertEquals(1, fDeltas.size());
-
- CDOFeatureDelta fDelta = fDeltas.get(0);
- assertEquals(true, fDelta instanceof CDOListFeatureDelta);
-
- List<CDOFeatureDelta> listDeltas = ((CDOListFeatureDelta)fDelta).getListChanges();
- for (CDOFeatureDelta lDelta : listDeltas)
- {
- System.out.println("---> listDelta: " + lDelta);
- }
-
- // Should find only 1 delta
- assertEquals(1, listDeltas.size());
-
- // And it should be a remove delta
- CDOFeatureDelta lDelta = listDeltas.get(0);
- assertEquals(true, lDelta instanceof CDORemoveFeatureDelta);
-
- // And its value should be a CDOID
- CDORemoveFeatureDelta removeDelta = (CDORemoveFeatureDelta)lDelta;
- Object removedValue = removeDelta.getValue();
- assertEquals(true, removedValue instanceof CDOID);
-
- // And that CDOID should match the CDOID we kept when removing the
- // object in the 2nd session
- assertEquals(removedID.toString(), removedValue.toString());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOConflictResolver2;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.collection.Pair;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_336590_Test extends AbstractCDOTest
+{
+ private CDOID removedID;
+
+ public void test() throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+
+ CDOTransaction tx = session.openTransaction();
+ tx.options().addConflictResolver(new TestResolver());
+
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+ Model1Factory f = getModel1Factory();
+ SalesOrder order = f.createSalesOrder();
+ for (int i = 0; i < 3; i++)
+ {
+ order.getOrderDetails().add(f.createOrderDetail());
+ }
+
+ resource.getContents().add(order);
+ tx.commit();
+
+ for (int i = 0; i < 3; i++)
+ {
+ order.getOrderDetails().add(f.createOrderDetail());
+ }
+
+ OrderDetail newDetail = f.createOrderDetail();
+ order.getOrderDetails().add(newDetail);
+ System.out.println("---> New object: " + newDetail);
+
+ doRemovalInOtherSession();
+ session.refresh();
+
+ session.close();
+ }
+
+ private void doRemovalInOtherSession() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.getResource(getResourcePath("test"));
+
+ SalesOrder order = (SalesOrder)resource.getContents().get(0);
+ OrderDetail removedDetail = order.getOrderDetails().get(0);
+ removedID = CDOUtil.getCDOObject(removedDetail).cdoID();
+ order.getOrderDetails().remove(0);
+
+ tx.commit();
+ session.close();
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private class TestResolver implements CDOConflictResolver2
+ {
+ private CDOTransaction tx;
+
+ public CDOTransaction getTransaction()
+ {
+ return tx;
+ }
+
+ public void setTransaction(CDOTransaction transaction)
+ {
+ tx = transaction;
+ }
+
+ public void resolveConflicts(Set<CDOObject> conflicts)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void resolveConflicts(Map<CDOObject, Pair<CDORevision, CDORevisionDelta>> conflicts,
+ List<CDORevisionDelta> allRemoteDeltas)
+ {
+ assertEquals(1, allRemoteDeltas.size());
+
+ List<CDOFeatureDelta> fDeltas = allRemoteDeltas.get(0).getFeatureDeltas();
+ assertEquals(1, fDeltas.size());
+
+ CDOFeatureDelta fDelta = fDeltas.get(0);
+ assertEquals(true, fDelta instanceof CDOListFeatureDelta);
+
+ List<CDOFeatureDelta> listDeltas = ((CDOListFeatureDelta)fDelta).getListChanges();
+ for (CDOFeatureDelta lDelta : listDeltas)
+ {
+ System.out.println("---> listDelta: " + lDelta);
+ }
+
+ // Should find only 1 delta
+ assertEquals(1, listDeltas.size());
+
+ // And it should be a remove delta
+ CDOFeatureDelta lDelta = listDeltas.get(0);
+ assertEquals(true, lDelta instanceof CDORemoveFeatureDelta);
+
+ // And its value should be a CDOID
+ CDORemoveFeatureDelta removeDelta = (CDORemoveFeatureDelta)lDelta;
+ Object removedValue = removeDelta.getValue();
+ assertEquals(true, removedValue instanceof CDOID);
+
+ // And that CDOID should match the CDOID we kept when removing the
+ // object in the 2nd session
+ assertEquals(removedID.toString(), removedValue.toString());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337054_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337054_Test.java
index c84b21a42b..2bbe51b31f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337054_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337054_Test.java
@@ -1,102 +1,102 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Szabolcs Bardy - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-/**
- * @author Szabolcs Bardy
- */
-public class Bugzilla_337054_Test extends AbstractCDOTest
-{
- private final static String RESOURCE_NAME = "/337054";
-
- private int testedListSize = 3;
-
- @Requires({ IRepositoryConfig.CAPABILITY_BRANCHING, IRepositoryConfig.CAPABILITY_RESTARTABLE })
- public void testCDOElementProxies() throws Exception
- {
- CDOSession session = openSession();
- session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(0, 300));
-
- CDOTransaction mainTransaction = session.openTransaction();
- CDOResource resource = mainTransaction.createResource(getResourcePath(RESOURCE_NAME));
-
- // fill up resource contents if empty
- int actualSize = resource.getContents().size();
- if (actualSize < testedListSize)
- {
- msg("Filling up list...");
-
- for (int i = actualSize; i < testedListSize; i++)
- {
- Company company = getModel1Factory().createCompany();
- company.setName("TestCompany_" + i);
- resource.getContents().add(company);
-
- resource.getContents().add(company);
-
- actualSize++;
- }
-
- msg("Committing data...");
- mainTransaction.commit();
- }
-
- mainTransaction.close();
-
- msg("Creating a branch with a new element: ");
-
- String branchName = String.valueOf(System.currentTimeMillis());
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch(branchName);
-
- Company branchCompany = getModel1Factory().createCompany();
- branchCompany.setName("TestCompany_" + actualSize);
-
- CDOTransaction branchTransaction = session.openTransaction(branch);
- CDOResource branchRootResource = branchTransaction.getOrCreateResource(getResourcePath(RESOURCE_NAME));
- branchRootResource.getContents().add(branchCompany);
-
- branchTransaction.commit();
- branchTransaction.close();
-
- // restart repository
- restartRepository();
-
- session = openSession();
- session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(0, 300));
-
- // merge
- mainTransaction = session.openTransaction(session.getBranchManager().getMainBranch());
- branch = session.getBranchManager().getMainBranch().getBranch(branchName);
-
- resource = mainTransaction.getResource(getResourcePath(RESOURCE_NAME));
- int resourceContentsBeforeMerge = resource.getContents().size();
- msg("Before: " + resourceContentsBeforeMerge);
-
- mainTransaction.merge(branch.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
- mainTransaction.commit();
-
- int resourceContentsAfterMerge = resource.getContents().size();
- msg("After: " + resourceContentsAfterMerge);
-
- assertEquals(resourceContentsBeforeMerge + 1, resourceContentsAfterMerge);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Szabolcs Bardy - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+/**
+ * @author Szabolcs Bardy
+ */
+public class Bugzilla_337054_Test extends AbstractCDOTest
+{
+ private final static String RESOURCE_NAME = "/337054";
+
+ private int testedListSize = 3;
+
+ @Requires({ IRepositoryConfig.CAPABILITY_BRANCHING, IRepositoryConfig.CAPABILITY_RESTARTABLE })
+ public void testCDOElementProxies() throws Exception
+ {
+ CDOSession session = openSession();
+ session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(0, 300));
+
+ CDOTransaction mainTransaction = session.openTransaction();
+ CDOResource resource = mainTransaction.createResource(getResourcePath(RESOURCE_NAME));
+
+ // fill up resource contents if empty
+ int actualSize = resource.getContents().size();
+ if (actualSize < testedListSize)
+ {
+ msg("Filling up list...");
+
+ for (int i = actualSize; i < testedListSize; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setName("TestCompany_" + i);
+ resource.getContents().add(company);
+
+ resource.getContents().add(company);
+
+ actualSize++;
+ }
+
+ msg("Committing data...");
+ mainTransaction.commit();
+ }
+
+ mainTransaction.close();
+
+ msg("Creating a branch with a new element: ");
+
+ String branchName = String.valueOf(System.currentTimeMillis());
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch(branchName);
+
+ Company branchCompany = getModel1Factory().createCompany();
+ branchCompany.setName("TestCompany_" + actualSize);
+
+ CDOTransaction branchTransaction = session.openTransaction(branch);
+ CDOResource branchRootResource = branchTransaction.getOrCreateResource(getResourcePath(RESOURCE_NAME));
+ branchRootResource.getContents().add(branchCompany);
+
+ branchTransaction.commit();
+ branchTransaction.close();
+
+ // restart repository
+ restartRepository();
+
+ session = openSession();
+ session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(0, 300));
+
+ // merge
+ mainTransaction = session.openTransaction(session.getBranchManager().getMainBranch());
+ branch = session.getBranchManager().getMainBranch().getBranch(branchName);
+
+ resource = mainTransaction.getResource(getResourcePath(RESOURCE_NAME));
+ int resourceContentsBeforeMerge = resource.getContents().size();
+ msg("Before: " + resourceContentsBeforeMerge);
+
+ mainTransaction.merge(branch.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ mainTransaction.commit();
+
+ int resourceContentsAfterMerge = resource.getContents().size();
+ msg("After: " + resourceContentsAfterMerge);
+
+ assertEquals(resourceContentsBeforeMerge + 1, resourceContentsAfterMerge);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337523_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337523_Test.java
index 4fe7d36008..f1a7d5de49 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337523_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337523_Test.java
@@ -1,48 +1,48 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Egidijus Vaisnora - initial API and implementation
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-
-import java.util.Map;
-
-/**
- * @author Egidijus Vaisnora, Caspar De Groot
- */
-public class Bugzilla_337523_Test extends AbstractCDOTest
-{
- public void testRootResource_loadByID() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- final CDOID rootID = session.getRepositoryInfo().getRootResourceID();
- CDOObject rootResource1 = transaction.getObject(rootID);
-
- Map<CDOID, InternalCDOObject> objects = ((InternalCDOTransaction)transaction).getObjects();
- CDOObject rootResource2 = objects.get(rootID);
-
- assertNotNull(rootResource2);
- assertSame(rootResource1, rootResource2);
-
- transaction.commit();
- transaction.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Egidijus Vaisnora - initial API and implementation
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+
+import java.util.Map;
+
+/**
+ * @author Egidijus Vaisnora, Caspar De Groot
+ */
+public class Bugzilla_337523_Test extends AbstractCDOTest
+{
+ public void testRootResource_loadByID() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ final CDOID rootID = session.getRepositoryInfo().getRootResourceID();
+ CDOObject rootResource1 = transaction.getObject(rootID);
+
+ Map<CDOID, InternalCDOObject> objects = ((InternalCDOTransaction)transaction).getObjects();
+ CDOObject rootResource2 = objects.get(rootID);
+
+ assertNotNull(rootResource2);
+ assertSame(rootResource1, rootResource2);
+
+ transaction.commit();
+ transaction.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337587_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337587_Test.java
index 79cf2abd90..4365cffef1 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337587_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337587_Test.java
@@ -1,85 +1,85 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-
-/**
- * @author Egidijus Vaisnora
- */
-public class Bugzilla_337587_Test extends AbstractCDOTest
-{
- public void testRevisionCompare() throws CommitException
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test1"));
-
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
- resource.getContents().add(customer);
-
- for (int i = 0; i < 10; i++)
- {
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setId(i);
- salesOrder.setCustomer(customer);
- resource.getContents().add(salesOrder);
- }
-
- transaction.commit();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- // ************************************************************* //
-
- CDOSession session = openSession();
- session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(1, 2));
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("test1"));
-
- Customer customer = (Customer)resource.getContents().get(0);
- EList<SalesOrder> salesOrders = customer.getSalesOrders();
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- resource.getContents().add(salesOrder);
- salesOrders.set(5, salesOrder);
-
- CDOObject cdoResource = CDOUtil.getCDOObject(resource);
- InternalCDORevision cleanRevision = ((InternalCDOTransaction)transaction).getCleanRevisions().get(cdoResource);
-
- try
- {
- cdoResource.cdoRevision().compare(cleanRevision);
- fail("Expected IllegalStateException during comparing EList with CDOProxyElement");
- }
- catch (IllegalStateException expected)
- {
- // expected exception
- }
-
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_337587_Test extends AbstractCDOTest
+{
+ public void testRevisionCompare() throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test1"));
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+ resource.getContents().add(customer);
+
+ for (int i = 0; i < 10; i++)
+ {
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(i);
+ salesOrder.setCustomer(customer);
+ resource.getContents().add(salesOrder);
+ }
+
+ transaction.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ // ************************************************************* //
+
+ CDOSession session = openSession();
+ session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(1, 2));
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("test1"));
+
+ Customer customer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> salesOrders = customer.getSalesOrders();
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ resource.getContents().add(salesOrder);
+ salesOrders.set(5, salesOrder);
+
+ CDOObject cdoResource = CDOUtil.getCDOObject(resource);
+ InternalCDORevision cleanRevision = ((InternalCDOTransaction)transaction).getCleanRevisions().get(cdoResource);
+
+ try
+ {
+ cdoResource.cdoRevision().compare(cleanRevision);
+ fail("Expected IllegalStateException during comparing EList with CDOProxyElement");
+ }
+ catch (IllegalStateException expected)
+ {
+ // expected exception
+ }
+
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338779_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338779_Test.java
index 88da1c9f2b..b2a4640364 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338779_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338779_Test.java
@@ -1,125 +1,125 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.Date;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_338779_Test extends AbstractCDOTest
-{
- private void test(PassiveUpdateMode passiveUpdateMode) throws CommitException
- {
- final CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- if (passiveUpdateMode != null)
- {
- session.options().setPassiveUpdateEnabled(true);
- session.options().setPassiveUpdateMode(passiveUpdateMode);
- }
- else
- {
- session.options().setPassiveUpdateEnabled(false);
- }
- CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
-
- PurchaseOrder po1 = getModel1Factory().createPurchaseOrder();
- po1.setDate(new Date());
- r1.getContents().add(po1);
-
- tx.commit();
-
- check(po1, session);
-
- long timestamp = doSecondSession();
- if (passiveUpdateMode != null)
- {
- session.waitForUpdate(timestamp);
-
- if (passiveUpdateMode == PassiveUpdateMode.INVALIDATIONS)
- {
- // Read something on the object to force load
- po1.getDate();
- }
- }
- else
- {
- session.refresh();
- }
-
- check(po1, session);
-
- tx.close();
- session.close();
- }
-
- public void test_refresh() throws CommitException
- {
- test(null);
- }
-
- public void test_passiveUpdate_invalidations() throws CommitException
- {
- test(PassiveUpdateMode.INVALIDATIONS);
- }
-
- public void test_passiveUpdate_changes() throws CommitException
- {
- test(PassiveUpdateMode.CHANGES);
- }
-
- public void test_passiveUpdate_additions() throws CommitException
- {
- test(PassiveUpdateMode.ADDITIONS);
- }
-
- private void check(EObject eObject, CDOSession session)
- {
- CDOObject obj = CDOUtil.getCDOObject(eObject);
- assertClean(obj, obj.cdoView());
- CDORevision rev1 = obj.cdoRevision();
- CDORevision rev2 = session.getRevisionManager().getRevisionByVersion(rev1.getID(), rev1, 0, false);
- assertEquals(rev1, rev2);
- assertSame(rev1, rev2);
- }
-
- private long doSecondSession() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getResource(getResourcePath("/r1")); //$NON-NLS-1$
-
- // Change the purchaseOrder
- PurchaseOrder po1 = (PurchaseOrder)r1.getContents().get(0);
- po1.setDate(new Date());
-
- CDOCommitInfo commitInfo = tx.commit();
- tx.close();
- session.close();
-
- return commitInfo.getTimeStamp();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.Date;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_338779_Test extends AbstractCDOTest
+{
+ private void test(PassiveUpdateMode passiveUpdateMode) throws CommitException
+ {
+ final CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ if (passiveUpdateMode != null)
+ {
+ session.options().setPassiveUpdateEnabled(true);
+ session.options().setPassiveUpdateMode(passiveUpdateMode);
+ }
+ else
+ {
+ session.options().setPassiveUpdateEnabled(false);
+ }
+ CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ PurchaseOrder po1 = getModel1Factory().createPurchaseOrder();
+ po1.setDate(new Date());
+ r1.getContents().add(po1);
+
+ tx.commit();
+
+ check(po1, session);
+
+ long timestamp = doSecondSession();
+ if (passiveUpdateMode != null)
+ {
+ session.waitForUpdate(timestamp);
+
+ if (passiveUpdateMode == PassiveUpdateMode.INVALIDATIONS)
+ {
+ // Read something on the object to force load
+ po1.getDate();
+ }
+ }
+ else
+ {
+ session.refresh();
+ }
+
+ check(po1, session);
+
+ tx.close();
+ session.close();
+ }
+
+ public void test_refresh() throws CommitException
+ {
+ test(null);
+ }
+
+ public void test_passiveUpdate_invalidations() throws CommitException
+ {
+ test(PassiveUpdateMode.INVALIDATIONS);
+ }
+
+ public void test_passiveUpdate_changes() throws CommitException
+ {
+ test(PassiveUpdateMode.CHANGES);
+ }
+
+ public void test_passiveUpdate_additions() throws CommitException
+ {
+ test(PassiveUpdateMode.ADDITIONS);
+ }
+
+ private void check(EObject eObject, CDOSession session)
+ {
+ CDOObject obj = CDOUtil.getCDOObject(eObject);
+ assertClean(obj, obj.cdoView());
+ CDORevision rev1 = obj.cdoRevision();
+ CDORevision rev2 = session.getRevisionManager().getRevisionByVersion(rev1.getID(), rev1, 0, false);
+ assertEquals(rev1, rev2);
+ assertSame(rev1, rev2);
+ }
+
+ private long doSecondSession() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ // Change the purchaseOrder
+ PurchaseOrder po1 = (PurchaseOrder)r1.getContents().get(0);
+ po1.setDate(new Date());
+
+ CDOCommitInfo commitInfo = tx.commit();
+ tx.close();
+ session.close();
+
+ return commitInfo.getTimeStamp();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java
index 0572ba8354..345c053a03 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java
@@ -1,247 +1,247 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
-import org.eclipse.emf.cdo.tests.model4.RefMultiContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.util.CommitIntegrityException;
-
-import org.eclipse.net4j.util.transaction.TransactionException;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * See bug 338884.
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_338884_Test extends AbstractCDOTest
-{
- public void test_single() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("test"));
-
- // 1. Create object A;
- model4Factory factory = getModel4Factory();
- RefSingleNonContainedNPL referencer = factory.createRefSingleNonContainedNPL();
- resource.getContents().add(referencer);
-
- // 2. Commit;
- tx.commit();
-
- // 3. Create object B;
- ContainedElementNoOpposite element = factory.createContainedElementNoOpposite();
- resource.getContents().add(element);
-
- // 4. Create reference from object A to object B;
- referencer.setElement(element);
-
- // 5. Add object A to committables, but not add B;
- tx.setCommittables(Collections.singleton(referencer));
-
- // 6. Commit.
- try
- {
- tx.commit();
- fail("Should have thrown " + CommitException.class.getName());
- }
- catch (CommitException e)
- {
- Throwable t = e.getCause().getCause();
- if (t instanceof CommitIntegrityException)
- {
- // Good
- }
- else
- {
- fail("Unexpected exception type: " + t.getClass().getName());
- }
- }
-
- tx.close();
- session.close();
- }
-
- public void test_multi() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("test"));
-
- // 1. Create object A;
- model4Factory factory = getModel4Factory();
- RefMultiNonContainedNPL referencer = factory.createRefMultiNonContainedNPL();
- resource.getContents().add(referencer);
-
- // 2. Commit;
- tx.commit();
-
- // 3. Create object B;
- ContainedElementNoOpposite element = factory.createContainedElementNoOpposite();
- resource.getContents().add(element);
-
- // 4. Create reference from object A to object B;
- referencer.getElements().add(element);
-
- // 5. Add object A to committables, but not add B;
- tx.setCommittables(Collections.singleton(referencer));
-
- // 6. Commit.
- try
- {
- tx.commit();
- fail("Should have thrown " + CommitException.class.getName());
- }
- catch (CommitException e)
- {
- Throwable t = e.getCause().getCause();
- if (t instanceof CommitIntegrityException)
- {
- // Good
- }
- else
- {
- fail("Unexpected exception type: " + t.getClass().getName());
- }
- }
-
- tx.close();
- session.close();
- }
-
- public void test_canHandleUnset() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("test"));
-
- model4Factory factory = getModel4Factory();
- ContainedElementNoOpposite dummy = factory.createContainedElementNoOpposite();
- resource.getContents().add(dummy);
-
- RefSingleNonContainedNPL referencer = factory.createRefSingleNonContainedNPL();
- resource.getContents().add(referencer);
-
- ContainedElementNoOpposite referencee = factory.createContainedElementNoOpposite();
- resource.getContents().add(referencee);
-
- referencer.setElement(referencee);
-
- tx.commit();
-
- EReference ref = getModel4Package().getRefSingleNonContainedNPL_Element();
- referencer.eUnset(ref);
-
- // Make the dummy object dirty to make the commit partial
- dummy.setName("dirty");
-
- Set<EObject> committables = new HashSet<EObject>();
- committables.add(referencer);
- committables.add(referencee);
- tx.setCommittables(committables);
- tx.commit();
-
- session.close();
- }
-
- public void test_nonBidiMultiRef_newTarget() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- model4Factory factory = getModel4Factory();
-
- CDOResource resource = transaction.createResource(getResourcePath("test"));
- transaction.commit();
-
- RefMultiContainedNPL parent = factory.createRefMultiContainedNPL();
- resource.getContents().add(parent);
-
- ContainedElementNoOpposite child = factory.createContainedElementNoOpposite();
- parent.getElements().add(child);
-
- transaction.setCommittables(new HashSet<EObject>(Arrays.asList(new EObject[] { resource, parent })));
- try
- {
- transaction.commit();
- fail("Should have thrown an exception");
- }
- catch (CommitException e)
- {
- Throwable c = e.getCause();
- if (c instanceof TransactionException && c.getCause() instanceof CommitIntegrityException)
- {
- // Good
- }
- else
- {
- throw e;
- }
- }
-
- session.close();
- }
-
- public void test_nonBidiSingleRef_newTarget() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- model4Factory factory = getModel4Factory();
-
- CDOResource resource = transaction.createResource(getResourcePath("test"));
- transaction.commit();
-
- RefSingleContainedNPL parent = factory.createRefSingleContainedNPL();
- resource.getContents().add(parent);
-
- ContainedElementNoOpposite child = factory.createContainedElementNoOpposite();
- parent.setElement(child);
-
- transaction.setCommittables(new HashSet<EObject>(Arrays.asList(new EObject[] { resource, parent })));
- try
- {
- transaction.commit();
- fail("Should have thrown an exception");
- }
- catch (CommitException e)
- {
- Throwable c = e.getCause();
- if (c instanceof TransactionException && c.getCause() instanceof CommitIntegrityException)
- {
- // Good
- }
- else
- {
- throw e;
- }
- }
-
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.RefMultiContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.CommitIntegrityException;
+
+import org.eclipse.net4j.util.transaction.TransactionException;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * See bug 338884.
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_338884_Test extends AbstractCDOTest
+{
+ public void test_single() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ // 1. Create object A;
+ model4Factory factory = getModel4Factory();
+ RefSingleNonContainedNPL referencer = factory.createRefSingleNonContainedNPL();
+ resource.getContents().add(referencer);
+
+ // 2. Commit;
+ tx.commit();
+
+ // 3. Create object B;
+ ContainedElementNoOpposite element = factory.createContainedElementNoOpposite();
+ resource.getContents().add(element);
+
+ // 4. Create reference from object A to object B;
+ referencer.setElement(element);
+
+ // 5. Add object A to committables, but not add B;
+ tx.setCommittables(Collections.singleton(referencer));
+
+ // 6. Commit.
+ try
+ {
+ tx.commit();
+ fail("Should have thrown " + CommitException.class.getName());
+ }
+ catch (CommitException e)
+ {
+ Throwable t = e.getCause().getCause();
+ if (t instanceof CommitIntegrityException)
+ {
+ // Good
+ }
+ else
+ {
+ fail("Unexpected exception type: " + t.getClass().getName());
+ }
+ }
+
+ tx.close();
+ session.close();
+ }
+
+ public void test_multi() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ // 1. Create object A;
+ model4Factory factory = getModel4Factory();
+ RefMultiNonContainedNPL referencer = factory.createRefMultiNonContainedNPL();
+ resource.getContents().add(referencer);
+
+ // 2. Commit;
+ tx.commit();
+
+ // 3. Create object B;
+ ContainedElementNoOpposite element = factory.createContainedElementNoOpposite();
+ resource.getContents().add(element);
+
+ // 4. Create reference from object A to object B;
+ referencer.getElements().add(element);
+
+ // 5. Add object A to committables, but not add B;
+ tx.setCommittables(Collections.singleton(referencer));
+
+ // 6. Commit.
+ try
+ {
+ tx.commit();
+ fail("Should have thrown " + CommitException.class.getName());
+ }
+ catch (CommitException e)
+ {
+ Throwable t = e.getCause().getCause();
+ if (t instanceof CommitIntegrityException)
+ {
+ // Good
+ }
+ else
+ {
+ fail("Unexpected exception type: " + t.getClass().getName());
+ }
+ }
+
+ tx.close();
+ session.close();
+ }
+
+ public void test_canHandleUnset() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ model4Factory factory = getModel4Factory();
+ ContainedElementNoOpposite dummy = factory.createContainedElementNoOpposite();
+ resource.getContents().add(dummy);
+
+ RefSingleNonContainedNPL referencer = factory.createRefSingleNonContainedNPL();
+ resource.getContents().add(referencer);
+
+ ContainedElementNoOpposite referencee = factory.createContainedElementNoOpposite();
+ resource.getContents().add(referencee);
+
+ referencer.setElement(referencee);
+
+ tx.commit();
+
+ EReference ref = getModel4Package().getRefSingleNonContainedNPL_Element();
+ referencer.eUnset(ref);
+
+ // Make the dummy object dirty to make the commit partial
+ dummy.setName("dirty");
+
+ Set<EObject> committables = new HashSet<EObject>();
+ committables.add(referencer);
+ committables.add(referencee);
+ tx.setCommittables(committables);
+ tx.commit();
+
+ session.close();
+ }
+
+ public void test_nonBidiMultiRef_newTarget() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ model4Factory factory = getModel4Factory();
+
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+ transaction.commit();
+
+ RefMultiContainedNPL parent = factory.createRefMultiContainedNPL();
+ resource.getContents().add(parent);
+
+ ContainedElementNoOpposite child = factory.createContainedElementNoOpposite();
+ parent.getElements().add(child);
+
+ transaction.setCommittables(new HashSet<EObject>(Arrays.asList(new EObject[] { resource, parent })));
+ try
+ {
+ transaction.commit();
+ fail("Should have thrown an exception");
+ }
+ catch (CommitException e)
+ {
+ Throwable c = e.getCause();
+ if (c instanceof TransactionException && c.getCause() instanceof CommitIntegrityException)
+ {
+ // Good
+ }
+ else
+ {
+ throw e;
+ }
+ }
+
+ session.close();
+ }
+
+ public void test_nonBidiSingleRef_newTarget() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ model4Factory factory = getModel4Factory();
+
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+ transaction.commit();
+
+ RefSingleContainedNPL parent = factory.createRefSingleContainedNPL();
+ resource.getContents().add(parent);
+
+ ContainedElementNoOpposite child = factory.createContainedElementNoOpposite();
+ parent.setElement(child);
+
+ transaction.setCommittables(new HashSet<EObject>(Arrays.asList(new EObject[] { resource, parent })));
+ try
+ {
+ transaction.commit();
+ fail("Should have thrown an exception");
+ }
+ catch (CommitException e)
+ {
+ Throwable c = e.getCause();
+ if (c instanceof TransactionException && c.getCause() instanceof CommitIntegrityException)
+ {
+ // Good
+ }
+ else
+ {
+ throw e;
+ }
+ }
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338921_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338921_Test.java
index 77f64feb20..944d55664f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338921_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338921_Test.java
@@ -1,175 +1,175 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-/**
- * Cannot load resource on a previously cleared ResourceSet
- * <p>
- * See Bug 338921
- *
- * @author Victor Roldan Betancort
- */
-public class Bugzilla_338921_Test extends AbstractCDOTest
-{
- public void testLoadResourceAfterSingleRemoval() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/Bug338921"));
- resource.getContents().add(company);
-
- transaction.commit();
-
- URI uri = resource.getURI();
-
- ResourceSet resourceSet = resource.getResourceSet();
- resourceSet.getResources().remove(resource);
-
- assertInvalid(resource);
-
- Resource resource2 = resourceSet.getResource(uri, true);
- assertNotNull(resource2);
- // forcing transition from PROXY to CLEAN. Revision is loaded
- resource2.getURI();
- assertClean((EObject)resource2, transaction);
-
- }
-
- public void testRemoveDirtyResourceOnResourceSetWithSingleResource() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/Bug338921"));
- resource.getContents().add(company);
-
- transaction.commit();
-
- company.setName("foobar");
- URI uri = resource.getURI();
-
- ResourceSet resourceSet = resource.getResourceSet();
- resourceSet.getResources().remove(resource);
-
- Resource resource2 = resourceSet.getResource(uri, true);
- assertNotNull(resource2);
- // forcing transition from PROXY to CLEAN. Revision is loaded
- resource2.getURI();
- assertClean((EObject)resource2, transaction);
-
- }
-
- public void testRemoveDirtyResourceOnResourceSetWithMultipleResource() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("/Bug338921/res1"));
- CDOResource resource2 = transaction.createResource(getResourcePath("/Bug338921/res2"));
- Company company1 = getModel1Factory().createCompany();
- Company company2 = getModel1Factory().createCompany();
-
- resource1.getContents().add(company1);
- resource2.getContents().add(company2);
-
- transaction.commit();
-
- company1.setName("foo");
- company2.setName("bar");
-
- ResourceSet resourceSet = resource1.getResourceSet();
-
- resourceSet.getResources().remove(resource1);
- assertEquals(true, transaction.isDirty());
- }
-
- public void testLoadResourceAfterClearOnCleanResourceSet() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("/Bug338921/res1"));
- transaction.createResource(getResourcePath("/Bug338921/res2"));
- resource1.getContents().add(company);
-
- transaction.commit();
-
- URI uri = resource1.getURI();
- company.setName("foobar");
-
- ResourceSet resourceSet = resource1.getResourceSet();
- resourceSet.getResources().clear();
-
- assertEquals(true, transaction.isDirty());
- assertInvalid(resource1);
-
- Resource resource3 = resourceSet.getResource(uri, true);
- assertNotNull(resource3);
- // forcing transition from PROXY to CLEAN. Revision is loaded
- resource3.getURI();
- assertClean((EObject)resource3, transaction);
-
- }
-
- public void testLoadResourceAfterClearOnDirtyResourceSet() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource1 = transaction.createResource(getResourcePath("/Bug338921/res1"));
- CDOResource resource2 = transaction.createResource(getResourcePath("/Bug338921/res2"));
- resource1.getContents().add(company);
-
- transaction.commit();
-
- URI uri1 = resource1.getURI();
- URI uri2 = resource2.getURI();
- company.setName("foobar");
-
- ResourceSet resourceSet = resource1.getResourceSet();
- resourceSet.getResources().clear();
-
- assertEquals(true, transaction.isDirty());
- assertInvalid(resource1);
- assertInvalid(resource2);
-
- CDOResource resource3 = (CDOResource)resourceSet.getResource(uri1, true);
- CDOResource resource4 = (CDOResource)resourceSet.getResource(uri2, true);
- assertNotNull(resource3);
- assertNotNull(resource4);
- // forcing transition from PROXY to CLEAN. Revision is loaded
- resource3.getURI();
- assertClean(resource3, transaction);
- resource4.getURI();
- assertClean(resource4, transaction);
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Cannot load resource on a previously cleared ResourceSet
+ * <p>
+ * See Bug 338921
+ *
+ * @author Victor Roldan Betancort
+ */
+public class Bugzilla_338921_Test extends AbstractCDOTest
+{
+ public void testLoadResourceAfterSingleRemoval() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/Bug338921"));
+ resource.getContents().add(company);
+
+ transaction.commit();
+
+ URI uri = resource.getURI();
+
+ ResourceSet resourceSet = resource.getResourceSet();
+ resourceSet.getResources().remove(resource);
+
+ assertInvalid(resource);
+
+ Resource resource2 = resourceSet.getResource(uri, true);
+ assertNotNull(resource2);
+ // forcing transition from PROXY to CLEAN. Revision is loaded
+ resource2.getURI();
+ assertClean((EObject)resource2, transaction);
+
+ }
+
+ public void testRemoveDirtyResourceOnResourceSetWithSingleResource() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/Bug338921"));
+ resource.getContents().add(company);
+
+ transaction.commit();
+
+ company.setName("foobar");
+ URI uri = resource.getURI();
+
+ ResourceSet resourceSet = resource.getResourceSet();
+ resourceSet.getResources().remove(resource);
+
+ Resource resource2 = resourceSet.getResource(uri, true);
+ assertNotNull(resource2);
+ // forcing transition from PROXY to CLEAN. Revision is loaded
+ resource2.getURI();
+ assertClean((EObject)resource2, transaction);
+
+ }
+
+ public void testRemoveDirtyResourceOnResourceSetWithMultipleResource() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("/Bug338921/res1"));
+ CDOResource resource2 = transaction.createResource(getResourcePath("/Bug338921/res2"));
+ Company company1 = getModel1Factory().createCompany();
+ Company company2 = getModel1Factory().createCompany();
+
+ resource1.getContents().add(company1);
+ resource2.getContents().add(company2);
+
+ transaction.commit();
+
+ company1.setName("foo");
+ company2.setName("bar");
+
+ ResourceSet resourceSet = resource1.getResourceSet();
+
+ resourceSet.getResources().remove(resource1);
+ assertEquals(true, transaction.isDirty());
+ }
+
+ public void testLoadResourceAfterClearOnCleanResourceSet() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("/Bug338921/res1"));
+ transaction.createResource(getResourcePath("/Bug338921/res2"));
+ resource1.getContents().add(company);
+
+ transaction.commit();
+
+ URI uri = resource1.getURI();
+ company.setName("foobar");
+
+ ResourceSet resourceSet = resource1.getResourceSet();
+ resourceSet.getResources().clear();
+
+ assertEquals(true, transaction.isDirty());
+ assertInvalid(resource1);
+
+ Resource resource3 = resourceSet.getResource(uri, true);
+ assertNotNull(resource3);
+ // forcing transition from PROXY to CLEAN. Revision is loaded
+ resource3.getURI();
+ assertClean((EObject)resource3, transaction);
+
+ }
+
+ public void testLoadResourceAfterClearOnDirtyResourceSet() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("/Bug338921/res1"));
+ CDOResource resource2 = transaction.createResource(getResourcePath("/Bug338921/res2"));
+ resource1.getContents().add(company);
+
+ transaction.commit();
+
+ URI uri1 = resource1.getURI();
+ URI uri2 = resource2.getURI();
+ company.setName("foobar");
+
+ ResourceSet resourceSet = resource1.getResourceSet();
+ resourceSet.getResources().clear();
+
+ assertEquals(true, transaction.isDirty());
+ assertInvalid(resource1);
+ assertInvalid(resource2);
+
+ CDOResource resource3 = (CDOResource)resourceSet.getResource(uri1, true);
+ CDOResource resource4 = (CDOResource)resourceSet.getResource(uri2, true);
+ assertNotNull(resource3);
+ assertNotNull(resource4);
+ // forcing transition from PROXY to CLEAN. Revision is loaded
+ resource3.getURI();
+ assertClean(resource3, transaction);
+ resource4.getURI();
+ assertClean(resource4, transaction);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339313_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339313_Test.java
index b494c696c1..74f9b7290d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339313_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339313_Test.java
@@ -1,61 +1,61 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_339313_Test extends AbstractCDOTest
-{
- public void test() throws CommitException
- {
- CDOID topObjectID = null;
-
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("test"));
-
- Model1Factory factory = getModel1Factory();
- Category c = factory.createCategory();
- c.getCategories().add(factory.createCategory());
- c.getCategories().add(factory.createCategory());
- resource.getContents().add(c);
-
- tx.commit();
-
- topObjectID = CDOUtil.getCDOObject(c).cdoID();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- CDOBranch main = session.getBranchManager().getMainBranch();
- CDORevision rev = session.getRevisionManager().getRevision(topObjectID, main.getHead(), 1, 1, true);
- msg(rev);
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_339313_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ CDOID topObjectID = null;
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ Model1Factory factory = getModel1Factory();
+ Category c = factory.createCategory();
+ c.getCategories().add(factory.createCategory());
+ c.getCategories().add(factory.createCategory());
+ resource.getContents().add(c);
+
+ tx.commit();
+
+ topObjectID = CDOUtil.getCDOObject(c).cdoID();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ CDOBranch main = session.getBranchManager().getMainBranch();
+ CDORevision rev = session.getRevisionManager().getRevision(topObjectID, main.getHead(), 1, 1, true);
+ msg(rev);
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339461_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339461_Test.java
index eb4e699ca8..47ba14c6af 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339461_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339461_Test.java
@@ -1,83 +1,83 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_339461_Test extends AbstractCDOTest
-{
- public void test() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("test"));
-
- Model1Factory factory = getModel1Factory();
- Company company = factory.createCompany();
- resource.getContents().add(company);
-
- SalesOrder order1 = factory.createSalesOrder();
- SalesOrder order2 = factory.createSalesOrder();
- OrderDetail detail = factory.createOrderDetail();
- order1.getOrderDetails().add(detail);
- resource.getContents().add(order1);
- resource.getContents().add(order2);
- tx.commit();
-
- order1.getOrderDetails().remove(detail);
- order2.getOrderDetails().add(detail);
-
- company.setName("dirty1"); // Ensures partial commit
- tx.setCommittables(createSet(order1, order2, detail));
- tx.commit();
-
- order2.getOrderDetails().remove(detail);
- order1.getOrderDetails().add(detail);
-
- tx.setCommittables(createSet(order1, order2, detail));
- tx.commit();
-
- tx.close();
- session.close();
- }
-
- private Set<EObject> createSet(EObject... objects)
- {
- Set<EObject> committables = new HashSet<EObject>();
- for (EObject o : objects)
- {
- if (o == null)
- {
- throw new NullPointerException();
- }
-
- committables.add(o);
- }
-
- return committables;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_339461_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ Model1Factory factory = getModel1Factory();
+ Company company = factory.createCompany();
+ resource.getContents().add(company);
+
+ SalesOrder order1 = factory.createSalesOrder();
+ SalesOrder order2 = factory.createSalesOrder();
+ OrderDetail detail = factory.createOrderDetail();
+ order1.getOrderDetails().add(detail);
+ resource.getContents().add(order1);
+ resource.getContents().add(order2);
+ tx.commit();
+
+ order1.getOrderDetails().remove(detail);
+ order2.getOrderDetails().add(detail);
+
+ company.setName("dirty1"); // Ensures partial commit
+ tx.setCommittables(createSet(order1, order2, detail));
+ tx.commit();
+
+ order2.getOrderDetails().remove(detail);
+ order1.getOrderDetails().add(detail);
+
+ tx.setCommittables(createSet(order1, order2, detail));
+ tx.commit();
+
+ tx.close();
+ session.close();
+ }
+
+ private Set<EObject> createSet(EObject... objects)
+ {
+ Set<EObject> committables = new HashSet<EObject>();
+ for (EObject o : objects)
+ {
+ if (o == null)
+ {
+ throw new NullPointerException();
+ }
+
+ committables.add(o);
+ }
+
+ return committables;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java
index a83c11febe..a27c43bc87 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java
@@ -1,96 +1,96 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model3.ClassWithIDAttribute;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-import java.io.ByteArrayOutputStream;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_339908_Test extends AbstractCDOTest
-{
- public void testIDAttribute() throws Exception
- {
- String[] ids = new String[10];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test"));
-
- for (int i = 0; i < ids.length; i++)
- {
- String id = java.util.UUID.randomUUID().toString();
- ids[i] = id;
-
- ClassWithIDAttribute object = getModel3Factory().createClassWithIDAttribute();
- object.setId(id);
- resource.getContents().add(object);
- }
-
- transaction.commit();
-
- clearCache(getRepository().getRevisionManager());
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("test"));
-
- int i = 0;
- EList<EObject> contents = resource.getContents();
- for (EObject object : contents)
- {
- assertEquals(ids[i], ((ClassWithIDAttribute)object).getId());
- assertEquals(ids[i], EcoreUtil.getID(object));
- ++i;
- }
- }
-
- @SuppressWarnings("unused")
- private String createXMI() throws Exception
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
- map.put("xmi", new XMIResourceFactoryImpl());
- Resource xmiResource = resourceSet.createResource(URI.createURI("test.xmi"));
-
- for (int i = 0; i < 10; i++)
- {
- ClassWithIDAttribute object = getModel3Factory().createClassWithIDAttribute();
- object.setId(java.util.UUID.randomUUID().toString());
- xmiResource.getContents().add(object);
- }
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- xmiResource.save(baos, null);
-
- String xmi = baos.toString();
- System.out.println(xmi);
- return xmi;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model3.ClassWithIDAttribute;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_339908_Test extends AbstractCDOTest
+{
+ public void testIDAttribute() throws Exception
+ {
+ String[] ids = new String[10];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+
+ for (int i = 0; i < ids.length; i++)
+ {
+ String id = java.util.UUID.randomUUID().toString();
+ ids[i] = id;
+
+ ClassWithIDAttribute object = getModel3Factory().createClassWithIDAttribute();
+ object.setId(id);
+ resource.getContents().add(object);
+ }
+
+ transaction.commit();
+
+ clearCache(getRepository().getRevisionManager());
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
+
+ int i = 0;
+ EList<EObject> contents = resource.getContents();
+ for (EObject object : contents)
+ {
+ assertEquals(ids[i], ((ClassWithIDAttribute)object).getId());
+ assertEquals(ids[i], EcoreUtil.getID(object));
+ ++i;
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private String createXMI() throws Exception
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
+ map.put("xmi", new XMIResourceFactoryImpl());
+ Resource xmiResource = resourceSet.createResource(URI.createURI("test.xmi"));
+
+ for (int i = 0; i < 10; i++)
+ {
+ ClassWithIDAttribute object = getModel3Factory().createClassWithIDAttribute();
+ object.setId(java.util.UUID.randomUUID().toString());
+ xmiResource.getContents().add(object);
+ }
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ xmiResource.save(baos, null);
+
+ String xmi = baos.toString();
+ System.out.println(xmi);
+ return xmi;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java
index 801568152c..07af88e49e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java
@@ -1,322 +1,322 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl;
-import org.eclipse.emf.cdo.server.IRepository.ReadAccessHandler;
-import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesAfter;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.util.TestRevisionManager;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author Egidijus Vaisnora
- */
-@CleanRepositoriesBefore
-@CleanRepositoriesAfter
-public class Bugzilla_340961_Test extends AbstractCDOTest
-{
- private PartialReadAccessHandler handler = new PartialReadAccessHandler();
-
- private final CDORevisionFactory revisionFactory = new CDORevisionFactory()
- {
- public CDORevision createRevision(EClass eClass)
- {
- return new CustomCDORevision(eClass);
- }
- };
-
- @Override
- protected void doSetUp() throws Exception
- {
- // setup RepositoryConfig.PROP_TEST_REVISION_MANAGER is needed for MEM store
- InternalCDORevisionManager internalCDORevisionManager = (InternalCDORevisionManager)getRepositoryConfig()
- .getTestProperty(RepositoryConfig.PROP_TEST_REVISION_MANAGER);
- if (internalCDORevisionManager == null)
- {
- internalCDORevisionManager = new TestRevisionManager();
- getRepositoryConfig().getTestProperties().put(RepositoryConfig.PROP_TEST_REVISION_MANAGER,
- internalCDORevisionManager);
- }
- internalCDORevisionManager.setFactory(revisionFactory);
- super.doSetUp();
- getRepository().addHandler(handler);
- }
-
- /**
- * @category Session
- */
- @Override
- public CDOSession openSession()
- {
- CDOSession openSession = super.openSession();
- CDORevisionManager revisionManager = openSession.getRevisionManager();
- ((InternalCDORevisionManager)revisionManager).deactivate();
- ((InternalCDORevisionManager)revisionManager).setFactory(revisionFactory);
- ((InternalCDORevisionManager)revisionManager).activate();
- return openSession;
- }
-
- /**
- * Create object structure of 3 in a containment, where middle object is "protected" Tests if custom revision was
- * successfully delivered to client. Tests if editing non-protected child elements is allowed
- */
- public void testObjectChilds() throws CommitException, IOException
- {
- CDOID closedCdoID = null;
- CDOID rootObjectID = null;
- {
- // init
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource openResource = transaction.createResource(getResourcePath("openResource"));
- Category rootObject = getModel1Factory().createCategory();
- openResource.getContents().add(rootObject);
- rootObject.getCategories().add(getModel1Factory().createCategory());
- Category closedCategory = getModel1Factory().createCategory();
- rootObject.getCategories().add(closedCategory);
- closedCategory.setName("ProtectedName");
- closedCategory.getCategories().add(getModel1Factory().createCategory());
- rootObject.getCategories().add(getModel1Factory().createCategory());
- transaction.commit();
- assertEquals("ProtectedName", closedCategory.getName());
- assertEquals(1, closedCategory.getCategories().size());
- closedCdoID = CDOUtil.getCDOObject(closedCategory).cdoID();
- rootObjectID = CDOUtil.getCDOObject(rootObject).cdoID();
- handler.setProtectedIDs(Arrays.asList(new CDOID[] { closedCdoID }));
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource openResource = transaction.getResource(getResourcePath("openResource"));
- assertEquals(1, openResource.getContents().size());
-
- // checking if protected object is empty - not readable for user
- CDOObject object = transaction.getObject(closedCdoID);
- CDOUtil.load(object, object.cdoView());
- Category eObject = (Category)CDOUtil.getEObject(object);
- assertEquals(null, eObject.getName());
- assertEquals(0, eObject.getCategories().size());
-
- Category rootCategory = (Category)CDOUtil.getEObject(transaction.getObject(rootObjectID));
- assertEquals(3, rootCategory.getCategories().size());
-
- // simple editing not protected elements. It must not fail
- EcoreUtil.delete(rootCategory.getCategories().get(0), false);
- transaction.commit();
- EcoreUtil.delete(rootCategory.getCategories().get(1), false);
- transaction.commit();
- rootCategory.getCategories().add(getModel1Factory().createCategory());
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- Category rootCategory = (Category)CDOUtil.getEObject(transaction.getObject(rootObjectID));
- assertEquals(2, rootCategory.getCategories().size());
- session.close();
- }
-
- }
-
- /**
- * Test covers case when one user retrieves restricted revision "empty", however another user has rights to see whole
- * revision. Server must ensure to give different copies for users
- */
- public void testMultiUserWork() throws CommitException
- {
- CDOID closedCdoID = null;
- {
- // init
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource openResource = transaction.createResource(getResourcePath("test"));
- Category rootObject = getModel1Factory().createCategory();
- openResource.getContents().add(rootObject);
- Category closedCategory = getModel1Factory().createCategory();
- rootObject.getCategories().add(closedCategory);
- closedCategory.setName("ProtectedName");
- closedCategory.getCategories().add(getModel1Factory().createCategory());
- transaction.commit();
-
- assertEquals("ProtectedName", closedCategory.getName());
- assertEquals(1, closedCategory.getCategories().size());
- closedCdoID = CDOUtil.getCDOObject(closedCategory).cdoID();
- handler.setProtectedIDs(Arrays.asList(new CDOID[] { closedCdoID }));
- session.close();
- }
-
- {
- // asserting that closed object cannot be read. Let say one user cannot see it
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource openResource = transaction.getResource(getResourcePath("test"));
- assertEquals(1, openResource.getContents().size());
-
- // checking if protected object is empty - not readable for user
- CDOObject object = transaction.getObject(closedCdoID);
- CDOUtil.load(object, object.cdoView());
- Category eObject = (Category)CDOUtil.getEObject(object);
- assertEquals(null, eObject.getName());
- assertEquals(0, eObject.getCategories().size());
- session.close();
- }
-
- {
- // opening closed object and checking if another user can see it
- handler.setProtectedIDs(Arrays.asList(new CDOID[] {}));
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource openResource = transaction.getResource(getResourcePath("test"));
- assertEquals(1, openResource.getContents().size());
-
- // checking if protected object is empty - not readable for user
- CDOObject object = transaction.getObject(closedCdoID);
- CDOUtil.load(object, object.cdoView());
- Category eObject = (Category)CDOUtil.getEObject(object);
- assertEquals("ProtectedName", eObject.getName());
- assertEquals(1, eObject.getCategories().size());
- session.close();
- }
- }
-
- /**
- * @author Egidijus Vaisnora
- */
- private static final class PartialReadAccessHandler implements ReadAccessHandler
- {
- private List<CDOID> ids = Collections.emptyList();
-
- public PartialReadAccessHandler()
- {
- }
-
- public void setProtectedIDs(List<CDOID> protectedIds)
- {
- ids = protectedIds;
- }
-
- public void handleRevisionsBeforeSending(ISession session, CDORevision[] revisions,
- List<CDORevision> additionalRevisions) throws RuntimeException
- {
- for (int i = 0; i < revisions.length; i++)
- {
- if (revisions[i] != null && ids.contains(revisions[i].getID()))
- {
- revisions[i] = makePartialRevision((InternalCDORevision)revisions[i]);
- }
- }
-
- for (int i = 0; i < additionalRevisions.size(); i++)
- {
- CDORevision cdoRevision = additionalRevisions.get(i);
- if (cdoRevision != null && ids.contains(cdoRevision.getID()))
- {
- additionalRevisions.set(i, makePartialRevision((InternalCDORevision)cdoRevision));
- }
- }
- }
-
- private InternalCDORevision makePartialRevision(InternalCDORevision revision)
- {
- InternalCDORevision ret = revision.copy();
- EStructuralFeature[] allPersistentFeatures = ret.getClassInfo().getAllPersistentFeatures();
- for (int i = 0; i < allPersistentFeatures.length; i++)
- {
- ret.clear(allPersistentFeatures[i]);
- }
-
- return ret;
- }
- }
-
- /**
- * @author Egidijus Vaisnora
- */
- private static final class CustomCDORevision extends CDORevisionImpl
- {
- public static final byte NORMAL = 0;
-
- private byte mark = NORMAL;
-
- public CustomCDORevision(EClass eClass)
- {
- super(eClass);
- }
-
- protected CustomCDORevision(CustomCDORevision source)
- {
- super(source);
- mark = source.getMark();
- }
-
- public byte getMark()
- {
- return mark;
- }
-
- public void setMark(byte mark)
- {
- this.mark = mark;
- }
-
- @Override
- public InternalCDORevision copy()
- {
- return new CustomCDORevision(this);
- }
-
- @Override
- protected void readSystemValues(CDODataInput in) throws IOException
- {
- super.readSystemValues(in);
- setMark(in.readByte());
- }
-
- @Override
- protected void writeSystemValues(CDODataOutput out) throws IOException
- {
- super.writeSystemValues(out);
- out.writeByte(getMark());
- }
-
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
+import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.server.IRepository.ReadAccessHandler;
+import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesAfter;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.util.TestRevisionManager;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+@CleanRepositoriesBefore
+@CleanRepositoriesAfter
+public class Bugzilla_340961_Test extends AbstractCDOTest
+{
+ private PartialReadAccessHandler handler = new PartialReadAccessHandler();
+
+ private final CDORevisionFactory revisionFactory = new CDORevisionFactory()
+ {
+ public CDORevision createRevision(EClass eClass)
+ {
+ return new CustomCDORevision(eClass);
+ }
+ };
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ // setup RepositoryConfig.PROP_TEST_REVISION_MANAGER is needed for MEM store
+ InternalCDORevisionManager internalCDORevisionManager = (InternalCDORevisionManager)getRepositoryConfig()
+ .getTestProperty(RepositoryConfig.PROP_TEST_REVISION_MANAGER);
+ if (internalCDORevisionManager == null)
+ {
+ internalCDORevisionManager = new TestRevisionManager();
+ getRepositoryConfig().getTestProperties().put(RepositoryConfig.PROP_TEST_REVISION_MANAGER,
+ internalCDORevisionManager);
+ }
+ internalCDORevisionManager.setFactory(revisionFactory);
+ super.doSetUp();
+ getRepository().addHandler(handler);
+ }
+
+ /**
+ * @category Session
+ */
+ @Override
+ public CDOSession openSession()
+ {
+ CDOSession openSession = super.openSession();
+ CDORevisionManager revisionManager = openSession.getRevisionManager();
+ ((InternalCDORevisionManager)revisionManager).deactivate();
+ ((InternalCDORevisionManager)revisionManager).setFactory(revisionFactory);
+ ((InternalCDORevisionManager)revisionManager).activate();
+ return openSession;
+ }
+
+ /**
+ * Create object structure of 3 in a containment, where middle object is "protected" Tests if custom revision was
+ * successfully delivered to client. Tests if editing non-protected child elements is allowed
+ */
+ public void testObjectChilds() throws CommitException, IOException
+ {
+ CDOID closedCdoID = null;
+ CDOID rootObjectID = null;
+ {
+ // init
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource openResource = transaction.createResource(getResourcePath("openResource"));
+ Category rootObject = getModel1Factory().createCategory();
+ openResource.getContents().add(rootObject);
+ rootObject.getCategories().add(getModel1Factory().createCategory());
+ Category closedCategory = getModel1Factory().createCategory();
+ rootObject.getCategories().add(closedCategory);
+ closedCategory.setName("ProtectedName");
+ closedCategory.getCategories().add(getModel1Factory().createCategory());
+ rootObject.getCategories().add(getModel1Factory().createCategory());
+ transaction.commit();
+ assertEquals("ProtectedName", closedCategory.getName());
+ assertEquals(1, closedCategory.getCategories().size());
+ closedCdoID = CDOUtil.getCDOObject(closedCategory).cdoID();
+ rootObjectID = CDOUtil.getCDOObject(rootObject).cdoID();
+ handler.setProtectedIDs(Arrays.asList(new CDOID[] { closedCdoID }));
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource openResource = transaction.getResource(getResourcePath("openResource"));
+ assertEquals(1, openResource.getContents().size());
+
+ // checking if protected object is empty - not readable for user
+ CDOObject object = transaction.getObject(closedCdoID);
+ CDOUtil.load(object, object.cdoView());
+ Category eObject = (Category)CDOUtil.getEObject(object);
+ assertEquals(null, eObject.getName());
+ assertEquals(0, eObject.getCategories().size());
+
+ Category rootCategory = (Category)CDOUtil.getEObject(transaction.getObject(rootObjectID));
+ assertEquals(3, rootCategory.getCategories().size());
+
+ // simple editing not protected elements. It must not fail
+ EcoreUtil.delete(rootCategory.getCategories().get(0), false);
+ transaction.commit();
+ EcoreUtil.delete(rootCategory.getCategories().get(1), false);
+ transaction.commit();
+ rootCategory.getCategories().add(getModel1Factory().createCategory());
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ Category rootCategory = (Category)CDOUtil.getEObject(transaction.getObject(rootObjectID));
+ assertEquals(2, rootCategory.getCategories().size());
+ session.close();
+ }
+
+ }
+
+ /**
+ * Test covers case when one user retrieves restricted revision "empty", however another user has rights to see whole
+ * revision. Server must ensure to give different copies for users
+ */
+ public void testMultiUserWork() throws CommitException
+ {
+ CDOID closedCdoID = null;
+ {
+ // init
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource openResource = transaction.createResource(getResourcePath("test"));
+ Category rootObject = getModel1Factory().createCategory();
+ openResource.getContents().add(rootObject);
+ Category closedCategory = getModel1Factory().createCategory();
+ rootObject.getCategories().add(closedCategory);
+ closedCategory.setName("ProtectedName");
+ closedCategory.getCategories().add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ assertEquals("ProtectedName", closedCategory.getName());
+ assertEquals(1, closedCategory.getCategories().size());
+ closedCdoID = CDOUtil.getCDOObject(closedCategory).cdoID();
+ handler.setProtectedIDs(Arrays.asList(new CDOID[] { closedCdoID }));
+ session.close();
+ }
+
+ {
+ // asserting that closed object cannot be read. Let say one user cannot see it
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource openResource = transaction.getResource(getResourcePath("test"));
+ assertEquals(1, openResource.getContents().size());
+
+ // checking if protected object is empty - not readable for user
+ CDOObject object = transaction.getObject(closedCdoID);
+ CDOUtil.load(object, object.cdoView());
+ Category eObject = (Category)CDOUtil.getEObject(object);
+ assertEquals(null, eObject.getName());
+ assertEquals(0, eObject.getCategories().size());
+ session.close();
+ }
+
+ {
+ // opening closed object and checking if another user can see it
+ handler.setProtectedIDs(Arrays.asList(new CDOID[] {}));
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource openResource = transaction.getResource(getResourcePath("test"));
+ assertEquals(1, openResource.getContents().size());
+
+ // checking if protected object is empty - not readable for user
+ CDOObject object = transaction.getObject(closedCdoID);
+ CDOUtil.load(object, object.cdoView());
+ Category eObject = (Category)CDOUtil.getEObject(object);
+ assertEquals("ProtectedName", eObject.getName());
+ assertEquals(1, eObject.getCategories().size());
+ session.close();
+ }
+ }
+
+ /**
+ * @author Egidijus Vaisnora
+ */
+ private static final class PartialReadAccessHandler implements ReadAccessHandler
+ {
+ private List<CDOID> ids = Collections.emptyList();
+
+ public PartialReadAccessHandler()
+ {
+ }
+
+ public void setProtectedIDs(List<CDOID> protectedIds)
+ {
+ ids = protectedIds;
+ }
+
+ public void handleRevisionsBeforeSending(ISession session, CDORevision[] revisions,
+ List<CDORevision> additionalRevisions) throws RuntimeException
+ {
+ for (int i = 0; i < revisions.length; i++)
+ {
+ if (revisions[i] != null && ids.contains(revisions[i].getID()))
+ {
+ revisions[i] = makePartialRevision((InternalCDORevision)revisions[i]);
+ }
+ }
+
+ for (int i = 0; i < additionalRevisions.size(); i++)
+ {
+ CDORevision cdoRevision = additionalRevisions.get(i);
+ if (cdoRevision != null && ids.contains(cdoRevision.getID()))
+ {
+ additionalRevisions.set(i, makePartialRevision((InternalCDORevision)cdoRevision));
+ }
+ }
+ }
+
+ private InternalCDORevision makePartialRevision(InternalCDORevision revision)
+ {
+ InternalCDORevision ret = revision.copy();
+ EStructuralFeature[] allPersistentFeatures = ret.getClassInfo().getAllPersistentFeatures();
+ for (int i = 0; i < allPersistentFeatures.length; i++)
+ {
+ ret.clear(allPersistentFeatures[i]);
+ }
+
+ return ret;
+ }
+ }
+
+ /**
+ * @author Egidijus Vaisnora
+ */
+ private static final class CustomCDORevision extends CDORevisionImpl
+ {
+ public static final byte NORMAL = 0;
+
+ private byte mark = NORMAL;
+
+ public CustomCDORevision(EClass eClass)
+ {
+ super(eClass);
+ }
+
+ protected CustomCDORevision(CustomCDORevision source)
+ {
+ super(source);
+ mark = source.getMark();
+ }
+
+ public byte getMark()
+ {
+ return mark;
+ }
+
+ public void setMark(byte mark)
+ {
+ this.mark = mark;
+ }
+
+ @Override
+ public InternalCDORevision copy()
+ {
+ return new CustomCDORevision(this);
+ }
+
+ @Override
+ protected void readSystemValues(CDODataInput in) throws IOException
+ {
+ super.readSystemValues(in);
+ setMark(in.readByte());
+ }
+
+ @Override
+ protected void writeSystemValues(CDODataOutput out) throws IOException
+ {
+ super.writeSystemValues(out);
+ out.writeByte(getMark());
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341875_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341875_Test.java
index 6c4466298b..013671c715 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341875_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341875_Test.java
@@ -1,71 +1,71 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model4.RefSingleContained;
-import org.eclipse.emf.cdo.tests.model4.SingleContainedElement;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.ecore.EReference;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_341875_Test extends AbstractCDOTest
-{
- private final model4Factory factory = getModel4Factory();
-
- private EReference ref_elToPar = getModel4Package().getSingleContainedElement_Parent();
-
- private EReference ref_parToEl = getModel4Package().getRefSingleContained_Element();
-
- @Override
- protected void doSetUp() throws Exception
- {
- ref_parToEl.setResolveProxies(true);
- super.doSetUp();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- ref_parToEl.setResolveProxies(false);
- super.doTearDown();
- }
-
- public void test()
- {
- SingleContainedElement element = factory.createSingleContainedElement();
-
- RefSingleContained parent = factory.createRefSingleContained();
- parent.setElement(element);
-
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("test"));
- resource.getContents().add(parent);
-
- assertEquals(CDOState.NEW, CDOUtil.getCDOObject(parent).cdoState());
- assertEquals(CDOState.NEW, CDOUtil.getCDOObject(element).cdoState());
-
- element.eUnset(ref_elToPar);
- assertNull(parent.eGet(ref_parToEl));
-
- tx.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model4.RefSingleContained;
+import org.eclipse.emf.cdo.tests.model4.SingleContainedElement;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_341875_Test extends AbstractCDOTest
+{
+ private final model4Factory factory = getModel4Factory();
+
+ private EReference ref_elToPar = getModel4Package().getSingleContainedElement_Parent();
+
+ private EReference ref_parToEl = getModel4Package().getRefSingleContained_Element();
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ ref_parToEl.setResolveProxies(true);
+ super.doSetUp();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ ref_parToEl.setResolveProxies(false);
+ super.doTearDown();
+ }
+
+ public void test()
+ {
+ SingleContainedElement element = factory.createSingleContainedElement();
+
+ RefSingleContained parent = factory.createRefSingleContained();
+ parent.setElement(element);
+
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+ resource.getContents().add(parent);
+
+ assertEquals(CDOState.NEW, CDOUtil.getCDOObject(parent).cdoState());
+ assertEquals(CDOState.NEW, CDOUtil.getCDOObject(element).cdoState());
+
+ element.eUnset(ref_elToPar);
+ assertNull(parent.eGet(ref_parToEl));
+
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341995_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341995_Test.java
index d96bac7071..42a2066903 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341995_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_341995_Test.java
@@ -1,114 +1,114 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.util.TestSessionManager;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * See bug 341995.
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_341995_Test extends AbstractCDOTest
-{
- public void test() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("test"));
-
- Model1Factory factory = getModel1Factory();
- Category cat = factory.createCategory();
- resource.getContents().add(cat);
- tx.commit();
-
- CDOObject cdoCat = CDOUtil.getCDOObject(cat);
- msg(cdoCat.cdoRevision().getVersion());
-
- long delay = 2000L;
-
- TestSessionManager sessionManager = (TestSessionManager)getRepository().getSessionManager();
- sessionManager.setCommitNotificationDelay(delay);
-
- try
- {
- doSecondSessionAsync();
- sessionManager.getDelayLatch().await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); // Wait until the delay commences
-
- long time1 = System.currentTimeMillis();
-
- // Attempt the lock; this must block for a while, because it needs to receive
- // the commitNotification from the commit in the other session, which we are
- // artificially delaying
- cdoCat.cdoWriteLock().lock(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
-
- long timeTaken = System.currentTimeMillis() - time1;
-
- // We verify that there really was a delay
- assertEquals("timeTaken == " + timeTaken, true, timeTaken >= delay);
-
- tx.close();
- session.close();
- }
- finally
- {
- sessionManager.setCommitNotificationDelay(0L);
- }
- }
-
- private void doSecondSessionAsync() throws CommitException
- {
- Runnable r = new Runnable()
- {
- public void run()
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.getResource(getResourcePath("test"));
-
- Category cat = (Category)resource.getContents().get(0);
- cat.setName("dirty");
-
- CDOCommitInfo info;
-
- try
- {
- info = tx.commit();
- }
- catch (CommitException ex)
- {
- throw new RuntimeException(ex);
- }
-
- msg(info.getTimeStamp());
-
- tx.close();
- session.close();
- }
- };
-
- Thread thread = new Thread(r);
- thread.setDaemon(true);
- thread.start();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.util.TestSessionManager;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * See bug 341995.
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_341995_Test extends AbstractCDOTest
+{
+ public void test() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ Model1Factory factory = getModel1Factory();
+ Category cat = factory.createCategory();
+ resource.getContents().add(cat);
+ tx.commit();
+
+ CDOObject cdoCat = CDOUtil.getCDOObject(cat);
+ msg(cdoCat.cdoRevision().getVersion());
+
+ long delay = 2000L;
+
+ TestSessionManager sessionManager = (TestSessionManager)getRepository().getSessionManager();
+ sessionManager.setCommitNotificationDelay(delay);
+
+ try
+ {
+ doSecondSessionAsync();
+ sessionManager.getDelayLatch().await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); // Wait until the delay commences
+
+ long time1 = System.currentTimeMillis();
+
+ // Attempt the lock; this must block for a while, because it needs to receive
+ // the commitNotification from the commit in the other session, which we are
+ // artificially delaying
+ cdoCat.cdoWriteLock().lock(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+
+ long timeTaken = System.currentTimeMillis() - time1;
+
+ // We verify that there really was a delay
+ assertEquals("timeTaken == " + timeTaken, true, timeTaken >= delay);
+
+ tx.close();
+ session.close();
+ }
+ finally
+ {
+ sessionManager.setCommitNotificationDelay(0L);
+ }
+ }
+
+ private void doSecondSessionAsync() throws CommitException
+ {
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.getResource(getResourcePath("test"));
+
+ Category cat = (Category)resource.getContents().get(0);
+ cat.setName("dirty");
+
+ CDOCommitInfo info;
+
+ try
+ {
+ info = tx.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+
+ msg(info.getTimeStamp());
+
+ tx.close();
+ session.close();
+ }
+ };
+
+ Thread thread = new Thread(r);
+ thread.setDaemon(true);
+ thread.start();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_342130_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_342130_Test.java
index eb0ee50aec..afffd8382f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_342130_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_342130_Test.java
@@ -1,61 +1,61 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_342130_Test extends AbstractCDOTest
-{
- public void test() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("test"));
-
- Model1Factory factory = getModel1Factory();
- Category cat = factory.createCategory();
-
- // List length must be 1 to reproduce problem
- Product1 product1 = factory.createProduct1();
- product1.setName("product1");
- cat.getProducts().add(product1);
- resource.getContents().add(cat);
- tx.commit();
-
- // Add 0 (makes list length 2)
- Product1 product2 = factory.createProduct1();
- product2.setName("product2");
- cat.getProducts().add(0, product2);
-
- // Set 1 (leaves list length 2)
- Product1 product3 = factory.createProduct1();
- product3.setName("product3");
- cat.getProducts().set(1, product3);
-
- // Remove 0 (makes list length 1)
- cat.getProducts().remove(0);
-
- tx.commit();
-
- tx.close();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_342130_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ Model1Factory factory = getModel1Factory();
+ Category cat = factory.createCategory();
+
+ // List length must be 1 to reproduce problem
+ Product1 product1 = factory.createProduct1();
+ product1.setName("product1");
+ cat.getProducts().add(product1);
+ resource.getContents().add(cat);
+ tx.commit();
+
+ // Add 0 (makes list length 2)
+ Product1 product2 = factory.createProduct1();
+ product2.setName("product2");
+ cat.getProducts().add(0, product2);
+
+ // Set 1 (leaves list length 2)
+ Product1 product3 = factory.createProduct1();
+ product3.setName("product3");
+ cat.getProducts().set(1, product3);
+
+ // Remove 0 (makes list length 1)
+ cat.getProducts().remove(0);
+
+ tx.commit();
+
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java
index b03dff21cf..3c18e488ce 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java
@@ -1,91 +1,91 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Egidijus Vaisnora - initial API and implementation
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.transaction.CDOTransactionHandler1;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Egidijus Vaisnora, Caspar De Groot
- */
-public class Bugzilla_343332_Test extends AbstractCDOTest
-{
- public void test() throws CommitException
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test"));
-
- Category category1 = getModel1Factory().createCategory();
- resource.getContents().add(category1);
-
- category1.getCategories().add(getModel1Factory().createCategory());
-
- Category category2 = getModel1Factory().createCategory();
- resource.getContents().add(category2);
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- final CDOObject[] attachedObject = new CDOObject[1];
- transaction.addTransactionHandler(new CDOTransactionHandler1()
- {
- public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta)
- {
- }
-
- public void detachingObject(CDOTransaction transaction, CDOObject object)
- {
- }
-
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- attachedObject[0] = object;
- }
- });
-
- CDOResource resource = transaction.getResource(getResourcePath("test"));
- Category c1 = (Category)resource.getContents().get(0);
- Category nestedCategory = c1.getCategories().get(0);
- CDOObject cdoCategory = CDOUtil.getCDOObject(nestedCategory);
-
- // Detach
- EcoreUtil.remove(nestedCategory);
-
- // Re-attach
- attachedObject[0] = null;
- ((Category)resource.getContents().get(1)).getCategories().add(nestedCategory);
-
- assertNotNull("CDOTransactionHandler1.attachingObject was not called", attachedObject[0]);
- assertEquals(MessageFormat.format("Re-attached object was not the expected object {0}", cdoCategory),
- cdoCategory, attachedObject[0]);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Egidijus Vaisnora - initial API and implementation
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandler1;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Egidijus Vaisnora, Caspar De Groot
+ */
+public class Bugzilla_343332_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+
+ Category category1 = getModel1Factory().createCategory();
+ resource.getContents().add(category1);
+
+ category1.getCategories().add(getModel1Factory().createCategory());
+
+ Category category2 = getModel1Factory().createCategory();
+ resource.getContents().add(category2);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ final CDOObject[] attachedObject = new CDOObject[1];
+ transaction.addTransactionHandler(new CDOTransactionHandler1()
+ {
+ public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta)
+ {
+ }
+
+ public void detachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ }
+
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ attachedObject[0] = object;
+ }
+ });
+
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
+ Category c1 = (Category)resource.getContents().get(0);
+ Category nestedCategory = c1.getCategories().get(0);
+ CDOObject cdoCategory = CDOUtil.getCDOObject(nestedCategory);
+
+ // Detach
+ EcoreUtil.remove(nestedCategory);
+
+ // Re-attach
+ attachedObject[0] = null;
+ ((Category)resource.getContents().get(1)).getCategories().add(nestedCategory);
+
+ assertNotNull("CDOTransactionHandler1.attachingObject was not called", attachedObject[0]);
+ assertEquals(MessageFormat.format("Re-attached object was not the expected object {0}", cdoCategory),
+ cdoCategory, attachedObject[0]);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343471_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343471_Test.java
index a81fc3c780..579935515f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343471_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343471_Test.java
@@ -1,88 +1,88 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Caspar De Groot
- */
-public class Bugzilla_343471_Test extends AbstractCDOTest
-{
- @Skips(IModelConfig.CAPABILITY_LEGACY)
- public void test() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
-
- CDOResource resource1 = tx.createResource(getResourcePath("test1"));
- CDOResource resource2 = tx.createResource(getResourcePath("test2"));
-
- Category c1 = getModel1Factory().createCategory();
- resource1.getContents().add(c1);
-
- Category c2 = getModel1Factory().createCategory();
- c1.getCategories().add(c2);
-
- // c3 serves only to make the later commit partial
- Category c3 = getModel1Factory().createCategory();
- resource2.getContents().add(c3);
-
- tx.commit();
-
- msg("c1 = " + c1);
- msg("c2 = " + c2);
- msg("c3 = " + c3);
-
- msg("resource1 = " + resource1);
- msg("resource2 = " + resource2);
-
- msg("");
- msg("c1's container? " + c1.eContainer());
- msg("c2 contained in c1? " + c1.getCategories().contains(c2));
- msg("c2 contained in c1? " + (c2.eContainer() == c1));
- msg("c2's resource is r2? " + (c2.eResource() == resource2));
-
- // Move c2 from resource1 to resource2
- resource2.getContents().add(c2);
-
- // assertSame(c1, c2.eContainer());
-
- msg("");
- msg("c1's container? " + c1.eContainer());
- msg("c2 contained in c1? " + c1.getCategories().contains(c2));
- msg("c2 contained in c1? " + (c2.eContainer() == c1));
- msg("c2's resource is r2? " + (c2.eResource() == resource2));
-
- // Make c3 dirty so that we can create a partial commit
- c3.setName("X");
-
- Set<EObject> committables = new HashSet<EObject>();
- committables.add(c2);
- committables.add(resource2);
-
- tx.setCommittables(committables);
- tx.commit();
-
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_343471_Test extends AbstractCDOTest
+{
+ @Skips(IModelConfig.CAPABILITY_LEGACY)
+ public void test() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+
+ CDOResource resource1 = tx.createResource(getResourcePath("test1"));
+ CDOResource resource2 = tx.createResource(getResourcePath("test2"));
+
+ Category c1 = getModel1Factory().createCategory();
+ resource1.getContents().add(c1);
+
+ Category c2 = getModel1Factory().createCategory();
+ c1.getCategories().add(c2);
+
+ // c3 serves only to make the later commit partial
+ Category c3 = getModel1Factory().createCategory();
+ resource2.getContents().add(c3);
+
+ tx.commit();
+
+ msg("c1 = " + c1);
+ msg("c2 = " + c2);
+ msg("c3 = " + c3);
+
+ msg("resource1 = " + resource1);
+ msg("resource2 = " + resource2);
+
+ msg("");
+ msg("c1's container? " + c1.eContainer());
+ msg("c2 contained in c1? " + c1.getCategories().contains(c2));
+ msg("c2 contained in c1? " + (c2.eContainer() == c1));
+ msg("c2's resource is r2? " + (c2.eResource() == resource2));
+
+ // Move c2 from resource1 to resource2
+ resource2.getContents().add(c2);
+
+ // assertSame(c1, c2.eContainer());
+
+ msg("");
+ msg("c1's container? " + c1.eContainer());
+ msg("c2 contained in c1? " + c1.getCategories().contains(c2));
+ msg("c2 contained in c1? " + (c2.eContainer() == c1));
+ msg("c2's resource is r2? " + (c2.eResource() == resource2));
+
+ // Make c3 dirty so that we can create a partial commit
+ c3.setName("X");
+
+ Set<EObject> committables = new HashSet<EObject>();
+ committables.add(c2);
+ committables.add(resource2);
+
+ tx.setCommittables(committables);
+ tx.commit();
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349793_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349793_Test.java
index 6c83c18e05..0582dc1774 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349793_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349793_Test.java
@@ -1,104 +1,104 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
-import java.util.concurrent.CountDownLatch;
-
-/**
- * @author Egidijus Vaisnora
- */
-public class Bugzilla_349793_Test extends AbstractCDOTest
-{
- /**
- * Creates new transaction at the same time when notification has been sent
- */
- public void testOpeningTransactionDuringInvalidation() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.createResource(getResourcePath("test"));
-
- Model1Factory factory = getModel1Factory();
- Category cat = factory.createCategory();
- resource.getContents().add(cat);
- tx.commit();
-
- final CountDownLatch invalidationLatch = new CountDownLatch(1);
- final CountDownLatch testExecutionLatch = new CountDownLatch(1);
- tx.addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOViewInvalidationEvent)
- {
- try
- {
- testExecutionLatch.countDown();
- invalidationLatch.await();
- }
- catch (InterruptedException ex)
- {
- Thread.currentThread().interrupt();
- }
- }
- }
- });
-
- long timestamp = doSecondSessionSync();
- testExecutionLatch.await();
- CDOTransaction freshTransaction = session.openTransaction();
- invalidationLatch.countDown();
-
- // wait for update from server
- freshTransaction.waitForUpdate(timestamp, DEFAULT_TIMEOUT);
-
- session.close();
- }
-
- private long doSecondSessionSync() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource resource = tx.getResource(getResourcePath("test"));
-
- Category cat = (Category)resource.getContents().get(0);
- cat.setName("dirty");
- CDOCommitInfo info;
-
- try
- {
- info = tx.commit();
- }
- catch (CommitException ex)
- {
- throw new RuntimeException(ex);
- }
-
- long timeStamp = info.getTimeStamp();
- msg(timeStamp);
-
- session.close();
- return timeStamp;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_349793_Test extends AbstractCDOTest
+{
+ /**
+ * Creates new transaction at the same time when notification has been sent
+ */
+ public void testOpeningTransactionDuringInvalidation() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ Model1Factory factory = getModel1Factory();
+ Category cat = factory.createCategory();
+ resource.getContents().add(cat);
+ tx.commit();
+
+ final CountDownLatch invalidationLatch = new CountDownLatch(1);
+ final CountDownLatch testExecutionLatch = new CountDownLatch(1);
+ tx.addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOViewInvalidationEvent)
+ {
+ try
+ {
+ testExecutionLatch.countDown();
+ invalidationLatch.await();
+ }
+ catch (InterruptedException ex)
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+ });
+
+ long timestamp = doSecondSessionSync();
+ testExecutionLatch.await();
+ CDOTransaction freshTransaction = session.openTransaction();
+ invalidationLatch.countDown();
+
+ // wait for update from server
+ freshTransaction.waitForUpdate(timestamp, DEFAULT_TIMEOUT);
+
+ session.close();
+ }
+
+ private long doSecondSessionSync() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.getResource(getResourcePath("test"));
+
+ Category cat = (Category)resource.getContents().get(0);
+ cat.setName("dirty");
+ CDOCommitInfo info;
+
+ try
+ {
+ info = tx.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+
+ long timeStamp = info.getTimeStamp();
+ msg(timeStamp);
+
+ session.close();
+ return timeStamp;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349804_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349804_Test.java
index c5937b50de..a5131107a4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349804_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_349804_Test.java
@@ -1,156 +1,156 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOLock;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository.WriteAccessHandler;
-import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
-import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-/**
- * @author Egidijus Vaisnora
- */
-public class Bugzilla_349804_Test extends AbstractCDOTest
-{
- public void testInvalidation() throws CommitException, InterruptedException
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
-
- transaction1.createResource(getResourcePath("test"));
- transaction1.commit();
-
- Failure handler = new Failure();
- getRepository().addHandler(handler);
- CDOTransaction failureTransaction = session.openTransaction();
- failureTransaction.createResource(getResourcePath("fail"));
-
- try
- {
- // Creating failure commit. It will change last update time on server TimeStampAuthority
- failureTransaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- }
-
- getRepository().removeHandler(handler);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- final CountDownLatch invalidationLatch = new CountDownLatch(1);
- session.addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOSessionInvalidationEvent)
- {
- invalidationLatch.countDown();
- }
- }
- });
-
- Company createCompany = getModel1Factory().createCompany();
- CDOResource resource = transaction.getResource(getResourcePath("test"));
- resource.getContents().add(createCompany);
-
- // Invalidation shall fail, because it will use lastUpdateTime from TimeStampAuthority for commit result
- transaction.commit();
-
- invalidationLatch.await(500, TimeUnit.MILLISECONDS);
- assertEquals("Invalidation was not delivered", 0, invalidationLatch.getCount());
- }
-
- public void testDeadlockWithLocking() throws CommitException, InterruptedException, TimeoutException
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction1 = session.openTransaction();
-
- transaction1.createResource(getResourcePath("test"));
- transaction1.commit();
-
- Failure handler = new Failure();
- getRepository().addHandler(handler);
-
- CDOTransaction failureTransaction = session.openTransaction();
- failureTransaction.createResource(getResourcePath("fail"));
-
- try
- {
- // Creating failure commit. It will change last update time on server TimeStampAuthority
- failureTransaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- }
-
- getRepository().removeHandler(handler);
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOTransaction updaterTransaction = session.openTransaction();
-
- CDOResource resourceOnUpdater = updaterTransaction.getResource(getResourcePath("test"));
- // Resolve PROXY state
- resourceOnUpdater.getName();
-
- Company createCompany = getModel1Factory().createCompany();
- CDOResource resource = transaction.getResource(getResourcePath("test"));
- resource.getContents().add(createCompany);
- // Invalidation shall fail, because it will use lastUpdateTime from TimeStampAuthority for commit result
- transaction.commit();
-
- CDOLock cdoWriteLock = resourceOnUpdater.cdoWriteLock();
- // Waiting for commit which already happen
- cdoWriteLock.lock(1000);
- }
-
- /**
- * @author Egidijus Vaisnora
- */
- private class Failure implements WriteAccessHandler
- {
- public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
- OMMonitor monitor) throws RuntimeException
- {
- throw new IllegalArgumentException("Fail on purpose");
- }
-
- public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext, OMMonitor monitor)
- {
- // Do nothing
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOLock;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository.WriteAccessHandler;
+import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_349804_Test extends AbstractCDOTest
+{
+ public void testInvalidation() throws CommitException, InterruptedException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+
+ transaction1.createResource(getResourcePath("test"));
+ transaction1.commit();
+
+ Failure handler = new Failure();
+ getRepository().addHandler(handler);
+ CDOTransaction failureTransaction = session.openTransaction();
+ failureTransaction.createResource(getResourcePath("fail"));
+
+ try
+ {
+ // Creating failure commit. It will change last update time on server TimeStampAuthority
+ failureTransaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+
+ getRepository().removeHandler(handler);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ final CountDownLatch invalidationLatch = new CountDownLatch(1);
+ session.addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOSessionInvalidationEvent)
+ {
+ invalidationLatch.countDown();
+ }
+ }
+ });
+
+ Company createCompany = getModel1Factory().createCompany();
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
+ resource.getContents().add(createCompany);
+
+ // Invalidation shall fail, because it will use lastUpdateTime from TimeStampAuthority for commit result
+ transaction.commit();
+
+ invalidationLatch.await(500, TimeUnit.MILLISECONDS);
+ assertEquals("Invalidation was not delivered", 0, invalidationLatch.getCount());
+ }
+
+ public void testDeadlockWithLocking() throws CommitException, InterruptedException, TimeoutException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+
+ transaction1.createResource(getResourcePath("test"));
+ transaction1.commit();
+
+ Failure handler = new Failure();
+ getRepository().addHandler(handler);
+
+ CDOTransaction failureTransaction = session.openTransaction();
+ failureTransaction.createResource(getResourcePath("fail"));
+
+ try
+ {
+ // Creating failure commit. It will change last update time on server TimeStampAuthority
+ failureTransaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+
+ getRepository().removeHandler(handler);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOTransaction updaterTransaction = session.openTransaction();
+
+ CDOResource resourceOnUpdater = updaterTransaction.getResource(getResourcePath("test"));
+ // Resolve PROXY state
+ resourceOnUpdater.getName();
+
+ Company createCompany = getModel1Factory().createCompany();
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
+ resource.getContents().add(createCompany);
+ // Invalidation shall fail, because it will use lastUpdateTime from TimeStampAuthority for commit result
+ transaction.commit();
+
+ CDOLock cdoWriteLock = resourceOnUpdater.cdoWriteLock();
+ // Waiting for commit which already happen
+ cdoWriteLock.lock(1000);
+ }
+
+ /**
+ * @author Egidijus Vaisnora
+ */
+ private class Failure implements WriteAccessHandler
+ {
+ public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor) throws RuntimeException
+ {
+ throw new IllegalArgumentException("Fail on purpose");
+ }
+
+ public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext, OMMonitor monitor)
+ {
+ // Do nothing
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_350027_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_350027_Test.java
index ff10f6b63b..0319de7795 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_350027_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_350027_Test.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOMoveFeatureDeltaImpl;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-
-/**
- * Fix index for moves from left to right.
- * <p>
- * See bug 350027
- *
- * @author Cyril Jaquier
- */
-@CleanRepositoriesBefore
-public class Bugzilla_350027_Test extends AbstractCDOTest
-{
- public void testMoveFromLeftToRight() throws Exception
- {
- // ABCD (before move)
- // ACDB (after move from 1 => 3)
- CDOMoveFeatureDeltaImpl move = new CDOMoveFeatureDeltaImpl(getModel1Package().getAddress_Name(), 3, 1);
-
- // This simulates the removal of D which is at position 3 before the move
- move.adjustAfterRemoval(3);
-
- // We should end up with ACB which correspond to a move from 1 => 2
- assertEquals(1, move.getOldPosition());
- assertEquals(2, move.getNewPosition());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOMoveFeatureDeltaImpl;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+
+/**
+ * Fix index for moves from left to right.
+ * <p>
+ * See bug 350027
+ *
+ * @author Cyril Jaquier
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_350027_Test extends AbstractCDOTest
+{
+ public void testMoveFromLeftToRight() throws Exception
+ {
+ // ABCD (before move)
+ // ACDB (after move from 1 => 3)
+ CDOMoveFeatureDeltaImpl move = new CDOMoveFeatureDeltaImpl(getModel1Package().getAddress_Name(), 3, 1);
+
+ // This simulates the removal of D which is at position 3 before the move
+ move.adjustAfterRemoval(3);
+
+ // We should end up with ACB which correspond to a move from 1 => 2
+ assertEquals(1, move.getOldPosition());
+ assertEquals(2, move.getNewPosition());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351067_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351067_Test.java
index b1bf728973..e29938bc6a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351067_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351067_Test.java
@@ -1,77 +1,77 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.lob.CDOBlob;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.bundle.OM;
-import org.eclipse.emf.cdo.tests.model3.Image;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.io.InputStream;
-
-/**
- * @author Egidijus Vaisnora
- */
-public class Bugzilla_351067_Test extends AbstractCDOTest
-{
- public void testCommitBlob() throws Exception
- {
- skipStoreWithoutLargeObjects();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("res"));
-
- InputStream inputStream = null;
-
- try
- {
- inputStream = OM.BUNDLE.getInputStream("copyright.txt");
- CDOBlob blob = new CDOBlob(inputStream);
-
- Image image = getModel3Factory().createImage();
- image.setWidth(320);
- image.setHeight(200);
- image.setData(blob);
-
- resource.getContents().add(image);
-
- transaction.commit();
- }
- finally
- {
- IOUtil.close(inputStream);
- }
-
- try
- {
- inputStream = OM.BUNDLE.getInputStream("copyright.txt");
- CDOBlob blob = new CDOBlob(inputStream);
-
- Image image = getModel3Factory().createImage();
- image.setWidth(320);
- image.setHeight(200);
- image.setData(blob);
- resource.getContents().add(image);
-
- transaction.commit();
- }
- finally
- {
- IOUtil.close(inputStream);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.lob.CDOBlob;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.bundle.OM;
+import org.eclipse.emf.cdo.tests.model3.Image;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.InputStream;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_351067_Test extends AbstractCDOTest
+{
+ public void testCommitBlob() throws Exception
+ {
+ skipStoreWithoutLargeObjects();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+
+ InputStream inputStream = null;
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOBlob blob = new CDOBlob(inputStream);
+
+ Image image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+ image.setData(blob);
+
+ resource.getContents().add(image);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOBlob blob = new CDOBlob(inputStream);
+
+ Image image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+ image.setData(blob);
+ resource.getContents().add(image);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351096_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351096_Test.java
index a194cefa19..9d0ea5fd97 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351096_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351096_Test.java
@@ -1,109 +1,109 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.lob.CDOBlob;
-import org.eclipse.emf.cdo.common.lob.CDOClob;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.bundle.OM;
-import org.eclipse.emf.cdo.tests.model3.File;
-import org.eclipse.emf.cdo.tests.model3.Image;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-/**
- * @author Egidijus Vaisnora
- */
-public class Bugzilla_351096_Test extends AbstractCDOTest
-{
- public void testCommit2Blob() throws Exception
- {
- skipStoreWithoutLargeObjects();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("res"));
-
- InputStream inputStream = null;
-
- try
- {
- inputStream = OM.BUNDLE.getInputStream("copyright.txt");
- CDOBlob blob = new CDOBlob(inputStream);
-
- Image image = getModel3Factory().createImage();
- image.setWidth(320);
- image.setHeight(200);
- image.setData(blob);
-
- resource.getContents().add(image);
-
- inputStream = new ByteArrayInputStream("Just another stream".getBytes());
- blob = new CDOBlob(inputStream);
-
- image = getModel3Factory().createImage();
- image.setWidth(320);
- image.setHeight(200);
- image.setData(blob);
-
- resource.getContents().add(image);
-
- transaction.commit();
- }
- finally
- {
- IOUtil.close(inputStream);
- }
- }
-
- public void testCommit2Clob() throws Exception
- {
- skipStoreWithoutLargeObjects();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("res"));
-
- InputStream inputStream = null;
-
- try
- {
- inputStream = OM.BUNDLE.getInputStream("copyright.txt");
- CDOClob clob = new CDOClob(new InputStreamReader(inputStream));
- File file = getModel3Factory().createFile();
- file.setName("copyright.txt");
- file.setData(clob);
-
- resource.getContents().add(file);
-
- inputStream = new ByteArrayInputStream("Just another stream".getBytes());
- clob = new CDOClob(new InputStreamReader(inputStream));
- file = getModel3Factory().createFile();
- file.setName("xxx.txt");
- file.setData(clob);
-
- resource.getContents().add(file);
-
- transaction.commit();
- }
- finally
- {
- IOUtil.close(inputStream);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.lob.CDOBlob;
+import org.eclipse.emf.cdo.common.lob.CDOClob;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.bundle.OM;
+import org.eclipse.emf.cdo.tests.model3.File;
+import org.eclipse.emf.cdo.tests.model3.Image;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_351096_Test extends AbstractCDOTest
+{
+ public void testCommit2Blob() throws Exception
+ {
+ skipStoreWithoutLargeObjects();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+
+ InputStream inputStream = null;
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOBlob blob = new CDOBlob(inputStream);
+
+ Image image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+ image.setData(blob);
+
+ resource.getContents().add(image);
+
+ inputStream = new ByteArrayInputStream("Just another stream".getBytes());
+ blob = new CDOBlob(inputStream);
+
+ image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+ image.setData(blob);
+
+ resource.getContents().add(image);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+
+ public void testCommit2Clob() throws Exception
+ {
+ skipStoreWithoutLargeObjects();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+
+ InputStream inputStream = null;
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOClob clob = new CDOClob(new InputStreamReader(inputStream));
+ File file = getModel3Factory().createFile();
+ file.setName("copyright.txt");
+ file.setData(clob);
+
+ resource.getContents().add(file);
+
+ inputStream = new ByteArrayInputStream("Just another stream".getBytes());
+ clob = new CDOClob(new InputStreamReader(inputStream));
+ file = getModel3Factory().createFile();
+ file.setName("xxx.txt");
+ file.setData(clob);
+
+ resource.getContents().add(file);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351393_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351393_Test.java
index 9486f6752e..4e7858470a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351393_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351393_Test.java
@@ -1,70 +1,70 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-/**
- * @author Stefan Winkler
- */
-public class Bugzilla_351393_Test extends AbstractCDOTest
-{
- public void testExtRef() throws Exception
- {
- skipStoreWithoutExternalReferences();
-
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
- URI uri = URI.createURI("test:///tmp/file.xmi?" + "12345678901234567890" + // 41
- "12345678901234567890" + // 61
- "12345678901234567890" + // 81
- "12345678901234567890" + // 101
- "12345678901234567890" + // 121
- "12345678901234567890" + // 141
- "12345678901234567890" + // 161
- "12345678901234567890" + // 181
- "12345678901234567890" + // 201
- "12345678901234567890" + // 221
- "12345678901234567890" + // 241
- "12345678901234567890" + // 261
- "12345678901234567890" + // 281
- "12345678901234567890" + // 301
- "12345678901234567890"); // 321 characters (> 256)
-
- Resource extRes = resourceSet.createResource(uri);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test1"));
-
- resourceSet.getResource(resource.getURI(), false);
-
- OrderDetail od1 = getModel1Factory().createOrderDetail();
- Product1 p1 = getModel1Factory().createProduct1();
- p1.getOrderDetails().add(od1);
-
- resource.getContents().add(p1);
- extRes.getContents().add(od1);
-
- transaction.commit();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_351393_Test extends AbstractCDOTest
+{
+ public void testExtRef() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("test", new XMIResourceFactoryImpl());
+ URI uri = URI.createURI("test:///tmp/file.xmi?" + "12345678901234567890" + // 41
+ "12345678901234567890" + // 61
+ "12345678901234567890" + // 81
+ "12345678901234567890" + // 101
+ "12345678901234567890" + // 121
+ "12345678901234567890" + // 141
+ "12345678901234567890" + // 161
+ "12345678901234567890" + // 181
+ "12345678901234567890" + // 201
+ "12345678901234567890" + // 221
+ "12345678901234567890" + // 241
+ "12345678901234567890" + // 261
+ "12345678901234567890" + // 281
+ "12345678901234567890" + // 301
+ "12345678901234567890"); // 321 characters (> 256)
+
+ Resource extRes = resourceSet.createResource(uri);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test1"));
+
+ resourceSet.getResource(resource.getURI(), false);
+
+ OrderDetail od1 = getModel1Factory().createOrderDetail();
+ Product1 p1 = getModel1Factory().createProduct1();
+ p1.getOrderDetails().add(od1);
+
+ resource.getContents().add(p1);
+ extRes.getContents().add(od1);
+
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351921_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351921_Test.java
index cd2cb6e2d4..379935bfd6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351921_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351921_Test.java
@@ -1,139 +1,139 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * @author Stefan Winkler
- */
-public class Bugzilla_351921_Test extends AbstractCDOTest
-{
- private EPackage pkg;
-
- private EClass cls;
-
- private EAttribute att;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- pkg = EMFUtil.createEPackage("customTest", "ct", "http://cdo.emf.eclipse.org/customTest.ecore");
- EDataType custom = EcoreFactory.eINSTANCE.createEDataType();
- custom.setInstanceClass(CustomType.class);
- custom.setName("CustomType");
-
- pkg.getEClassifiers().add(custom);
-
- cls = EMFUtil.createEClass(pkg, "Foobar", false, false);
- att = EMFUtil.createEAttribute(cls, "att", custom);
- att.setDefaultValue(null);
-
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- protected EAttribute getAtt()
- {
- return att;
- }
-
- public void testDefaultValueNull() throws CommitException
- {
- EObject obj = EcoreUtil.create(cls);
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction tx = session.openTransaction();
- CDOResource res = tx.createResource(getResourcePath("/test"));
- res.getContents().add(obj);
- tx.commit();
- tx.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView v = session.openView();
- CDOResource res = v.getResource(getResourcePath("/test"));
- EObject persistent = res.getContents().get(0);
-
- CustomType pCustom = (CustomType)persistent.eGet(att);
- assertNull(pCustom);
-
- v.close();
- session.close();
- }
- }
-
- public static class CustomType
- {
- private int a = 0;
-
- private int b = 0;
-
- public CustomType(int _a, int _b)
- {
- a = _a;
- b = _b;
- }
-
- public CustomType(String literal)
- {
- String[] values = literal.split(";");
- if (values.length != 2)
- {
- throw new RuntimeException("Error: only 2 values allowed");
- }
- else
- {
- a = Integer.valueOf(values[0]);
- b = Integer.valueOf(values[1]);
- }
- }
-
- @Override
- public String toString()
- {
- return a + ";" + b;
- }
-
- public int getA()
- {
- return a;
- }
-
- public int getB()
- {
- return b;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_351921_Test extends AbstractCDOTest
+{
+ private EPackage pkg;
+
+ private EClass cls;
+
+ private EAttribute att;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ pkg = EMFUtil.createEPackage("customTest", "ct", "http://cdo.emf.eclipse.org/customTest.ecore");
+ EDataType custom = EcoreFactory.eINSTANCE.createEDataType();
+ custom.setInstanceClass(CustomType.class);
+ custom.setName("CustomType");
+
+ pkg.getEClassifiers().add(custom);
+
+ cls = EMFUtil.createEClass(pkg, "Foobar", false, false);
+ att = EMFUtil.createEAttribute(cls, "att", custom);
+ att.setDefaultValue(null);
+
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ protected EAttribute getAtt()
+ {
+ return att;
+ }
+
+ public void testDefaultValueNull() throws CommitException
+ {
+ EObject obj = EcoreUtil.create(cls);
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource(getResourcePath("/test"));
+ res.getContents().add(obj);
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView v = session.openView();
+ CDOResource res = v.getResource(getResourcePath("/test"));
+ EObject persistent = res.getContents().get(0);
+
+ CustomType pCustom = (CustomType)persistent.eGet(att);
+ assertNull(pCustom);
+
+ v.close();
+ session.close();
+ }
+ }
+
+ public static class CustomType
+ {
+ private int a = 0;
+
+ private int b = 0;
+
+ public CustomType(int _a, int _b)
+ {
+ a = _a;
+ b = _b;
+ }
+
+ public CustomType(String literal)
+ {
+ String[] values = literal.split(";");
+ if (values.length != 2)
+ {
+ throw new RuntimeException("Error: only 2 values allowed");
+ }
+ else
+ {
+ a = Integer.valueOf(values[0]);
+ b = Integer.valueOf(values[1]);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return a + ";" + b;
+ }
+
+ public int getA()
+ {
+ return a;
+ }
+
+ public int getB()
+ {
+ return b;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_352303_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_352303_Test.java
index e9e5e541fb..86ef0360c8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_352303_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_352303_Test.java
@@ -1,71 +1,71 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.common.lob.CDOBlob;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model3.Image;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.io.InputStream;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_352303_Test extends AbstractCDOTest
-{
- @CleanRepositoriesBefore
- public void testReadBlob() throws Exception
- {
- commitBlob();
-
- getRepository().getRevisionManager().getCache().clear();
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("res"));
-
- Image image = (Image)resource.getContents().get(0);
- assertEquals(320, image.getWidth());
- assertEquals(200, image.getHeight());
-
- CDOBlob blob = image.getData();
- assertEquals(null, blob);
- }
-
- private void commitBlob() throws Exception
- {
- InputStream inputStream = null;
-
- try
- {
- Image image = getModel3Factory().createImage();
- image.setWidth(320);
- image.setHeight(200);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("res"));
- resource.getContents().add(image);
-
- transaction.commit();
- }
- finally
- {
- IOUtil.close(inputStream);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.lob.CDOBlob;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model3.Image;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.InputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_352303_Test extends AbstractCDOTest
+{
+ @CleanRepositoriesBefore
+ public void testReadBlob() throws Exception
+ {
+ commitBlob();
+
+ getRepository().getRevisionManager().getCache().clear();
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("res"));
+
+ Image image = (Image)resource.getContents().get(0);
+ assertEquals(320, image.getWidth());
+ assertEquals(200, image.getHeight());
+
+ CDOBlob blob = image.getData();
+ assertEquals(null, blob);
+ }
+
+ private void commitBlob() throws Exception
+ {
+ InputStream inputStream = null;
+
+ try
+ {
+ Image image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+ resource.getContents().add(image);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_354395_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_354395_Test.java
index 3c1362e8c0..a7fe474fbb 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_354395_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_354395_Test.java
@@ -1,140 +1,140 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.util.EList;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-/**
- * ContainsAll with detached objects
- * <p>
- * See bug
- *
- * @author Stefan Schedl
- */
-public class Bugzilla_354395_Test extends AbstractCDOTest
-{
- public void testContains() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
-
- Company company = getModel1Factory().createCompany();
- company.getSalesOrders().add(salesOrder);
-
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
- customer.getSalesOrders().add(salesOrder);
-
- company.getCustomers().add(customer);
- resource.getContents().add(company);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Company company = (Company)resource.getContents().get(0);
- SalesOrder salesOrder = company.getSalesOrders().get(0);
-
- // remove salesOrder from its containment list, salesOrder now detached
- company.getSalesOrders().remove(salesOrder);
- assertTransient(salesOrder);
-
- Customer customer = company.getCustomers().get(0);
- EList<SalesOrder> salesOrders = customer.getSalesOrders();
-
- List<SalesOrder> javaList = new ArrayList<SalesOrder>();
- for (SalesOrder order : salesOrders)
- {
- javaList.add(order);
- }
-
- Set<SalesOrder> lookFor = Collections.singleton(salesOrder);
-
- // Test contains & containsAll with "normal" java list
- assertEquals(true, javaList.contains(salesOrder));
- assertEquals(true, javaList.containsAll(lookFor));
-
- // Test contains & containsAll direct with the elist
- assertEquals(true, salesOrders.contains(salesOrder));
- assertEquals(true, salesOrders.containsAll(lookFor));
- }
-
- public void testIndexOf() throws Exception
- {
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
-
- Company company = getModel1Factory().createCompany();
- company.getSalesOrders().add(salesOrder);
-
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("customer");
- customer.getSalesOrders().add(salesOrder);
-
- company.getCustomers().add(customer);
- resource.getContents().add(company);
-
- transaction.commit();
- session.close();
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- Company company = (Company)resource.getContents().get(0);
- SalesOrder salesOrder = company.getSalesOrders().get(0);
-
- // remove salesOrder from its containment list, salesOrder now detached
- company.getSalesOrders().remove(salesOrder);
- assertTransient(salesOrder);
-
- Customer customer = company.getCustomers().get(0);
- EList<SalesOrder> salesOrders = customer.getSalesOrders();
-
- List<SalesOrder> javaList = new ArrayList<SalesOrder>();
- for (SalesOrder order : salesOrders)
- {
- javaList.add(order);
- }
-
- // Test indexOf & lastIndexOf with "normal" java list
- assertEquals(0, javaList.indexOf(salesOrder));
- assertEquals(0, javaList.lastIndexOf(salesOrder));
-
- // Test indexOf & lastIndexOf direct with the elist
- assertEquals(0, salesOrders.indexOf(salesOrder));
- assertEquals(0, salesOrders.lastIndexOf(salesOrder));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.EList;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * ContainsAll with detached objects
+ * <p>
+ * See bug
+ *
+ * @author Stefan Schedl
+ */
+public class Bugzilla_354395_Test extends AbstractCDOTest
+{
+ public void testContains() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+
+ Company company = getModel1Factory().createCompany();
+ company.getSalesOrders().add(salesOrder);
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+ customer.getSalesOrders().add(salesOrder);
+
+ company.getCustomers().add(customer);
+ resource.getContents().add(company);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Company company = (Company)resource.getContents().get(0);
+ SalesOrder salesOrder = company.getSalesOrders().get(0);
+
+ // remove salesOrder from its containment list, salesOrder now detached
+ company.getSalesOrders().remove(salesOrder);
+ assertTransient(salesOrder);
+
+ Customer customer = company.getCustomers().get(0);
+ EList<SalesOrder> salesOrders = customer.getSalesOrders();
+
+ List<SalesOrder> javaList = new ArrayList<SalesOrder>();
+ for (SalesOrder order : salesOrders)
+ {
+ javaList.add(order);
+ }
+
+ Set<SalesOrder> lookFor = Collections.singleton(salesOrder);
+
+ // Test contains & containsAll with "normal" java list
+ assertEquals(true, javaList.contains(salesOrder));
+ assertEquals(true, javaList.containsAll(lookFor));
+
+ // Test contains & containsAll direct with the elist
+ assertEquals(true, salesOrders.contains(salesOrder));
+ assertEquals(true, salesOrders.containsAll(lookFor));
+ }
+
+ public void testIndexOf() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+
+ Company company = getModel1Factory().createCompany();
+ company.getSalesOrders().add(salesOrder);
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+ customer.getSalesOrders().add(salesOrder);
+
+ company.getCustomers().add(customer);
+ resource.getContents().add(company);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ Company company = (Company)resource.getContents().get(0);
+ SalesOrder salesOrder = company.getSalesOrders().get(0);
+
+ // remove salesOrder from its containment list, salesOrder now detached
+ company.getSalesOrders().remove(salesOrder);
+ assertTransient(salesOrder);
+
+ Customer customer = company.getCustomers().get(0);
+ EList<SalesOrder> salesOrders = customer.getSalesOrders();
+
+ List<SalesOrder> javaList = new ArrayList<SalesOrder>();
+ for (SalesOrder order : salesOrders)
+ {
+ javaList.add(order);
+ }
+
+ // Test indexOf & lastIndexOf with "normal" java list
+ assertEquals(0, javaList.indexOf(salesOrder));
+ assertEquals(0, javaList.lastIndexOf(salesOrder));
+
+ // Test indexOf & lastIndexOf direct with the elist
+ assertEquals(0, salesOrders.indexOf(salesOrder));
+ assertEquals(0, salesOrders.lastIndexOf(salesOrder));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_355915_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_355915_Test.java
index 1489b98f37..be5d25e207 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_355915_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_355915_Test.java
@@ -1,187 +1,187 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.resource.Resource;
-
-import java.util.Collections;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_355915_Test extends AbstractCDOTest
-{
- private static final String RESOURCE_PATH = "/test1";
-
- private CountDownLatch latch;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- latch = new CountDownLatch(1);
- }
-
- @Requires(IModelConfig.CAPABILITY_LEGACY)
- @CleanRepositoriesBefore
- public void testInvalidationNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOUtil.setLegacyModeDefault(true);
-
- CDOTransaction transaction1 = session.openTransaction();
- transaction1.options().setInvalidationNotificationEnabled(true);
-
- CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
-
- // 1. Create a example model
- Customer customer1 = getModel1Factory().createCustomer();
- customer1.setName("Martin Fluegge");
- customer1.setStreet("ABC Street 7");
- customer1.setCity("Berlin");
-
- TestAdapter adapter = new TestAdapter();
- customer1.eAdapters().add(adapter);
-
- resource1.getContents().add(customer1);
- resource1.save(Collections.emptyMap());
-
- Thread thread = new Thread(new Runnable()
- {
- public void run()
- {
- CDOSession session = openSession();
- CDOUtil.setLegacyModeDefault(true);
-
- CDOTransaction transaction2 = session.openTransaction();
-
- Resource resource2 = transaction2.getResource(getResourcePath(RESOURCE_PATH));
- Customer customer2 = (Customer)resource2.getContents().get(0);
- customer2.setName("newName");
-
- try
- {
- transaction2.commit();
- }
- catch (CommitException ex)
- {
- ex.printStackTrace();
- }
- }
- });
-
- thread.start();
- thread.join();
-
- latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- assertEquals(true, adapter.notified());
- assertEquals(true, adapter.assertCorrectNotification());
- }
-
- @Requires(IModelConfig.CAPABILITY_LEGACY)
- @CleanRepositoriesBefore
- public void testDeltaNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOUtil.setLegacyModeDefault(true);
-
- CDOTransaction transaction1 = session.openTransaction();
- transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
-
- // 1. Create a example model
- Customer customer1 = getModel1Factory().createCustomer();
- customer1.setName("Martin Fluegge");
- customer1.setStreet("ABC Street 7");
- customer1.setCity("Berlin");
-
- TestAdapter adapter = new TestAdapter();
- customer1.eAdapters().add(adapter);
-
- resource1.getContents().add(customer1);
- resource1.save(Collections.emptyMap());
-
- Thread thread = new Thread(new Runnable()
- {
- public void run()
- {
- CDOSession session = openSession();
- CDOUtil.setLegacyModeDefault(true);
-
- CDOTransaction transaction2 = session.openTransaction();
-
- Resource resource2 = transaction2.getResource(getResourcePath(RESOURCE_PATH));
- Customer customer2 = (Customer)resource2.getContents().get(0);
- customer2.setName("newName");
-
- try
- {
- transaction2.commit();
- }
- catch (CommitException ex)
- {
- ex.printStackTrace();
- }
- }
- });
-
- thread.start();
- thread.join();
-
- latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- assertEquals(true, adapter.notified());
- assertEquals(true, adapter.assertCorrectNotification());
- }
-
- /**
- * @author Martin Fluegge
- */
- class TestAdapter extends AdapterImpl
- {
- private boolean assertCorrectNotification;
-
- private boolean notified;
-
- @Override
- public void notifyChanged(Notification notification)
- {
- notified = true;
- Object notifier = notification.getNotifier();
- assertCorrectNotification = notifier instanceof Customer;
- latch.countDown();
- }
-
- public boolean notified()
- {
- return notified;
- }
-
- public boolean assertCorrectNotification()
- {
- return assertCorrectNotification;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+
+import java.util.Collections;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_355915_Test extends AbstractCDOTest
+{
+ private static final String RESOURCE_PATH = "/test1";
+
+ private CountDownLatch latch;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ latch = new CountDownLatch(1);
+ }
+
+ @Requires(IModelConfig.CAPABILITY_LEGACY)
+ @CleanRepositoriesBefore
+ public void testInvalidationNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ CDOTransaction transaction1 = session.openTransaction();
+ transaction1.options().setInvalidationNotificationEnabled(true);
+
+ CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
+
+ // 1. Create a example model
+ Customer customer1 = getModel1Factory().createCustomer();
+ customer1.setName("Martin Fluegge");
+ customer1.setStreet("ABC Street 7");
+ customer1.setCity("Berlin");
+
+ TestAdapter adapter = new TestAdapter();
+ customer1.eAdapters().add(adapter);
+
+ resource1.getContents().add(customer1);
+ resource1.save(Collections.emptyMap());
+
+ Thread thread = new Thread(new Runnable()
+ {
+ public void run()
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ CDOTransaction transaction2 = session.openTransaction();
+
+ Resource resource2 = transaction2.getResource(getResourcePath(RESOURCE_PATH));
+ Customer customer2 = (Customer)resource2.getContents().get(0);
+ customer2.setName("newName");
+
+ try
+ {
+ transaction2.commit();
+ }
+ catch (CommitException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ thread.start();
+ thread.join();
+
+ latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ assertEquals(true, adapter.notified());
+ assertEquals(true, adapter.assertCorrectNotification());
+ }
+
+ @Requires(IModelConfig.CAPABILITY_LEGACY)
+ @CleanRepositoriesBefore
+ public void testDeltaNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ CDOTransaction transaction1 = session.openTransaction();
+ transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
+
+ // 1. Create a example model
+ Customer customer1 = getModel1Factory().createCustomer();
+ customer1.setName("Martin Fluegge");
+ customer1.setStreet("ABC Street 7");
+ customer1.setCity("Berlin");
+
+ TestAdapter adapter = new TestAdapter();
+ customer1.eAdapters().add(adapter);
+
+ resource1.getContents().add(customer1);
+ resource1.save(Collections.emptyMap());
+
+ Thread thread = new Thread(new Runnable()
+ {
+ public void run()
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ CDOTransaction transaction2 = session.openTransaction();
+
+ Resource resource2 = transaction2.getResource(getResourcePath(RESOURCE_PATH));
+ Customer customer2 = (Customer)resource2.getContents().get(0);
+ customer2.setName("newName");
+
+ try
+ {
+ transaction2.commit();
+ }
+ catch (CommitException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ thread.start();
+ thread.join();
+
+ latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ assertEquals(true, adapter.notified());
+ assertEquals(true, adapter.assertCorrectNotification());
+ }
+
+ /**
+ * @author Martin Fluegge
+ */
+ class TestAdapter extends AdapterImpl
+ {
+ private boolean assertCorrectNotification;
+
+ private boolean notified;
+
+ @Override
+ public void notifyChanged(Notification notification)
+ {
+ notified = true;
+ Object notifier = notification.getNotifier();
+ assertCorrectNotification = notifier instanceof Customer;
+ latch.countDown();
+ }
+
+ public boolean notified()
+ {
+ return notified;
+ }
+
+ public boolean assertCorrectNotification()
+ {
+ return assertCorrectNotification;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_357441_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_357441_Test.java
index c8e12540a3..60f2380839 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_357441_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_357441_Test.java
@@ -1,88 +1,88 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-/**
- * [DB] Range-based list mappings can be very slow.
- * <p>
- * See bug 357441
- *
- * @author Eike Stepper
- * @since 4.1
- */
-public class Bugzilla_357441_Test extends AbstractCDOTest
-{
- private final int NUM_PRODUCTS = 200;
-
- @Skips("DB.ranges")
- // Too slow in DB.ranges (11 minutes), see bug 357441
- public void testManyListChanges() throws Exception
- {
- disableConsole();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company company = getModel1Factory().createCompany();
- Category catA = getModel1Factory().createCategory();
- catA.setName("CatA");
- company.getCategories().add(catA);
- Category catB = getModel1Factory().createCategory();
- catB.setName("CatB");
- company.getCategories().add(catB);
- resource.getContents().add(company);
-
- for (int i = 0; i < NUM_PRODUCTS; i++)
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Product" + i);
- catA.getProducts().add(product);
- }
-
- transaction.commit();
-
- // Do a lot of changes
- for (int i = 0; i < NUM_PRODUCTS; i++)
- {
- Product1 p = catA.getProducts().remove(0);
- catB.getProducts().add(p);
- catB.getProducts().move(0, p);
-
- long start = System.currentTimeMillis();
- transaction.commit();
-
- System.out.println(i + "," + (System.currentTimeMillis() - start));
- }
-
- catA.setName(catA.getName() + " empty");
- transaction.commit();
- }
-
- @Override
- public void disableConsole()
- {
- OMPlatform.INSTANCE.setDebugging(false);
- OMPlatform.INSTANCE.removeTraceHandler(PrintTraceHandler.CONSOLE);
- // OMPlatform.INSTANCE.removeLogHandler(PrintLogHandler.CONSOLE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+/**
+ * [DB] Range-based list mappings can be very slow.
+ * <p>
+ * See bug 357441
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+public class Bugzilla_357441_Test extends AbstractCDOTest
+{
+ private final int NUM_PRODUCTS = 200;
+
+ @Skips("DB.ranges")
+ // Too slow in DB.ranges (11 minutes), see bug 357441
+ public void testManyListChanges() throws Exception
+ {
+ disableConsole();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ Category catA = getModel1Factory().createCategory();
+ catA.setName("CatA");
+ company.getCategories().add(catA);
+ Category catB = getModel1Factory().createCategory();
+ catB.setName("CatB");
+ company.getCategories().add(catB);
+ resource.getContents().add(company);
+
+ for (int i = 0; i < NUM_PRODUCTS; i++)
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Product" + i);
+ catA.getProducts().add(product);
+ }
+
+ transaction.commit();
+
+ // Do a lot of changes
+ for (int i = 0; i < NUM_PRODUCTS; i++)
+ {
+ Product1 p = catA.getProducts().remove(0);
+ catB.getProducts().add(p);
+ catB.getProducts().move(0, p);
+
+ long start = System.currentTimeMillis();
+ transaction.commit();
+
+ System.out.println(i + "," + (System.currentTimeMillis() - start));
+ }
+
+ catA.setName(catA.getName() + " empty");
+ transaction.commit();
+ }
+
+ @Override
+ public void disableConsole()
+ {
+ OMPlatform.INSTANCE.setDebugging(false);
+ OMPlatform.INSTANCE.removeTraceHandler(PrintTraceHandler.CONSOLE);
+ // OMPlatform.INSTANCE.removeLogHandler(PrintLogHandler.CONSOLE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359669_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359669_Test.java
index 92a8540e69..f7db3d7d7f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359669_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359669_Test.java
@@ -1,67 +1,67 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * @author Martin Fluegge
- */
-public class Bugzilla_359669_Test extends AbstractCDOTest
-{
- public void testReloadFromIndex() throws Exception
- {
- Category category = getModel1Factory().createCategory();
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test1"));
-
- resource.getContents().add(category);
- transaction.commit();
-
- EObject reloaded = resource.getEObject("/0");
- assertEquals(category, reloaded);
- }
-
- public void testReloadFromIndexComplex() throws Exception
- {
- Product1 product0 = getModel1Factory().createProduct1();
- Product1 product1 = getModel1Factory().createProduct1();
- Product1 product2 = getModel1Factory().createProduct1();
-
- Category category = getModel1Factory().createCategory();
- category.getProducts().add(product0);
- category.getProducts().add(product1);
- category.getProducts().add(product2);
-
- Company company = getModel1Factory().createCompany();
- company.getCategories().add(category);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test1"));
-
- resource.getContents().add(company);
- transaction.commit();
-
- EObject reloaded = resource.getEObject("//@categories.0/@products.2");
- assertEquals(product2, reloaded);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_359669_Test extends AbstractCDOTest
+{
+ public void testReloadFromIndex() throws Exception
+ {
+ Category category = getModel1Factory().createCategory();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test1"));
+
+ resource.getContents().add(category);
+ transaction.commit();
+
+ EObject reloaded = resource.getEObject("/0");
+ assertEquals(category, reloaded);
+ }
+
+ public void testReloadFromIndexComplex() throws Exception
+ {
+ Product1 product0 = getModel1Factory().createProduct1();
+ Product1 product1 = getModel1Factory().createProduct1();
+ Product1 product2 = getModel1Factory().createProduct1();
+
+ Category category = getModel1Factory().createCategory();
+ category.getProducts().add(product0);
+ category.getProducts().add(product1);
+ category.getProducts().add(product2);
+
+ Company company = getModel1Factory().createCompany();
+ company.getCategories().add(category);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test1"));
+
+ resource.getContents().add(company);
+ transaction.commit();
+
+ EObject reloaded = resource.getEObject("//@categories.0/@products.2");
+ assertEquals(product2, reloaded);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359992_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359992_Test.java
index 0c1c29abcc..103067f8ba 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359992_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_359992_Test.java
@@ -1,241 +1,241 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOInvalidationNotification;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest;
-import org.eclipse.emf.cdo.net4j.CDONet4jSession;
-import org.eclipse.emf.cdo.net4j.CDONet4jSession.Options;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.legacy.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.Collections;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Bug 359992.
- *
- * @author Martin Fluegge
- */
-public class Bugzilla_359992_Test extends AbstractCDOTest
-{
- private static final String RESOURCE_PATH = "/test1";
-
- private CountDownLatch latch;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- latch = new CountDownLatch(1);
- }
-
- @Requires(IModelConfig.CAPABILITY_LEGACY)
- @CleanRepositoriesBefore
- public void testInvalidationNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOUtil.setLegacyModeDefault(true);
- CDONet4jSession.Options options = (Options)session.options();
- options.setCommitTimeout(10 * CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS);
-
- CDOTransaction transaction1 = session.openTransaction();
- transaction1.options().setInvalidationNotificationEnabled(true);
-
- CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
-
- // 1. Create a example model
- Customer customer1 = initializeModel(resource1);
-
- resource1.getContents().add(customer1);
- resource1.save(Collections.emptyMap());
-
- transaction1.close();
- session.close();
-
- session = openSession();
- CDOUtil.setLegacyModeDefault(true);
-
- transaction1 = session.openTransaction();
- transaction1.options().setInvalidationNotificationEnabled(true);
-
- resource1 = transaction1.getResource(getResourcePath(RESOURCE_PATH));
- customer1 = (Customer)resource1.getContents().get(1);
-
- TestAdapter adapter = new TestAdapter();
- customer1.eAdapters().add(adapter);
-
- doClient2();
-
- latch.await(10 * DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- assertEquals(true, adapter.notified());
- assertEquals(adapter.getFailureMessage(), true, adapter.assertCorrectNotification());
- }
-
- @Requires(IModelConfig.CAPABILITY_LEGACY)
- @CleanRepositoriesBefore
- public void testDeltaNotification() throws Exception
- {
- CDOSession session = openSession();
- CDOUtil.setLegacyModeDefault(true);
- CDONet4jSession.Options options = (Options)session.options();
- options.setCommitTimeout(10 * CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS);
-
- CDOTransaction transaction1 = session.openTransaction();
- transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
-
- // 1. Create a example model
- Customer customer1 = initializeModel(resource1);
-
- resource1.getContents().add(customer1);
- resource1.save(Collections.emptyMap());
-
- transaction1.close();
- session.close();
-
- session = openSession();
- CDOUtil.setLegacyModeDefault(true);
-
- transaction1 = session.openTransaction();
- transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- resource1 = transaction1.getResource(getResourcePath(RESOURCE_PATH));
- customer1 = (Customer)resource1.getContents().get(1);
-
- TestAdapter adapter = new TestAdapter();
- customer1.eAdapters().add(adapter);
-
- doClient2();
-
- latch.await(10 * DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- assertEquals(true, adapter.notified());
- assertEquals(adapter.getFailureMessage(), true, adapter.assertCorrectNotification());
- }
-
- private Customer initializeModel(CDOResource resource1)
- {
- Customer customer1 = Model1Factory.eINSTANCE.createCustomer();
- customer1.setName("Martin Fluegge");
- customer1.setStreet("ABC Street 7");
- customer1.setCity("Berlin");
-
- SalesOrder salesOrder = Model1Factory.eINSTANCE.createSalesOrder();
- customer1.getSalesOrders().add(salesOrder);
- resource1.getContents().add(salesOrder);
-
- return customer1;
- }
-
- private void doClient2() throws CommitException
- {
- CDOSession session = openSession();
- CDOUtil.setLegacyModeDefault(true);
- CDONet4jSession.Options options = (Options)session.options();
- options.setCommitTimeout(10 * CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS);
- CDOTransaction transaction2 = session.openTransaction();
-
- Resource resource2 = transaction2.getResource(getResourcePath(RESOURCE_PATH));
- Customer customer2 = (Customer)resource2.getContents().get(1);
-
- SalesOrder existingSalesOrder = customer2.getSalesOrders().get(0);
- EcoreUtil.delete(existingSalesOrder);
-
- SalesOrder newSalesOrder = Model1Factory.eINSTANCE.createSalesOrder();
- customer2.getSalesOrders().add(newSalesOrder);
- resource2.getContents().add(newSalesOrder);
-
- transaction2.commit();
- }
-
- /**
- * @author Martin Fluegge
- */
- class TestAdapter extends AdapterImpl
- {
- private boolean assertCorrectNotification;
-
- private boolean notified;
-
- private String failureMessage;
-
- @Override
- public void notifyChanged(Notification notification)
- {
- // If a previous received notification was incorrect we doesn't checks anymore
- if (!notified || notified && assertCorrectNotification)
- {
- Object notifier = notification.getNotifier();
- assertCorrectNotification = notifier instanceof Customer;
- if (!assertCorrectNotification)
- {
- failureMessage = "Notifier is not the expected type : " + notifier.getClass().getName();
- }
- if (!(notification instanceof CDOInvalidationNotification) && assertCorrectNotification)
- {
- int eventType = notification.getEventType();
- if (Notification.ADD == eventType)
- {
- Object newValue = notification.getNewValue();
- assertCorrectNotification = newValue instanceof SalesOrder;
- if (!assertCorrectNotification)
- {
- failureMessage = "Notification.getNewValue() is not the expected type : " + newValue.getClass().getName();
- }
- }
- else if (Notification.REMOVE == eventType)
- {
- Object oldValue = notification.getOldValue();
- assertCorrectNotification = oldValue instanceof SalesOrder;
- if (!assertCorrectNotification)
- {
- failureMessage = "Notification.getOldValue() is not the expected type : " + oldValue.getClass().getName();
- }
- }
- }
-
- notified = true;
- latch.countDown();
- }
- }
-
- public boolean notified()
- {
- return notified;
- }
-
- public boolean assertCorrectNotification()
- {
- return assertCorrectNotification;
- }
-
- public String getFailureMessage()
- {
- return failureMessage;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOInvalidationNotification;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession.Options;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.legacy.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.Collections;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Bug 359992.
+ *
+ * @author Martin Fluegge
+ */
+public class Bugzilla_359992_Test extends AbstractCDOTest
+{
+ private static final String RESOURCE_PATH = "/test1";
+
+ private CountDownLatch latch;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ latch = new CountDownLatch(1);
+ }
+
+ @Requires(IModelConfig.CAPABILITY_LEGACY)
+ @CleanRepositoriesBefore
+ public void testInvalidationNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+ CDONet4jSession.Options options = (Options)session.options();
+ options.setCommitTimeout(10 * CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS);
+
+ CDOTransaction transaction1 = session.openTransaction();
+ transaction1.options().setInvalidationNotificationEnabled(true);
+
+ CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
+
+ // 1. Create a example model
+ Customer customer1 = initializeModel(resource1);
+
+ resource1.getContents().add(customer1);
+ resource1.save(Collections.emptyMap());
+
+ transaction1.close();
+ session.close();
+
+ session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ transaction1 = session.openTransaction();
+ transaction1.options().setInvalidationNotificationEnabled(true);
+
+ resource1 = transaction1.getResource(getResourcePath(RESOURCE_PATH));
+ customer1 = (Customer)resource1.getContents().get(1);
+
+ TestAdapter adapter = new TestAdapter();
+ customer1.eAdapters().add(adapter);
+
+ doClient2();
+
+ latch.await(10 * DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ assertEquals(true, adapter.notified());
+ assertEquals(adapter.getFailureMessage(), true, adapter.assertCorrectNotification());
+ }
+
+ @Requires(IModelConfig.CAPABILITY_LEGACY)
+ @CleanRepositoriesBefore
+ public void testDeltaNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+ CDONet4jSession.Options options = (Options)session.options();
+ options.setCommitTimeout(10 * CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS);
+
+ CDOTransaction transaction1 = session.openTransaction();
+ transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
+
+ // 1. Create a example model
+ Customer customer1 = initializeModel(resource1);
+
+ resource1.getContents().add(customer1);
+ resource1.save(Collections.emptyMap());
+
+ transaction1.close();
+ session.close();
+
+ session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ transaction1 = session.openTransaction();
+ transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ resource1 = transaction1.getResource(getResourcePath(RESOURCE_PATH));
+ customer1 = (Customer)resource1.getContents().get(1);
+
+ TestAdapter adapter = new TestAdapter();
+ customer1.eAdapters().add(adapter);
+
+ doClient2();
+
+ latch.await(10 * DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ assertEquals(true, adapter.notified());
+ assertEquals(adapter.getFailureMessage(), true, adapter.assertCorrectNotification());
+ }
+
+ private Customer initializeModel(CDOResource resource1)
+ {
+ Customer customer1 = Model1Factory.eINSTANCE.createCustomer();
+ customer1.setName("Martin Fluegge");
+ customer1.setStreet("ABC Street 7");
+ customer1.setCity("Berlin");
+
+ SalesOrder salesOrder = Model1Factory.eINSTANCE.createSalesOrder();
+ customer1.getSalesOrders().add(salesOrder);
+ resource1.getContents().add(salesOrder);
+
+ return customer1;
+ }
+
+ private void doClient2() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+ CDONet4jSession.Options options = (Options)session.options();
+ options.setCommitTimeout(10 * CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS);
+ CDOTransaction transaction2 = session.openTransaction();
+
+ Resource resource2 = transaction2.getResource(getResourcePath(RESOURCE_PATH));
+ Customer customer2 = (Customer)resource2.getContents().get(1);
+
+ SalesOrder existingSalesOrder = customer2.getSalesOrders().get(0);
+ EcoreUtil.delete(existingSalesOrder);
+
+ SalesOrder newSalesOrder = Model1Factory.eINSTANCE.createSalesOrder();
+ customer2.getSalesOrders().add(newSalesOrder);
+ resource2.getContents().add(newSalesOrder);
+
+ transaction2.commit();
+ }
+
+ /**
+ * @author Martin Fluegge
+ */
+ class TestAdapter extends AdapterImpl
+ {
+ private boolean assertCorrectNotification;
+
+ private boolean notified;
+
+ private String failureMessage;
+
+ @Override
+ public void notifyChanged(Notification notification)
+ {
+ // If a previous received notification was incorrect we doesn't checks anymore
+ if (!notified || notified && assertCorrectNotification)
+ {
+ Object notifier = notification.getNotifier();
+ assertCorrectNotification = notifier instanceof Customer;
+ if (!assertCorrectNotification)
+ {
+ failureMessage = "Notifier is not the expected type : " + notifier.getClass().getName();
+ }
+ if (!(notification instanceof CDOInvalidationNotification) && assertCorrectNotification)
+ {
+ int eventType = notification.getEventType();
+ if (Notification.ADD == eventType)
+ {
+ Object newValue = notification.getNewValue();
+ assertCorrectNotification = newValue instanceof SalesOrder;
+ if (!assertCorrectNotification)
+ {
+ failureMessage = "Notification.getNewValue() is not the expected type : " + newValue.getClass().getName();
+ }
+ }
+ else if (Notification.REMOVE == eventType)
+ {
+ Object oldValue = notification.getOldValue();
+ assertCorrectNotification = oldValue instanceof SalesOrder;
+ if (!assertCorrectNotification)
+ {
+ failureMessage = "Notification.getOldValue() is not the expected type : " + oldValue.getClass().getName();
+ }
+ }
+ }
+
+ notified = true;
+ latch.countDown();
+ }
+ }
+
+ public boolean notified()
+ {
+ return notified;
+ }
+
+ public boolean assertCorrectNotification()
+ {
+ return assertCorrectNotification;
+ }
+
+ public String getFailureMessage()
+ {
+ return failureMessage;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_361819_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_361819_Test.java
index ed086d748b..fb6a4f6ca2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_361819_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_361819_Test.java
@@ -1,75 +1,75 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * Bug 361819.
- *
- * @author Egidijus Vaisnora
- */
-public class Bugzilla_361819_Test extends AbstractCDOTest
-{
- public void testDoubleRefreshBug() throws Exception
- {
- createData(getResourcePath("test"));
-
- CDOSession session = openSession();
- session.options().setPassiveUpdateEnabled(false);
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("test"));
- EObject testingEObject = resource.getContents().get(0);
- CDOObject testingObject = CDOUtil.getCDOObject(testingEObject);
-
- CDOSession session2 = openSession();
- CDOTransaction transaction = session2.openTransaction();
- CDOResource resource2 = transaction.getResource(getResourcePath("test"));
-
- Category category = (Category)resource2.getContents().get(0);
- category.setName("v2");
- transaction.commit();
-
- category.setName("v3");
- transaction.commit();
- assertEquals(3, CDOUtil.getCDOObject(category).cdoRevision().getVersion());
-
- assertClean(testingObject, testingObject.cdoView());
- session.refresh();
- session.refresh();
-
- // Load proxy
- ((Category)testingEObject).getName();
-
- // Version of object should be 3
- assertEquals(3, testingObject.cdoRevision().getVersion());
- }
-
- private void createData(String resourcePath) throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(resourcePath);
- resource.getContents().add(getModel1Factory().createCategory());
- transaction.commit();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * Bug 361819.
+ *
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_361819_Test extends AbstractCDOTest
+{
+ public void testDoubleRefreshBug() throws Exception
+ {
+ createData(getResourcePath("test"));
+
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("test"));
+ EObject testingEObject = resource.getContents().get(0);
+ CDOObject testingObject = CDOUtil.getCDOObject(testingEObject);
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction = session2.openTransaction();
+ CDOResource resource2 = transaction.getResource(getResourcePath("test"));
+
+ Category category = (Category)resource2.getContents().get(0);
+ category.setName("v2");
+ transaction.commit();
+
+ category.setName("v3");
+ transaction.commit();
+ assertEquals(3, CDOUtil.getCDOObject(category).cdoRevision().getVersion());
+
+ assertClean(testingObject, testingObject.cdoView());
+ session.refresh();
+ session.refresh();
+
+ // Load proxy
+ ((Category)testingEObject).getName();
+
+ // Version of object should be 3
+ assertEquals(3, testingObject.cdoRevision().getVersion());
+ }
+
+ private void createData(String resourcePath) throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(resourcePath);
+ resource.getContents().add(getModel1Factory().createCategory());
+ transaction.commit();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_362270_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_362270_Test.java
index 858ec993bd..b497305b27 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_362270_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_362270_Test.java
@@ -1,184 +1,184 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDODeltaNotification;
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.ResourceSetChangeEvent;
-import org.eclipse.emf.transaction.ResourceSetListenerImpl;
-import org.eclipse.emf.transaction.RollbackException;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-import org.eclipse.core.runtime.Status;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * Test case for {@link CDODeltaNotification#getNewValue()} which must returns a local {@link EObject} contained in a
- * {@link XMIResource} because a {@link CDOObject} stored in a {@link CDOResource} references the local {@link EObject}.
- *
- * @author Esteban Dugueperoux
- */
-public class Bugzilla_362270_Test extends AbstractCDOTest
-{
- private final EReference SUPPLIERS = getModel1Package().getCompany_Suppliers();
-
- private final EReference PURCHASE_ORDERS = getModel1Package().getSupplier_PurchaseOrders();
-
- public void testNotifierNotACDOLegacyAdapter() throws Exception
- {
- TransactionalEditingDomain domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
- ResourceSet resourceSet = domain.getResourceSet();
- registerXMIFactory(resourceSet);
-
- // 1. Create the CDOResource
- Company obeoCompany = getModel1Factory().createCompany();
- obeoCompany.setName("OBEO");
- obeoCompany.setCity("Nantes");
-
- Supplier martinSupplier = getModel1Factory().createSupplier();
- obeoCompany.getSuppliers().add(martinSupplier);
-
- CDOSession session = openSession();
- CDOUtil.setLegacyModeDefault(true);
- final CDOTransaction cdoTransaction = session.openTransaction(resourceSet);
-
- CDOResource cdoResource = cdoTransaction.createResource(getResourcePath("/test1"));
- cdoResource.getContents().add(obeoCompany);
- cdoTransaction.commit();
-
- // 2. Create the local XMI resource
- URI localResourceURI = createXMIResource();
-
- // Reload the local resource through the CDOTransaction!!!
- Resource localResource = resourceSet.getResource(localResourceURI, true);
- Company martinCompany = (Company)localResource.getContents().get(0);
- PurchaseOrder purchaseOrder = martinCompany.getPurchaseOrders().get(0);
-
- Command addPurchaseOrderCmd = AddCommand.create(domain, martinSupplier, PURCHASE_ORDERS, purchaseOrder);
- domain.getCommandStack().execute(addPurchaseOrderCmd);
-
- // 4. Commit
- cdoTransaction.commit();
-
- domain.addResourceSetListener(new ResourceSetListenerImpl()
- {
- @Override
- public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException
- {
- throw new RollbackException(Status.CANCEL_STATUS);
- }
- });
-
- Command removeMartinSupplierCmd = RemoveCommand.create(domain, obeoCompany, SUPPLIERS, martinSupplier);
- domain.getCommandStack().execute(removeMartinSupplierCmd);
-
- AssertAdapter assertAdapter = new AssertAdapter(purchaseOrder);
- martinSupplier.eAdapters().add(assertAdapter);
-
- // 6. rollback the previous operation
- domain.getCommandStack().execute(new RecordingCommand(domain)
- {
- @Override
- protected void doExecute()
- {
- cdoTransaction.rollback();
- }
- });
- }
-
- private URI createXMIResource() throws IOException
- {
- ResourceSet localResourceSet = new ResourceSetImpl();
- registerXMIFactory(localResourceSet);
-
- File localResourceFile = createTempFile("localResource", ".model1").getAbsoluteFile();
- URI localResourceURI = URI.createFileURI(localResourceFile.getAbsolutePath());
- Resource localResource = localResourceSet.createResource(localResourceURI);
-
- Company martinCompany = getModel1Factory().createCompany();
- martinCompany.setName("Martin");
- martinCompany.setCity("Berlin");
-
- PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
- martinCompany.getPurchaseOrders().add(purchaseOrder);
-
- localResource.getContents().add(martinCompany);
- localResource.save(Collections.emptyMap());
-
- return localResourceURI;
- }
-
- private void registerXMIFactory(ResourceSet resourceSet)
- {
- Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
- map.put("model1", new XMIResourceFactoryImpl());
- }
-
- private final class AssertAdapter extends AdapterImpl
- {
- private EObject eObject;
-
- private int notifyCounter;
-
- public AssertAdapter(EObject eObject)
- {
- this.eObject = eObject;
- }
-
- @Override
- public void notifyChanged(Notification msg)
- {
- if (getModel1Package().getSupplier_PurchaseOrders().equals(msg.getFeature()))
- {
- switch (++notifyCounter)
- {
- case 1:
- assertEquals(null, msg.getNewValue());
- break;
-
- case 2:
- assertEquals(eObject, msg.getNewValue());
- break;
-
- default:
- fail("Only 0 or 2 calls are expected");
- }
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDODeltaNotification;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.emf.transaction.ResourceSetListenerImpl;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+import org.eclipse.core.runtime.Status;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Test case for {@link CDODeltaNotification#getNewValue()} which must returns a local {@link EObject} contained in a
+ * {@link XMIResource} because a {@link CDOObject} stored in a {@link CDOResource} references the local {@link EObject}.
+ *
+ * @author Esteban Dugueperoux
+ */
+public class Bugzilla_362270_Test extends AbstractCDOTest
+{
+ private final EReference SUPPLIERS = getModel1Package().getCompany_Suppliers();
+
+ private final EReference PURCHASE_ORDERS = getModel1Package().getSupplier_PurchaseOrders();
+
+ public void testNotifierNotACDOLegacyAdapter() throws Exception
+ {
+ TransactionalEditingDomain domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
+ ResourceSet resourceSet = domain.getResourceSet();
+ registerXMIFactory(resourceSet);
+
+ // 1. Create the CDOResource
+ Company obeoCompany = getModel1Factory().createCompany();
+ obeoCompany.setName("OBEO");
+ obeoCompany.setCity("Nantes");
+
+ Supplier martinSupplier = getModel1Factory().createSupplier();
+ obeoCompany.getSuppliers().add(martinSupplier);
+
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+ final CDOTransaction cdoTransaction = session.openTransaction(resourceSet);
+
+ CDOResource cdoResource = cdoTransaction.createResource(getResourcePath("/test1"));
+ cdoResource.getContents().add(obeoCompany);
+ cdoTransaction.commit();
+
+ // 2. Create the local XMI resource
+ URI localResourceURI = createXMIResource();
+
+ // Reload the local resource through the CDOTransaction!!!
+ Resource localResource = resourceSet.getResource(localResourceURI, true);
+ Company martinCompany = (Company)localResource.getContents().get(0);
+ PurchaseOrder purchaseOrder = martinCompany.getPurchaseOrders().get(0);
+
+ Command addPurchaseOrderCmd = AddCommand.create(domain, martinSupplier, PURCHASE_ORDERS, purchaseOrder);
+ domain.getCommandStack().execute(addPurchaseOrderCmd);
+
+ // 4. Commit
+ cdoTransaction.commit();
+
+ domain.addResourceSetListener(new ResourceSetListenerImpl()
+ {
+ @Override
+ public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException
+ {
+ throw new RollbackException(Status.CANCEL_STATUS);
+ }
+ });
+
+ Command removeMartinSupplierCmd = RemoveCommand.create(domain, obeoCompany, SUPPLIERS, martinSupplier);
+ domain.getCommandStack().execute(removeMartinSupplierCmd);
+
+ AssertAdapter assertAdapter = new AssertAdapter(purchaseOrder);
+ martinSupplier.eAdapters().add(assertAdapter);
+
+ // 6. rollback the previous operation
+ domain.getCommandStack().execute(new RecordingCommand(domain)
+ {
+ @Override
+ protected void doExecute()
+ {
+ cdoTransaction.rollback();
+ }
+ });
+ }
+
+ private URI createXMIResource() throws IOException
+ {
+ ResourceSet localResourceSet = new ResourceSetImpl();
+ registerXMIFactory(localResourceSet);
+
+ File localResourceFile = createTempFile("localResource", ".model1").getAbsoluteFile();
+ URI localResourceURI = URI.createFileURI(localResourceFile.getAbsolutePath());
+ Resource localResource = localResourceSet.createResource(localResourceURI);
+
+ Company martinCompany = getModel1Factory().createCompany();
+ martinCompany.setName("Martin");
+ martinCompany.setCity("Berlin");
+
+ PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
+ martinCompany.getPurchaseOrders().add(purchaseOrder);
+
+ localResource.getContents().add(martinCompany);
+ localResource.save(Collections.emptyMap());
+
+ return localResourceURI;
+ }
+
+ private void registerXMIFactory(ResourceSet resourceSet)
+ {
+ Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
+ map.put("model1", new XMIResourceFactoryImpl());
+ }
+
+ private final class AssertAdapter extends AdapterImpl
+ {
+ private EObject eObject;
+
+ private int notifyCounter;
+
+ public AssertAdapter(EObject eObject)
+ {
+ this.eObject = eObject;
+ }
+
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ if (getModel1Package().getSupplier_PurchaseOrders().equals(msg.getFeature()))
+ {
+ switch (++notifyCounter)
+ {
+ case 1:
+ assertEquals(null, msg.getNewValue());
+ break;
+
+ case 2:
+ assertEquals(eObject, msg.getNewValue());
+ break;
+
+ default:
+ fail("Only 0 or 2 calls are expected");
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java
index ef7d3b846c..45a66f63e6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java
@@ -1,67 +1,67 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestAdapter;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
-import org.eclipse.emf.cdo.view.CDOView;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_363287_Test extends AbstractCDOTest
-{
- public void testDetach() throws Exception
- {
- Company company = getModel1Factory().createCompany();
-
- CDOSession session1 = openSession();
- CDOTransaction transaction = session1.openTransaction();
- CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
-
- resource1.getContents().add(company);
- transaction.commit();
-
- // ************************************************************* //
-
- CDOSession session2 = openSession();
- CDOView view = session2.openTransaction();
- view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
-
- CDOResource resource2 = view.getResource(getResourcePath("/test1"));
-
- final TestAdapter testAdapter = new TestAdapter();
- resource2.eAdapters().add(testAdapter);
-
- // ************************************************************* //
-
- resource1.getContents().remove(0);
- transaction.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
-
- Object oldValue = testAdapter.getNotifications()[0].getOldValue();
- assertNull(oldValue);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - maintenance
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestAdapter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_363287_Test extends AbstractCDOTest
+{
+ public void testDetach() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session1 = openSession();
+ CDOTransaction transaction = session1.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+
+ resource1.getContents().add(company);
+ transaction.commit();
+
+ // ************************************************************* //
+
+ CDOSession session2 = openSession();
+ CDOView view = session2.openTransaction();
+ view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resource2 = view.getResource(getResourcePath("/test1"));
+
+ final TestAdapter testAdapter = new TestAdapter();
+ resource2.eAdapters().add(testAdapter);
+
+ // ************************************************************* //
+
+ resource1.getContents().remove(0);
+ transaction.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return testAdapter.getNotifications().length == 1;
+ }
+ }.assertNoTimeOut();
+
+ Object oldValue = testAdapter.getNotifications()[0].getOldValue();
+ assertNull(oldValue);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_365832_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_365832_Test.java
index 9448128205..52ca8749ef 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_365832_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_365832_Test.java
@@ -1,205 +1,205 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model6.A;
-import org.eclipse.emf.cdo.tests.model6.D;
-import org.eclipse.emf.cdo.tests.model6.E;
-import org.eclipse.emf.cdo.tests.model6.F;
-import org.eclipse.emf.cdo.transaction.CDOPushTransaction;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.MeasurementUnit;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Bug 365832: Issues when trying to import changes: Cannot modify a frozen exception issue
- *
- * @author Alex Lagarde
- */
-public class Bugzilla_365832_Test extends AbstractCDOTest
-{
- private static final String MODEL_LOCATION_PATH = "myResource";
-
- public void testWithoutPushTransaction() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(MODEL_LOCATION_PATH));
- resource.getContents().add(createModel());
- transaction.commit();
-
- addNewChildren(transaction);
- checkDiagramAsCorrectlyBeenModified(transaction);
-
- transaction.commit();
- checkDiagramAsCorrectlyBeenModified(transaction);
- }
-
- public void testWithReconstructSavepoints() throws Exception
- {
- importWithNewLegacyElements(true);
- }
-
- public void testWithoutReconstructSavepoints() throws Exception
- {
- importWithNewLegacyElements(false);
- }
-
- private void importWithNewLegacyElements(boolean reconstructSavePoints) throws Exception
- {
- // Step 1 : create model
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(MODEL_LOCATION_PATH));
- resource.getContents().add(createModel());
- transaction.commit();
- session.close();
-
- // Step 2 : open a push transaction a save locally a modification
- // Step 2.1 : open a push transaction
- File fileForStoringChanges = createTempFile();
- CDOPushTransaction pushTransaction = createPushTransaction(fileForStoringChanges, reconstructSavePoints);
-
- // Step 2.2 : create a new element
- addNewChildren(pushTransaction);
-
- // => make sure that diagram is modified as expected
- checkDiagramAsCorrectlyBeenModified(pushTransaction);
-
- // Step 2.3 : save locally
- pushTransaction.commit();
- pushTransaction.getSession().close();
-
- // Step 3 : load changes
- pushTransaction = createPushTransaction(fileForStoringChanges, reconstructSavePoints);
-
- // => check that diagram is modified as expected
- checkDiagramAsCorrectlyBeenModified(pushTransaction);
-
- // => check that diagram is modified as expected
- checkDiagramAsCorrectlyBeenModified(pushTransaction);
-
- // Step 4 : try to modify objects and commit
- Diagram diagram = getDiagram(pushTransaction);
-
- @SuppressWarnings("unchecked")
- EList<Node> children = (EList<Node>)(EList<?>)diagram.getPersistedChildren();
- Node newElement = children.get(1);
- newElement.setType("newType");
- pushTransaction.commit();
-
- pushTransaction.getSession().close();
- }
-
- /**
- * Creates a Push Transaction with the given options.
- *
- * @param fileForStoringChanges
- * the file that CDOPushTransaction should use to store changes (can be null)
- * @param reconstructSavePoints
- * if CDOSavePoints should be reconstructed when creating the PushTransaction
- */
- private CDOPushTransaction createPushTransaction(File fileForStoringChanges, boolean reconstructSavePoints)
- throws IOException
- {
- CDOSession session = openSession();
- CDOTransaction delegate = session.openTransaction();
- return new CDOPushTransaction(delegate, fileForStoringChanges, reconstructSavePoints);
- }
-
- /**
- * Ensures that the given diagram has correctly been modified :
- * <ul>
- * <li>it should contains 2 Nodes</li>
- * <li>the Second Node should have a "type" Type and its associated element should be the diagram's container's
- * container</li>
- * </ul>
- */
- @SuppressWarnings("rawtypes")
- private void checkDiagramAsCorrectlyBeenModified(CDOView view)
- {
- Diagram diagram = getDiagram(view);
- EList children = diagram.getPersistedChildren();
-
- assertEquals("Failure when loading changes: New elements have not been created.", 2, children.size());
-
- Node newElement = (Node)children.get(1);
- assertEquals("Attribute not correctly set.", "type", newElement.getType());
- assertEquals("Cross reference not correctly set.", diagram.eContainer().eContainer(), newElement.getElement());
- }
-
- /**
- * Returns the diagram model to use for this test.
- */
- private Diagram getDiagram(CDOView view)
- {
- CDOResource resource = view.getResource(getResourcePath(MODEL_LOCATION_PATH));
- F f = (F)resource.getContents().get(0);
- E e = f.getOwnedEs().get(0);
- A a = e.getOwnedAs().get(0);
- D d = a.getOwnedDs().get(0);
- return (Diagram)d.getData();
- }
-
- /**
- * Creates the test model.
- */
- @SuppressWarnings("unchecked")
- private EObject createModel()
- {
- F f = getModel6Factory().createF();
- E e = getModel6Factory().createE();
- A a = getModel6Factory().createA();
- D d = getModel6Factory().createD();
-
- Node child1 = NotationFactory.eINSTANCE.createNode();
- child1.setElement(a);
-
- Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
- diagram.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL);
- diagram.getPersistedChildren().add(child1);
-
- d.setData(diagram);
- a.getOwnedDs().add(d);
- e.getOwnedAs().add(a);
- f.getOwnedEs().add(e);
-
- return f;
- }
-
- /**
- * Modifies the model by adding a new children of type Node to the Diagram.
- */
- @SuppressWarnings("unchecked")
- private void addNewChildren(CDOTransaction transaction)
- {
- Diagram diagram = getDiagram(transaction);
- A a = (A)diagram.eContainer().eContainer();
-
- Node child2 = NotationFactory.eINSTANCE.createNode();
- child2.setElement(a);
- child2.setType("type");
- diagram.getPersistedChildren().add(child2);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model6.A;
+import org.eclipse.emf.cdo.tests.model6.D;
+import org.eclipse.emf.cdo.tests.model6.E;
+import org.eclipse.emf.cdo.tests.model6.F;
+import org.eclipse.emf.cdo.transaction.CDOPushTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.MeasurementUnit;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Bug 365832: Issues when trying to import changes: Cannot modify a frozen exception issue
+ *
+ * @author Alex Lagarde
+ */
+public class Bugzilla_365832_Test extends AbstractCDOTest
+{
+ private static final String MODEL_LOCATION_PATH = "myResource";
+
+ public void testWithoutPushTransaction() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(MODEL_LOCATION_PATH));
+ resource.getContents().add(createModel());
+ transaction.commit();
+
+ addNewChildren(transaction);
+ checkDiagramAsCorrectlyBeenModified(transaction);
+
+ transaction.commit();
+ checkDiagramAsCorrectlyBeenModified(transaction);
+ }
+
+ public void testWithReconstructSavepoints() throws Exception
+ {
+ importWithNewLegacyElements(true);
+ }
+
+ public void testWithoutReconstructSavepoints() throws Exception
+ {
+ importWithNewLegacyElements(false);
+ }
+
+ private void importWithNewLegacyElements(boolean reconstructSavePoints) throws Exception
+ {
+ // Step 1 : create model
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(MODEL_LOCATION_PATH));
+ resource.getContents().add(createModel());
+ transaction.commit();
+ session.close();
+
+ // Step 2 : open a push transaction a save locally a modification
+ // Step 2.1 : open a push transaction
+ File fileForStoringChanges = createTempFile();
+ CDOPushTransaction pushTransaction = createPushTransaction(fileForStoringChanges, reconstructSavePoints);
+
+ // Step 2.2 : create a new element
+ addNewChildren(pushTransaction);
+
+ // => make sure that diagram is modified as expected
+ checkDiagramAsCorrectlyBeenModified(pushTransaction);
+
+ // Step 2.3 : save locally
+ pushTransaction.commit();
+ pushTransaction.getSession().close();
+
+ // Step 3 : load changes
+ pushTransaction = createPushTransaction(fileForStoringChanges, reconstructSavePoints);
+
+ // => check that diagram is modified as expected
+ checkDiagramAsCorrectlyBeenModified(pushTransaction);
+
+ // => check that diagram is modified as expected
+ checkDiagramAsCorrectlyBeenModified(pushTransaction);
+
+ // Step 4 : try to modify objects and commit
+ Diagram diagram = getDiagram(pushTransaction);
+
+ @SuppressWarnings("unchecked")
+ EList<Node> children = (EList<Node>)(EList<?>)diagram.getPersistedChildren();
+ Node newElement = children.get(1);
+ newElement.setType("newType");
+ pushTransaction.commit();
+
+ pushTransaction.getSession().close();
+ }
+
+ /**
+ * Creates a Push Transaction with the given options.
+ *
+ * @param fileForStoringChanges
+ * the file that CDOPushTransaction should use to store changes (can be null)
+ * @param reconstructSavePoints
+ * if CDOSavePoints should be reconstructed when creating the PushTransaction
+ */
+ private CDOPushTransaction createPushTransaction(File fileForStoringChanges, boolean reconstructSavePoints)
+ throws IOException
+ {
+ CDOSession session = openSession();
+ CDOTransaction delegate = session.openTransaction();
+ return new CDOPushTransaction(delegate, fileForStoringChanges, reconstructSavePoints);
+ }
+
+ /**
+ * Ensures that the given diagram has correctly been modified :
+ * <ul>
+ * <li>it should contains 2 Nodes</li>
+ * <li>the Second Node should have a "type" Type and its associated element should be the diagram's container's
+ * container</li>
+ * </ul>
+ */
+ @SuppressWarnings("rawtypes")
+ private void checkDiagramAsCorrectlyBeenModified(CDOView view)
+ {
+ Diagram diagram = getDiagram(view);
+ EList children = diagram.getPersistedChildren();
+
+ assertEquals("Failure when loading changes: New elements have not been created.", 2, children.size());
+
+ Node newElement = (Node)children.get(1);
+ assertEquals("Attribute not correctly set.", "type", newElement.getType());
+ assertEquals("Cross reference not correctly set.", diagram.eContainer().eContainer(), newElement.getElement());
+ }
+
+ /**
+ * Returns the diagram model to use for this test.
+ */
+ private Diagram getDiagram(CDOView view)
+ {
+ CDOResource resource = view.getResource(getResourcePath(MODEL_LOCATION_PATH));
+ F f = (F)resource.getContents().get(0);
+ E e = f.getOwnedEs().get(0);
+ A a = e.getOwnedAs().get(0);
+ D d = a.getOwnedDs().get(0);
+ return (Diagram)d.getData();
+ }
+
+ /**
+ * Creates the test model.
+ */
+ @SuppressWarnings("unchecked")
+ private EObject createModel()
+ {
+ F f = getModel6Factory().createF();
+ E e = getModel6Factory().createE();
+ A a = getModel6Factory().createA();
+ D d = getModel6Factory().createD();
+
+ Node child1 = NotationFactory.eINSTANCE.createNode();
+ child1.setElement(a);
+
+ Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ diagram.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL);
+ diagram.getPersistedChildren().add(child1);
+
+ d.setData(diagram);
+ a.getOwnedDs().add(d);
+ e.getOwnedAs().add(a);
+ f.getOwnedEs().add(e);
+
+ return f;
+ }
+
+ /**
+ * Modifies the model by adding a new children of type Node to the Diagram.
+ */
+ @SuppressWarnings("unchecked")
+ private void addNewChildren(CDOTransaction transaction)
+ {
+ Diagram diagram = getDiagram(transaction);
+ A a = (A)diagram.eContainer().eContainer();
+
+ Node child2 = NotationFactory.eINSTANCE.createNode();
+ child2.setElement(a);
+ child2.setType("type");
+ diagram.getPersistedChildren().add(child2);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_368223_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_368223_Test.java
index 8e2fa299b1..c098fa863e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_368223_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_368223_Test.java
@@ -1,240 +1,240 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ronald Krijgsheld - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.InvalidObjectException;
-import org.eclipse.emf.cdo.util.ObjectNotFoundException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * @author Ronald Krijgsheld
- */
-public class Bugzilla_368223_Test extends AbstractCDOTest
-{
- @Requires({ IRepositoryConfig.CAPABILITY_BRANCHING, "MEM" })
- public void testRules1() throws Throwable
- {
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
- transaction.createResource(getResourcePath("/test1"));
- transaction.commit();
-
- AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
- long start = System.currentTimeMillis();
-
- Creator creator = new Creator(exception);
- creator.start();
-
- Loader loader = new Loader(exception);
- loader.start();
-
- creator.join();
- loader.join();
-
- System.out.println(System.currentTimeMillis() - start);
-
- Throwable ex = exception.get();
- if (ex != null && !(ex instanceof Success))
- {
- throw exception.get();
- }
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- disableConsole();
- super.doSetUp();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- disableConsole();
- super.doTearDown();
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class Success extends Exception
- {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * @author Eike Stepper
- */
- private abstract class Actor extends Thread
- {
- private final AtomicReference<Throwable> exception;
-
- protected Actor(AtomicReference<Throwable> exception)
- {
- this.exception = exception;
- }
-
- @Override
- public final void run()
- {
- try
- {
- runSafe(exception);
- }
- catch (Throwable ex)
- {
- exception.compareAndSet(null, ex);
- }
- }
-
- protected abstract void runSafe(AtomicReference<Throwable> exception) throws Exception;
- }
-
- /**
- * @author Ronald Krijgsheld
- */
- private final class Creator extends Actor
- {
- public Creator(AtomicReference<Throwable> exception)
- {
- super(exception);
- }
-
- @Override
- protected void runSafe(AtomicReference<Throwable> exception) throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- List<Company> listOfCompanies = new ArrayList<Company>();
-
- int loop = 10;
- while (exception.get() == null && --loop != 0)
- {
- // System.out.println(loop);
- synchronized (transaction)
- {
- for (int i = 0; i < 100; i++)
- {
- Company company = createCompanyWithCategories(resource);
- listOfCompanies.add(company);
- }
-
- transaction.commit();
-
- while (!listOfCompanies.isEmpty())
- {
- Company company = listOfCompanies.remove(0);
-
- EList<Category> categories = company.getCategories();
- while (!categories.isEmpty())
- {
- categories.remove(0);
- transaction.commit();
- }
-
- resource.getContents().remove(company);
- transaction.commit();
- }
- }
- }
-
- throw new Success();
- }
-
- private Company createCompanyWithCategories(CDOResource resource)
- {
- Company company = getModel1Factory().createCompany();
- EList<Category> categories = company.getCategories();
-
- for (int i = 0; i < 10; i++)
- {
- Category category = getModel1Factory().createCategory();
- categories.add(category);
- }
-
- resource.getContents().add(company);
- return company;
- }
- }
-
- /**
- * @author Ronald Krijgsheld
- */
- private final class Loader extends Actor
- {
- public Loader(AtomicReference<Throwable> exception)
- {
- super(exception);
- }
-
- @Override
- protected void runSafe(AtomicReference<Throwable> exception) throws Exception
- {
- getTestProperties().put(SessionConfig.PROP_TEST_FETCH_RULE_MANAGER, CDOUtil.createThreadLocalFetchRuleManager());
- CDOSession session = openSession();
-
- CDOTransaction transaction = session.openTransaction();
- transaction.options().setFeatureAnalyzer(CDOUtil.createModelBasedFeatureAnalyzer());
-
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- while (exception.get() == null)
- {
- try
- {
- synchronized (transaction)
- {
- for (EObject object : resource.getContents())
- {
- Company company = (Company)object;
- EList<Category> categories = company.getCategories();
- if (categories.size() > 0)
- {
- Category category = categories.get(0);
- msg(category);
- }
- }
- }
- }
- catch (InvalidObjectException ex)
- {
- System.err.println(ex.getMessage());
- continue;
- }
- catch (ObjectNotFoundException ex)
- {
- System.err.println(ex.getMessage());
- continue;
- }
- }
-
- throw new Success();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ronald Krijgsheld - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.InvalidObjectException;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * @author Ronald Krijgsheld
+ */
+public class Bugzilla_368223_Test extends AbstractCDOTest
+{
+ @Requires({ IRepositoryConfig.CAPABILITY_BRANCHING, "MEM" })
+ public void testRules1() throws Throwable
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ transaction.createResource(getResourcePath("/test1"));
+ transaction.commit();
+
+ AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
+ long start = System.currentTimeMillis();
+
+ Creator creator = new Creator(exception);
+ creator.start();
+
+ Loader loader = new Loader(exception);
+ loader.start();
+
+ creator.join();
+ loader.join();
+
+ System.out.println(System.currentTimeMillis() - start);
+
+ Throwable ex = exception.get();
+ if (ex != null && !(ex instanceof Success))
+ {
+ throw exception.get();
+ }
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ disableConsole();
+ super.doSetUp();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ disableConsole();
+ super.doTearDown();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class Success extends Exception
+ {
+ private static final long serialVersionUID = 1L;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private abstract class Actor extends Thread
+ {
+ private final AtomicReference<Throwable> exception;
+
+ protected Actor(AtomicReference<Throwable> exception)
+ {
+ this.exception = exception;
+ }
+
+ @Override
+ public final void run()
+ {
+ try
+ {
+ runSafe(exception);
+ }
+ catch (Throwable ex)
+ {
+ exception.compareAndSet(null, ex);
+ }
+ }
+
+ protected abstract void runSafe(AtomicReference<Throwable> exception) throws Exception;
+ }
+
+ /**
+ * @author Ronald Krijgsheld
+ */
+ private final class Creator extends Actor
+ {
+ public Creator(AtomicReference<Throwable> exception)
+ {
+ super(exception);
+ }
+
+ @Override
+ protected void runSafe(AtomicReference<Throwable> exception) throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ List<Company> listOfCompanies = new ArrayList<Company>();
+
+ int loop = 10;
+ while (exception.get() == null && --loop != 0)
+ {
+ // System.out.println(loop);
+ synchronized (transaction)
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ Company company = createCompanyWithCategories(resource);
+ listOfCompanies.add(company);
+ }
+
+ transaction.commit();
+
+ while (!listOfCompanies.isEmpty())
+ {
+ Company company = listOfCompanies.remove(0);
+
+ EList<Category> categories = company.getCategories();
+ while (!categories.isEmpty())
+ {
+ categories.remove(0);
+ transaction.commit();
+ }
+
+ resource.getContents().remove(company);
+ transaction.commit();
+ }
+ }
+ }
+
+ throw new Success();
+ }
+
+ private Company createCompanyWithCategories(CDOResource resource)
+ {
+ Company company = getModel1Factory().createCompany();
+ EList<Category> categories = company.getCategories();
+
+ for (int i = 0; i < 10; i++)
+ {
+ Category category = getModel1Factory().createCategory();
+ categories.add(category);
+ }
+
+ resource.getContents().add(company);
+ return company;
+ }
+ }
+
+ /**
+ * @author Ronald Krijgsheld
+ */
+ private final class Loader extends Actor
+ {
+ public Loader(AtomicReference<Throwable> exception)
+ {
+ super(exception);
+ }
+
+ @Override
+ protected void runSafe(AtomicReference<Throwable> exception) throws Exception
+ {
+ getTestProperties().put(SessionConfig.PROP_TEST_FETCH_RULE_MANAGER, CDOUtil.createThreadLocalFetchRuleManager());
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ transaction.options().setFeatureAnalyzer(CDOUtil.createModelBasedFeatureAnalyzer());
+
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ while (exception.get() == null)
+ {
+ try
+ {
+ synchronized (transaction)
+ {
+ for (EObject object : resource.getContents())
+ {
+ Company company = (Company)object;
+ EList<Category> categories = company.getCategories();
+ if (categories.size() > 0)
+ {
+ Category category = categories.get(0);
+ msg(category);
+ }
+ }
+ }
+ }
+ catch (InvalidObjectException ex)
+ {
+ System.err.println(ex.getMessage());
+ continue;
+ }
+ catch (ObjectNotFoundException ex)
+ {
+ System.err.println(ex.getMessage());
+ continue;
+ }
+ }
+
+ throw new Success();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bundle/OM.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bundle/OM.java
index 1570270954..0edf03f0a5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bundle/OM.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.tests"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bundle;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Eike Stepper
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.emf.cdo.tests"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConfig.java
index 14130c3a96..e751a5dea0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConfig.java
@@ -1,31 +1,31 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public interface IConfig extends ITestLifecycle, Serializable
-{
- public String getName();
-
- public Map<String, Object> getTestProperties();
-
- public Object getTestProperty(String key);
-
- public boolean isValid(Set<IConfig> configs);
-
- public void initCapabilities(Set<String> capabilities);
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IConfig extends ITestLifecycle, Serializable
+{
+ public String getName();
+
+ public Map<String, Object> getTestProperties();
+
+ public Object getTestProperty(String key);
+
+ public boolean isValid(Set<IConfig> configs);
+
+ public void initCapabilities(Set<String> capabilities);
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java
index 7919707f15..481ec3b33b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java
@@ -1,56 +1,56 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.config.impl.ContainerConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ModelConfig;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.MEMConfig;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.MEMOfflineConfig;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
-
-/**
- * @author Eike Stepper
- */
-public interface IConstants
-{
- public static final ContainerConfig COMBINED = ContainerConfig.Combined.INSTANCE;
-
- public static final ContainerConfig SEPARATED = ContainerConfig.Separated.INSTANCE;
-
- public static final RepositoryConfig MEM = new MEMConfig(false, false, IDGenerationLocation.STORE);
-
- public static final RepositoryConfig MEM_AUDITS = new MEMConfig(true, false, IDGenerationLocation.STORE);
-
- public static final RepositoryConfig MEM_BRANCHES = new MEMConfig(true, true, IDGenerationLocation.STORE);
-
- public static final RepositoryConfig MEM_BRANCHES_UUIDS = new MEMConfig(true, true, IDGenerationLocation.CLIENT);
-
- public static final RepositoryConfig MEM_OFFLINE = new MEMOfflineConfig(IDGenerationLocation.CLIENT);
-
- /**
- * @deprecated Not yet supported.
- */
- @Deprecated
- public static final SessionConfig EMBEDDED = SessionConfig.Embedded.INSTANCE;
-
- public static final SessionConfig JVM = Net4j.JVM.INSTANCE;
-
- public static final SessionConfig TCP = Net4j.TCP.INSTANCE;
-
- public static final SessionConfig SSL = Net4j.SSL.INSTANCE;
-
- public static final ModelConfig NATIVE = ModelConfig.Native.INSTANCE;
-
- public static final ModelConfig LEGACY = ModelConfig.Legacy.INSTANCE;
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.config.impl.ContainerConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ModelConfig;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.MEMConfig;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.MEMOfflineConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IConstants
+{
+ public static final ContainerConfig COMBINED = ContainerConfig.Combined.INSTANCE;
+
+ public static final ContainerConfig SEPARATED = ContainerConfig.Separated.INSTANCE;
+
+ public static final RepositoryConfig MEM = new MEMConfig(false, false, IDGenerationLocation.STORE);
+
+ public static final RepositoryConfig MEM_AUDITS = new MEMConfig(true, false, IDGenerationLocation.STORE);
+
+ public static final RepositoryConfig MEM_BRANCHES = new MEMConfig(true, true, IDGenerationLocation.STORE);
+
+ public static final RepositoryConfig MEM_BRANCHES_UUIDS = new MEMConfig(true, true, IDGenerationLocation.CLIENT);
+
+ public static final RepositoryConfig MEM_OFFLINE = new MEMOfflineConfig(IDGenerationLocation.CLIENT);
+
+ /**
+ * @deprecated Not yet supported.
+ */
+ @Deprecated
+ public static final SessionConfig EMBEDDED = SessionConfig.Embedded.INSTANCE;
+
+ public static final SessionConfig JVM = Net4j.JVM.INSTANCE;
+
+ public static final SessionConfig TCP = Net4j.TCP.INSTANCE;
+
+ public static final SessionConfig SSL = Net4j.SSL.INSTANCE;
+
+ public static final ModelConfig NATIVE = ModelConfig.Native.INSTANCE;
+
+ public static final ModelConfig LEGACY = ModelConfig.Legacy.INSTANCE;
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IContainerConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IContainerConfig.java
index 769536b8bd..368865ac67 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IContainerConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IContainerConfig.java
@@ -1,31 +1,31 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config;
-
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-/**
- * @author Eike Stepper
- */
-public interface IContainerConfig extends IConfig
-{
- public static final String CAPABILITY_COMBINED = "containers.combined";
-
- public static final String CAPABILITY_SEPARATED = "containers.separated";
-
- public boolean hasClientContainer();
-
- public boolean hasServerContainer();
-
- public IManagedContainer getClientContainer();
-
- public IManagedContainer getServerContainer();
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config;
+
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IContainerConfig extends IConfig
+{
+ public static final String CAPABILITY_COMBINED = "containers.combined";
+
+ public static final String CAPABILITY_SEPARATED = "containers.separated";
+
+ public boolean hasClientContainer();
+
+ public boolean hasServerContainer();
+
+ public IManagedContainer getClientContainer();
+
+ public IManagedContainer getServerContainer();
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IModelConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IModelConfig.java
index 6f17bb0056..6fd379e974 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IModelConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IModelConfig.java
@@ -1,73 +1,73 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config;
-
-import org.eclipse.emf.cdo.tests.mango.MangoFactory;
-import org.eclipse.emf.cdo.tests.mango.MangoPackage;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.model2.Model2Factory;
-import org.eclipse.emf.cdo.tests.model2.Model2Package;
-import org.eclipse.emf.cdo.tests.model3.Model3Factory;
-import org.eclipse.emf.cdo.tests.model3.Model3Package;
-import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackageFactory;
-import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.tests.model4.model4Package;
-import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
-import org.eclipse.emf.cdo.tests.model5.Model5Factory;
-import org.eclipse.emf.cdo.tests.model5.Model5Package;
-import org.eclipse.emf.cdo.tests.model6.Model6Factory;
-import org.eclipse.emf.cdo.tests.model6.Model6Package;
-
-/**
- * @author Eike Stepper
- */
-public interface IModelConfig extends IConfig
-{
- public static final String CAPABILITY_NATIVE = "model.native";
-
- public static final String CAPABILITY_LEGACY = "model.legacy";
-
- public MangoFactory getMangoFactory();
-
- public MangoPackage getMangoPackage();
-
- public Model1Factory getModel1Factory();
-
- public Model1Package getModel1Package();
-
- public Model2Factory getModel2Factory();
-
- public Model2Package getModel2Package();
-
- public Model3Factory getModel3Factory();
-
- public Model3Package getModel3Package();
-
- public SubpackageFactory getModel3SubPackageFactory();
-
- public SubpackagePackage getModel3SubPackagePackage();
-
- public model4Factory getModel4Factory();
-
- public model4Package getModel4Package();
-
- public model4interfacesPackage getModel4InterfacesPackage();
-
- public Model5Factory getModel5Factory();
-
- public Model5Package getModel5Package();
-
- public Model6Factory getModel6Factory();
-
- public Model6Package getModel6Package();
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config;
+
+import org.eclipse.emf.cdo.tests.mango.MangoFactory;
+import org.eclipse.emf.cdo.tests.mango.MangoPackage;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model2.Model2Factory;
+import org.eclipse.emf.cdo.tests.model2.Model2Package;
+import org.eclipse.emf.cdo.tests.model3.Model3Factory;
+import org.eclipse.emf.cdo.tests.model3.Model3Package;
+import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackageFactory;
+import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.tests.model4.model4Package;
+import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
+import org.eclipse.emf.cdo.tests.model5.Model5Factory;
+import org.eclipse.emf.cdo.tests.model5.Model5Package;
+import org.eclipse.emf.cdo.tests.model6.Model6Factory;
+import org.eclipse.emf.cdo.tests.model6.Model6Package;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IModelConfig extends IConfig
+{
+ public static final String CAPABILITY_NATIVE = "model.native";
+
+ public static final String CAPABILITY_LEGACY = "model.legacy";
+
+ public MangoFactory getMangoFactory();
+
+ public MangoPackage getMangoPackage();
+
+ public Model1Factory getModel1Factory();
+
+ public Model1Package getModel1Package();
+
+ public Model2Factory getModel2Factory();
+
+ public Model2Package getModel2Package();
+
+ public Model3Factory getModel3Factory();
+
+ public Model3Package getModel3Package();
+
+ public SubpackageFactory getModel3SubPackageFactory();
+
+ public SubpackagePackage getModel3SubPackagePackage();
+
+ public model4Factory getModel4Factory();
+
+ public model4Package getModel4Package();
+
+ public model4interfacesPackage getModel4InterfacesPackage();
+
+ public Model5Factory getModel5Factory();
+
+ public Model5Package getModel5Package();
+
+ public Model6Factory getModel6Factory();
+
+ public Model6Package getModel6Package();
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IScenario.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IScenario.java
index 217141c5e3..7877cc38c3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IScenario.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IScenario.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config;
-
-import java.io.Serializable;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public interface IScenario extends ITestLifecycle, Serializable
-{
- public IContainerConfig getContainerConfig();
-
- public IScenario setContainerConfig(IContainerConfig containerConfig);
-
- public IRepositoryConfig getRepositoryConfig();
-
- public IScenario setRepositoryConfig(IRepositoryConfig repositoryConfig);
-
- public ISessionConfig getSessionConfig();
-
- public IScenario setSessionConfig(ISessionConfig sessionConfig);
-
- public IModelConfig getModelConfig();
-
- public IScenario setModelConfig(IModelConfig modelConfig);
-
- public Set<IConfig> getConfigs();
-
- public Set<String> getCapabilities();
-
- public boolean isValid();
-
- public void save();
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config;
+
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IScenario extends ITestLifecycle, Serializable
+{
+ public IContainerConfig getContainerConfig();
+
+ public IScenario setContainerConfig(IContainerConfig containerConfig);
+
+ public IRepositoryConfig getRepositoryConfig();
+
+ public IScenario setRepositoryConfig(IRepositoryConfig repositoryConfig);
+
+ public ISessionConfig getSessionConfig();
+
+ public IScenario setSessionConfig(ISessionConfig sessionConfig);
+
+ public IModelConfig getModelConfig();
+
+ public IScenario setModelConfig(IModelConfig modelConfig);
+
+ public Set<IConfig> getConfigs();
+
+ public Set<String> getCapabilities();
+
+ public boolean isValid();
+
+ public void save();
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java
index d16ebfe333..63a56df20e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java
@@ -1,39 +1,39 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-
-/**
- * @author Eike Stepper
- */
-public interface ISessionConfig extends IConfig
-{
- public static final String CAPABILITY_EMBEDDED = "session.embedded";
-
- public static final String CAPABILITY_NET4J = "session.net4j";
-
- public static final String CAPABILITY_NET4J_JVM = "session.net4j.jvm";
-
- public static final String CAPABILITY_NET4J_TCP = "session.net4j.tcp";
-
- public static final String CAPABILITY_NET4J_SSL = "session.net4j.ssl";
-
- public void startTransport() throws Exception;
-
- public void stopTransport() throws Exception;
-
- public String getURIPrefix();
-
- public CDOSession openSession();
-
- public CDOSession openSession(String repositoryName);
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ISessionConfig extends IConfig
+{
+ public static final String CAPABILITY_EMBEDDED = "session.embedded";
+
+ public static final String CAPABILITY_NET4J = "session.net4j";
+
+ public static final String CAPABILITY_NET4J_JVM = "session.net4j.jvm";
+
+ public static final String CAPABILITY_NET4J_TCP = "session.net4j.tcp";
+
+ public static final String CAPABILITY_NET4J_SSL = "session.net4j.ssl";
+
+ public void startTransport() throws Exception;
+
+ public void stopTransport() throws Exception;
+
+ public String getURIPrefix();
+
+ public CDOSession openSession();
+
+ public CDOSession openSession(String repositoryName);
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ITestLifecycle.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ITestLifecycle.java
index 7cf6a8b517..8802074116 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ITestLifecycle.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ITestLifecycle.java
@@ -1,27 +1,27 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config;
-
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-
-/**
- * @author Eike Stepper
- */
-public interface ITestLifecycle
-{
- public ConfigTest getCurrentTest();
-
- public void setCurrentTest(ConfigTest currentTest);
-
- public void setUp() throws Exception;
-
- public void tearDown() throws Exception;
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config;
+
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ITestLifecycle
+{
+ public ConfigTest getCurrentTest();
+
+ public void setCurrentTest(ConfigTest currentTest);
+
+ public void setUp() throws Exception;
+
+ public void tearDown() throws Exception;
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java
index d69230007d..d25c0d79b7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java
@@ -1,112 +1,112 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config.impl;
-
-import org.eclipse.emf.cdo.tests.config.IConfig;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public abstract class Config implements IConfig
-{
- private static final long serialVersionUID = 1L;
-
- private String name;
-
- private transient ConfigTest currentTest;
-
- public Config(String name)
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- @Override
- public String toString()
- {
- return getName();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof IConfig)
- {
- IConfig that = (IConfig)obj;
- return ObjectUtil.equals(name, that.getName());
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return ObjectUtil.hashCode(name);
- }
-
- public ConfigTest getCurrentTest()
- {
- return currentTest;
- }
-
- public void setCurrentTest(ConfigTest currentTest)
- {
- this.currentTest = currentTest;
- }
-
- public Map<String, Object> getTestProperties()
- {
- return currentTest.getTestProperties();
- }
-
- public Object getTestProperty(String key)
- {
- Map<String, Object> testProperties = getTestProperties();
- if (testProperties != null)
- {
- return testProperties.get(key);
- }
-
- return null;
- }
-
- public boolean isValid(Set<IConfig> configs)
- {
- return true;
- }
-
- public void setUp() throws Exception
- {
- if (currentTest == null)
- {
- throw new IllegalStateException("currentTest == null");
- }
- }
-
- public void tearDown() throws Exception
- {
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config.impl;
+
+import org.eclipse.emf.cdo.tests.config.IConfig;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class Config implements IConfig
+{
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+
+ private transient ConfigTest currentTest;
+
+ public Config(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getName();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof IConfig)
+ {
+ IConfig that = (IConfig)obj;
+ return ObjectUtil.equals(name, that.getName());
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(name);
+ }
+
+ public ConfigTest getCurrentTest()
+ {
+ return currentTest;
+ }
+
+ public void setCurrentTest(ConfigTest currentTest)
+ {
+ this.currentTest = currentTest;
+ }
+
+ public Map<String, Object> getTestProperties()
+ {
+ return currentTest.getTestProperties();
+ }
+
+ public Object getTestProperty(String key)
+ {
+ Map<String, Object> testProperties = getTestProperties();
+ if (testProperties != null)
+ {
+ return testProperties.get(key);
+ }
+
+ return null;
+ }
+
+ public boolean isValid(Set<IConfig> configs)
+ {
+ return true;
+ }
+
+ public void setUp() throws Exception
+ {
+ if (currentTest == null)
+ {
+ throw new IllegalStateException("currentTest == null");
+ }
+ }
+
+ public void tearDown() throws Exception
+ {
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java
index 7d5c3500eb..49b1158a8e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java
@@ -1,681 +1,681 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config.impl;
-
-import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalStore.NoExternalReferences;
-import org.eclipse.emf.cdo.spi.server.InternalStore.NoFeatureMaps;
-import org.eclipse.emf.cdo.spi.server.InternalStore.NoHandleRevisions;
-import org.eclipse.emf.cdo.spi.server.InternalStore.NoLargeObjects;
-import org.eclipse.emf.cdo.spi.server.InternalStore.NoQueryXRefs;
-import org.eclipse.emf.cdo.spi.server.InternalStore.NoRawAccess;
-import org.eclipse.emf.cdo.tests.config.IConstants;
-import org.eclipse.emf.cdo.tests.config.IContainerConfig;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.ISessionConfig;
-import org.eclipse.emf.cdo.tests.mango.MangoFactory;
-import org.eclipse.emf.cdo.tests.mango.MangoPackage;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.model2.Model2Factory;
-import org.eclipse.emf.cdo.tests.model2.Model2Package;
-import org.eclipse.emf.cdo.tests.model3.Model3Factory;
-import org.eclipse.emf.cdo.tests.model3.Model3Package;
-import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackageFactory;
-import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.tests.model4.model4Package;
-import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
-import org.eclipse.emf.cdo.tests.model5.Model5Factory;
-import org.eclipse.emf.cdo.tests.model5.Model5Package;
-import org.eclipse.emf.cdo.tests.model6.Model6Factory;
-import org.eclipse.emf.cdo.tests.model6.Model6Package;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import junit.framework.TestResult;
-
-/**
- * @author Eike Stepper
- */
-public abstract class ConfigTest extends AbstractOMTest implements IConstants
-{
- @Inherited
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ ElementType.TYPE, ElementType.METHOD })
- public @interface CleanRepositoriesBefore
- {
- }
-
- @Inherited
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ ElementType.TYPE, ElementType.METHOD })
- public @interface CleanRepositoriesAfter
- {
- }
-
- @Inherited
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ ElementType.TYPE, ElementType.METHOD })
- public @interface Requires
- {
- String[] value();
- }
-
- @Inherited
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ ElementType.TYPE, ElementType.METHOD })
- public @interface Skips
- {
- String[] value();
- }
-
- public ConfigTest()
- {
- }
-
- private IScenario scenario;
-
- public synchronized IScenario getScenario()
- {
- if (scenario == null)
- {
- setScenario(getDefaultScenario());
- }
-
- return scenario;
- }
-
- public synchronized void setScenario(IScenario scenario)
- {
- this.scenario = scenario;
- if (scenario != null)
- {
- scenario.setCurrentTest(this);
- }
- }
-
- private Properties homeProperties;
-
- private Map<String, Object> testProperties;
-
- public synchronized Properties getHomeProperties()
- {
- if (homeProperties == null)
- {
- homeProperties = new Properties();
- String home = System.getProperty("user.home");
- if (home != null)
- {
- File file = new File(home, ".cdo_config_test.properties");
- if (file.exists())
- {
- FileInputStream stream = IOUtil.openInputStream(file);
-
- try
- {
- homeProperties.load(stream);
- }
- catch (IOException ex)
- {
- throw WrappedException.wrap(ex);
- }
- finally
- {
- IOUtil.close(stream);
- }
- }
- }
- }
-
- return homeProperties;
- }
-
- public synchronized void setHomeProperties(Properties homeProperties)
- {
- this.homeProperties = homeProperties;
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // //////////////////////// Container //////////////////////////////////////
-
- /**
- * @category Container
- */
- public IContainerConfig getContainerConfig()
- {
- return getScenario().getContainerConfig();
- }
-
- /**
- * @category Container
- */
- public boolean hasClientContainer()
- {
- return getContainerConfig().hasClientContainer();
- }
-
- /**
- * @category Container
- */
- public boolean hasServerContainer()
- {
- return getContainerConfig().hasServerContainer();
- }
-
- /**
- * @category Container
- */
- public IManagedContainer getClientContainer()
- {
- return getContainerConfig().getClientContainer();
- }
-
- /**
- * @category Container
- */
- public IManagedContainer getServerContainer()
- {
- return getContainerConfig().getServerContainer();
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // //////////////////////// CDORepositoryInfo /////////////////////////////////////
-
- /**
- * @category CDORepositoryInfo
- */
- public IRepositoryConfig getRepositoryConfig()
- {
- return getScenario().getRepositoryConfig();
- }
-
- /**
- * @category CDORepositoryInfo
- */
- public Map<String, String> getRepositoryProperties()
- {
- return getRepositoryConfig().getRepositoryProperties();
- }
-
- /**
- * @category CDORepositoryInfo
- */
- public InternalRepository getRepository(String name, boolean activate)
- {
- return getRepositoryConfig().getRepository(name, activate);
- }
-
- /**
- * @category CDORepositoryInfo
- */
- public InternalRepository getRepository(String name)
- {
- return getRepositoryConfig().getRepository(name);
- }
-
- /**
- * @category CDORepositoryInfo
- */
- public InternalRepository getRepository()
- {
- return getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
- }
-
- public void registerRepository(IRepository repository)
- {
- getRepositoryConfig().registerRepository((InternalRepository)repository);
- }
-
- public InternalRepository restartRepository()
- {
- return restartRepository(IRepositoryConfig.REPOSITORY_NAME);
- }
-
- public InternalRepository restartRepository(String name)
- {
- try
- {
- getRepositoryConfig().setRestarting(true);
- InternalRepository repo = getRepository(name);
- LifecycleUtil.deactivate(repo);
- return getRepository(name);
- }
- finally
- {
- getRepositoryConfig().setRestarting(false);
- }
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // //////////////////////// Session ////////////////////////////////////////
-
- /**
- * @category Session
- */
- public ISessionConfig getSessionConfig()
- {
- return getScenario().getSessionConfig();
- }
-
- /**
- * @category Session
- */
- public void startTransport() throws Exception
- {
- getSessionConfig().startTransport();
- }
-
- /**
- * @category Session
- */
- public void stopTransport() throws Exception
- {
- getSessionConfig().stopTransport();
- }
-
- public String getURIPrefix()
- {
- return getSessionConfig().getURIPrefix();
- }
-
- /**
- * @category Session
- */
- public CDOSession openSession()
- {
- determineCodeLink();
- return getSessionConfig().openSession();
- }
-
- /**
- * @category Session
- */
- public CDOSession openSession(String repositoryName)
- {
- determineCodeLink();
- return getSessionConfig().openSession(repositoryName);
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // //////////////////////// Model //////////////////////////////////////////
-
- /**
- * @category Model
- */
- public IModelConfig getModelConfig()
- {
- return getScenario().getModelConfig();
- }
-
- /**
- * @category Model
- */
- public MangoFactory getMangoFactory()
- {
- return getModelConfig().getMangoFactory();
- }
-
- /**
- * @category Model
- */
- public MangoPackage getMangoPackage()
- {
- return getModelConfig().getMangoPackage();
- }
-
- /**
- * @category Model
- */
- public Model1Factory getModel1Factory()
- {
- return getModelConfig().getModel1Factory();
- }
-
- /**
- * @category Model
- */
- public Model1Package getModel1Package()
- {
- return getModelConfig().getModel1Package();
- }
-
- /**
- * @category Model
- */
- public Model2Factory getModel2Factory()
- {
- return getModelConfig().getModel2Factory();
- }
-
- /**
- * @category Model
- */
- public Model2Package getModel2Package()
- {
- return getModelConfig().getModel2Package();
- }
-
- /**
- * @category Model
- */
- public Model3Factory getModel3Factory()
- {
- return getModelConfig().getModel3Factory();
- }
-
- /**
- * @category Model
- */
- public Model3Package getModel3Package()
- {
- return getModelConfig().getModel3Package();
- }
-
- /**
- * @category Model
- */
- public SubpackageFactory getModel3SubpackageFactory()
- {
- return getModelConfig().getModel3SubPackageFactory();
- }
-
- /**
- * @category Model
- */
- public SubpackagePackage getModel3SubpackagePackage()
- {
- return getModelConfig().getModel3SubPackagePackage();
- }
-
- /**
- * @category Model
- */
- public model4Factory getModel4Factory()
- {
- return getModelConfig().getModel4Factory();
- }
-
- /**
- * @category Model
- */
- public model4Package getModel4Package()
- {
- return getModelConfig().getModel4Package();
- }
-
- /**
- * @category Model
- */
- public model4interfacesPackage getModel4InterfacesPackage()
- {
- return getModelConfig().getModel4InterfacesPackage();
- }
-
- /**
- * @category Model
- */
- public Model5Factory getModel5Factory()
- {
- return getModelConfig().getModel5Factory();
- }
-
- /**
- * @category Model
- */
- public Model5Package getModel5Package()
- {
- return getModelConfig().getModel5Package();
- }
-
- /**
- * @category Model
- */
- public Model6Factory getModel6Factory()
- {
- return getModelConfig().getModel6Factory();
- }
-
- /**
- * @category Model
- */
- public Model6Package getModel6Package()
- {
- return getModelConfig().getModel6Package();
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // /////////////////////////////////////////////////////////////////////////
-
- public synchronized Map<String, Object> getTestProperties()
- {
- if (testProperties == null)
- {
- testProperties = new HashMap<String, Object>();
- }
-
- return testProperties;
- }
-
- public boolean isValid()
- {
- return true;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}.{1} [{2}, {3}, {4}, {5}]", getClass().getSimpleName(), getName(),
- getContainerConfig(), getRepositoryConfig(), getSessionConfig(), getModelConfig());
- }
-
- @Override
- public TestResult run()
- {
- try
- {
- return super.run();
- }
- catch (ConfigTestException ex)
- {
- throw ex;
- }
- catch (Throwable ex)
- {
- throw new ConfigTestException("Error in " + this, ex);
- }
- }
-
- @Override
- public void runBare() throws Throwable
- {
- try
- {
- super.runBare();
- }
- catch (AssertionError error)
- {
- throw error;
- }
- catch (Throwable ex)
- {
- // We wrap anything that is not a test failure
- throw new ConfigTestException("Error in " + this, ex);
- }
- }
-
- /**
- * Constructs a test-specific resource path of the format "/TestClass_testMethod/resourceName". Using this instead of
- * (just) a hardcoded name for the test resource, ensures that the test method is isolated from all others at the
- * resource level.
- *
- * @param resourceName
- * - the test-local name of the resource (or null if one wants to receive the path of the test-local resource
- * folder
- * @return the full path of the resource
- */
- public final String getResourcePath(String resourceName)
- {
- StringBuilder builder = new StringBuilder();
- builder.append('/');
- builder.append(getClass().getSimpleName()); // Name of this test class
- builder.append('_');
- builder.append(getName()); // Name of the executing test method
-
- if (resourceName == null || resourceName.length() == 0 || resourceName.charAt(0) != '/')
- {
- builder.append('/');
- }
-
- if (resourceName != null)
- {
- builder.append(resourceName);
- }
-
- return builder.toString();
- }
-
- protected boolean isConfig(Config config)
- {
- return ObjectUtil.equals(getContainerConfig(), config) //
- || ObjectUtil.equals(getRepositoryConfig(), config) //
- || ObjectUtil.equals(getSessionConfig(), config) //
- || ObjectUtil.equals(getModelConfig(), config);
- }
-
- protected void skipStoreWithoutExternalReferences()
- {
- skipTest(getRepository().getStore() instanceof NoExternalReferences);
- }
-
- protected void skipStoreWithoutQueryXRefs()
- {
- skipTest(getRepository().getStore() instanceof NoQueryXRefs);
- }
-
- protected void skipStoreWithoutLargeObjects()
- {
- skipTest(getRepository().getStore() instanceof NoLargeObjects);
- }
-
- protected void skipStoreWithoutFeatureMaps()
- {
- skipTest(getRepository().getStore() instanceof NoFeatureMaps);
- }
-
- protected void skipStoreWithoutHandleRevisions()
- {
- skipTest(getRepository().getStore() instanceof NoHandleRevisions);
- }
-
- protected void skipStoreWithoutRawAccess()
- {
- skipTest(getRepository().getStore() instanceof NoRawAccess);
- }
-
- protected void clearCache(CDORevisionManager revisionManager)
- {
- ((InternalCDORevisionManager)revisionManager).getCache().clear();
- }
-
- public void restartScenario() throws Exception
- {
- IOUtil.OUT().println("RESTARTING SCENARIO");
- stopTransport();
-
- IScenario scenario = getScenario();
- scenario.tearDown();
- scenario.setUp();
-
- startTransport();
- IOUtil.OUT().println("RESTARTING SCENARIO - FINISHED");
- }
-
- protected IScenario getDefaultScenario()
- {
- IScenario scenario;
-
- try
- {
- scenario = Scenario.load();
- if (scenario == null)
- {
- scenario = Scenario.getDefault();
- }
- }
- catch (Exception ex)
- {
- scenario = Scenario.getDefault();
- }
-
- return scenario;
- }
-
- @Override
- public void setUp() throws Exception
- {
- getScenario();
- super.setUp();
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- getScenario().setUp();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- try
- {
- getScenario().tearDown();
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- }
-
- try
- {
- super.doTearDown();
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config.impl;
+
+import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalStore.NoExternalReferences;
+import org.eclipse.emf.cdo.spi.server.InternalStore.NoFeatureMaps;
+import org.eclipse.emf.cdo.spi.server.InternalStore.NoHandleRevisions;
+import org.eclipse.emf.cdo.spi.server.InternalStore.NoLargeObjects;
+import org.eclipse.emf.cdo.spi.server.InternalStore.NoQueryXRefs;
+import org.eclipse.emf.cdo.spi.server.InternalStore.NoRawAccess;
+import org.eclipse.emf.cdo.tests.config.IConstants;
+import org.eclipse.emf.cdo.tests.config.IContainerConfig;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.ISessionConfig;
+import org.eclipse.emf.cdo.tests.mango.MangoFactory;
+import org.eclipse.emf.cdo.tests.mango.MangoPackage;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model2.Model2Factory;
+import org.eclipse.emf.cdo.tests.model2.Model2Package;
+import org.eclipse.emf.cdo.tests.model3.Model3Factory;
+import org.eclipse.emf.cdo.tests.model3.Model3Package;
+import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackageFactory;
+import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.tests.model4.model4Package;
+import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
+import org.eclipse.emf.cdo.tests.model5.Model5Factory;
+import org.eclipse.emf.cdo.tests.model5.Model5Package;
+import org.eclipse.emf.cdo.tests.model6.Model6Factory;
+import org.eclipse.emf.cdo.tests.model6.Model6Package;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.TestResult;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class ConfigTest extends AbstractOMTest implements IConstants
+{
+ @Inherited
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ ElementType.TYPE, ElementType.METHOD })
+ public @interface CleanRepositoriesBefore
+ {
+ }
+
+ @Inherited
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ ElementType.TYPE, ElementType.METHOD })
+ public @interface CleanRepositoriesAfter
+ {
+ }
+
+ @Inherited
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ ElementType.TYPE, ElementType.METHOD })
+ public @interface Requires
+ {
+ String[] value();
+ }
+
+ @Inherited
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ ElementType.TYPE, ElementType.METHOD })
+ public @interface Skips
+ {
+ String[] value();
+ }
+
+ public ConfigTest()
+ {
+ }
+
+ private IScenario scenario;
+
+ public synchronized IScenario getScenario()
+ {
+ if (scenario == null)
+ {
+ setScenario(getDefaultScenario());
+ }
+
+ return scenario;
+ }
+
+ public synchronized void setScenario(IScenario scenario)
+ {
+ this.scenario = scenario;
+ if (scenario != null)
+ {
+ scenario.setCurrentTest(this);
+ }
+ }
+
+ private Properties homeProperties;
+
+ private Map<String, Object> testProperties;
+
+ public synchronized Properties getHomeProperties()
+ {
+ if (homeProperties == null)
+ {
+ homeProperties = new Properties();
+ String home = System.getProperty("user.home");
+ if (home != null)
+ {
+ File file = new File(home, ".cdo_config_test.properties");
+ if (file.exists())
+ {
+ FileInputStream stream = IOUtil.openInputStream(file);
+
+ try
+ {
+ homeProperties.load(stream);
+ }
+ catch (IOException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ finally
+ {
+ IOUtil.close(stream);
+ }
+ }
+ }
+ }
+
+ return homeProperties;
+ }
+
+ public synchronized void setHomeProperties(Properties homeProperties)
+ {
+ this.homeProperties = homeProperties;
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // //////////////////////// Container //////////////////////////////////////
+
+ /**
+ * @category Container
+ */
+ public IContainerConfig getContainerConfig()
+ {
+ return getScenario().getContainerConfig();
+ }
+
+ /**
+ * @category Container
+ */
+ public boolean hasClientContainer()
+ {
+ return getContainerConfig().hasClientContainer();
+ }
+
+ /**
+ * @category Container
+ */
+ public boolean hasServerContainer()
+ {
+ return getContainerConfig().hasServerContainer();
+ }
+
+ /**
+ * @category Container
+ */
+ public IManagedContainer getClientContainer()
+ {
+ return getContainerConfig().getClientContainer();
+ }
+
+ /**
+ * @category Container
+ */
+ public IManagedContainer getServerContainer()
+ {
+ return getContainerConfig().getServerContainer();
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // //////////////////////// CDORepositoryInfo /////////////////////////////////////
+
+ /**
+ * @category CDORepositoryInfo
+ */
+ public IRepositoryConfig getRepositoryConfig()
+ {
+ return getScenario().getRepositoryConfig();
+ }
+
+ /**
+ * @category CDORepositoryInfo
+ */
+ public Map<String, String> getRepositoryProperties()
+ {
+ return getRepositoryConfig().getRepositoryProperties();
+ }
+
+ /**
+ * @category CDORepositoryInfo
+ */
+ public InternalRepository getRepository(String name, boolean activate)
+ {
+ return getRepositoryConfig().getRepository(name, activate);
+ }
+
+ /**
+ * @category CDORepositoryInfo
+ */
+ public InternalRepository getRepository(String name)
+ {
+ return getRepositoryConfig().getRepository(name);
+ }
+
+ /**
+ * @category CDORepositoryInfo
+ */
+ public InternalRepository getRepository()
+ {
+ return getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME);
+ }
+
+ public void registerRepository(IRepository repository)
+ {
+ getRepositoryConfig().registerRepository((InternalRepository)repository);
+ }
+
+ public InternalRepository restartRepository()
+ {
+ return restartRepository(IRepositoryConfig.REPOSITORY_NAME);
+ }
+
+ public InternalRepository restartRepository(String name)
+ {
+ try
+ {
+ getRepositoryConfig().setRestarting(true);
+ InternalRepository repo = getRepository(name);
+ LifecycleUtil.deactivate(repo);
+ return getRepository(name);
+ }
+ finally
+ {
+ getRepositoryConfig().setRestarting(false);
+ }
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // //////////////////////// Session ////////////////////////////////////////
+
+ /**
+ * @category Session
+ */
+ public ISessionConfig getSessionConfig()
+ {
+ return getScenario().getSessionConfig();
+ }
+
+ /**
+ * @category Session
+ */
+ public void startTransport() throws Exception
+ {
+ getSessionConfig().startTransport();
+ }
+
+ /**
+ * @category Session
+ */
+ public void stopTransport() throws Exception
+ {
+ getSessionConfig().stopTransport();
+ }
+
+ public String getURIPrefix()
+ {
+ return getSessionConfig().getURIPrefix();
+ }
+
+ /**
+ * @category Session
+ */
+ public CDOSession openSession()
+ {
+ determineCodeLink();
+ return getSessionConfig().openSession();
+ }
+
+ /**
+ * @category Session
+ */
+ public CDOSession openSession(String repositoryName)
+ {
+ determineCodeLink();
+ return getSessionConfig().openSession(repositoryName);
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // //////////////////////// Model //////////////////////////////////////////
+
+ /**
+ * @category Model
+ */
+ public IModelConfig getModelConfig()
+ {
+ return getScenario().getModelConfig();
+ }
+
+ /**
+ * @category Model
+ */
+ public MangoFactory getMangoFactory()
+ {
+ return getModelConfig().getMangoFactory();
+ }
+
+ /**
+ * @category Model
+ */
+ public MangoPackage getMangoPackage()
+ {
+ return getModelConfig().getMangoPackage();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model1Factory getModel1Factory()
+ {
+ return getModelConfig().getModel1Factory();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model1Package getModel1Package()
+ {
+ return getModelConfig().getModel1Package();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model2Factory getModel2Factory()
+ {
+ return getModelConfig().getModel2Factory();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model2Package getModel2Package()
+ {
+ return getModelConfig().getModel2Package();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model3Factory getModel3Factory()
+ {
+ return getModelConfig().getModel3Factory();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model3Package getModel3Package()
+ {
+ return getModelConfig().getModel3Package();
+ }
+
+ /**
+ * @category Model
+ */
+ public SubpackageFactory getModel3SubpackageFactory()
+ {
+ return getModelConfig().getModel3SubPackageFactory();
+ }
+
+ /**
+ * @category Model
+ */
+ public SubpackagePackage getModel3SubpackagePackage()
+ {
+ return getModelConfig().getModel3SubPackagePackage();
+ }
+
+ /**
+ * @category Model
+ */
+ public model4Factory getModel4Factory()
+ {
+ return getModelConfig().getModel4Factory();
+ }
+
+ /**
+ * @category Model
+ */
+ public model4Package getModel4Package()
+ {
+ return getModelConfig().getModel4Package();
+ }
+
+ /**
+ * @category Model
+ */
+ public model4interfacesPackage getModel4InterfacesPackage()
+ {
+ return getModelConfig().getModel4InterfacesPackage();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model5Factory getModel5Factory()
+ {
+ return getModelConfig().getModel5Factory();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model5Package getModel5Package()
+ {
+ return getModelConfig().getModel5Package();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model6Factory getModel6Factory()
+ {
+ return getModelConfig().getModel6Factory();
+ }
+
+ /**
+ * @category Model
+ */
+ public Model6Package getModel6Package()
+ {
+ return getModelConfig().getModel6Package();
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////////////
+
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ if (testProperties == null)
+ {
+ testProperties = new HashMap<String, Object>();
+ }
+
+ return testProperties;
+ }
+
+ public boolean isValid()
+ {
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}.{1} [{2}, {3}, {4}, {5}]", getClass().getSimpleName(), getName(),
+ getContainerConfig(), getRepositoryConfig(), getSessionConfig(), getModelConfig());
+ }
+
+ @Override
+ public TestResult run()
+ {
+ try
+ {
+ return super.run();
+ }
+ catch (ConfigTestException ex)
+ {
+ throw ex;
+ }
+ catch (Throwable ex)
+ {
+ throw new ConfigTestException("Error in " + this, ex);
+ }
+ }
+
+ @Override
+ public void runBare() throws Throwable
+ {
+ try
+ {
+ super.runBare();
+ }
+ catch (AssertionError error)
+ {
+ throw error;
+ }
+ catch (Throwable ex)
+ {
+ // We wrap anything that is not a test failure
+ throw new ConfigTestException("Error in " + this, ex);
+ }
+ }
+
+ /**
+ * Constructs a test-specific resource path of the format "/TestClass_testMethod/resourceName". Using this instead of
+ * (just) a hardcoded name for the test resource, ensures that the test method is isolated from all others at the
+ * resource level.
+ *
+ * @param resourceName
+ * - the test-local name of the resource (or null if one wants to receive the path of the test-local resource
+ * folder
+ * @return the full path of the resource
+ */
+ public final String getResourcePath(String resourceName)
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append('/');
+ builder.append(getClass().getSimpleName()); // Name of this test class
+ builder.append('_');
+ builder.append(getName()); // Name of the executing test method
+
+ if (resourceName == null || resourceName.length() == 0 || resourceName.charAt(0) != '/')
+ {
+ builder.append('/');
+ }
+
+ if (resourceName != null)
+ {
+ builder.append(resourceName);
+ }
+
+ return builder.toString();
+ }
+
+ protected boolean isConfig(Config config)
+ {
+ return ObjectUtil.equals(getContainerConfig(), config) //
+ || ObjectUtil.equals(getRepositoryConfig(), config) //
+ || ObjectUtil.equals(getSessionConfig(), config) //
+ || ObjectUtil.equals(getModelConfig(), config);
+ }
+
+ protected void skipStoreWithoutExternalReferences()
+ {
+ skipTest(getRepository().getStore() instanceof NoExternalReferences);
+ }
+
+ protected void skipStoreWithoutQueryXRefs()
+ {
+ skipTest(getRepository().getStore() instanceof NoQueryXRefs);
+ }
+
+ protected void skipStoreWithoutLargeObjects()
+ {
+ skipTest(getRepository().getStore() instanceof NoLargeObjects);
+ }
+
+ protected void skipStoreWithoutFeatureMaps()
+ {
+ skipTest(getRepository().getStore() instanceof NoFeatureMaps);
+ }
+
+ protected void skipStoreWithoutHandleRevisions()
+ {
+ skipTest(getRepository().getStore() instanceof NoHandleRevisions);
+ }
+
+ protected void skipStoreWithoutRawAccess()
+ {
+ skipTest(getRepository().getStore() instanceof NoRawAccess);
+ }
+
+ protected void clearCache(CDORevisionManager revisionManager)
+ {
+ ((InternalCDORevisionManager)revisionManager).getCache().clear();
+ }
+
+ public void restartScenario() throws Exception
+ {
+ IOUtil.OUT().println("RESTARTING SCENARIO");
+ stopTransport();
+
+ IScenario scenario = getScenario();
+ scenario.tearDown();
+ scenario.setUp();
+
+ startTransport();
+ IOUtil.OUT().println("RESTARTING SCENARIO - FINISHED");
+ }
+
+ protected IScenario getDefaultScenario()
+ {
+ IScenario scenario;
+
+ try
+ {
+ scenario = Scenario.load();
+ if (scenario == null)
+ {
+ scenario = Scenario.getDefault();
+ }
+ }
+ catch (Exception ex)
+ {
+ scenario = Scenario.getDefault();
+ }
+
+ return scenario;
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ getScenario();
+ super.setUp();
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ getScenario().setUp();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ try
+ {
+ getScenario().tearDown();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ }
+
+ try
+ {
+ super.doTearDown();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestException.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestException.java
index d18a2c08f1..1f68cab73c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestException.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestException.java
@@ -1,38 +1,38 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config.impl;
-
-/**
- * @author Eike Stepper
- */
-public class ConfigTestException extends RuntimeException
-{
- private static final long serialVersionUID = 1L;
-
- public ConfigTestException()
- {
- }
-
- public ConfigTestException(String message)
- {
- super(message);
- }
-
- public ConfigTestException(Throwable cause)
- {
- super(cause);
- }
-
- public ConfigTestException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config.impl;
+
+/**
+ * @author Eike Stepper
+ */
+public class ConfigTestException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public ConfigTestException()
+ {
+ }
+
+ public ConfigTestException(String message)
+ {
+ super(message);
+ }
+
+ public ConfigTestException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public ConfigTestException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java
index 1a7c5c0f38..ba5a645482 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java
@@ -1,312 +1,312 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config.impl;
-
-import org.eclipse.emf.cdo.tests.config.IConstants;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Skips;
-
-import org.eclipse.net4j.util.om.OMBundle;
-
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.Test;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public abstract class ConfigTestSuite implements IConstants
-{
- public ConfigTestSuite()
- {
- }
-
- public Test getTestSuite(String name)
- {
- TestSuite suite = new MainSuite(name);
- initConfigSuites(suite);
- return suite;
- }
-
- public void addScenario(TestSuite parent, ContainerConfig containerConfig, RepositoryConfig repositoryConfig,
- SessionConfig sessionConfig, ModelConfig modelConfig)
- {
- IScenario scenario = new Scenario();
- scenario.setContainerConfig(containerConfig);
- scenario.setRepositoryConfig(repositoryConfig);
- scenario.setSessionConfig(sessionConfig);
- scenario.setModelConfig(modelConfig);
-
- if (scenario.isValid())
- {
- TestSuite suite = new TestSuite(scenario.toString());
-
- List<Class<? extends ConfigTest>> testClasses = new ArrayList<Class<? extends ConfigTest>>();
- initTestClasses(testClasses, scenario);
-
- for (Class<? extends ConfigTest> testClass : testClasses)
- {
- try
- {
- TestWrapper wrapper = new TestWrapper(testClass, scenario, this);
- if (wrapper.testCount() != 0)
- {
- suite.addTest(wrapper);
- }
- }
- catch (ConstraintsViolatedException ex)
- {
- //$FALL-THROUGH$
- }
- }
-
- parent.addTest(suite);
- }
- }
-
- protected List<Class<? extends ConfigTest>> getTestClasses(OMBundle bundle, String packageName)
- {
- List<Class<? extends ConfigTest>> result = new ArrayList<Class<? extends ConfigTest>>();
-
- for (Iterator<Class<?>> it = bundle.getClasses(); it.hasNext();)
- {
- Class<?> c = it.next();
- if (ConfigTest.class.isAssignableFrom(c) && c.getName().startsWith(packageName))
- {
- @SuppressWarnings("unchecked")
- Class<? extends ConfigTest> configTest = (Class<? extends ConfigTest>)c;
- result.add(configTest);
- }
- }
-
- Collections.sort(result, new Comparator<Class<? extends ConfigTest>>()
- {
- public int compare(Class<? extends ConfigTest> c1, Class<? extends ConfigTest> c2)
- {
- return c1.getName().compareTo(c2.getName());
- }
- });
-
- return result;
- }
-
- protected abstract void initConfigSuites(TestSuite parent);
-
- protected abstract void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario);
-
- /**
- * Can be overridden by subclasses.
- */
- protected void prepareTest(ConfigTest configTest)
- {
- }
-
- /**
- * Can be overridden by subclasses.
- */
- protected void mainSuiteFinished()
- {
- }
-
- /**
- * @author Eike Stepper
- */
- private final class MainSuite extends TestSuite
- {
- public MainSuite(String name)
- {
- super(name);
- }
-
- @Override
- public void run(TestResult result)
- {
- super.run(result);
- mainSuiteFinished();
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class ConstraintsViolatedException extends Exception
- {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class TestWrapper extends TestSuite
- {
- private IScenario scenario;
-
- public TestWrapper(Class<? extends ConfigTest> testClass, IScenario scenario, ConfigTestSuite suite)
- throws ConstraintsViolatedException
- {
- // super(testClass, testClass.getName()); // Important for the UI to set the *qualified* class name!
- this.scenario = scenario;
- addTestsFromTestCase(testClass, suite);
- }
-
- @Override
- public void runTest(Test test, TestResult result)
- {
- if (test instanceof ConfigTest)
- {
- scenario.save();
-
- ConfigTest configTest = (ConfigTest)test;
- configTest.setScenario(scenario);
-
- if (configTest.isValid())
- {
- super.runTest(configTest, result);
- }
- }
- else
- {
- super.runTest(test, result);
- }
- }
-
- private void addTestsFromTestCase(final Class<?> theClass, ConfigTestSuite suite)
- throws ConstraintsViolatedException
- {
- setName(theClass.getName());
-
- try
- {
- getTestConstructor(theClass); // Avoid generating multiple error messages
- }
- catch (NoSuchMethodException e)
- {
- addTest(warning("Class " + theClass.getName()
- + " has no public constructor TestCase(String name) or TestCase()"));
- return;
- }
-
- if (!Modifier.isPublic(theClass.getModifiers()))
- {
- addTest(warning("Class " + theClass.getName() + " is not public"));
- return;
- }
-
- Set<String> capabilities = scenario.getCapabilities();
-
- Class<?> superClass = theClass;
- while (Test.class.isAssignableFrom(superClass))
- {
- if (!validateConstraints(superClass, capabilities))
- {
- throw new ConstraintsViolatedException();
- }
-
- superClass = superClass.getSuperclass();
- }
-
- List<String> names = new ArrayList<String>();
-
- superClass = theClass;
- while (Test.class.isAssignableFrom(superClass))
- {
- for (Method method : superClass.getDeclaredMethods())
- {
- if (validateConstraints(method, capabilities))
- {
- addTestMethod(method, names, theClass, suite);
- }
- }
-
- superClass = superClass.getSuperclass();
- }
- }
-
- private boolean validateConstraints(AnnotatedElement element, Set<String> capabilities)
- {
- Requires requires = element.getAnnotation(Requires.class);
- if (requires != null)
- {
- for (String require : requires.value())
- {
- if (!capabilities.contains(require))
- {
- return false;
- }
- }
- }
-
- Skips skips = element.getAnnotation(Skips.class);
- if (skips != null)
- {
- for (String skip : skips.value())
- {
- if (capabilities.contains(skip))
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- private void addTestMethod(Method m, List<String> names, Class<?> theClass, ConfigTestSuite suite)
- {
- String name = m.getName();
- if (names.contains(name))
- {
- return;
- }
-
- if (!isPublicTestMethod(m))
- {
- if (isTestMethod(m))
- {
- addTest(warning("Test method isn't public: " + m.getName() + "(" + theClass.getCanonicalName() + ")"));
- }
-
- return;
- }
-
- names.add(name);
- Test test = createTest(theClass, name);
- if (test instanceof ConfigTest)
- {
- ConfigTest configTest = (ConfigTest)test;
- suite.prepareTest(configTest);
- }
-
- addTest(test);
- }
-
- private boolean isPublicTestMethod(Method m)
- {
- return isTestMethod(m) && Modifier.isPublic(m.getModifiers());
- }
-
- private boolean isTestMethod(Method m)
- {
- return m.getParameterTypes().length == 0 && m.getName().startsWith("test") && m.getReturnType().equals(Void.TYPE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config.impl;
+
+import org.eclipse.emf.cdo.tests.config.IConstants;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Skips;
+
+import org.eclipse.net4j.util.om.OMBundle;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class ConfigTestSuite implements IConstants
+{
+ public ConfigTestSuite()
+ {
+ }
+
+ public Test getTestSuite(String name)
+ {
+ TestSuite suite = new MainSuite(name);
+ initConfigSuites(suite);
+ return suite;
+ }
+
+ public void addScenario(TestSuite parent, ContainerConfig containerConfig, RepositoryConfig repositoryConfig,
+ SessionConfig sessionConfig, ModelConfig modelConfig)
+ {
+ IScenario scenario = new Scenario();
+ scenario.setContainerConfig(containerConfig);
+ scenario.setRepositoryConfig(repositoryConfig);
+ scenario.setSessionConfig(sessionConfig);
+ scenario.setModelConfig(modelConfig);
+
+ if (scenario.isValid())
+ {
+ TestSuite suite = new TestSuite(scenario.toString());
+
+ List<Class<? extends ConfigTest>> testClasses = new ArrayList<Class<? extends ConfigTest>>();
+ initTestClasses(testClasses, scenario);
+
+ for (Class<? extends ConfigTest> testClass : testClasses)
+ {
+ try
+ {
+ TestWrapper wrapper = new TestWrapper(testClass, scenario, this);
+ if (wrapper.testCount() != 0)
+ {
+ suite.addTest(wrapper);
+ }
+ }
+ catch (ConstraintsViolatedException ex)
+ {
+ //$FALL-THROUGH$
+ }
+ }
+
+ parent.addTest(suite);
+ }
+ }
+
+ protected List<Class<? extends ConfigTest>> getTestClasses(OMBundle bundle, String packageName)
+ {
+ List<Class<? extends ConfigTest>> result = new ArrayList<Class<? extends ConfigTest>>();
+
+ for (Iterator<Class<?>> it = bundle.getClasses(); it.hasNext();)
+ {
+ Class<?> c = it.next();
+ if (ConfigTest.class.isAssignableFrom(c) && c.getName().startsWith(packageName))
+ {
+ @SuppressWarnings("unchecked")
+ Class<? extends ConfigTest> configTest = (Class<? extends ConfigTest>)c;
+ result.add(configTest);
+ }
+ }
+
+ Collections.sort(result, new Comparator<Class<? extends ConfigTest>>()
+ {
+ public int compare(Class<? extends ConfigTest> c1, Class<? extends ConfigTest> c2)
+ {
+ return c1.getName().compareTo(c2.getName());
+ }
+ });
+
+ return result;
+ }
+
+ protected abstract void initConfigSuites(TestSuite parent);
+
+ protected abstract void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario);
+
+ /**
+ * Can be overridden by subclasses.
+ */
+ protected void prepareTest(ConfigTest configTest)
+ {
+ }
+
+ /**
+ * Can be overridden by subclasses.
+ */
+ protected void mainSuiteFinished()
+ {
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class MainSuite extends TestSuite
+ {
+ public MainSuite(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public void run(TestResult result)
+ {
+ super.run(result);
+ mainSuiteFinished();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class ConstraintsViolatedException extends Exception
+ {
+ private static final long serialVersionUID = 1L;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class TestWrapper extends TestSuite
+ {
+ private IScenario scenario;
+
+ public TestWrapper(Class<? extends ConfigTest> testClass, IScenario scenario, ConfigTestSuite suite)
+ throws ConstraintsViolatedException
+ {
+ // super(testClass, testClass.getName()); // Important for the UI to set the *qualified* class name!
+ this.scenario = scenario;
+ addTestsFromTestCase(testClass, suite);
+ }
+
+ @Override
+ public void runTest(Test test, TestResult result)
+ {
+ if (test instanceof ConfigTest)
+ {
+ scenario.save();
+
+ ConfigTest configTest = (ConfigTest)test;
+ configTest.setScenario(scenario);
+
+ if (configTest.isValid())
+ {
+ super.runTest(configTest, result);
+ }
+ }
+ else
+ {
+ super.runTest(test, result);
+ }
+ }
+
+ private void addTestsFromTestCase(final Class<?> theClass, ConfigTestSuite suite)
+ throws ConstraintsViolatedException
+ {
+ setName(theClass.getName());
+
+ try
+ {
+ getTestConstructor(theClass); // Avoid generating multiple error messages
+ }
+ catch (NoSuchMethodException e)
+ {
+ addTest(warning("Class " + theClass.getName()
+ + " has no public constructor TestCase(String name) or TestCase()"));
+ return;
+ }
+
+ if (!Modifier.isPublic(theClass.getModifiers()))
+ {
+ addTest(warning("Class " + theClass.getName() + " is not public"));
+ return;
+ }
+
+ Set<String> capabilities = scenario.getCapabilities();
+
+ Class<?> superClass = theClass;
+ while (Test.class.isAssignableFrom(superClass))
+ {
+ if (!validateConstraints(superClass, capabilities))
+ {
+ throw new ConstraintsViolatedException();
+ }
+
+ superClass = superClass.getSuperclass();
+ }
+
+ List<String> names = new ArrayList<String>();
+
+ superClass = theClass;
+ while (Test.class.isAssignableFrom(superClass))
+ {
+ for (Method method : superClass.getDeclaredMethods())
+ {
+ if (validateConstraints(method, capabilities))
+ {
+ addTestMethod(method, names, theClass, suite);
+ }
+ }
+
+ superClass = superClass.getSuperclass();
+ }
+ }
+
+ private boolean validateConstraints(AnnotatedElement element, Set<String> capabilities)
+ {
+ Requires requires = element.getAnnotation(Requires.class);
+ if (requires != null)
+ {
+ for (String require : requires.value())
+ {
+ if (!capabilities.contains(require))
+ {
+ return false;
+ }
+ }
+ }
+
+ Skips skips = element.getAnnotation(Skips.class);
+ if (skips != null)
+ {
+ for (String skip : skips.value())
+ {
+ if (capabilities.contains(skip))
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private void addTestMethod(Method m, List<String> names, Class<?> theClass, ConfigTestSuite suite)
+ {
+ String name = m.getName();
+ if (names.contains(name))
+ {
+ return;
+ }
+
+ if (!isPublicTestMethod(m))
+ {
+ if (isTestMethod(m))
+ {
+ addTest(warning("Test method isn't public: " + m.getName() + "(" + theClass.getCanonicalName() + ")"));
+ }
+
+ return;
+ }
+
+ names.add(name);
+ Test test = createTest(theClass, name);
+ if (test instanceof ConfigTest)
+ {
+ ConfigTest configTest = (ConfigTest)test;
+ suite.prepareTest(configTest);
+ }
+
+ addTest(test);
+ }
+
+ private boolean isPublicTestMethod(Method m)
+ {
+ return isTestMethod(m) && Modifier.isPublic(m.getModifiers());
+ }
+
+ private boolean isTestMethod(Method m)
+ {
+ return m.getParameterTypes().length == 0 && m.getName().startsWith("test") && m.getReturnType().equals(Void.TYPE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ContainerConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ContainerConfig.java
index 71393ef012..fbc87ec5f5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ContainerConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ContainerConfig.java
@@ -1,169 +1,169 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config.impl;
-
-import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
-import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
-import org.eclipse.emf.cdo.tests.config.IContainerConfig;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public abstract class ContainerConfig extends Config implements IContainerConfig
-{
- private static final long serialVersionUID = 1L;
-
- protected transient IManagedContainer clientContainer;
-
- protected transient IManagedContainer serverContainer;
-
- public ContainerConfig(String name)
- {
- super(name);
- }
-
- public boolean hasClientContainer()
- {
- return clientContainer != null;
- }
-
- public boolean hasServerContainer()
- {
- return serverContainer != null;
- }
-
- @Override
- public void tearDown() throws Exception
- {
- LifecycleUtil.deactivate(clientContainer);
- clientContainer = null;
-
- LifecycleUtil.deactivate(serverContainer);
- serverContainer = null;
-
- super.tearDown();
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class Combined extends ContainerConfig
- {
- public static final String NAME = "Combined";
-
- public static final Combined INSTANCE = new Combined();
-
- private static final long serialVersionUID = 1L;
-
- public Combined()
- {
- super(NAME);
- }
-
- public void initCapabilities(Set<String> capabilities)
- {
- capabilities.add(CAPABILITY_COMBINED);
- }
-
- public synchronized IManagedContainer getClientContainer()
- {
- if (clientContainer == null)
- {
- clientContainer = createContainer();
- LifecycleUtil.activate(clientContainer);
- serverContainer = clientContainer;
- }
-
- return clientContainer;
- }
-
- public IManagedContainer getServerContainer()
- {
- return getClientContainer();
- }
-
- private IManagedContainer createContainer()
- {
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- CDONet4jUtil.prepareContainer(container);
- CDONet4jServerUtil.prepareContainer(container);
- return container;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class Separated extends ContainerConfig
- {
- public static final String NAME = "Separated";
-
- public static final Separated INSTANCE = new Separated();
-
- private static final long serialVersionUID = 1L;
-
- public Separated()
- {
- super(NAME);
- }
-
- public void initCapabilities(Set<String> capabilities)
- {
- capabilities.add(CAPABILITY_SEPARATED);
- }
-
- public synchronized IManagedContainer getClientContainer()
- {
- if (clientContainer == null)
- {
- clientContainer = createClientContainer();
- LifecycleUtil.activate(clientContainer);
- }
-
- return clientContainer;
- }
-
- public synchronized IManagedContainer getServerContainer()
- {
- if (serverContainer == null)
- {
- serverContainer = createServerContainer();
- LifecycleUtil.activate(serverContainer);
- }
-
- return serverContainer;
- }
-
- private IManagedContainer createClientContainer()
- {
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- CDONet4jUtil.prepareContainer(container);
- return container;
- }
-
- private IManagedContainer createServerContainer()
- {
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- CDONet4jServerUtil.prepareContainer(container);
- return container;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config.impl;
+
+import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
+import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
+import org.eclipse.emf.cdo.tests.config.IContainerConfig;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class ContainerConfig extends Config implements IContainerConfig
+{
+ private static final long serialVersionUID = 1L;
+
+ protected transient IManagedContainer clientContainer;
+
+ protected transient IManagedContainer serverContainer;
+
+ public ContainerConfig(String name)
+ {
+ super(name);
+ }
+
+ public boolean hasClientContainer()
+ {
+ return clientContainer != null;
+ }
+
+ public boolean hasServerContainer()
+ {
+ return serverContainer != null;
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ LifecycleUtil.deactivate(clientContainer);
+ clientContainer = null;
+
+ LifecycleUtil.deactivate(serverContainer);
+ serverContainer = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Combined extends ContainerConfig
+ {
+ public static final String NAME = "Combined";
+
+ public static final Combined INSTANCE = new Combined();
+
+ private static final long serialVersionUID = 1L;
+
+ public Combined()
+ {
+ super(NAME);
+ }
+
+ public void initCapabilities(Set<String> capabilities)
+ {
+ capabilities.add(CAPABILITY_COMBINED);
+ }
+
+ public synchronized IManagedContainer getClientContainer()
+ {
+ if (clientContainer == null)
+ {
+ clientContainer = createContainer();
+ LifecycleUtil.activate(clientContainer);
+ serverContainer = clientContainer;
+ }
+
+ return clientContainer;
+ }
+
+ public IManagedContainer getServerContainer()
+ {
+ return getClientContainer();
+ }
+
+ private IManagedContainer createContainer()
+ {
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ CDONet4jUtil.prepareContainer(container);
+ CDONet4jServerUtil.prepareContainer(container);
+ return container;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Separated extends ContainerConfig
+ {
+ public static final String NAME = "Separated";
+
+ public static final Separated INSTANCE = new Separated();
+
+ private static final long serialVersionUID = 1L;
+
+ public Separated()
+ {
+ super(NAME);
+ }
+
+ public void initCapabilities(Set<String> capabilities)
+ {
+ capabilities.add(CAPABILITY_SEPARATED);
+ }
+
+ public synchronized IManagedContainer getClientContainer()
+ {
+ if (clientContainer == null)
+ {
+ clientContainer = createClientContainer();
+ LifecycleUtil.activate(clientContainer);
+ }
+
+ return clientContainer;
+ }
+
+ public synchronized IManagedContainer getServerContainer()
+ {
+ if (serverContainer == null)
+ {
+ serverContainer = createServerContainer();
+ LifecycleUtil.activate(serverContainer);
+ }
+
+ return serverContainer;
+ }
+
+ private IManagedContainer createClientContainer()
+ {
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ CDONet4jUtil.prepareContainer(container);
+ return container;
+ }
+
+ private IManagedContainer createServerContainer()
+ {
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ CDONet4jServerUtil.prepareContainer(container);
+ return container;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ModelConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ModelConfig.java
index 1da6c1849d..461da26ebd 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ModelConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ModelConfig.java
@@ -1,259 +1,259 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config.impl;
-
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.mango.MangoFactory;
-import org.eclipse.emf.cdo.tests.mango.MangoPackage;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.model2.Model2Factory;
-import org.eclipse.emf.cdo.tests.model2.Model2Package;
-import org.eclipse.emf.cdo.tests.model3.Model3Factory;
-import org.eclipse.emf.cdo.tests.model3.Model3Package;
-import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackageFactory;
-import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage;
-import org.eclipse.emf.cdo.tests.model4.model4Factory;
-import org.eclipse.emf.cdo.tests.model4.model4Package;
-import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
-import org.eclipse.emf.cdo.tests.model5.Model5Factory;
-import org.eclipse.emf.cdo.tests.model5.Model5Package;
-import org.eclipse.emf.cdo.tests.model6.Model6Factory;
-import org.eclipse.emf.cdo.tests.model6.Model6Package;
-
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public abstract class ModelConfig extends Config implements IModelConfig
-{
- private static final long serialVersionUID = 1L;
-
- public ModelConfig(String name)
- {
- super(name);
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class Native extends ModelConfig
- {
- public static final String NAME = "Native";
-
- public static final Native INSTANCE = new Native();
-
- private static final long serialVersionUID = 1L;
-
- public Native()
- {
- super(NAME);
- }
-
- public void initCapabilities(Set<String> capabilities)
- {
- capabilities.add(CAPABILITY_NATIVE);
- }
-
- public MangoFactory getMangoFactory()
- {
- return org.eclipse.emf.cdo.tests.mango.MangoFactory.eINSTANCE;
- }
-
- public MangoPackage getMangoPackage()
- {
- return org.eclipse.emf.cdo.tests.mango.MangoPackage.eINSTANCE;
- }
-
- public Model1Factory getModel1Factory()
- {
- return org.eclipse.emf.cdo.tests.model1.Model1Factory.eINSTANCE;
- }
-
- public Model1Package getModel1Package()
- {
- return org.eclipse.emf.cdo.tests.model1.Model1Package.eINSTANCE;
- }
-
- public Model2Factory getModel2Factory()
- {
- return org.eclipse.emf.cdo.tests.model2.Model2Factory.eINSTANCE;
- }
-
- public Model2Package getModel2Package()
- {
- return org.eclipse.emf.cdo.tests.model2.Model2Package.eINSTANCE;
- }
-
- public Model3Factory getModel3Factory()
- {
- return org.eclipse.emf.cdo.tests.model3.Model3Factory.eINSTANCE;
- }
-
- public Model3Package getModel3Package()
- {
- return org.eclipse.emf.cdo.tests.model3.Model3Package.eINSTANCE;
- }
-
- public SubpackageFactory getModel3SubPackageFactory()
- {
- return org.eclipse.emf.cdo.tests.model3.subpackage.SubpackageFactory.eINSTANCE;
- }
-
- public SubpackagePackage getModel3SubPackagePackage()
- {
- return org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage.eINSTANCE;
- }
-
- public model4Factory getModel4Factory()
- {
- return org.eclipse.emf.cdo.tests.model4.model4Factory.eINSTANCE;
- }
-
- public model4Package getModel4Package()
- {
- return org.eclipse.emf.cdo.tests.model4.model4Package.eINSTANCE;
- }
-
- public model4interfacesPackage getModel4InterfacesPackage()
- {
- return org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage.eINSTANCE;
- }
-
- public Model5Factory getModel5Factory()
- {
- return org.eclipse.emf.cdo.tests.model5.Model5Factory.eINSTANCE;
- }
-
- public Model5Package getModel5Package()
- {
- return org.eclipse.emf.cdo.tests.model5.Model5Package.eINSTANCE;
- }
-
- public Model6Factory getModel6Factory()
- {
- return org.eclipse.emf.cdo.tests.model6.Model6Factory.eINSTANCE;
- }
-
- public Model6Package getModel6Package()
- {
- return org.eclipse.emf.cdo.tests.model6.Model6Package.eINSTANCE;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class Legacy extends ModelConfig
- {
- private static final long serialVersionUID = 1L;
-
- public static final String NAME = "Legacy";
-
- public static final Legacy INSTANCE = new Legacy();
-
- public Legacy()
- {
- super(NAME);
- }
-
- public void initCapabilities(Set<String> capabilities)
- {
- capabilities.add(CAPABILITY_LEGACY);
- }
-
- public MangoFactory getMangoFactory()
- {
- return org.eclipse.emf.cdo.tests.legacy.mango.impl.MangoFactoryImpl.eINSTANCE;
- }
-
- public MangoPackage getMangoPackage()
- {
- return org.eclipse.emf.cdo.tests.legacy.mango.impl.MangoPackageImpl.eINSTANCE;
- }
-
- public Model1Factory getModel1Factory()
- {
- return org.eclipse.emf.cdo.tests.legacy.model1.Model1Factory.eINSTANCE;
- }
-
- public Model1Package getModel1Package()
- {
- return org.eclipse.emf.cdo.tests.legacy.model1.Model1Package.eINSTANCE;
- }
-
- public Model2Factory getModel2Factory()
- {
- return org.eclipse.emf.cdo.tests.legacy.model2.Model2Factory.eINSTANCE;
- }
-
- public Model2Package getModel2Package()
- {
- return org.eclipse.emf.cdo.tests.legacy.model2.Model2Package.eINSTANCE;
- }
-
- public Model3Factory getModel3Factory()
- {
- return org.eclipse.emf.cdo.tests.legacy.model3.Model3Factory.eINSTANCE;
- }
-
- public Model3Package getModel3Package()
- {
- return org.eclipse.emf.cdo.tests.legacy.model3.Model3Package.eINSTANCE;
- }
-
- public SubpackageFactory getModel3SubPackageFactory()
- {
- return org.eclipse.emf.cdo.tests.legacy.model3.subpackage.SubpackageFactory.eINSTANCE;
- }
-
- public SubpackagePackage getModel3SubPackagePackage()
- {
- return org.eclipse.emf.cdo.tests.legacy.model3.subpackage.SubpackagePackage.eINSTANCE;
- }
-
- public model4Factory getModel4Factory()
- {
- return org.eclipse.emf.cdo.tests.legacy.model4.model4Factory.eINSTANCE;
- }
-
- public model4Package getModel4Package()
- {
- return org.eclipse.emf.cdo.tests.legacy.model4.model4Package.eINSTANCE;
- }
-
- public model4interfacesPackage getModel4InterfacesPackage()
- {
- return org.eclipse.emf.cdo.tests.legacy.model4interfaces.model4interfacesPackage.eINSTANCE;
- }
-
- public Model5Factory getModel5Factory()
- {
- return org.eclipse.emf.cdo.tests.legacy.model5.Model5Factory.eINSTANCE;
- }
-
- public Model5Package getModel5Package()
- {
- return org.eclipse.emf.cdo.tests.legacy.model5.Model5Package.eINSTANCE;
- }
-
- public Model6Factory getModel6Factory()
- {
- return org.eclipse.emf.cdo.tests.legacy.model6.Model6Factory.eINSTANCE;
- }
-
- public Model6Package getModel6Package()
- {
- return org.eclipse.emf.cdo.tests.legacy.model6.Model6Package.eINSTANCE;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config.impl;
+
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.mango.MangoFactory;
+import org.eclipse.emf.cdo.tests.mango.MangoPackage;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model2.Model2Factory;
+import org.eclipse.emf.cdo.tests.model2.Model2Package;
+import org.eclipse.emf.cdo.tests.model3.Model3Factory;
+import org.eclipse.emf.cdo.tests.model3.Model3Package;
+import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackageFactory;
+import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage;
+import org.eclipse.emf.cdo.tests.model4.model4Factory;
+import org.eclipse.emf.cdo.tests.model4.model4Package;
+import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
+import org.eclipse.emf.cdo.tests.model5.Model5Factory;
+import org.eclipse.emf.cdo.tests.model5.Model5Package;
+import org.eclipse.emf.cdo.tests.model6.Model6Factory;
+import org.eclipse.emf.cdo.tests.model6.Model6Package;
+
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class ModelConfig extends Config implements IModelConfig
+{
+ private static final long serialVersionUID = 1L;
+
+ public ModelConfig(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Native extends ModelConfig
+ {
+ public static final String NAME = "Native";
+
+ public static final Native INSTANCE = new Native();
+
+ private static final long serialVersionUID = 1L;
+
+ public Native()
+ {
+ super(NAME);
+ }
+
+ public void initCapabilities(Set<String> capabilities)
+ {
+ capabilities.add(CAPABILITY_NATIVE);
+ }
+
+ public MangoFactory getMangoFactory()
+ {
+ return org.eclipse.emf.cdo.tests.mango.MangoFactory.eINSTANCE;
+ }
+
+ public MangoPackage getMangoPackage()
+ {
+ return org.eclipse.emf.cdo.tests.mango.MangoPackage.eINSTANCE;
+ }
+
+ public Model1Factory getModel1Factory()
+ {
+ return org.eclipse.emf.cdo.tests.model1.Model1Factory.eINSTANCE;
+ }
+
+ public Model1Package getModel1Package()
+ {
+ return org.eclipse.emf.cdo.tests.model1.Model1Package.eINSTANCE;
+ }
+
+ public Model2Factory getModel2Factory()
+ {
+ return org.eclipse.emf.cdo.tests.model2.Model2Factory.eINSTANCE;
+ }
+
+ public Model2Package getModel2Package()
+ {
+ return org.eclipse.emf.cdo.tests.model2.Model2Package.eINSTANCE;
+ }
+
+ public Model3Factory getModel3Factory()
+ {
+ return org.eclipse.emf.cdo.tests.model3.Model3Factory.eINSTANCE;
+ }
+
+ public Model3Package getModel3Package()
+ {
+ return org.eclipse.emf.cdo.tests.model3.Model3Package.eINSTANCE;
+ }
+
+ public SubpackageFactory getModel3SubPackageFactory()
+ {
+ return org.eclipse.emf.cdo.tests.model3.subpackage.SubpackageFactory.eINSTANCE;
+ }
+
+ public SubpackagePackage getModel3SubPackagePackage()
+ {
+ return org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage.eINSTANCE;
+ }
+
+ public model4Factory getModel4Factory()
+ {
+ return org.eclipse.emf.cdo.tests.model4.model4Factory.eINSTANCE;
+ }
+
+ public model4Package getModel4Package()
+ {
+ return org.eclipse.emf.cdo.tests.model4.model4Package.eINSTANCE;
+ }
+
+ public model4interfacesPackage getModel4InterfacesPackage()
+ {
+ return org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage.eINSTANCE;
+ }
+
+ public Model5Factory getModel5Factory()
+ {
+ return org.eclipse.emf.cdo.tests.model5.Model5Factory.eINSTANCE;
+ }
+
+ public Model5Package getModel5Package()
+ {
+ return org.eclipse.emf.cdo.tests.model5.Model5Package.eINSTANCE;
+ }
+
+ public Model6Factory getModel6Factory()
+ {
+ return org.eclipse.emf.cdo.tests.model6.Model6Factory.eINSTANCE;
+ }
+
+ public Model6Package getModel6Package()
+ {
+ return org.eclipse.emf.cdo.tests.model6.Model6Package.eINSTANCE;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Legacy extends ModelConfig
+ {
+ private static final long serialVersionUID = 1L;
+
+ public static final String NAME = "Legacy";
+
+ public static final Legacy INSTANCE = new Legacy();
+
+ public Legacy()
+ {
+ super(NAME);
+ }
+
+ public void initCapabilities(Set<String> capabilities)
+ {
+ capabilities.add(CAPABILITY_LEGACY);
+ }
+
+ public MangoFactory getMangoFactory()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.mango.impl.MangoFactoryImpl.eINSTANCE;
+ }
+
+ public MangoPackage getMangoPackage()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.mango.impl.MangoPackageImpl.eINSTANCE;
+ }
+
+ public Model1Factory getModel1Factory()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model1.Model1Factory.eINSTANCE;
+ }
+
+ public Model1Package getModel1Package()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model1.Model1Package.eINSTANCE;
+ }
+
+ public Model2Factory getModel2Factory()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model2.Model2Factory.eINSTANCE;
+ }
+
+ public Model2Package getModel2Package()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model2.Model2Package.eINSTANCE;
+ }
+
+ public Model3Factory getModel3Factory()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model3.Model3Factory.eINSTANCE;
+ }
+
+ public Model3Package getModel3Package()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model3.Model3Package.eINSTANCE;
+ }
+
+ public SubpackageFactory getModel3SubPackageFactory()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model3.subpackage.SubpackageFactory.eINSTANCE;
+ }
+
+ public SubpackagePackage getModel3SubPackagePackage()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model3.subpackage.SubpackagePackage.eINSTANCE;
+ }
+
+ public model4Factory getModel4Factory()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model4.model4Factory.eINSTANCE;
+ }
+
+ public model4Package getModel4Package()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model4.model4Package.eINSTANCE;
+ }
+
+ public model4interfacesPackage getModel4InterfacesPackage()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model4interfaces.model4interfacesPackage.eINSTANCE;
+ }
+
+ public Model5Factory getModel5Factory()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model5.Model5Factory.eINSTANCE;
+ }
+
+ public Model5Package getModel5Package()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model5.Model5Package.eINSTANCE;
+ }
+
+ public Model6Factory getModel6Factory()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model6.Model6Factory.eINSTANCE;
+ }
+
+ public Model6Package getModel6Package()
+ {
+ return org.eclipse.emf.cdo.tests.legacy.model6.Model6Package.eINSTANCE;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java
index 75038e7db0..a2d64c0a0c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java
@@ -1,352 +1,352 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.config.impl;
-
-import org.eclipse.emf.cdo.tests.config.IConfig;
-import org.eclipse.emf.cdo.tests.config.IConstants;
-import org.eclipse.emf.cdo.tests.config.IContainerConfig;
-import org.eclipse.emf.cdo.tests.config.IModelConfig;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.ISessionConfig;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.collection.CaseInsensitiveStringSet;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.text.MessageFormat;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class Scenario implements IScenario
-{
- public static final String STATE_FILE = "cdo_config_test.state";
-
- private static final long serialVersionUID = 1L;
-
- private IContainerConfig containerConfig;
-
- private IRepositoryConfig repositoryConfig;
-
- private ISessionConfig sessionConfig;
-
- private IModelConfig modelConfig;
-
- private transient Set<IConfig> configs;
-
- private transient ConfigTest currentTest;
-
- public Scenario()
- {
- }
-
- public Scenario(IContainerConfig containerConfig, IRepositoryConfig repositoryConfig, ISessionConfig sessionConfig,
- IModelConfig modelConfig)
- {
- this.containerConfig = containerConfig;
- this.repositoryConfig = repositoryConfig;
- this.sessionConfig = sessionConfig;
- this.modelConfig = modelConfig;
- }
-
- public IContainerConfig getContainerConfig()
- {
- return containerConfig;
- }
-
- public Scenario setContainerConfig(IContainerConfig containerConfig)
- {
- configs = null;
- this.containerConfig = containerConfig;
- if (containerConfig != null)
- {
- containerConfig.setCurrentTest(currentTest);
- }
-
- return this;
- }
-
- public IRepositoryConfig getRepositoryConfig()
- {
- return repositoryConfig;
- }
-
- public Scenario setRepositoryConfig(IRepositoryConfig repositoryConfig)
- {
- configs = null;
- this.repositoryConfig = repositoryConfig;
- if (repositoryConfig != null)
- {
- repositoryConfig.setCurrentTest(currentTest);
- }
-
- return this;
- }
-
- public ISessionConfig getSessionConfig()
- {
- return sessionConfig;
- }
-
- public Scenario setSessionConfig(ISessionConfig sessionConfig)
- {
- configs = null;
- this.sessionConfig = sessionConfig;
- if (sessionConfig != null)
- {
- sessionConfig.setCurrentTest(currentTest);
- }
-
- return this;
- }
-
- public IModelConfig getModelConfig()
- {
- return modelConfig;
- }
-
- public Scenario setModelConfig(IModelConfig modelConfig)
- {
- configs = null;
- this.modelConfig = modelConfig;
- if (modelConfig != null)
- {
- modelConfig.setCurrentTest(currentTest);
- }
-
- return this;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("Scenario[{0}, {1}, {2}, {3}]", //
- getContainerConfig(), getRepositoryConfig(), getSessionConfig(), getModelConfig());
- }
-
- public Set<IConfig> getConfigs()
- {
- if (configs == null)
- {
- configs = new HashSet<IConfig>();
- configs.add(getContainerConfig());
- configs.add(getRepositoryConfig());
- configs.add(getSessionConfig());
- configs.add(getModelConfig());
- }
-
- return configs;
- }
-
- public Set<String> getCapabilities()
- {
- Set<String> capabilities = new CaseInsensitiveStringSet();
- containerConfig.initCapabilities(capabilities);
- repositoryConfig.initCapabilities(capabilities);
- sessionConfig.initCapabilities(capabilities);
- modelConfig.initCapabilities(capabilities);
- return capabilities;
- }
-
- public boolean isValid()
- {
- Set<IConfig> configs = getConfigs();
- for (IConfig config : configs)
- {
- if (!config.isValid(configs))
- {
- return false;
- }
- }
-
- return true;
- }
-
- public ConfigTest getCurrentTest()
- {
- return currentTest;
- }
-
- public void setCurrentTest(ConfigTest currentTest)
- {
- this.currentTest = currentTest;
- if (containerConfig != null)
- {
- containerConfig.setCurrentTest(currentTest);
- }
-
- if (repositoryConfig != null)
- {
- repositoryConfig.setCurrentTest(currentTest);
- }
-
- if (sessionConfig != null)
- {
- sessionConfig.setCurrentTest(currentTest);
- }
-
- if (modelConfig != null)
- {
- modelConfig.setCurrentTest(currentTest);
- }
- }
-
- public void setUp() throws Exception
- {
- try
- {
- getContainerConfig().setUp();
- }
- finally
- {
- try
- {
- getRepositoryConfig().setUp();
- }
- finally
- {
- try
- {
- getSessionConfig().setUp();
- }
- finally
- {
- getModelConfig().setUp();
- }
- }
- }
- }
-
- public void tearDown() throws Exception
- {
- try
- {
- getModelConfig().tearDown();
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- }
-
- try
- {
- getSessionConfig().tearDown();
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- }
-
- try
- {
- getRepositoryConfig().tearDown();
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- }
-
- try
- {
- getContainerConfig().tearDown();
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- }
- }
-
- public void save()
- {
- File file = getStateFile();
- ObjectOutputStream stream = null;
-
- try
- {
- stream = new ObjectOutputStream(IOUtil.openOutputStream(file));
- stream.writeObject(this);
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- finally
- {
- IOUtil.close(stream);
- }
- }
-
- public static IScenario load()
- {
- File file = getStateFile();
- if (file.exists())
- {
- FileInputStream stream = IOUtil.openInputStream(file);
-
- try
- {
- return (IScenario)new ObjectInputStream(stream).readObject();
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- finally
- {
- IOUtil.close(stream);
- }
- }
-
- return null;
- }
-
- public static File getStateFile()
- {
- String home = OMPlatform.INSTANCE.getProperty("user.home");
- if (home != null)
- {
- return new File(home, STATE_FILE);
- }
-
- return new File(STATE_FILE);
- }
-
- public static IScenario getDefault()
- {
- return Default.INSTANCE;
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class Default extends Scenario
- {
- public static final IScenario INSTANCE = new Default();
-
- private static final long serialVersionUID = 1L;
-
- private Default()
- {
- setContainerConfig(IConstants.COMBINED);
- setRepositoryConfig(IConstants.MEM_BRANCHES);
- setSessionConfig(IConstants.JVM);
- setModelConfig(IConstants.NATIVE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.config.impl;
+
+import org.eclipse.emf.cdo.tests.config.IConfig;
+import org.eclipse.emf.cdo.tests.config.IConstants;
+import org.eclipse.emf.cdo.tests.config.IContainerConfig;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.ISessionConfig;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.collection.CaseInsensitiveStringSet;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.text.MessageFormat;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class Scenario implements IScenario
+{
+ public static final String STATE_FILE = "cdo_config_test.state";
+
+ private static final long serialVersionUID = 1L;
+
+ private IContainerConfig containerConfig;
+
+ private IRepositoryConfig repositoryConfig;
+
+ private ISessionConfig sessionConfig;
+
+ private IModelConfig modelConfig;
+
+ private transient Set<IConfig> configs;
+
+ private transient ConfigTest currentTest;
+
+ public Scenario()
+ {
+ }
+
+ public Scenario(IContainerConfig containerConfig, IRepositoryConfig repositoryConfig, ISessionConfig sessionConfig,
+ IModelConfig modelConfig)
+ {
+ this.containerConfig = containerConfig;
+ this.repositoryConfig = repositoryConfig;
+ this.sessionConfig = sessionConfig;
+ this.modelConfig = modelConfig;
+ }
+
+ public IContainerConfig getContainerConfig()
+ {
+ return containerConfig;
+ }
+
+ public Scenario setContainerConfig(IContainerConfig containerConfig)
+ {
+ configs = null;
+ this.containerConfig = containerConfig;
+ if (containerConfig != null)
+ {
+ containerConfig.setCurrentTest(currentTest);
+ }
+
+ return this;
+ }
+
+ public IRepositoryConfig getRepositoryConfig()
+ {
+ return repositoryConfig;
+ }
+
+ public Scenario setRepositoryConfig(IRepositoryConfig repositoryConfig)
+ {
+ configs = null;
+ this.repositoryConfig = repositoryConfig;
+ if (repositoryConfig != null)
+ {
+ repositoryConfig.setCurrentTest(currentTest);
+ }
+
+ return this;
+ }
+
+ public ISessionConfig getSessionConfig()
+ {
+ return sessionConfig;
+ }
+
+ public Scenario setSessionConfig(ISessionConfig sessionConfig)
+ {
+ configs = null;
+ this.sessionConfig = sessionConfig;
+ if (sessionConfig != null)
+ {
+ sessionConfig.setCurrentTest(currentTest);
+ }
+
+ return this;
+ }
+
+ public IModelConfig getModelConfig()
+ {
+ return modelConfig;
+ }
+
+ public Scenario setModelConfig(IModelConfig modelConfig)
+ {
+ configs = null;
+ this.modelConfig = modelConfig;
+ if (modelConfig != null)
+ {
+ modelConfig.setCurrentTest(currentTest);
+ }
+
+ return this;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("Scenario[{0}, {1}, {2}, {3}]", //
+ getContainerConfig(), getRepositoryConfig(), getSessionConfig(), getModelConfig());
+ }
+
+ public Set<IConfig> getConfigs()
+ {
+ if (configs == null)
+ {
+ configs = new HashSet<IConfig>();
+ configs.add(getContainerConfig());
+ configs.add(getRepositoryConfig());
+ configs.add(getSessionConfig());
+ configs.add(getModelConfig());
+ }
+
+ return configs;
+ }
+
+ public Set<String> getCapabilities()
+ {
+ Set<String> capabilities = new CaseInsensitiveStringSet();
+ containerConfig.initCapabilities(capabilities);
+ repositoryConfig.initCapabilities(capabilities);
+ sessionConfig.initCapabilities(capabilities);
+ modelConfig.initCapabilities(capabilities);
+ return capabilities;
+ }
+
+ public boolean isValid()
+ {
+ Set<IConfig> configs = getConfigs();
+ for (IConfig config : configs)
+ {
+ if (!config.isValid(configs))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public ConfigTest getCurrentTest()
+ {
+ return currentTest;
+ }
+
+ public void setCurrentTest(ConfigTest currentTest)
+ {
+ this.currentTest = currentTest;
+ if (containerConfig != null)
+ {
+ containerConfig.setCurrentTest(currentTest);
+ }
+
+ if (repositoryConfig != null)
+ {
+ repositoryConfig.setCurrentTest(currentTest);
+ }
+
+ if (sessionConfig != null)
+ {
+ sessionConfig.setCurrentTest(currentTest);
+ }
+
+ if (modelConfig != null)
+ {
+ modelConfig.setCurrentTest(currentTest);
+ }
+ }
+
+ public void setUp() throws Exception
+ {
+ try
+ {
+ getContainerConfig().setUp();
+ }
+ finally
+ {
+ try
+ {
+ getRepositoryConfig().setUp();
+ }
+ finally
+ {
+ try
+ {
+ getSessionConfig().setUp();
+ }
+ finally
+ {
+ getModelConfig().setUp();
+ }
+ }
+ }
+ }
+
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ getModelConfig().tearDown();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ }
+
+ try
+ {
+ getSessionConfig().tearDown();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ }
+
+ try
+ {
+ getRepositoryConfig().tearDown();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ }
+
+ try
+ {
+ getContainerConfig().tearDown();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+
+ public void save()
+ {
+ File file = getStateFile();
+ ObjectOutputStream stream = null;
+
+ try
+ {
+ stream = new ObjectOutputStream(IOUtil.openOutputStream(file));
+ stream.writeObject(this);
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ finally
+ {
+ IOUtil.close(stream);
+ }
+ }
+
+ public static IScenario load()
+ {
+ File file = getStateFile();
+ if (file.exists())
+ {
+ FileInputStream stream = IOUtil.openInputStream(file);
+
+ try
+ {
+ return (IScenario)new ObjectInputStream(stream).readObject();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ finally
+ {
+ IOUtil.close(stream);
+ }
+ }
+
+ return null;
+ }
+
+ public static File getStateFile()
+ {
+ String home = OMPlatform.INSTANCE.getProperty("user.home");
+ if (home != null)
+ {
+ return new File(home, STATE_FILE);
+ }
+
+ return new File(STATE_FILE);
+ }
+
+ public static IScenario getDefault()
+ {
+ return Default.INSTANCE;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class Default extends Scenario
+ {
+ public static final IScenario INSTANCE = new Default();
+
+ private static final long serialVersionUID = 1L;
+
+ private Default()
+ {
+ setContainerConfig(IConstants.COMBINED);
+ setRepositoryConfig(IConstants.MEM_BRANCHES);
+ setSessionConfig(IConstants.JVM);
+ setModelConfig(IConstants.NATIVE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/AllTestsCDODefs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/AllTestsCDODefs.java
index 9cf2352050..57cd8f0c27 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/AllTestsCDODefs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/AllTestsCDODefs.java
@@ -1,51 +1,51 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.defs;
-
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Andre Dietisheim
- */
-public class AllTestsCDODefs extends ConfigTestSuite
-{
- public static Test suite()
- {
- return new AllTestsCDODefs().getTestSuite("CDO Defs Tests");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM, TCP, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- testClasses.add(EGlobalPackageDefImplTest.class);
- testClasses.add(CDOPackageRegistryDefImplTest.class);
- testClasses.add(CDOSessionDefImplTest.class);
- testClasses.add(CDOViewDefImplTest.class);
- testClasses.add(CDOAuditDefImplTest.class);
- testClasses.add(CDOTransactionDefImplTest.class);
- testClasses.add(CDOViewDefImplTest.class);
- testClasses.add(CDOResourceDefImplTest.class);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.defs;
+
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class AllTestsCDODefs extends ConfigTestSuite
+{
+ public static Test suite()
+ {
+ return new AllTestsCDODefs().getTestSuite("CDO Defs Tests");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM, TCP, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.add(EGlobalPackageDefImplTest.class);
+ testClasses.add(CDOPackageRegistryDefImplTest.class);
+ testClasses.add(CDOSessionDefImplTest.class);
+ testClasses.add(CDOViewDefImplTest.class);
+ testClasses.add(CDOAuditDefImplTest.class);
+ testClasses.add(CDOTransactionDefImplTest.class);
+ testClasses.add(CDOViewDefImplTest.class);
+ testClasses.add(CDOResourceDefImplTest.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOAuditDefImplTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOAuditDefImplTest.java
index 2e27c608a2..16b33a530a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOAuditDefImplTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOAuditDefImplTest.java
@@ -1,82 +1,82 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.defs;
-
-import org.eclipse.emf.cdo.defs.CDOAuditDef;
-import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.defs.util.Net4jDefsUtil;
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-/**
- * @author Andre Dietisheim
- */
-public class CDOAuditDefImplTest extends AbstractCDOTest
-{
- private static final String RESOURCE_ID = "/defsTest1";
-
- public void testCreateAuditCanRead() throws CommitException
- {
- final String customerName = "Heino";
-
- CDOTransaction transaction = openSession().openTransaction();
- Customer customer = getModel1Factory().createCustomer();
- customer.setName(customerName);
- transaction.createResource(RESOURCE_ID).getContents().add(customer);
- transaction.commit();
-
- CDOAuditDef cdoAuditDef = CDODefsUtil.createCDOAuditDef( //
- CDODefsUtil.createSessionDef( //
- IRepositoryConfig.REPOSITORY_NAME, //
- CDODefsUtil.createEagerPackageRegistryDef(), //
- Net4jDefsUtil.createTCPConnectorDef( //
- Net4j.TCP.CONNECTOR_HOST)));
- cdoAuditDef.setTimeStamp(new Date());
-
- CDOView cdoAudit = (CDOView)cdoAuditDef.getInstance();
- EObject object = cdoAudit.getResource(getResourcePath(RESOURCE_ID)).getContents().get(0);
- assertEquals(true, object instanceof Customer && customerName.equals(customer.getName()));
- }
-
- public void testCreateAuditCreatesOnceAndReusesEvenOnChangedTimestamp()
- {
- CDOAuditDef cdoAuditDef = CDODefsUtil.createCDOAuditDef( //
- CDODefsUtil.createSessionDef( //
- IRepositoryConfig.REPOSITORY_NAME, //
- CDODefsUtil.createEagerPackageRegistryDef(), //
- Net4jDefsUtil.createTCPConnectorDef( //
- Net4j.TCP.CONNECTOR_HOST)));
- cdoAuditDef.setTimeStamp(new Date());
-
- CDOView thisCdoAuditReference = (CDOView)cdoAuditDef.getInstance();
-
- Calendar calendar = GregorianCalendar.getInstance();
- ConcurrencyUtil.sleep(1000l);
- calendar.roll(Calendar.SECOND, true);
- cdoAuditDef.setTimeStamp(calendar.getTime());
- CDOView thatCdoAuditReference = (CDOView)cdoAuditDef.getInstance();
- assertEquals(true, thisCdoAuditReference == thatCdoAuditReference);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.defs;
+
+import org.eclipse.emf.cdo.defs.CDOAuditDef;
+import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.defs.util.Net4jDefsUtil;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CDOAuditDefImplTest extends AbstractCDOTest
+{
+ private static final String RESOURCE_ID = "/defsTest1";
+
+ public void testCreateAuditCanRead() throws CommitException
+ {
+ final String customerName = "Heino";
+
+ CDOTransaction transaction = openSession().openTransaction();
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName(customerName);
+ transaction.createResource(RESOURCE_ID).getContents().add(customer);
+ transaction.commit();
+
+ CDOAuditDef cdoAuditDef = CDODefsUtil.createCDOAuditDef( //
+ CDODefsUtil.createSessionDef( //
+ IRepositoryConfig.REPOSITORY_NAME, //
+ CDODefsUtil.createEagerPackageRegistryDef(), //
+ Net4jDefsUtil.createTCPConnectorDef( //
+ Net4j.TCP.CONNECTOR_HOST)));
+ cdoAuditDef.setTimeStamp(new Date());
+
+ CDOView cdoAudit = (CDOView)cdoAuditDef.getInstance();
+ EObject object = cdoAudit.getResource(getResourcePath(RESOURCE_ID)).getContents().get(0);
+ assertEquals(true, object instanceof Customer && customerName.equals(customer.getName()));
+ }
+
+ public void testCreateAuditCreatesOnceAndReusesEvenOnChangedTimestamp()
+ {
+ CDOAuditDef cdoAuditDef = CDODefsUtil.createCDOAuditDef( //
+ CDODefsUtil.createSessionDef( //
+ IRepositoryConfig.REPOSITORY_NAME, //
+ CDODefsUtil.createEagerPackageRegistryDef(), //
+ Net4jDefsUtil.createTCPConnectorDef( //
+ Net4j.TCP.CONNECTOR_HOST)));
+ cdoAuditDef.setTimeStamp(new Date());
+
+ CDOView thisCdoAuditReference = (CDOView)cdoAuditDef.getInstance();
+
+ Calendar calendar = GregorianCalendar.getInstance();
+ ConcurrencyUtil.sleep(1000l);
+ calendar.roll(Calendar.SECOND, true);
+ cdoAuditDef.setTimeStamp(calendar.getTime());
+ CDOView thatCdoAuditReference = (CDOView)cdoAuditDef.getInstance();
+ assertEquals(true, thisCdoAuditReference == thatCdoAuditReference);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOPackageRegistryDefImplTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOPackageRegistryDefImplTest.java
index 1ccdd4611f..8d26ea4466 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOPackageRegistryDefImplTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOPackageRegistryDefImplTest.java
@@ -1,52 +1,52 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.defs;
-
-import org.eclipse.emf.cdo.defs.CDODefsFactory;
-import org.eclipse.emf.cdo.defs.CDOPackageRegistryDef;
-import org.eclipse.emf.cdo.defs.EGlobalPackageDef;
-import org.eclipse.emf.cdo.defs.EPackageDef;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.model2.Model2Package;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EPackage;
-
-/**
- * @author Andre Dietisheim
- */
-public class CDOPackageRegistryDefImplTest extends AbstractCDOTest
-{
- public void testReturnsPackageInstances()
- {
- CDOPackageRegistryDef packageRegistryDef = CDODefsFactory.eINSTANCE.createCDOPackageRegistryDef();
- EList<EPackageDef> packages = packageRegistryDef.getPackages();
- Model1Package model1package = getModel1Package();
- packages.add(createEGlobalPackageDef(model1package));
- Model2Package model2Package = getModel2Package();
- packages.add(createEGlobalPackageDef(model2Package));
-
- EPackage.Registry packageRegistry = (EPackage.Registry)packageRegistryDef.getInstance();
- EPackage ePackage1 = packageRegistry.getEPackage(getModel1Package().getNsURI());
- assertEquals(true, ePackage1 instanceof Model1Package);
- EPackage ePackage2 = packageRegistry.getEPackage(getModel2Package().getNsURI());
- assertEquals(true, ePackage2 instanceof Model2Package);
- }
-
- private EGlobalPackageDef createEGlobalPackageDef(EPackage ePackage)
- {
- EGlobalPackageDef eGlobalPackageDef = CDODefsFactory.eINSTANCE.createEGlobalPackageDef();
- eGlobalPackageDef.setNsURI(ePackage.getNsURI());
- return eGlobalPackageDef;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.defs;
+
+import org.eclipse.emf.cdo.defs.CDODefsFactory;
+import org.eclipse.emf.cdo.defs.CDOPackageRegistryDef;
+import org.eclipse.emf.cdo.defs.EGlobalPackageDef;
+import org.eclipse.emf.cdo.defs.EPackageDef;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model2.Model2Package;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CDOPackageRegistryDefImplTest extends AbstractCDOTest
+{
+ public void testReturnsPackageInstances()
+ {
+ CDOPackageRegistryDef packageRegistryDef = CDODefsFactory.eINSTANCE.createCDOPackageRegistryDef();
+ EList<EPackageDef> packages = packageRegistryDef.getPackages();
+ Model1Package model1package = getModel1Package();
+ packages.add(createEGlobalPackageDef(model1package));
+ Model2Package model2Package = getModel2Package();
+ packages.add(createEGlobalPackageDef(model2Package));
+
+ EPackage.Registry packageRegistry = (EPackage.Registry)packageRegistryDef.getInstance();
+ EPackage ePackage1 = packageRegistry.getEPackage(getModel1Package().getNsURI());
+ assertEquals(true, ePackage1 instanceof Model1Package);
+ EPackage ePackage2 = packageRegistry.getEPackage(getModel2Package().getNsURI());
+ assertEquals(true, ePackage2 instanceof Model2Package);
+ }
+
+ private EGlobalPackageDef createEGlobalPackageDef(EPackage ePackage)
+ {
+ EGlobalPackageDef eGlobalPackageDef = CDODefsFactory.eINSTANCE.createEGlobalPackageDef();
+ eGlobalPackageDef.setNsURI(ePackage.getNsURI());
+ return eGlobalPackageDef;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOResourceDefImplTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOResourceDefImplTest.java
index a9013e9957..a443332762 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOResourceDefImplTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOResourceDefImplTest.java
@@ -1,85 +1,85 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.defs;
-
-import org.eclipse.emf.cdo.defs.CDOResourceDef;
-import org.eclipse.emf.cdo.defs.CDOSessionDef;
-import org.eclipse.emf.cdo.defs.ResourceMode;
-import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.InvalidURIException;
-
-import org.eclipse.net4j.defs.util.Net4jDefsUtil;
-
-import org.eclipse.emf.common.util.WrappedException;
-
-/**
- * @author Andre Dietisheim
- */
-public class CDOResourceDefImplTest extends AbstractCDOTest
-{
- private static final String TEST_RESOURCE = "/test1";
-
- public void testGetOrCreateResourceCreatesIfResourceDoesNotExist()
- {
- CDOSessionDef cdoSessionDef = //
- CDODefsUtil.createSessionDef( //
- IRepositoryConfig.REPOSITORY_NAME, //
- CDODefsUtil.createEagerPackageRegistryDef(), //
- Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
-
- CDOResourceDef resourceDef = CDODefsUtil.createCDOResourceDef(CDODefsUtil.createCDOTransactionDef(cdoSessionDef));
- resourceDef.setResourceMode(ResourceMode.GET_OR_CREATE);
- resourceDef.setPath(TEST_RESOURCE);
- CDOResource cdoResource = (CDOResource)resourceDef.getInstance();
- assertNotNull(cdoResource);
-
- // clean up
- CDOTransaction transaction = (CDOTransaction)resourceDef.getCdoTransaction().getInstance();
- transaction.getSession().close();
- }
-
- public void testGetResourceFailsIfDoesExist()
- {
- CDOSessionDef cdoSessionDef = //
-
- CDODefsUtil.createSessionDef( //
- IRepositoryConfig.REPOSITORY_NAME, //
- CDODefsUtil.createEagerPackageRegistryDef(), //
- Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
-
- CDOResourceDef resourceDef = CDODefsUtil.createCDOResourceDef(//
- CDODefsUtil.createCDOTransactionDef(cdoSessionDef));
- resourceDef.setResourceMode(ResourceMode.GET);
- resourceDef.setPath(TEST_RESOURCE);
-
- try
- {
- resourceDef.getInstance();
- fail("Exception expected!");
- }
- catch (WrappedException e)
- {
- assertEquals(true, e.getCause().getClass() == InvalidURIException.class);
- }
- finally
- {
- // clean up
- CDOTransaction transaction = (CDOTransaction)resourceDef.getCdoTransaction().getInstance();
- transaction.getSession().close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.defs;
+
+import org.eclipse.emf.cdo.defs.CDOResourceDef;
+import org.eclipse.emf.cdo.defs.CDOSessionDef;
+import org.eclipse.emf.cdo.defs.ResourceMode;
+import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.InvalidURIException;
+
+import org.eclipse.net4j.defs.util.Net4jDefsUtil;
+
+import org.eclipse.emf.common.util.WrappedException;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CDOResourceDefImplTest extends AbstractCDOTest
+{
+ private static final String TEST_RESOURCE = "/test1";
+
+ public void testGetOrCreateResourceCreatesIfResourceDoesNotExist()
+ {
+ CDOSessionDef cdoSessionDef = //
+ CDODefsUtil.createSessionDef( //
+ IRepositoryConfig.REPOSITORY_NAME, //
+ CDODefsUtil.createEagerPackageRegistryDef(), //
+ Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
+
+ CDOResourceDef resourceDef = CDODefsUtil.createCDOResourceDef(CDODefsUtil.createCDOTransactionDef(cdoSessionDef));
+ resourceDef.setResourceMode(ResourceMode.GET_OR_CREATE);
+ resourceDef.setPath(TEST_RESOURCE);
+ CDOResource cdoResource = (CDOResource)resourceDef.getInstance();
+ assertNotNull(cdoResource);
+
+ // clean up
+ CDOTransaction transaction = (CDOTransaction)resourceDef.getCdoTransaction().getInstance();
+ transaction.getSession().close();
+ }
+
+ public void testGetResourceFailsIfDoesExist()
+ {
+ CDOSessionDef cdoSessionDef = //
+
+ CDODefsUtil.createSessionDef( //
+ IRepositoryConfig.REPOSITORY_NAME, //
+ CDODefsUtil.createEagerPackageRegistryDef(), //
+ Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
+
+ CDOResourceDef resourceDef = CDODefsUtil.createCDOResourceDef(//
+ CDODefsUtil.createCDOTransactionDef(cdoSessionDef));
+ resourceDef.setResourceMode(ResourceMode.GET);
+ resourceDef.setPath(TEST_RESOURCE);
+
+ try
+ {
+ resourceDef.getInstance();
+ fail("Exception expected!");
+ }
+ catch (WrappedException e)
+ {
+ assertEquals(true, e.getCause().getClass() == InvalidURIException.class);
+ }
+ finally
+ {
+ // clean up
+ CDOTransaction transaction = (CDOTransaction)resourceDef.getCdoTransaction().getInstance();
+ transaction.getSession().close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java
index 08799fa1a1..1c9cb2cd4b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java
@@ -1,71 +1,71 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.defs;
-
-import org.eclipse.emf.cdo.defs.CDODefsFactory;
-import org.eclipse.emf.cdo.defs.CDOSessionDef;
-import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
-
-import org.eclipse.net4j.defs.util.Net4jDefsUtil;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-/**
- * @author Andre Dietisheim
- */
-public class CDOSessionDefImplTest extends AbstractCDOTest
-{
- public void testNoPackageRegistryThrows()
- {
- try
- {
- CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
- cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
- cdoSessionDef.setLegacySupportEnabled(false);
- cdoSessionDef.setRepositoryName(IRepositoryConfig.REPOSITORY_NAME);
- cdoSessionDef.getInstance();
- fail("IllegalStateException expected!");
- }
- catch (IllegalStateException e)
- {
- // Success
- }
- }
-
- public void testConnectorAndFailMayBeUnset()
- {
- {
- CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
- cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
- }
-
- {
- CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
- cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
- cdoSessionDef.unsetConnectorDef();
- }
- }
-
- public void testSessionInstanceIsActive()
- {
- CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
- cdoSessionDef.setConnectorDef( //
- Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
- cdoSessionDef.setLegacySupportEnabled(false);
- cdoSessionDef.setRepositoryName(IRepositoryConfig.REPOSITORY_NAME);
- cdoSessionDef.setCdoPackageRegistryDef(CDODefsUtil.createEagerPackageRegistryDef());
- CDOSession cdoSession = (CDOSession)cdoSessionDef.getInstance();
- assertEquals(true, LifecycleUtil.isActive(cdoSession));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.defs;
+
+import org.eclipse.emf.cdo.defs.CDODefsFactory;
+import org.eclipse.emf.cdo.defs.CDOSessionDef;
+import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
+
+import org.eclipse.net4j.defs.util.Net4jDefsUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CDOSessionDefImplTest extends AbstractCDOTest
+{
+ public void testNoPackageRegistryThrows()
+ {
+ try
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
+ cdoSessionDef.setLegacySupportEnabled(false);
+ cdoSessionDef.setRepositoryName(IRepositoryConfig.REPOSITORY_NAME);
+ cdoSessionDef.getInstance();
+ fail("IllegalStateException expected!");
+ }
+ catch (IllegalStateException e)
+ {
+ // Success
+ }
+ }
+
+ public void testConnectorAndFailMayBeUnset()
+ {
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
+ }
+
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
+ cdoSessionDef.unsetConnectorDef();
+ }
+ }
+
+ public void testSessionInstanceIsActive()
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setConnectorDef( //
+ Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
+ cdoSessionDef.setLegacySupportEnabled(false);
+ cdoSessionDef.setRepositoryName(IRepositoryConfig.REPOSITORY_NAME);
+ cdoSessionDef.setCdoPackageRegistryDef(CDODefsUtil.createEagerPackageRegistryDef());
+ CDOSession cdoSession = (CDOSession)cdoSessionDef.getInstance();
+ assertEquals(true, LifecycleUtil.isActive(cdoSession));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOTransactionDefImplTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOTransactionDefImplTest.java
index ebb1ad17c3..3193837897 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOTransactionDefImplTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOTransactionDefImplTest.java
@@ -1,88 +1,88 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.defs;
-
-import org.eclipse.emf.cdo.defs.CDOSessionDef;
-import org.eclipse.emf.cdo.defs.CDOTransactionDef;
-import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.defs.util.Net4jDefsUtil;
-
-/**
- * @author Andre Dietisheim
- */
-public class CDOTransactionDefImplTest extends AbstractCDOTest
-{
- private static final String TEST_RESOURCE = "/test1";
-
- public void testTransactionIsReused()
- {
- CDOTransactionDef transactionDef = CDODefsUtil.createCDOTransactionDef( //
- CDODefsUtil.createSessionDef( //
- IRepositoryConfig.REPOSITORY_NAME, //
- CDODefsUtil.createEagerPackageRegistryDef(), //
- Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST)));
-
- CDOTransaction thisCdoTransactionReference = (CDOTransaction)transactionDef.getInstance();
- CDOTransaction thatCdoTransactionReference = (CDOTransaction)transactionDef.getInstance();
-
- assertEquals(true, thisCdoTransactionReference == thatCdoTransactionReference);
-
- thisCdoTransactionReference.getSession().close();
- }
-
- public void testClosedTransactionIsRecreated()
- {
- CDOTransactionDef cdoTransactionDef = CDODefsUtil.createCDOTransactionDef( //
- CDODefsUtil.createSessionDef( //
- IRepositoryConfig.REPOSITORY_NAME, //
- CDODefsUtil.createEagerPackageRegistryDef(), //
- Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST)));
- CDOTransaction transactionInstance = (CDOTransaction)cdoTransactionDef.getInstance();
- transactionInstance.close();
- CDOTransaction newTransactionInstance = (CDOTransaction)cdoTransactionDef.getInstance();
-
- assertEquals(true, newTransactionInstance != transactionInstance);
-
- newTransactionInstance.getSession().close();
- }
-
- public void testCreateAndReadModel() throws CommitException
- {
- CDOSessionDef cdoSessionDef = //
- CDODefsUtil.createSessionDef( //
- IRepositoryConfig.REPOSITORY_NAME, //
- CDODefsUtil.createEagerPackageRegistryDef(), //
- Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
-
- CDOTransactionDef transactionDef = CDODefsUtil.createCDOTransactionDef(cdoSessionDef);
- CDOTransaction transaction = (CDOTransaction)transactionDef.getInstance();
-
- transaction.getSession().getPackageRegistry().putEPackage(getModel1Package());
- CDOResource resource = transaction.createResource(TEST_RESOURCE);
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- transaction.commit();
-
- CDOResource resourceFetched = transaction.getResource(getResourcePath(TEST_RESOURCE));
- assertEquals(true, resourceFetched.eContents().contains(customer));
-
- transaction.getSession().close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.defs;
+
+import org.eclipse.emf.cdo.defs.CDOSessionDef;
+import org.eclipse.emf.cdo.defs.CDOTransactionDef;
+import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.defs.util.Net4jDefsUtil;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CDOTransactionDefImplTest extends AbstractCDOTest
+{
+ private static final String TEST_RESOURCE = "/test1";
+
+ public void testTransactionIsReused()
+ {
+ CDOTransactionDef transactionDef = CDODefsUtil.createCDOTransactionDef( //
+ CDODefsUtil.createSessionDef( //
+ IRepositoryConfig.REPOSITORY_NAME, //
+ CDODefsUtil.createEagerPackageRegistryDef(), //
+ Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST)));
+
+ CDOTransaction thisCdoTransactionReference = (CDOTransaction)transactionDef.getInstance();
+ CDOTransaction thatCdoTransactionReference = (CDOTransaction)transactionDef.getInstance();
+
+ assertEquals(true, thisCdoTransactionReference == thatCdoTransactionReference);
+
+ thisCdoTransactionReference.getSession().close();
+ }
+
+ public void testClosedTransactionIsRecreated()
+ {
+ CDOTransactionDef cdoTransactionDef = CDODefsUtil.createCDOTransactionDef( //
+ CDODefsUtil.createSessionDef( //
+ IRepositoryConfig.REPOSITORY_NAME, //
+ CDODefsUtil.createEagerPackageRegistryDef(), //
+ Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST)));
+ CDOTransaction transactionInstance = (CDOTransaction)cdoTransactionDef.getInstance();
+ transactionInstance.close();
+ CDOTransaction newTransactionInstance = (CDOTransaction)cdoTransactionDef.getInstance();
+
+ assertEquals(true, newTransactionInstance != transactionInstance);
+
+ newTransactionInstance.getSession().close();
+ }
+
+ public void testCreateAndReadModel() throws CommitException
+ {
+ CDOSessionDef cdoSessionDef = //
+ CDODefsUtil.createSessionDef( //
+ IRepositoryConfig.REPOSITORY_NAME, //
+ CDODefsUtil.createEagerPackageRegistryDef(), //
+ Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST));
+
+ CDOTransactionDef transactionDef = CDODefsUtil.createCDOTransactionDef(cdoSessionDef);
+ CDOTransaction transaction = (CDOTransaction)transactionDef.getInstance();
+
+ transaction.getSession().getPackageRegistry().putEPackage(getModel1Package());
+ CDOResource resource = transaction.createResource(TEST_RESOURCE);
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ CDOResource resourceFetched = transaction.getResource(getResourcePath(TEST_RESOURCE));
+ assertEquals(true, resourceFetched.eContents().contains(customer));
+
+ transaction.getSession().close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOViewDefImplTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOViewDefImplTest.java
index 624c86f0b8..5a77c961ff 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOViewDefImplTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOViewDefImplTest.java
@@ -1,99 +1,99 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.defs;
-
-import org.eclipse.emf.cdo.defs.CDODefsFactory;
-import org.eclipse.emf.cdo.defs.CDOSessionDef;
-import org.eclipse.emf.cdo.defs.CDOViewDef;
-import org.eclipse.emf.cdo.defs.impl.CDOViewDefImpl;
-import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.defs.TCPConnectorDef;
-import org.eclipse.net4j.defs.util.Net4jDefsUtil;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-/**
- * @author Andre Dietisheim
- */
-public class CDOViewDefImplTest extends AbstractCDOTest
-{
- private CDOViewDef cdoViewDef;
-
- private CDOSessionDef cdoSessionDef;
-
- private TCPConnectorDef tcpConnectorDef;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- cdoViewDef = CDODefsFactory.eINSTANCE.createCDOViewDef();
- tcpConnectorDef = Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST);
- cdoSessionDef = CDODefsUtil.createSessionDef(//
- IRepositoryConfig.REPOSITORY_NAME, //
- CDODefsUtil.createEagerPackageRegistryDef(), //
- tcpConnectorDef);
- cdoViewDef.setCdoSessionDef( //
- cdoSessionDef);
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- cdoViewDef.unsetInstance();
- cdoSessionDef.unsetInstance();
- tcpConnectorDef.unsetInstance();
- super.doTearDown();
- }
-
- private static final String RESOURCE_ID = "/test1";
-
- public void testCreateView()
- {
- CDOView cdoView = (CDOView)cdoViewDef.getInstance();
- assertEquals(true, cdoView.isReadOnly());
- }
-
- public void testCreateViewCreatesOnceAndReuses()
- {
- CDOView thisCdoViewReference = (CDOView)cdoViewDef.getInstance();
- CDOView thatCdoViewReference = (CDOView)cdoViewDef.getInstance();
-
- assertEquals(true, thisCdoViewReference == thatCdoViewReference);
- }
-
- public void testViewCreatedCanRead() throws CommitException
- {
- CDOTransaction transaction = openSession().openTransaction();
- transaction.createResource(RESOURCE_ID);
- transaction.commit();
-
- CDOView cdoView = (CDOView)cdoViewDef.getInstance();
-
- assertEquals(true, cdoView.hasResource(RESOURCE_ID));
- assertEquals(false, cdoView.hasResource("/test2"));
- }
-
- public void testViewMayBeUnset()
- {
- CDOView cdoView = (CDOView)cdoViewDef.getInstance();
- cdoViewDef.unsetInstance(); // deactivates instance
- assertEquals(true, ((CDOViewDefImpl)cdoViewDef).getInternalInstance() == null);
- assertEquals(true, !LifecycleUtil.isActive(cdoView));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.defs;
+
+import org.eclipse.emf.cdo.defs.CDODefsFactory;
+import org.eclipse.emf.cdo.defs.CDOSessionDef;
+import org.eclipse.emf.cdo.defs.CDOViewDef;
+import org.eclipse.emf.cdo.defs.impl.CDOViewDefImpl;
+import org.eclipse.emf.cdo.defs.util.CDODefsUtil;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.defs.TCPConnectorDef;
+import org.eclipse.net4j.defs.util.Net4jDefsUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CDOViewDefImplTest extends AbstractCDOTest
+{
+ private CDOViewDef cdoViewDef;
+
+ private CDOSessionDef cdoSessionDef;
+
+ private TCPConnectorDef tcpConnectorDef;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ cdoViewDef = CDODefsFactory.eINSTANCE.createCDOViewDef();
+ tcpConnectorDef = Net4jDefsUtil.createTCPConnectorDef(Net4j.TCP.CONNECTOR_HOST);
+ cdoSessionDef = CDODefsUtil.createSessionDef(//
+ IRepositoryConfig.REPOSITORY_NAME, //
+ CDODefsUtil.createEagerPackageRegistryDef(), //
+ tcpConnectorDef);
+ cdoViewDef.setCdoSessionDef( //
+ cdoSessionDef);
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ cdoViewDef.unsetInstance();
+ cdoSessionDef.unsetInstance();
+ tcpConnectorDef.unsetInstance();
+ super.doTearDown();
+ }
+
+ private static final String RESOURCE_ID = "/test1";
+
+ public void testCreateView()
+ {
+ CDOView cdoView = (CDOView)cdoViewDef.getInstance();
+ assertEquals(true, cdoView.isReadOnly());
+ }
+
+ public void testCreateViewCreatesOnceAndReuses()
+ {
+ CDOView thisCdoViewReference = (CDOView)cdoViewDef.getInstance();
+ CDOView thatCdoViewReference = (CDOView)cdoViewDef.getInstance();
+
+ assertEquals(true, thisCdoViewReference == thatCdoViewReference);
+ }
+
+ public void testViewCreatedCanRead() throws CommitException
+ {
+ CDOTransaction transaction = openSession().openTransaction();
+ transaction.createResource(RESOURCE_ID);
+ transaction.commit();
+
+ CDOView cdoView = (CDOView)cdoViewDef.getInstance();
+
+ assertEquals(true, cdoView.hasResource(RESOURCE_ID));
+ assertEquals(false, cdoView.hasResource("/test2"));
+ }
+
+ public void testViewMayBeUnset()
+ {
+ CDOView cdoView = (CDOView)cdoViewDef.getInstance();
+ cdoViewDef.unsetInstance(); // deactivates instance
+ assertEquals(true, ((CDOViewDefImpl)cdoViewDef).getInternalInstance() == null);
+ assertEquals(true, !LifecycleUtil.isActive(cdoView));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/EGlobalPackageDefImplTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/EGlobalPackageDefImplTest.java
index 99b8e9d474..2d6f951961 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/EGlobalPackageDefImplTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/EGlobalPackageDefImplTest.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.defs;
-
-import org.eclipse.emf.cdo.defs.CDODefsFactory;
-import org.eclipse.emf.cdo.defs.EGlobalPackageDef;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-
-import org.eclipse.emf.ecore.EPackage;
-
-/**
- * @author Eike Stepper
- */
-public class EGlobalPackageDefImplTest extends AbstractCDOTest
-{
- public void testEGlobalPackageDefReturnsPackage()
- {
- EPackage model1Package = getModel1Package();
- EPackage.Registry.INSTANCE.put(model1Package.getNsURI(), model1Package);
-
- EGlobalPackageDef packageDef = CDODefsFactory.eINSTANCE.createEGlobalPackageDef();
- packageDef.setNsURI(model1Package.getNsURI());
-
- packageDef.getInstance();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.defs;
+
+import org.eclipse.emf.cdo.defs.CDODefsFactory;
+import org.eclipse.emf.cdo.defs.EGlobalPackageDef;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ * @author Eike Stepper
+ */
+public class EGlobalPackageDefImplTest extends AbstractCDOTest
+{
+ public void testEGlobalPackageDefReturnsPackage()
+ {
+ EPackage model1Package = getModel1Package();
+ EPackage.Registry.INSTANCE.put(model1Package.getNsURI(), model1Package);
+
+ EGlobalPackageDef packageDef = CDODefsFactory.eINSTANCE.createEGlobalPackageDef();
+ packageDef.setNsURI(model1Package.getNsURI());
+
+ packageDef.getInstance();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java
index 4be784ff3d..5c2dba3dac 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java
@@ -1,91 +1,91 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * "Attempt to modify historical revision" on raw replication.
- * <p>
- * See bug 319552
- *
- * @author Pascal Lehmann
- * @since 4.0
- */
-@CleanRepositoriesBefore
-public class Bugzilla_319552_Test extends AbstractSyncingTest
-{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- public void test() throws Exception
- {
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
-
- CDOSession session = openSession();
-
- // Doing this that client notifications are built upon RevisionDeltas instead of RevisionKeys.
- session.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company company = getModel1Factory().createCompany();
- resource.getContents().add(company);
- transaction.setCommitComment("resource with one company created on clone");
- transaction.commit();
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- // do some online changes to increase the revision.
- Company masterCompany = (Company)masterTransaction.getObject(CDOUtil.getCDOObject(company).cdoID());
-
- masterCompany.setName("revision2");
- masterTransaction.commit();
-
- masterCompany.setName("revision3");
- masterTransaction.commit();
-
- masterCompany.setName("revision4");
- masterTransaction.commit();
-
- // go online again.
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
-
- company.setName("revision5");
- transaction.commit();
-
- // do a change online.
- masterCompany.getName();
- company.getName();
-
- // check revision versions.
- assertEquals(CDOUtil.getCDOObject(masterCompany).cdoRevision().getVersion(), CDOUtil.getCDOObject(company)
- .cdoRevision().getVersion());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * "Attempt to modify historical revision" on raw replication.
+ * <p>
+ * See bug 319552
+ *
+ * @author Pascal Lehmann
+ * @since 4.0
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_319552_Test extends AbstractSyncingTest
+{
+ @Override
+ protected boolean isRawReplication()
+ {
+ return true;
+ }
+
+ public void test() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+
+ CDOSession session = openSession();
+
+ // Doing this that client notifications are built upon RevisionDeltas instead of RevisionKeys.
+ session.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ // do some online changes to increase the revision.
+ Company masterCompany = (Company)masterTransaction.getObject(CDOUtil.getCDOObject(company).cdoID());
+
+ masterCompany.setName("revision2");
+ masterTransaction.commit();
+
+ masterCompany.setName("revision3");
+ masterTransaction.commit();
+
+ masterCompany.setName("revision4");
+ masterTransaction.commit();
+
+ // go online again.
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+
+ company.setName("revision5");
+ transaction.commit();
+
+ // do a change online.
+ masterCompany.getName();
+ company.getName();
+
+ // check revision versions.
+ assertEquals(CDOUtil.getCDOObject(masterCompany).cdoRevision().getVersion(), CDOUtil.getCDOObject(company)
+ .cdoRevision().getVersion());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java
index 4d7f61f1d5..8e54f4ee76 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java
@@ -1,133 +1,133 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.acceptor.IAcceptor;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-/**
- * @author Eike Stepper
- */
-@CleanRepositoriesBefore
-public class Bugzilla_325097_Test extends AbstractSyncingTest
-{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- @Override
- protected boolean isFailover()
- {
- return true;
- }
-
- private IAcceptor backupAcceptor;
-
- @Override
- public void tearDown() throws Exception
- {
- super.tearDown();
- stopBackupTransport();
- }
-
- protected void startBackupTransport()
- {
- if (backupAcceptor == null)
- {
- IOUtil.OUT().println();
- IOUtil.OUT().println("startBackupTransport()");
- IOUtil.OUT().println();
- IManagedContainer container = getServerContainer();
- backupAcceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "jvm", "backup");
- }
- }
-
- protected void stopBackupTransport()
- {
- if (backupAcceptor != null)
- {
- IOUtil.OUT().println();
- IOUtil.OUT().println("stopBackupTransport()");
- IOUtil.OUT().println();
- backupAcceptor.close();
- backupAcceptor = null;
- }
- }
-
- public void testNewObjectAfterSwitch() throws Exception
- {
- InternalSynchronizableRepository repo1_master = (InternalSynchronizableRepository)getRepository("master");
- InternalSynchronizableRepository repo1 = getRepository();
-
- InternalSynchronizableRepository master = repo1_master;
- InternalSynchronizableRepository backup = repo1;
-
- CDOSession session = openSession(master.getName());
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- resource.getContents().add(company);
- transaction.setCommitComment("Company created");
- transaction.commit();
-
- sleep(1000);
-
- startBackupTransport();
- repo1.setType(CDOCommonRepository.Type.MASTER);
- repo1_master.setType(CDOCommonRepository.Type.BACKUP);
-
- master = repo1;
- backup = repo1_master;
-
- assertEquals(CDOCommonRepository.Type.MASTER, master.getType());
- assertEquals(CDOCommonRepository.Type.BACKUP, backup.getType());
-
- // make sure the backup repository is in sync
- waitForOnline(backup);
-
- session.close();
- session = openSession(master.getName());
-
- // make sure we are running the session on the master
- assertEquals(CDOCommonRepository.Type.MASTER, session.getRepositoryInfo().getType());
- transaction = session.openTransaction();
-
- resource = transaction.getResource(getResourcePath("/my/resource"));
- company = (Company)resource.getContents().get(0);
-
- // Create a new company
- company = getModel1Factory().createCompany();
- company.setName("Test2");
-
- resource.getContents().add(company);
- transaction.commit();
-
- session.close();
- LifecycleUtil.deactivate(backup);
- LifecycleUtil.deactivate(master);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+/**
+ * @author Eike Stepper
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_325097_Test extends AbstractSyncingTest
+{
+ @Override
+ protected boolean isRawReplication()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean isFailover()
+ {
+ return true;
+ }
+
+ private IAcceptor backupAcceptor;
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ stopBackupTransport();
+ }
+
+ protected void startBackupTransport()
+ {
+ if (backupAcceptor == null)
+ {
+ IOUtil.OUT().println();
+ IOUtil.OUT().println("startBackupTransport()");
+ IOUtil.OUT().println();
+ IManagedContainer container = getServerContainer();
+ backupAcceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "jvm", "backup");
+ }
+ }
+
+ protected void stopBackupTransport()
+ {
+ if (backupAcceptor != null)
+ {
+ IOUtil.OUT().println();
+ IOUtil.OUT().println("stopBackupTransport()");
+ IOUtil.OUT().println();
+ backupAcceptor.close();
+ backupAcceptor = null;
+ }
+ }
+
+ public void testNewObjectAfterSwitch() throws Exception
+ {
+ InternalSynchronizableRepository repo1_master = (InternalSynchronizableRepository)getRepository("master");
+ InternalSynchronizableRepository repo1 = getRepository();
+
+ InternalSynchronizableRepository master = repo1_master;
+ InternalSynchronizableRepository backup = repo1;
+
+ CDOSession session = openSession(master.getName());
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ resource.getContents().add(company);
+ transaction.setCommitComment("Company created");
+ transaction.commit();
+
+ sleep(1000);
+
+ startBackupTransport();
+ repo1.setType(CDOCommonRepository.Type.MASTER);
+ repo1_master.setType(CDOCommonRepository.Type.BACKUP);
+
+ master = repo1;
+ backup = repo1_master;
+
+ assertEquals(CDOCommonRepository.Type.MASTER, master.getType());
+ assertEquals(CDOCommonRepository.Type.BACKUP, backup.getType());
+
+ // make sure the backup repository is in sync
+ waitForOnline(backup);
+
+ session.close();
+ session = openSession(master.getName());
+
+ // make sure we are running the session on the master
+ assertEquals(CDOCommonRepository.Type.MASTER, session.getRepositoryInfo().getType());
+ transaction = session.openTransaction();
+
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ company = (Company)resource.getContents().get(0);
+
+ // Create a new company
+ company = getModel1Factory().createCompany();
+ company.setName("Test2");
+
+ resource.getContents().add(company);
+ transaction.commit();
+
+ session.close();
+ LifecycleUtil.deactivate(backup);
+ LifecycleUtil.deactivate(master);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java
index 08e12e4270..f14ce4ea43 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java
@@ -1,109 +1,109 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.transaction.CDOMerger.ConflictException;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-/**
- * Revision not revised on rawImport for deleted objects.
- * <p>
- * See bug 326047
- *
- * @author Pascal Lehmann
- * @since 4.0
- */
-@CleanRepositoriesBefore
-public class Bugzilla_326047_Test extends AbstractSyncingTest
-{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- public void test() throws Exception
- {
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
-
- CDOSession session = openSession();
-
- // Doing this that client notifications are built upon RevisionDeltas instead of RevisionKeys.
- session.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company company = getModel1Factory().createCompany();
- Customer customer = getModel1Factory().createCustomer();
- company.getCustomers().add(customer);
- resource.getContents().add(company);
- transaction.setCommitComment("resource with one company created on clone");
- transaction.commit();
-
- // setup another branch.
- final CDOBranch otherBranch = transaction.getBranch().createBranch("other");
- final CDOTransaction otherTransaction = session.openTransaction(otherBranch);
-
- Customer branchCustomer = otherTransaction.getObject(customer);
- assertNotSame(null, branchCustomer);
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- // change the name of the customer on branch offline.
- branchCustomer.setName("branch-offline");
- otherTransaction.commit();
-
- // delete the customer on the online transaction.
- Company masterCompany = (Company)masterTransaction.getObject(CDOUtil.getCDOObject(company).cdoID());
- masterCompany.getCustomers().remove(0);
- masterTransaction.commit();
-
- // go online again.
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
-
- Exception exception = null;
-
- try
- {
- // merge branch.
- CDOBranchPoint source = otherTransaction.getBranch().getHead();
- DefaultCDOMerger.PerFeature.ManyValued merger = new DefaultCDOMerger.PerFeature.ManyValued();
- transaction.merge(source, merger); // <-- this merge should generate a conflict.
- transaction.commit(); // <-- commit will fail, because no conflict thrown.
- }
- catch (Exception e)
- {
- exception = e;
- }
-
- assertInstanceOf(ConflictException.class, exception);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOMerger.ConflictException;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+/**
+ * Revision not revised on rawImport for deleted objects.
+ * <p>
+ * See bug 326047
+ *
+ * @author Pascal Lehmann
+ * @since 4.0
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_326047_Test extends AbstractSyncingTest
+{
+ @Override
+ protected boolean isRawReplication()
+ {
+ return true;
+ }
+
+ public void test() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+
+ CDOSession session = openSession();
+
+ // Doing this that client notifications are built upon RevisionDeltas instead of RevisionKeys.
+ session.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ Customer customer = getModel1Factory().createCustomer();
+ company.getCustomers().add(customer);
+ resource.getContents().add(company);
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ // setup another branch.
+ final CDOBranch otherBranch = transaction.getBranch().createBranch("other");
+ final CDOTransaction otherTransaction = session.openTransaction(otherBranch);
+
+ Customer branchCustomer = otherTransaction.getObject(customer);
+ assertNotSame(null, branchCustomer);
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ // change the name of the customer on branch offline.
+ branchCustomer.setName("branch-offline");
+ otherTransaction.commit();
+
+ // delete the customer on the online transaction.
+ Company masterCompany = (Company)masterTransaction.getObject(CDOUtil.getCDOObject(company).cdoID());
+ masterCompany.getCustomers().remove(0);
+ masterTransaction.commit();
+
+ // go online again.
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+
+ Exception exception = null;
+
+ try
+ {
+ // merge branch.
+ CDOBranchPoint source = otherTransaction.getBranch().getHead();
+ DefaultCDOMerger.PerFeature.ManyValued merger = new DefaultCDOMerger.PerFeature.ManyValued();
+ transaction.merge(source, merger); // <-- this merge should generate a conflict.
+ transaction.commit(); // <-- commit will fail, because no conflict thrown.
+ }
+ catch (Exception e)
+ {
+ exception = e;
+ }
+
+ assertInstanceOf(ConflictException.class, exception);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_328352_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_328352_Test.java
index f336646341..22f6f5aff7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_328352_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_328352_Test.java
@@ -1,158 +1,158 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-import java.text.MessageFormat;
-
-/**
- * CommitNotifications overtaking each other.
- * <p>
- * See bug 328352
- *
- * @author Pascal Lehmann
- * @since 4.0
- */
-@CleanRepositoriesBefore
-public class Bugzilla_328352_Test extends AbstractSyncingTest
-{
- private final int NUM_PRODUCTS = 200;
-
- private final int NUM_CLIENT_VIEWS = 10;
-
- @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
- @Skips("DB.ranges")
- // Too slow in DB.ranges (11 minutes), see bug 357441
- public void testOfflineCloneSynchronization() throws Exception
- {
- disableConsole();
-
- // create an offline clone.
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- // create master session & transaction.
- InternalRepository master = getRepository("master");
- CDOSession masterSession = openSession(master.getName());
- CDOTransaction masterTransaction = masterSession.openTransaction();
-
- // create client session & transaction.
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- // doing this that client notifications are built upon RevisionDeltas instead of RevisionKeys.
- session.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
-
- // create additional client sessions.
- CDOView[] cloneViews = new CDOView[NUM_CLIENT_VIEWS + 1];
- for (int i = 0; i < NUM_CLIENT_VIEWS; i++)
- {
- CDOView view = session.openView();
- cloneViews[i] = view;
- }
-
- cloneViews[NUM_CLIENT_VIEWS] = transaction;
-
- // create resource and base model.
- CDOResource resource = masterTransaction.createResource(getResourcePath("/my/resource"));
- Company company = getModel1Factory().createCompany();
- Category catA = getModel1Factory().createCategory();
- catA.setName("CatA");
- company.getCategories().add(catA);
- Category catB = getModel1Factory().createCategory();
- catB.setName("CatB");
- company.getCategories().add(catB);
- resource.getContents().add(company);
-
- for (int i = 0; i < NUM_PRODUCTS; i++)
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setName("Product" + i);
- catA.getProducts().add(product);
- }
-
- masterTransaction.commit();
- transaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
-
- // touch the objects on the views to actually receive updates.
- for (CDOView view : cloneViews)
- {
- Category vCatA = (Category)view.getObject(CDOUtil.getCDOObject(catA).cdoID());
- Category vCatB = (Category)view.getObject(CDOUtil.getCDOObject(catB).cdoID());
- vCatB.getName();
- for (Product1 vProduct : vCatA.getProducts())
- {
- vProduct.getName();
- }
- }
-
- // do a lot of changes on master session.
- long start = System.currentTimeMillis();
- for (int i = 0; i < NUM_PRODUCTS; i++)
- {
- Product1 p = catA.getProducts().remove(0);
- catB.getProducts().add(p);
- catB.getProducts().move(0, p);
-
- masterTransaction.commit();
- }
-
- Thread.sleep(100);
- catA.setName(catA.getName() + " empty");
- masterTransaction.commit();
-
- System.out.println(MessageFormat.format("## Committing changes on {0} products took: {1}", NUM_PRODUCTS,
- System.currentTimeMillis() - start));
-
- // session.waitForUpdate(masterTransaction.getLastCommitTime(), 5000);
- for (CDOView view : cloneViews)
- {
- view.waitForUpdate(masterTransaction.getLastCommitTime(), 5000);
- }
-
- // adding this sleep as the waitForUpdate does not seem to work as expected in case of an error.
- sleep(5000);
- System.out.println("## Started checking....");
-
- // check if all changes are made.
- Category cloneCatA = (Category)transaction.getObject(CDOUtil.getCDOObject(catA).cdoID());
- Category cloneCatB = (Category)transaction.getObject(CDOUtil.getCDOObject(catB).cdoID());
- System.out.println("CatA IdVersion: " + CDOUtil.getCDOObject(cloneCatA).cdoRevision().toString());
- System.out.println("CatB IdVersion: " + CDOUtil.getCDOObject(cloneCatB).cdoRevision().toString());
- assertEquals(NUM_PRODUCTS, cloneCatB.getProducts().size());
- assertEquals(0, cloneCatA.getProducts().size());
- assertEquals(catA.getName(), cloneCatA.getName());
- }
-
- @Override
- public void disableConsole()
- {
- OMPlatform.INSTANCE.setDebugging(false);
- OMPlatform.INSTANCE.removeTraceHandler(PrintTraceHandler.CONSOLE);
- // OMPlatform.INSTANCE.removeLogHandler(PrintLogHandler.CONSOLE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+import java.text.MessageFormat;
+
+/**
+ * CommitNotifications overtaking each other.
+ * <p>
+ * See bug 328352
+ *
+ * @author Pascal Lehmann
+ * @since 4.0
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_328352_Test extends AbstractSyncingTest
+{
+ private final int NUM_PRODUCTS = 200;
+
+ private final int NUM_CLIENT_VIEWS = 10;
+
+ @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
+ @Skips("DB.ranges")
+ // Too slow in DB.ranges (11 minutes), see bug 357441
+ public void testOfflineCloneSynchronization() throws Exception
+ {
+ disableConsole();
+
+ // create an offline clone.
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ // create master session & transaction.
+ InternalRepository master = getRepository("master");
+ CDOSession masterSession = openSession(master.getName());
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+
+ // create client session & transaction.
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ // doing this that client notifications are built upon RevisionDeltas instead of RevisionKeys.
+ session.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+
+ // create additional client sessions.
+ CDOView[] cloneViews = new CDOView[NUM_CLIENT_VIEWS + 1];
+ for (int i = 0; i < NUM_CLIENT_VIEWS; i++)
+ {
+ CDOView view = session.openView();
+ cloneViews[i] = view;
+ }
+
+ cloneViews[NUM_CLIENT_VIEWS] = transaction;
+
+ // create resource and base model.
+ CDOResource resource = masterTransaction.createResource(getResourcePath("/my/resource"));
+ Company company = getModel1Factory().createCompany();
+ Category catA = getModel1Factory().createCategory();
+ catA.setName("CatA");
+ company.getCategories().add(catA);
+ Category catB = getModel1Factory().createCategory();
+ catB.setName("CatB");
+ company.getCategories().add(catB);
+ resource.getContents().add(company);
+
+ for (int i = 0; i < NUM_PRODUCTS; i++)
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Product" + i);
+ catA.getProducts().add(product);
+ }
+
+ masterTransaction.commit();
+ transaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
+
+ // touch the objects on the views to actually receive updates.
+ for (CDOView view : cloneViews)
+ {
+ Category vCatA = (Category)view.getObject(CDOUtil.getCDOObject(catA).cdoID());
+ Category vCatB = (Category)view.getObject(CDOUtil.getCDOObject(catB).cdoID());
+ vCatB.getName();
+ for (Product1 vProduct : vCatA.getProducts())
+ {
+ vProduct.getName();
+ }
+ }
+
+ // do a lot of changes on master session.
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < NUM_PRODUCTS; i++)
+ {
+ Product1 p = catA.getProducts().remove(0);
+ catB.getProducts().add(p);
+ catB.getProducts().move(0, p);
+
+ masterTransaction.commit();
+ }
+
+ Thread.sleep(100);
+ catA.setName(catA.getName() + " empty");
+ masterTransaction.commit();
+
+ System.out.println(MessageFormat.format("## Committing changes on {0} products took: {1}", NUM_PRODUCTS,
+ System.currentTimeMillis() - start));
+
+ // session.waitForUpdate(masterTransaction.getLastCommitTime(), 5000);
+ for (CDOView view : cloneViews)
+ {
+ view.waitForUpdate(masterTransaction.getLastCommitTime(), 5000);
+ }
+
+ // adding this sleep as the waitForUpdate does not seem to work as expected in case of an error.
+ sleep(5000);
+ System.out.println("## Started checking....");
+
+ // check if all changes are made.
+ Category cloneCatA = (Category)transaction.getObject(CDOUtil.getCDOObject(catA).cdoID());
+ Category cloneCatB = (Category)transaction.getObject(CDOUtil.getCDOObject(catB).cdoID());
+ System.out.println("CatA IdVersion: " + CDOUtil.getCDOObject(cloneCatA).cdoRevision().toString());
+ System.out.println("CatB IdVersion: " + CDOUtil.getCDOObject(cloneCatB).cdoRevision().toString());
+ assertEquals(NUM_PRODUCTS, cloneCatB.getProducts().size());
+ assertEquals(0, cloneCatA.getProducts().size());
+ assertEquals(catA.getName(), cloneCatA.getName());
+ }
+
+ @Override
+ public void disableConsole()
+ {
+ OMPlatform.INSTANCE.setDebugging(false);
+ OMPlatform.INSTANCE.removeTraceHandler(PrintTraceHandler.CONSOLE);
+ // OMPlatform.INSTANCE.removeLogHandler(PrintLogHandler.CONSOLE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java
index 6291e8d447..7349e351c6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java
@@ -1,297 +1,297 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Pascal Lehmann - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * LastUpdateTimestamp of ReplicatorSession not set on local commits.
- * <p>
- * See bug 329014
- *
- * @author Pascal Lehmann
- * @since 4.0
- */
-@CleanRepositoriesBefore
-public class Bugzilla_329014_Test extends AbstractSyncingTest
-{
- private static final String RESOURCE_NAME = "/my/resource";
-
- private CDOID id;
-
- private InternalRepository master;
-
- private InternalRepository clone;
-
- private CDOSession masterSession;
-
- private CDOSession cloneSession;
-
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
-
- clone = getRepository();
- cloneSession = openSession();
- cloneSession.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
- waitForOnline(clone);
-
- master = getRepository("master");
- masterSession = openSession(master.getName());
- masterSession.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
-
- // initial model.
- CDOTransaction transaction = masterSession.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_NAME));
- Company company = getModel1Factory().createCompany();
- company.setName("Company1");
- resource.getContents().add(company);
- transaction.commit();
- id = CDOUtil.getCDOObject(company).cdoID();
-
- transaction.close();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- if (cloneSession != null)
- {
- cloneSession.close();
- cloneSession = null;
- }
-
- if (masterSession != null)
- {
- masterSession.close();
- masterSession = null;
- }
-
- super.doTearDown();
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
- public void testSynchronizationMasterCloneWithoutReplication() throws Exception
- {
- // open transactions.
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOTransaction cloneTransaction = cloneSession.openTransaction();
- sleep(1000);
-
- // grab and touch the company on master.
- Company masterCompany = (Company)masterTransaction.getObject(id);
- assertNotNull(masterCompany);
- masterCompany.getName();
-
- // grab and touch the company on clone.
- Company cloneCompany = (Company)cloneTransaction.getObject(id);
- assertNotNull(cloneCompany);
- cloneCompany.getName();
-
- // do changes: master / clone / master
-
- masterCompany.setName("Company2");
- masterTransaction.commit();
- masterCompany.setName("Company3");
- masterTransaction.commit();
-
- cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
-
- cloneCompany.setName("Company4");
- cloneTransaction.commit();
- cloneCompany.setName("Company5");
- cloneTransaction.commit();
-
- masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
-
- masterCompany.setName("Company6");
- masterTransaction.commit();
- masterCompany.setName("Company7");
- masterTransaction.commit();
-
- cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
-
- // check.
- assertEquals(masterCompany.getName(), cloneCompany.getName());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
- public void testSynchronizationCloneMasterWithoutReplication() throws Exception
- {
- // open transactions.
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOTransaction cloneTransaction = cloneSession.openTransaction();
- sleep(1000);
-
- // grab and touch the company on master.
- Company masterCompany = (Company)masterTransaction.getObject(id);
- assertNotNull(masterCompany);
- masterCompany.getName();
-
- // grab and touch the company on clone.
- Company cloneCompany = (Company)cloneTransaction.getObject(id);
- assertNotNull(cloneCompany);
- cloneCompany.getName();
-
- // do changes: clone / master / clone
-
- cloneCompany.setName("Company2");
- cloneTransaction.commit();
- cloneCompany.setName("Company3");
- cloneTransaction.commit();
-
- masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
-
- masterCompany.setName("Company4");
- masterTransaction.commit();
- masterCompany.setName("Company5");
- masterTransaction.commit();
-
- cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
-
- cloneCompany.setName("Company6");
- cloneTransaction.commit();
- cloneCompany.setName("Company7");
- cloneTransaction.commit();
-
- masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
-
- // check.
- assertEquals(cloneCompany.getName(), masterCompany.getName());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
- public void testSynchronizationMasterCloneWithReplication() throws Exception
- {
- // open transactions.
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOTransaction cloneTransaction = cloneSession.openTransaction();
- sleep(1000);
-
- // grab and touch the company on master.
- Company masterCompany = (Company)masterTransaction.getObject(id);
- assertNotNull(masterCompany);
- masterCompany.getName();
-
- // grab and touch the company on clone.
- Company cloneCompany = (Company)cloneTransaction.getObject(id);
- assertNotNull(cloneCompany);
- cloneCompany.getName();
-
- // do changes: master / clone / master
-
- // go offline.
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- masterCompany.setName("Company2");
- masterTransaction.commit();
- masterCompany.setName("Company3");
- masterTransaction.commit();
- msg(CDOUtil.getCDOObject(masterCompany).cdoRevision().getVersion());
-
- // go online.
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
-
- cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
-
- cloneCompany.getName();
- msg(CDOUtil.getCDOObject(cloneCompany).cdoRevision().getVersion());
-
- cloneCompany.setName("Company4");
- cloneTransaction.commit();
- cloneCompany.setName("Company5");
- cloneTransaction.commit();
-
- masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
-
- masterCompany.setName("Company6");
- masterTransaction.commit();
- masterCompany.setName("Company7");
- masterTransaction.commit();
-
- cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
-
- // check.
- assertEquals(masterCompany.getName(), cloneCompany.getName());
- }
-
- @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
- public void testSynchronizationCloneMasterWithReplication() throws Exception
- {
- // open transactions.
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOTransaction cloneTransaction = cloneSession.openTransaction();
- sleep(1000);
-
- // grab and touch the company on master.
- Company masterCompany = (Company)masterTransaction.getObject(id);
- assertNotNull(masterCompany);
- masterCompany.getName();
-
- // grab and touch the company on clone.
- Company cloneCompany = (Company)cloneTransaction.getObject(id);
- assertNotNull(cloneCompany);
- cloneCompany.getName();
-
- // do changes: clone / master / clone
-
- cloneCompany.setName("Company2");
- cloneTransaction.commit();
- cloneCompany.setName("Company3");
- cloneTransaction.commit();
-
- masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
-
- // go offline.
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- masterCompany.setName("Company4");
- masterTransaction.commit();
- masterCompany.setName("Company5");
- masterTransaction.commit();
-
- // go online.
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
-
- cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
-
- cloneCompany.setName("Company6");
- cloneTransaction.commit();
- cloneCompany.setName("Company7");
- cloneTransaction.commit();
-
- masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
-
- // check.
- assertEquals(cloneCompany.getName(), masterCompany.getName());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Pascal Lehmann - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * LastUpdateTimestamp of ReplicatorSession not set on local commits.
+ * <p>
+ * See bug 329014
+ *
+ * @author Pascal Lehmann
+ * @since 4.0
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_329014_Test extends AbstractSyncingTest
+{
+ private static final String RESOURCE_NAME = "/my/resource";
+
+ private CDOID id;
+
+ private InternalRepository master;
+
+ private InternalRepository clone;
+
+ private CDOSession masterSession;
+
+ private CDOSession cloneSession;
+
+ @Override
+ protected boolean isRawReplication()
+ {
+ return true;
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+
+ clone = getRepository();
+ cloneSession = openSession();
+ cloneSession.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+ waitForOnline(clone);
+
+ master = getRepository("master");
+ masterSession = openSession(master.getName());
+ masterSession.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+
+ // initial model.
+ CDOTransaction transaction = masterSession.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_NAME));
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company1");
+ resource.getContents().add(company);
+ transaction.commit();
+ id = CDOUtil.getCDOObject(company).cdoID();
+
+ transaction.close();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ if (cloneSession != null)
+ {
+ cloneSession.close();
+ cloneSession = null;
+ }
+
+ if (masterSession != null)
+ {
+ masterSession.close();
+ masterSession = null;
+ }
+
+ super.doTearDown();
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
+ public void testSynchronizationMasterCloneWithoutReplication() throws Exception
+ {
+ // open transactions.
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOTransaction cloneTransaction = cloneSession.openTransaction();
+ sleep(1000);
+
+ // grab and touch the company on master.
+ Company masterCompany = (Company)masterTransaction.getObject(id);
+ assertNotNull(masterCompany);
+ masterCompany.getName();
+
+ // grab and touch the company on clone.
+ Company cloneCompany = (Company)cloneTransaction.getObject(id);
+ assertNotNull(cloneCompany);
+ cloneCompany.getName();
+
+ // do changes: master / clone / master
+
+ masterCompany.setName("Company2");
+ masterTransaction.commit();
+ masterCompany.setName("Company3");
+ masterTransaction.commit();
+
+ cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
+
+ cloneCompany.setName("Company4");
+ cloneTransaction.commit();
+ cloneCompany.setName("Company5");
+ cloneTransaction.commit();
+
+ masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
+
+ masterCompany.setName("Company6");
+ masterTransaction.commit();
+ masterCompany.setName("Company7");
+ masterTransaction.commit();
+
+ cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
+
+ // check.
+ assertEquals(masterCompany.getName(), cloneCompany.getName());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
+ public void testSynchronizationCloneMasterWithoutReplication() throws Exception
+ {
+ // open transactions.
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOTransaction cloneTransaction = cloneSession.openTransaction();
+ sleep(1000);
+
+ // grab and touch the company on master.
+ Company masterCompany = (Company)masterTransaction.getObject(id);
+ assertNotNull(masterCompany);
+ masterCompany.getName();
+
+ // grab and touch the company on clone.
+ Company cloneCompany = (Company)cloneTransaction.getObject(id);
+ assertNotNull(cloneCompany);
+ cloneCompany.getName();
+
+ // do changes: clone / master / clone
+
+ cloneCompany.setName("Company2");
+ cloneTransaction.commit();
+ cloneCompany.setName("Company3");
+ cloneTransaction.commit();
+
+ masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
+
+ masterCompany.setName("Company4");
+ masterTransaction.commit();
+ masterCompany.setName("Company5");
+ masterTransaction.commit();
+
+ cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
+
+ cloneCompany.setName("Company6");
+ cloneTransaction.commit();
+ cloneCompany.setName("Company7");
+ cloneTransaction.commit();
+
+ masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
+
+ // check.
+ assertEquals(cloneCompany.getName(), masterCompany.getName());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
+ public void testSynchronizationMasterCloneWithReplication() throws Exception
+ {
+ // open transactions.
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOTransaction cloneTransaction = cloneSession.openTransaction();
+ sleep(1000);
+
+ // grab and touch the company on master.
+ Company masterCompany = (Company)masterTransaction.getObject(id);
+ assertNotNull(masterCompany);
+ masterCompany.getName();
+
+ // grab and touch the company on clone.
+ Company cloneCompany = (Company)cloneTransaction.getObject(id);
+ assertNotNull(cloneCompany);
+ cloneCompany.getName();
+
+ // do changes: master / clone / master
+
+ // go offline.
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ masterCompany.setName("Company2");
+ masterTransaction.commit();
+ masterCompany.setName("Company3");
+ masterTransaction.commit();
+ msg(CDOUtil.getCDOObject(masterCompany).cdoRevision().getVersion());
+
+ // go online.
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+
+ cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
+
+ cloneCompany.getName();
+ msg(CDOUtil.getCDOObject(cloneCompany).cdoRevision().getVersion());
+
+ cloneCompany.setName("Company4");
+ cloneTransaction.commit();
+ cloneCompany.setName("Company5");
+ cloneTransaction.commit();
+
+ masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
+
+ masterCompany.setName("Company6");
+ masterTransaction.commit();
+ masterCompany.setName("Company7");
+ masterTransaction.commit();
+
+ cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
+
+ // check.
+ assertEquals(masterCompany.getName(), cloneCompany.getName());
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
+ public void testSynchronizationCloneMasterWithReplication() throws Exception
+ {
+ // open transactions.
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOTransaction cloneTransaction = cloneSession.openTransaction();
+ sleep(1000);
+
+ // grab and touch the company on master.
+ Company masterCompany = (Company)masterTransaction.getObject(id);
+ assertNotNull(masterCompany);
+ masterCompany.getName();
+
+ // grab and touch the company on clone.
+ Company cloneCompany = (Company)cloneTransaction.getObject(id);
+ assertNotNull(cloneCompany);
+ cloneCompany.getName();
+
+ // do changes: clone / master / clone
+
+ cloneCompany.setName("Company2");
+ cloneTransaction.commit();
+ cloneCompany.setName("Company3");
+ cloneTransaction.commit();
+
+ masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
+
+ // go offline.
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ masterCompany.setName("Company4");
+ masterTransaction.commit();
+ masterCompany.setName("Company5");
+ masterTransaction.commit();
+
+ // go online.
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+
+ cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
+
+ cloneCompany.setName("Company6");
+ cloneTransaction.commit();
+ cloneCompany.setName("Company7");
+ cloneTransaction.commit();
+
+ masterTransaction.waitForUpdate(cloneTransaction.getLastCommitTime(), 1000);
+
+ // check.
+ assertEquals(cloneCompany.getName(), masterCompany.getName());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java
index f4e61f084e..0540d8faeb 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java
@@ -1,632 +1,632 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-import org.eclipse.emf.common.util.EList;
-
-/**
- * Support raw replication in HorizontalBranchingMappingStrategyWithRanges.
- * <p>
- * See bug 351078
- *
- * @author Eike Stepper
- */
-@Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
-@CleanRepositoriesBefore
-public class Bugzilla_351078_Test extends AbstractSyncingTest
-{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- OMPlatform.INSTANCE.setDebugging(false);
- OMPlatform.INSTANCE.removeTraceHandler(PrintTraceHandler.CONSOLE);
- super.doSetUp();
- }
-
- public void testDoNothing() throws Exception
- {
- run(new CompanyChanger());
- }
-
- public void testAddTwoRemoveFirst_DoNothing() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.remove(0);
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddTwoRemoveFirst_AddTwo() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.remove(0);
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddTwoRemoveSecond_DoNothing() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.remove(1);
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddTwoRemoveSecond_AddTwo() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.remove(1);
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- }
- });
- }
-
- public void testAddTwo_RemoveFirst() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.remove(0);
- transaction.commit();
- }
- });
- }
-
- public void testAddTwo_RemoveFirstAddOne() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.remove(0);
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddTwo_RemoveSecond() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.remove(1);
- transaction.commit();
- }
- });
- }
-
- public void testAddTwo_RemoveSecondAddOne() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.remove(1);
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddTwo_AddOneRemoveThird() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.remove(2);
- transaction.commit();
- }
- });
- }
-
- public void testAddOne_AddOne() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddTwo_AddTwo() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddThree_MoveFirst() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.move(5, 0);
- transaction.commit();
- }
- });
- }
-
- public void testAddThree_MoveLast() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.move(0, 5);
- transaction.commit();
- }
- });
- }
-
- public void testAddOne_ReplaceIt() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.set(0, getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddOneAddOne_ReplaceFirst() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.set(0, getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddOneRemoveIt() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.remove(0);
- transaction.commit();
- }
- });
- }
-
- public void testAddOneAddOne_RemoveFirst() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.remove(0);
- transaction.commit();
- }
- });
- }
-
- public void testAddOneReplaceFirst_ReplaceFirst() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.set(0, getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.set(0, getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddOneAddOneReplaceFirst_ReplaceFirst() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.set(0, getModel1Factory().createCategory());
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.set(0, getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- public void testAddAddReplaceAddRmove_ReplaceAdd() throws Exception
- {
- run(new CompanyChanger()
- {
- @Override
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.set(0, getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(getModel1Factory().createCategory());
- transaction.commit();
-
- categories.remove(0);
- transaction.commit();
- }
-
- @Override
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- categories.set(0, getModel1Factory().createCategory());
- transaction.commit();
-
- categories.add(0, getModel1Factory().createCategory());
- transaction.commit();
- }
- });
- }
-
- protected void run(CompanyChanger changer) throws Exception
- {
- // Create master session & transaction.
- InternalRepository master = getRepository("master");
- CDOSession masterSession = openSession(master.getName());
- CDOTransaction masterTransaction = masterSession.openTransaction();
-
- // Create resource and base model.
- CDOResource resource = masterTransaction.createResource(getResourcePath("/my/resource"));
- Company masterCompany = getModel1Factory().createCompany();
- resource.getContents().add(masterCompany);
- masterTransaction.commit();
-
- changer.beforeConnect(masterCompany.getCategories(), masterTransaction);
-
- // Create an offline clone.
- InternalRepository clone = getRepository();
- waitForOnline(clone);
- sleep(500); // TODO Clarify why waitForOnline() alone is not enough
-
- check(master, masterCompany, "after connect");
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
- sleep(500);
-
- changer.beforeReconnect(masterCompany.getCategories(), masterTransaction);
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- sleep(500);
-
- check(master, masterCompany, "after reconnect");
- }
-
- protected void check(InternalRepository master, Company masterCompany, String when)
- {
- EList<Category> masterCategories = masterCompany.getCategories();
-
- CDOSession session = openSession();
- CDOView view = session.openView();
-
- CDOID id = CDOUtil.getCDOObject(masterCompany).cdoID();
- Company company = (Company)view.getObject(id);
- EList<Category> categories = company.getCategories();
-
- assertEquals("Size (" + when + ")", masterCategories.size(), categories.size());
-
- for (int i = 0; i < masterCategories.size(); i++)
- {
- CDOObject masterCategory = CDOUtil.getCDOObject(masterCategories.get(i));
- CDOObject category = CDOUtil.getCDOObject(categories.get(i));
- assertEquals("Element " + i + " (" + when + ")", masterCategory.cdoID(), category.cdoID());
- }
-
- session.close();
- }
-
- /**
- * @author Eike Stepper
- */
- protected static class CompanyChanger
- {
- public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- }
-
- public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
- {
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * Support raw replication in HorizontalBranchingMappingStrategyWithRanges.
+ * <p>
+ * See bug 351078
+ *
+ * @author Eike Stepper
+ */
+@Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
+@CleanRepositoriesBefore
+public class Bugzilla_351078_Test extends AbstractSyncingTest
+{
+ @Override
+ protected boolean isRawReplication()
+ {
+ return true;
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ OMPlatform.INSTANCE.setDebugging(false);
+ OMPlatform.INSTANCE.removeTraceHandler(PrintTraceHandler.CONSOLE);
+ super.doSetUp();
+ }
+
+ public void testDoNothing() throws Exception
+ {
+ run(new CompanyChanger());
+ }
+
+ public void testAddTwoRemoveFirst_DoNothing() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.remove(0);
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwoRemoveFirst_AddTwo() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.remove(0);
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwoRemoveSecond_DoNothing() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.remove(1);
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwoRemoveSecond_AddTwo() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.remove(1);
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ }
+ });
+ }
+
+ public void testAddTwo_RemoveFirst() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.remove(0);
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwo_RemoveFirstAddOne() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.remove(0);
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwo_RemoveSecond() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.remove(1);
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwo_RemoveSecondAddOne() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.remove(1);
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwo_AddOneRemoveThird() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.remove(2);
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddOne_AddOne() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwo_AddTwo() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddThree_MoveFirst() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.move(5, 0);
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddThree_MoveLast() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.move(0, 5);
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddOne_ReplaceIt() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.set(0, getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddOneAddOne_ReplaceFirst() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.set(0, getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddOneRemoveIt() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.remove(0);
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddOneAddOne_RemoveFirst() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.remove(0);
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddOneReplaceFirst_ReplaceFirst() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.set(0, getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.set(0, getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddOneAddOneReplaceFirst_ReplaceFirst() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.set(0, getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.set(0, getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddAddReplaceAddRmove_ReplaceAdd() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.set(0, getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.remove(0);
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.set(0, getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(0, getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ protected void run(CompanyChanger changer) throws Exception
+ {
+ // Create master session & transaction.
+ InternalRepository master = getRepository("master");
+ CDOSession masterSession = openSession(master.getName());
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+
+ // Create resource and base model.
+ CDOResource resource = masterTransaction.createResource(getResourcePath("/my/resource"));
+ Company masterCompany = getModel1Factory().createCompany();
+ resource.getContents().add(masterCompany);
+ masterTransaction.commit();
+
+ changer.beforeConnect(masterCompany.getCategories(), masterTransaction);
+
+ // Create an offline clone.
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+ sleep(500); // TODO Clarify why waitForOnline() alone is not enough
+
+ check(master, masterCompany, "after connect");
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+ sleep(500);
+
+ changer.beforeReconnect(masterCompany.getCategories(), masterTransaction);
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ sleep(500);
+
+ check(master, masterCompany, "after reconnect");
+ }
+
+ protected void check(InternalRepository master, Company masterCompany, String when)
+ {
+ EList<Category> masterCategories = masterCompany.getCategories();
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOID id = CDOUtil.getCDOObject(masterCompany).cdoID();
+ Company company = (Company)view.getObject(id);
+ EList<Category> categories = company.getCategories();
+
+ assertEquals("Size (" + when + ")", masterCategories.size(), categories.size());
+
+ for (int i = 0; i < masterCategories.size(); i++)
+ {
+ CDOObject masterCategory = CDOUtil.getCDOObject(masterCategories.get(i));
+ CDOObject category = CDOUtil.getCDOObject(categories.get(i));
+ assertEquals("Element " + i + " (" + when + ")", masterCategory.cdoID(), category.cdoID());
+ }
+
+ session.close();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ protected static class CompanyChanger
+ {
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ }
+
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java
index 0e78017b43..845dc201eb 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java
@@ -1,342 +1,342 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.acceptor.IAcceptor;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.io.IOUtil;
-
-/**
- * @author Eike Stepper
- */
-public class FailoverTest extends AbstractSyncingTest
-{
- private IAcceptor backupAcceptor;
-
- @Override
- public void tearDown() throws Exception
- {
- super.tearDown();
- stopBackupTransport();
- }
-
- protected void startBackupTransport()
- {
- if (backupAcceptor == null)
- {
- IOUtil.OUT().println();
- IOUtil.OUT().println("startBackupTransport()");
- IOUtil.OUT().println();
- IManagedContainer container = getServerContainer();
- backupAcceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "jvm", "backup");
- }
- }
-
- protected void stopBackupTransport()
- {
- if (backupAcceptor != null)
- {
- IOUtil.OUT().println();
- IOUtil.OUT().println("stopBackupTransport()");
- IOUtil.OUT().println();
- backupAcceptor.close();
- backupAcceptor = null;
- }
- }
-
- @Override
- protected boolean isFailover()
- {
- return true;
- }
-
- public void testMasterCommits_ArrivalInBackup() throws Exception
- {
- CDOSession session = openSession("master");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- // 2 * Root resource + folder + resource + company
- int expectedRevisions = 2 + 1 + 1 + 1;
-
- resource.getContents().add(company);
- long timeStamp = transaction.commit().getTimeStamp();
- checkRevisions(getRepository(), timeStamp, expectedRevisions);
-
- for (int i = 0; i < 10; i++)
- {
- company.setName("Test" + i);
- timeStamp = transaction.commit().getTimeStamp();
- expectedRevisions += 1; // Changed company
- checkRevisions(getRepository(), timeStamp, expectedRevisions);
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().add(getModel1Factory().createCategory());
- timeStamp = transaction.commit().getTimeStamp();
- expectedRevisions += 2; // Changed company + new category
- checkRevisions(getRepository(), timeStamp, expectedRevisions);
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().remove(0);
- timeStamp = transaction.commit().getTimeStamp();
- expectedRevisions += 2; // Changed company + detached category
- checkRevisions(getRepository(), timeStamp, expectedRevisions);
- }
-
- session.close();
- }
-
- public void testMasterCommits_NotificationsFromBackup() throws Exception
- {
- CDOSession masterSession = openSession("master");
- CDOTransaction transaction = masterSession.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- TestListener listener = new TestListener();
- CDOSession backupSession = openSession();
- backupSession.addListener(listener);
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- resource.getContents().add(company);
- long timeStamp = transaction.commit().getTimeStamp();
- assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
- checkEvent(listener, 1, 3, 1, 0);
-
- for (int i = 0; i < 10; i++)
- {
- company.setName("Test" + i);
- timeStamp = transaction.commit().getTimeStamp();
- assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
- checkEvent(listener, 0, 0, 1, 0);
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().add(getModel1Factory().createCategory());
- timeStamp = transaction.commit().getTimeStamp();
- assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
- checkEvent(listener, 0, 1, 1, 0);
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().remove(0);
- timeStamp = transaction.commit().getTimeStamp();
- assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
- checkEvent(listener, 0, 0, 1, 1);
- }
-
- backupSession.close();
- masterSession.close();
- }
-
- public void testClientCommitsToBackupForbidden() throws Exception
- {
- /* InternalRepository backup = */
- getRepository();
-
- InternalRepository master = getRepository("master");
-
- TestListener listener = new TestListener();
- CDOSession masterSession = openSession(master.getName());
- masterSession.addListener(listener);
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- CDOSession backupSession = openSession();
- waitForOnline(backupSession.getRepositoryInfo());
-
- CDOTransaction transaction = backupSession.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- resource.getContents().add(company);
-
- try
- {
- transaction.commit();
- fail("Exception expected");
- }
- catch (Exception expected)
- {
- // SUCCESS
- }
- }
-
- public void testPauseMasterTransport() throws Exception
- {
- CDOSession session = openSession("master");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- resource.getContents().add(company);
- long timeStamp = transaction.commit().getTimeStamp();
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(getRepository());
-
- for (int i = 0; i < 10; i++)
- {
- company.setName("Test" + i);
- timeStamp = transaction.commit().getTimeStamp();
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().add(getModel1Factory().createCategory());
- timeStamp = transaction.commit().getTimeStamp();
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().remove(0);
- timeStamp = transaction.commit().getTimeStamp();
- }
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(getRepository());
-
- assertEquals(timeStamp, getRepository().getLastReplicatedCommitTime());
- session.close();
- }
-
- public void testSwitchMaster() throws Exception
- {
- CDOSession session = openSession("master");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- resource.getContents().add(company);
- transaction.commit();
-
- for (int i = 0; i < 10; i++)
- {
- company.setName("Test" + i);
- transaction.commit();
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().add(getModel1Factory().createCategory());
- transaction.commit();
- }
-
- for (int i = 0; i < 5; i++)
- {
- company.getCategories().remove(0);
- transaction.commit();
- }
-
- startBackupTransport();
-
- try
- {
- getRepository().setType(CDOCommonRepository.Type.MASTER);
- getRepository("master").setType(CDOCommonRepository.Type.BACKUP);
- company.setName("Commit should fail");
-
- try
- {
- transaction.commit();
- fail("Exception expected");
- }
- catch (Exception expected)
- {
- // SUCCESS
- }
-
- session.close();
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("/my/resource"));
- company = (Company)resource.getContents().get(0);
- company.setName("Commit should NOT fail");
- transaction.commit();
- }
- finally
- {
- stopBackupTransport();
- session.close();
- }
- }
-
- public void testSwitchMasterAndCommit() throws Exception
- {
- CDOSession session = openSession("master");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- resource.getContents().add(company);
- transaction.setCommitComment("Company created");
- transaction.commit();
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().add(getModel1Factory().createCategory());
- transaction.setCommitComment("Category added");
- transaction.commit();
- }
-
- startBackupTransport();
-
- try
- {
- getRepository().setType(CDOCommonRepository.Type.MASTER);
- getRepository("master").setType(CDOCommonRepository.Type.BACKUP);
-
- session.close();
- session = openSession();
- transaction = session.openTransaction();
-
- resource = transaction.getResource(getResourcePath("/my/resource"));
- company = (Company)resource.getContents().get(0);
-
- for (int i = 0; i < 10; i++)
- {
- company.setName("AfterFailover-" + i);
- transaction.setCommitComment("Name changed after failover");
- transaction.commit();
- }
- }
- finally
- {
- stopBackupTransport();
- session.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestListener;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.IOUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class FailoverTest extends AbstractSyncingTest
+{
+ private IAcceptor backupAcceptor;
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ stopBackupTransport();
+ }
+
+ protected void startBackupTransport()
+ {
+ if (backupAcceptor == null)
+ {
+ IOUtil.OUT().println();
+ IOUtil.OUT().println("startBackupTransport()");
+ IOUtil.OUT().println();
+ IManagedContainer container = getServerContainer();
+ backupAcceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "jvm", "backup");
+ }
+ }
+
+ protected void stopBackupTransport()
+ {
+ if (backupAcceptor != null)
+ {
+ IOUtil.OUT().println();
+ IOUtil.OUT().println("stopBackupTransport()");
+ IOUtil.OUT().println();
+ backupAcceptor.close();
+ backupAcceptor = null;
+ }
+ }
+
+ @Override
+ protected boolean isFailover()
+ {
+ return true;
+ }
+
+ public void testMasterCommits_ArrivalInBackup() throws Exception
+ {
+ CDOSession session = openSession("master");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ // 2 * Root resource + folder + resource + company
+ int expectedRevisions = 2 + 1 + 1 + 1;
+
+ resource.getContents().add(company);
+ long timeStamp = transaction.commit().getTimeStamp();
+ checkRevisions(getRepository(), timeStamp, expectedRevisions);
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.setName("Test" + i);
+ timeStamp = transaction.commit().getTimeStamp();
+ expectedRevisions += 1; // Changed company
+ checkRevisions(getRepository(), timeStamp, expectedRevisions);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().add(getModel1Factory().createCategory());
+ timeStamp = transaction.commit().getTimeStamp();
+ expectedRevisions += 2; // Changed company + new category
+ checkRevisions(getRepository(), timeStamp, expectedRevisions);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().remove(0);
+ timeStamp = transaction.commit().getTimeStamp();
+ expectedRevisions += 2; // Changed company + detached category
+ checkRevisions(getRepository(), timeStamp, expectedRevisions);
+ }
+
+ session.close();
+ }
+
+ public void testMasterCommits_NotificationsFromBackup() throws Exception
+ {
+ CDOSession masterSession = openSession("master");
+ CDOTransaction transaction = masterSession.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ TestListener listener = new TestListener();
+ CDOSession backupSession = openSession();
+ backupSession.addListener(listener);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ resource.getContents().add(company);
+ long timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 1, 3, 1, 0);
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.setName("Test" + i);
+ timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 0, 0, 1, 0);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().add(getModel1Factory().createCategory());
+ timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 0, 1, 1, 0);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().remove(0);
+ timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 0, 0, 1, 1);
+ }
+
+ backupSession.close();
+ masterSession.close();
+ }
+
+ public void testClientCommitsToBackupForbidden() throws Exception
+ {
+ /* InternalRepository backup = */
+ getRepository();
+
+ InternalRepository master = getRepository("master");
+
+ TestListener listener = new TestListener();
+ CDOSession masterSession = openSession(master.getName());
+ masterSession.addListener(listener);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ CDOSession backupSession = openSession();
+ waitForOnline(backupSession.getRepositoryInfo());
+
+ CDOTransaction transaction = backupSession.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ resource.getContents().add(company);
+
+ try
+ {
+ transaction.commit();
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ public void testPauseMasterTransport() throws Exception
+ {
+ CDOSession session = openSession("master");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ resource.getContents().add(company);
+ long timeStamp = transaction.commit().getTimeStamp();
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(getRepository());
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.setName("Test" + i);
+ timeStamp = transaction.commit().getTimeStamp();
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().add(getModel1Factory().createCategory());
+ timeStamp = transaction.commit().getTimeStamp();
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().remove(0);
+ timeStamp = transaction.commit().getTimeStamp();
+ }
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(getRepository());
+
+ assertEquals(timeStamp, getRepository().getLastReplicatedCommitTime());
+ session.close();
+ }
+
+ public void testSwitchMaster() throws Exception
+ {
+ CDOSession session = openSession("master");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ resource.getContents().add(company);
+ transaction.commit();
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.setName("Test" + i);
+ transaction.commit();
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ for (int i = 0; i < 5; i++)
+ {
+ company.getCategories().remove(0);
+ transaction.commit();
+ }
+
+ startBackupTransport();
+
+ try
+ {
+ getRepository().setType(CDOCommonRepository.Type.MASTER);
+ getRepository("master").setType(CDOCommonRepository.Type.BACKUP);
+ company.setName("Commit should fail");
+
+ try
+ {
+ transaction.commit();
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // SUCCESS
+ }
+
+ session.close();
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ company = (Company)resource.getContents().get(0);
+ company.setName("Commit should NOT fail");
+ transaction.commit();
+ }
+ finally
+ {
+ stopBackupTransport();
+ session.close();
+ }
+ }
+
+ public void testSwitchMasterAndCommit() throws Exception
+ {
+ CDOSession session = openSession("master");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ resource.getContents().add(company);
+ transaction.setCommitComment("Company created");
+ transaction.commit();
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().add(getModel1Factory().createCategory());
+ transaction.setCommitComment("Category added");
+ transaction.commit();
+ }
+
+ startBackupTransport();
+
+ try
+ {
+ getRepository().setType(CDOCommonRepository.Type.MASTER);
+ getRepository("master").setType(CDOCommonRepository.Type.BACKUP);
+
+ session.close();
+ session = openSession();
+ transaction = session.openTransaction();
+
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ company = (Company)resource.getContents().get(0);
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.setName("AfterFailover-" + i);
+ transaction.setCommitComment("Name changed after failover");
+ transaction.commit();
+ }
+ }
+ finally
+ {
+ stopBackupTransport();
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayed2Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayed2Test.java
index 47955eaf6e..f2d9fa235d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayed2Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayed2Test.java
@@ -1,69 +1,69 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-/**
- * @author Eike Stepper
- */
-public class OfflineDelayed2Test extends AbstractSyncingTest
-{
- @Override
- protected long getTestDelayed2CommitHandling()
- {
- return 1000L;
- }
-
- public void testCommitOrder() throws Exception
- {
- int nbrOfCommits = 5;
-
- InternalRepository master = getRepository("master");
-
- CDOSession masterSession = openSession(master.getName());
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.createResource("/my/resource");
-
- Company masterCompany = getModel1Factory().createCompany();
- masterCompany.setName("Test");
- masterResource.getContents().add(masterCompany);
-
- masterTransaction.commit();
-
- CDOSession cloneSession = openSession();
- waitForOnline(cloneSession.getRepositoryInfo());
-
- for (int i = 0; i < nbrOfCommits; i++)
- {
- masterCompany.setName(Integer.toString(i));
- masterTransaction.commit();
- }
-
- sleep(1000);
- sleep(1000);
- sleep(1000);
- sleep(1000);
- sleep(1000);
-
- CDOTransaction cloneTransaction = cloneSession.openTransaction();
- CDOObject cloneCompany = CDOUtil.getCDOObject(cloneTransaction.getObject(CDOUtil.getCDOObject(masterCompany)
- .cdoID()));
- assertEquals(nbrOfCommits + 1, cloneCompany.cdoRevision().getVersion());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class OfflineDelayed2Test extends AbstractSyncingTest
+{
+ @Override
+ protected long getTestDelayed2CommitHandling()
+ {
+ return 1000L;
+ }
+
+ public void testCommitOrder() throws Exception
+ {
+ int nbrOfCommits = 5;
+
+ InternalRepository master = getRepository("master");
+
+ CDOSession masterSession = openSession(master.getName());
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.createResource("/my/resource");
+
+ Company masterCompany = getModel1Factory().createCompany();
+ masterCompany.setName("Test");
+ masterResource.getContents().add(masterCompany);
+
+ masterTransaction.commit();
+
+ CDOSession cloneSession = openSession();
+ waitForOnline(cloneSession.getRepositoryInfo());
+
+ for (int i = 0; i < nbrOfCommits; i++)
+ {
+ masterCompany.setName(Integer.toString(i));
+ masterTransaction.commit();
+ }
+
+ sleep(1000);
+ sleep(1000);
+ sleep(1000);
+ sleep(1000);
+ sleep(1000);
+
+ CDOTransaction cloneTransaction = cloneSession.openTransaction();
+ CDOObject cloneCompany = CDOUtil.getCDOObject(cloneTransaction.getObject(CDOUtil.getCDOObject(masterCompany)
+ .cdoID()));
+ assertEquals(nbrOfCommits + 1, cloneCompany.cdoRevision().getVersion());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java
index 788f958ca1..a9ecd52bff 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java
@@ -1,161 +1,161 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.event.IEvent;
-
-/**
- * @author Eike Stepper
- */
-@CleanRepositoriesBefore
-public class OfflineDelayedTest extends AbstractSyncingTest
-{
- @Override
- protected long getTestDelayedCommitHandling()
- {
- return 500L;
- }
-
- public void _testSyncBeforeCommittingToMaster() throws Exception
- {
- TestListener listener = new TestListener();
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- {
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.createResource("/master/resource");
- for (int i = 0; i < 10; i++)
- {
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.commit();
- }
-
- masterTransaction.close();
- masterSession.addListener(listener);
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- }
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- resource.getContents().add(company);
- transaction.commit();
-
- IEvent[] events = listener.getEvents();
- assertEquals(1, events.length);
- }
-
- public void testSyncWhileCommittingToMaster() throws Exception
- {
- disableConsole();
-
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- {
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.createResource("/master/resource");
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.commit();
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- for (int i = 0; i < 20; i++)
- {
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.commit();
- }
-
- masterTransaction.close();
- enableConsole();
-
- getOfflineConfig().startMasterTransport();
- sleep(1000L);
- }
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- resource.getContents().add(company);
- transaction.commit();
-
- waitForOnline(clone);
- }
-
- public void _testSyncWhileCommittingToMaster_NewPackage() throws Exception
- {
- TestListener listener = new TestListener();
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- {
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.createResource("/master/resource");
- for (int i = 0; i < 20; i++)
- {
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.commit();
- }
-
- masterTransaction.close();
- masterSession.addListener(listener);
-
- getOfflineConfig().startMasterTransport();
- sleep(1000L);
- }
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- resource.getContents().add(company);
- transaction.commit();
-
- waitForOnline(clone);
-
- IEvent[] events = listener.getEvents();
- assertEquals(1, events.length);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestListener;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.event.IEvent;
+
+/**
+ * @author Eike Stepper
+ */
+@CleanRepositoriesBefore
+public class OfflineDelayedTest extends AbstractSyncingTest
+{
+ @Override
+ protected long getTestDelayedCommitHandling()
+ {
+ return 500L;
+ }
+
+ public void _testSyncBeforeCommittingToMaster() throws Exception
+ {
+ TestListener listener = new TestListener();
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ {
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.createResource("/master/resource");
+ for (int i = 0; i < 10; i++)
+ {
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.commit();
+ }
+
+ masterTransaction.close();
+ masterSession.addListener(listener);
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ }
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ resource.getContents().add(company);
+ transaction.commit();
+
+ IEvent[] events = listener.getEvents();
+ assertEquals(1, events.length);
+ }
+
+ public void testSyncWhileCommittingToMaster() throws Exception
+ {
+ disableConsole();
+
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ {
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.createResource("/master/resource");
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.commit();
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ for (int i = 0; i < 20; i++)
+ {
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.commit();
+ }
+
+ masterTransaction.close();
+ enableConsole();
+
+ getOfflineConfig().startMasterTransport();
+ sleep(1000L);
+ }
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ resource.getContents().add(company);
+ transaction.commit();
+
+ waitForOnline(clone);
+ }
+
+ public void _testSyncWhileCommittingToMaster_NewPackage() throws Exception
+ {
+ TestListener listener = new TestListener();
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ {
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.createResource("/master/resource");
+ for (int i = 0; i < 20; i++)
+ {
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.commit();
+ }
+
+ masterTransaction.close();
+ masterSession.addListener(listener);
+
+ getOfflineConfig().startMasterTransport();
+ sleep(1000L);
+ }
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ resource.getContents().add(company);
+ transaction.commit();
+
+ waitForOnline(clone);
+
+ IEvent[] events = listener.getEvents();
+ assertEquals(1, events.length);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java
index 863440f3f1..2ff8bce185 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java
@@ -1,192 +1,192 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.server.syncing.OfflineClone;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
-import org.eclipse.emf.cdo.session.CDOSessionLocksChangedEvent;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener2;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-/**
- * @author Caspar De Groot
- */
-public class OfflineLockingTest extends AbstractSyncingTest
-{
- public void testLockAndUnlockThrough() throws Exception
- {
- assertEquals(true, getRepository("repo1") instanceof OfflineClone);
-
- CDOSession masterSession = openSession("master");
- CDOSession cloneSession = openSession("repo1");
- waitForOnline(cloneSession.getRepositoryInfo());
-
- CDOTransaction cloneTx = cloneSession.openTransaction();
- cloneTx.enableDurableLocking();
-
- CDOResource res = cloneTx.createResource(getResourcePath("test"));
- Company company = getModel1Factory().createCompany();
- res.getContents().add(company);
- cloneTx.commit();
- CDOObject cdoCompany = CDOUtil.getCDOObject(company);
-
- CDOView masterView = masterSession.openView();
- masterView.options().setLockNotificationEnabled(true);
- TestListener2 masterViewListener = new TestListener2(CDOViewLocksChangedEvent.class);
- masterView.addListener(masterViewListener);
- CDOObject cdoCompanyOnMaster = masterView.getObject(cdoCompany.cdoID());
-
- cdoCompany.cdoWriteLock().lock();
- masterViewListener.waitFor(1);
- assertEquals(true, cdoCompanyOnMaster.cdoWriteLock().isLockedByOthers());
-
- cdoCompany.cdoWriteLock().unlock();
- masterViewListener.waitFor(2);
- assertEquals(false, cdoCompanyOnMaster.cdoWriteLock().isLockedByOthers());
-
- cloneSession.close();
- masterSession.close();
- }
-
- public void testCloneLocks_arrivalInOtherClone() throws Exception
- {
- // Create a 2nd clone repository
- assertEquals(true, getRepository("repo1") instanceof OfflineClone);
- assertEquals(true, getRepository("repo2") instanceof OfflineClone);
-
- CDOSession clone1Session = openSession("repo1");
- TestListener2 session1lockListener = new TestListener2(CDOSessionLocksChangedEvent.class, "session1lockListener");
- clone1Session.addListener(session1lockListener);
- waitForOnline(clone1Session.getRepositoryInfo());
-
- CDOSession clone2Session = openSession("repo2");
- TestListener2 session2invalidationListener = new TestListener2(CDOSessionInvalidationEvent.class,
- "session2invalidationListener");
- clone2Session.addListener(session2invalidationListener);
- TestListener2 session2lockListener = new TestListener2(CDOSessionLocksChangedEvent.class, "session2lockListener");
- clone2Session.addListener(session2lockListener);
- waitForOnline(clone2Session.getRepositoryInfo());
-
- CDOTransaction clone1Tx = openTransaction(clone1Session);
-
- CDOResource resourceInSession1 = clone1Tx.createResource(getResourcePath("test"));
- Company companyA = getModel1Factory().createCompany();
- Company companyB = getModel1Factory().createCompany();
- Company companyC = getModel1Factory().createCompany();
- resourceInSession1.getContents().add(companyA);
- resourceInSession1.getContents().add(companyB);
- resourceInSession1.getContents().add(companyC);
- clone1Tx.commit();
-
- CDOObject companyA_session1 = CDOUtil.getCDOObject(companyA);
- CDOObject companyB_session1 = CDOUtil.getCDOObject(companyB);
- CDOObject companyC_session1 = CDOUtil.getCDOObject(companyC);
-
- session2invalidationListener.setTimeout(Integer.MAX_VALUE);
- session2invalidationListener.waitFor(1); // Wait for the commit notification
-
- CDOTransaction clone2Tx = openTransaction(clone2Session);
-
- CDOResource resourceInSession2 = clone2Tx.getResource(getResourcePath("test"));
- CDOObject companyA_session2 = CDOUtil.getCDOObject(resourceInSession2.getContents().get(0));
- CDOObject companyB_session2 = CDOUtil.getCDOObject(resourceInSession2.getContents().get(1));
- CDOObject companyC_session2 = CDOUtil.getCDOObject(resourceInSession2.getContents().get(2));
-
- CDOSessionLocksChangedEvent e;
-
- // Verify that thusfar we haven't received any locking events in session 1
- assertEquals(0, session1lockListener.getEvents().size());
-
- // Perform the lock in session 2, connected to clone 2
- companyA_session2.cdoWriteLock().lock();
-
- // Wait for the lock notification in session 1, which is connected to clone 1
- session1lockListener.waitFor(1);
-
- e = (CDOSessionLocksChangedEvent)session1lockListener.getEvents().get(0);
- assertSame(LockType.WRITE, e.getLockType());
- assertSame(Operation.LOCK, e.getOperation());
- assertEquals(true, companyA_session1.cdoWriteLock().isLockedByOthers());
-
- // Perform the unlock in session 2, connected to clone 2
- companyA_session2.cdoWriteLock().unlock();
-
- // Wait for the lock notification in session 1, which is connected to clone 1
- session1lockListener.waitFor(2);
-
- e = (CDOSessionLocksChangedEvent)session1lockListener.getEvents().get(1);
- assertSame(LockType.WRITE, e.getLockType());
- assertSame(Operation.UNLOCK, e.getOperation());
- assertEquals(false, companyA_session1.cdoWriteLock().isLockedByOthers());
-
- // Now vice versa . . .
-
- session2lockListener.getEvents().clear();
-
- // Perform the lock in session 1, connected to clone 1
- companyA_session1.cdoWriteLock().lock();
-
- // Wait for the lock notification in session 2, which is connected to clone 2
- session2lockListener.waitFor(1);
-
- e = (CDOSessionLocksChangedEvent)session2lockListener.getEvents().get(0);
- assertSame(LockType.WRITE, e.getLockType());
- assertSame(Operation.LOCK, e.getOperation());
- assertEquals(true, companyA_session2.cdoWriteLock().isLockedByOthers());
-
- // Perform the unlock in session 1, connected to clone 1
- companyA_session1.cdoWriteLock().unlock();
-
- // Wait for the lock notification in session 1, which is connected to clone 1
- session2lockListener.waitFor(2);
-
- e = (CDOSessionLocksChangedEvent)session2lockListener.getEvents().get(1);
- assertSame(LockType.WRITE, e.getLockType());
- assertSame(Operation.UNLOCK, e.getOperation());
- assertEquals(false, companyA_session2.cdoWriteLock().isLockedByOthers());
-
- // Now try an unlock-all . . .
-
- session1lockListener.getEvents().clear();
-
- companyA_session2.cdoReadLock().lock();
- companyB_session2.cdoWriteLock().lock();
- companyC_session2.cdoWriteOption().lock();
-
- session1lockListener.waitFor(3);
-
- assertEquals(true, companyA_session1.cdoReadLock().isLockedByOthers());
- assertEquals(true, companyB_session1.cdoWriteLock().isLockedByOthers());
- assertEquals(true, companyC_session1.cdoWriteOption().isLockedByOthers());
-
- clone2Tx.unlockObjects();
-
- session1lockListener.waitFor(4);
-
- assertEquals(false, companyA_session1.cdoReadLock().isLockedByOthers());
- assertEquals(false, companyA_session1.cdoWriteLock().isLockedByOthers());
- assertEquals(false, companyA_session1.cdoWriteOption().isLockedByOthers());
-
- clone1Session.close();
- clone2Session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.server.syncing.OfflineClone;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
+import org.eclipse.emf.cdo.session.CDOSessionLocksChangedEvent;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.TestListener2;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+
+/**
+ * @author Caspar De Groot
+ */
+public class OfflineLockingTest extends AbstractSyncingTest
+{
+ public void testLockAndUnlockThrough() throws Exception
+ {
+ assertEquals(true, getRepository("repo1") instanceof OfflineClone);
+
+ CDOSession masterSession = openSession("master");
+ CDOSession cloneSession = openSession("repo1");
+ waitForOnline(cloneSession.getRepositoryInfo());
+
+ CDOTransaction cloneTx = cloneSession.openTransaction();
+ cloneTx.enableDurableLocking();
+
+ CDOResource res = cloneTx.createResource(getResourcePath("test"));
+ Company company = getModel1Factory().createCompany();
+ res.getContents().add(company);
+ cloneTx.commit();
+ CDOObject cdoCompany = CDOUtil.getCDOObject(company);
+
+ CDOView masterView = masterSession.openView();
+ masterView.options().setLockNotificationEnabled(true);
+ TestListener2 masterViewListener = new TestListener2(CDOViewLocksChangedEvent.class);
+ masterView.addListener(masterViewListener);
+ CDOObject cdoCompanyOnMaster = masterView.getObject(cdoCompany.cdoID());
+
+ cdoCompany.cdoWriteLock().lock();
+ masterViewListener.waitFor(1);
+ assertEquals(true, cdoCompanyOnMaster.cdoWriteLock().isLockedByOthers());
+
+ cdoCompany.cdoWriteLock().unlock();
+ masterViewListener.waitFor(2);
+ assertEquals(false, cdoCompanyOnMaster.cdoWriteLock().isLockedByOthers());
+
+ cloneSession.close();
+ masterSession.close();
+ }
+
+ public void testCloneLocks_arrivalInOtherClone() throws Exception
+ {
+ // Create a 2nd clone repository
+ assertEquals(true, getRepository("repo1") instanceof OfflineClone);
+ assertEquals(true, getRepository("repo2") instanceof OfflineClone);
+
+ CDOSession clone1Session = openSession("repo1");
+ TestListener2 session1lockListener = new TestListener2(CDOSessionLocksChangedEvent.class, "session1lockListener");
+ clone1Session.addListener(session1lockListener);
+ waitForOnline(clone1Session.getRepositoryInfo());
+
+ CDOSession clone2Session = openSession("repo2");
+ TestListener2 session2invalidationListener = new TestListener2(CDOSessionInvalidationEvent.class,
+ "session2invalidationListener");
+ clone2Session.addListener(session2invalidationListener);
+ TestListener2 session2lockListener = new TestListener2(CDOSessionLocksChangedEvent.class, "session2lockListener");
+ clone2Session.addListener(session2lockListener);
+ waitForOnline(clone2Session.getRepositoryInfo());
+
+ CDOTransaction clone1Tx = openTransaction(clone1Session);
+
+ CDOResource resourceInSession1 = clone1Tx.createResource(getResourcePath("test"));
+ Company companyA = getModel1Factory().createCompany();
+ Company companyB = getModel1Factory().createCompany();
+ Company companyC = getModel1Factory().createCompany();
+ resourceInSession1.getContents().add(companyA);
+ resourceInSession1.getContents().add(companyB);
+ resourceInSession1.getContents().add(companyC);
+ clone1Tx.commit();
+
+ CDOObject companyA_session1 = CDOUtil.getCDOObject(companyA);
+ CDOObject companyB_session1 = CDOUtil.getCDOObject(companyB);
+ CDOObject companyC_session1 = CDOUtil.getCDOObject(companyC);
+
+ session2invalidationListener.setTimeout(Integer.MAX_VALUE);
+ session2invalidationListener.waitFor(1); // Wait for the commit notification
+
+ CDOTransaction clone2Tx = openTransaction(clone2Session);
+
+ CDOResource resourceInSession2 = clone2Tx.getResource(getResourcePath("test"));
+ CDOObject companyA_session2 = CDOUtil.getCDOObject(resourceInSession2.getContents().get(0));
+ CDOObject companyB_session2 = CDOUtil.getCDOObject(resourceInSession2.getContents().get(1));
+ CDOObject companyC_session2 = CDOUtil.getCDOObject(resourceInSession2.getContents().get(2));
+
+ CDOSessionLocksChangedEvent e;
+
+ // Verify that thusfar we haven't received any locking events in session 1
+ assertEquals(0, session1lockListener.getEvents().size());
+
+ // Perform the lock in session 2, connected to clone 2
+ companyA_session2.cdoWriteLock().lock();
+
+ // Wait for the lock notification in session 1, which is connected to clone 1
+ session1lockListener.waitFor(1);
+
+ e = (CDOSessionLocksChangedEvent)session1lockListener.getEvents().get(0);
+ assertSame(LockType.WRITE, e.getLockType());
+ assertSame(Operation.LOCK, e.getOperation());
+ assertEquals(true, companyA_session1.cdoWriteLock().isLockedByOthers());
+
+ // Perform the unlock in session 2, connected to clone 2
+ companyA_session2.cdoWriteLock().unlock();
+
+ // Wait for the lock notification in session 1, which is connected to clone 1
+ session1lockListener.waitFor(2);
+
+ e = (CDOSessionLocksChangedEvent)session1lockListener.getEvents().get(1);
+ assertSame(LockType.WRITE, e.getLockType());
+ assertSame(Operation.UNLOCK, e.getOperation());
+ assertEquals(false, companyA_session1.cdoWriteLock().isLockedByOthers());
+
+ // Now vice versa . . .
+
+ session2lockListener.getEvents().clear();
+
+ // Perform the lock in session 1, connected to clone 1
+ companyA_session1.cdoWriteLock().lock();
+
+ // Wait for the lock notification in session 2, which is connected to clone 2
+ session2lockListener.waitFor(1);
+
+ e = (CDOSessionLocksChangedEvent)session2lockListener.getEvents().get(0);
+ assertSame(LockType.WRITE, e.getLockType());
+ assertSame(Operation.LOCK, e.getOperation());
+ assertEquals(true, companyA_session2.cdoWriteLock().isLockedByOthers());
+
+ // Perform the unlock in session 1, connected to clone 1
+ companyA_session1.cdoWriteLock().unlock();
+
+ // Wait for the lock notification in session 1, which is connected to clone 1
+ session2lockListener.waitFor(2);
+
+ e = (CDOSessionLocksChangedEvent)session2lockListener.getEvents().get(1);
+ assertSame(LockType.WRITE, e.getLockType());
+ assertSame(Operation.UNLOCK, e.getOperation());
+ assertEquals(false, companyA_session2.cdoWriteLock().isLockedByOthers());
+
+ // Now try an unlock-all . . .
+
+ session1lockListener.getEvents().clear();
+
+ companyA_session2.cdoReadLock().lock();
+ companyB_session2.cdoWriteLock().lock();
+ companyC_session2.cdoWriteOption().lock();
+
+ session1lockListener.waitFor(3);
+
+ assertEquals(true, companyA_session1.cdoReadLock().isLockedByOthers());
+ assertEquals(true, companyB_session1.cdoWriteLock().isLockedByOthers());
+ assertEquals(true, companyC_session1.cdoWriteOption().isLockedByOthers());
+
+ clone2Tx.unlockObjects();
+
+ session1lockListener.waitFor(4);
+
+ assertEquals(false, companyA_session1.cdoReadLock().isLockedByOthers());
+ assertEquals(false, companyA_session1.cdoWriteLock().isLockedByOthers());
+ assertEquals(false, companyA_session1.cdoWriteOption().isLockedByOthers());
+
+ clone1Session.close();
+ clone2Session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java
index ca0001f6ec..9992c4c632 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java
@@ -1,257 +1,257 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.util.TestListener;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.om.monitor.NotifyingMonitor.ProgressEvent;
-
-/**
- * @author Eike Stepper
- */
-@CleanRepositoriesBefore
-public class OfflineRawTest extends OfflineTest
-{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- public void _testMasterCommits_NotificationsFromClone() throws Exception
- {
- masterCommits_NotificationsFromClone();
- }
-
- /**
- * @since 4.0
- */
- public void _testNotification() throws Exception
- {
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.setCommitComment("resource with one company created on clone");
- transaction.commit();
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- TestListener sessionListener = new TestListener();
- session.addListener(sessionListener);
-
- TestListener transactionListener = new TestListener();
- transaction.addListener(transactionListener);
-
- {
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.getResource("/my/resource");
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
-
- masterTransaction.close();
- }
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- sleep(1000);
-
- IEvent[] sessionEvents = sessionListener.getEvents();
- assertEquals(4, sessionEvents.length); // 3x repo state change + 1x invalidation
-
- int count = 0;
- for (IEvent sessionEvent : sessionEvents)
- {
- if (sessionEvent instanceof CDOSessionInvalidationEvent)
- {
- CDOSessionInvalidationEvent sessionInvalidationEvent = (CDOSessionInvalidationEvent)sessionEvent;
- assertEquals(2, sessionInvalidationEvent.getNewObjects().size());
- assertEquals(1, sessionInvalidationEvent.getChangedObjects().size());
- assertEquals(0, sessionInvalidationEvent.getDetachedObjects().size());
- ++count;
- }
- }
-
- assertEquals(1, count);
-
- IEvent[] transactionEvents = transactionListener.getEvents();
- assertEquals(2, transactionEvents.length); // 1x invalidation + 1x adapters notified
-
- CDOViewInvalidationEvent viewInvalidationEvent = (CDOViewInvalidationEvent)transactionEvents[0];
- assertEquals(1, viewInvalidationEvent.getDirtyObjects().size());
- assertEquals(1, viewInvalidationEvent.getRevisionDeltas().size());
- assertEquals(0, viewInvalidationEvent.getDetachedObjects().size());
-
- CDORevisionDelta delta = viewInvalidationEvent.getRevisionDeltas().get(resource);
- assertEquals(null, delta);
- assertEquals(true, viewInvalidationEvent.getRevisionDeltas().containsKey(resource));
- }
-
- /**
- * @since 4.0
- */
- public void testNotificationAllDeltas() throws Exception
- {
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- CDOSession session = openSession();
- session.options().setPassiveUpdateMode(PassiveUpdateMode.ADDITIONS);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.setCommitComment("resource with one company created on clone");
- transaction.commit();
-
- TestListener sessionListener = new TestListener();
- session.addListener(sessionListener);
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- TestListener transactionListener = new TestListener();
- transaction.addListener(transactionListener);
-
- {
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.getResource("/my/resource");
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
-
- masterTransaction.close();
- }
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- sleep(1000);
-
- IEvent[] sessionEvents = sessionListener.getEvents();
- assertEquals(4, sessionEvents.length); // 3x repo state change + 1x invalidation
-
- int count = 0;
- for (IEvent sessionEvent : sessionEvents)
- {
- if (sessionEvent instanceof CDOSessionInvalidationEvent)
- {
- CDOSessionInvalidationEvent sessionInvalidationEvent = (CDOSessionInvalidationEvent)sessionEvent;
- assertEquals(2, sessionInvalidationEvent.getNewObjects().size());
- assertEquals(1, sessionInvalidationEvent.getChangedObjects().size());
- assertEquals(0, sessionInvalidationEvent.getDetachedObjects().size());
- ++count;
- }
- }
-
- assertEquals(1, count);
-
- IEvent[] transactionEvents = transactionListener.getEvents();
- assertEquals(2, transactionEvents.length); // 1x invalidation + 1x adapters notified
-
- CDOViewInvalidationEvent viewInvalidationEvent = (CDOViewInvalidationEvent)transactionEvents[0];
- assertEquals(1, viewInvalidationEvent.getDirtyObjects().size());
- assertEquals(1, viewInvalidationEvent.getRevisionDeltas().size());
- assertEquals(0, viewInvalidationEvent.getDetachedObjects().size());
-
- CDORevisionDelta delta = viewInvalidationEvent.getRevisionDeltas().get(resource);
- assertEquals(1, delta.getFeatureDeltas().size());
-
- CDOListFeatureDelta listDelta = (CDOListFeatureDelta)delta.getFeatureDeltas().get(0);
- assertEquals(2, listDelta.getListChanges().size());
- }
-
- /**
- * @since 4.0
- */
- public void testSyncProgressEvents() throws Exception
- {
- InternalSynchronizableRepository clone = getRepository();
- waitForOnline(clone);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.setCommitComment("resource with one company created on clone");
- transaction.commit();
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- {
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.getResource("/my/resource");
-
- for (int i = 0; i < 100; i++)
- {
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
- }
-
- masterTransaction.close();
- }
-
- final int[] workPercent = { 0 };
- TestListener listener = new TestListener()
- {
- @Override
- public void notifyEvent(IEvent event)
- {
- super.notifyEvent(event);
- if (event instanceof ProgressEvent)
- {
- ProgressEvent e = (ProgressEvent)event;
- workPercent[0] = (int)e.getWorkPercent();
- msg(e.getTask() + ": " + workPercent[0] + " percent");
- }
- }
- };
-
- clone.getSynchronizer().addListener(listener);
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- assertEquals(100, workPercent[0]);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.util.TestListener;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.om.monitor.NotifyingMonitor.ProgressEvent;
+
+/**
+ * @author Eike Stepper
+ */
+@CleanRepositoriesBefore
+public class OfflineRawTest extends OfflineTest
+{
+ @Override
+ protected boolean isRawReplication()
+ {
+ return true;
+ }
+
+ public void _testMasterCommits_NotificationsFromClone() throws Exception
+ {
+ masterCommits_NotificationsFromClone();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void _testNotification() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ TestListener sessionListener = new TestListener();
+ session.addListener(sessionListener);
+
+ TestListener transactionListener = new TestListener();
+ transaction.addListener(transactionListener);
+
+ {
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+
+ masterTransaction.close();
+ }
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ sleep(1000);
+
+ IEvent[] sessionEvents = sessionListener.getEvents();
+ assertEquals(4, sessionEvents.length); // 3x repo state change + 1x invalidation
+
+ int count = 0;
+ for (IEvent sessionEvent : sessionEvents)
+ {
+ if (sessionEvent instanceof CDOSessionInvalidationEvent)
+ {
+ CDOSessionInvalidationEvent sessionInvalidationEvent = (CDOSessionInvalidationEvent)sessionEvent;
+ assertEquals(2, sessionInvalidationEvent.getNewObjects().size());
+ assertEquals(1, sessionInvalidationEvent.getChangedObjects().size());
+ assertEquals(0, sessionInvalidationEvent.getDetachedObjects().size());
+ ++count;
+ }
+ }
+
+ assertEquals(1, count);
+
+ IEvent[] transactionEvents = transactionListener.getEvents();
+ assertEquals(2, transactionEvents.length); // 1x invalidation + 1x adapters notified
+
+ CDOViewInvalidationEvent viewInvalidationEvent = (CDOViewInvalidationEvent)transactionEvents[0];
+ assertEquals(1, viewInvalidationEvent.getDirtyObjects().size());
+ assertEquals(1, viewInvalidationEvent.getRevisionDeltas().size());
+ assertEquals(0, viewInvalidationEvent.getDetachedObjects().size());
+
+ CDORevisionDelta delta = viewInvalidationEvent.getRevisionDeltas().get(resource);
+ assertEquals(null, delta);
+ assertEquals(true, viewInvalidationEvent.getRevisionDeltas().containsKey(resource));
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void testNotificationAllDeltas() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateMode(PassiveUpdateMode.ADDITIONS);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ TestListener sessionListener = new TestListener();
+ session.addListener(sessionListener);
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ TestListener transactionListener = new TestListener();
+ transaction.addListener(transactionListener);
+
+ {
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+
+ masterTransaction.close();
+ }
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ sleep(1000);
+
+ IEvent[] sessionEvents = sessionListener.getEvents();
+ assertEquals(4, sessionEvents.length); // 3x repo state change + 1x invalidation
+
+ int count = 0;
+ for (IEvent sessionEvent : sessionEvents)
+ {
+ if (sessionEvent instanceof CDOSessionInvalidationEvent)
+ {
+ CDOSessionInvalidationEvent sessionInvalidationEvent = (CDOSessionInvalidationEvent)sessionEvent;
+ assertEquals(2, sessionInvalidationEvent.getNewObjects().size());
+ assertEquals(1, sessionInvalidationEvent.getChangedObjects().size());
+ assertEquals(0, sessionInvalidationEvent.getDetachedObjects().size());
+ ++count;
+ }
+ }
+
+ assertEquals(1, count);
+
+ IEvent[] transactionEvents = transactionListener.getEvents();
+ assertEquals(2, transactionEvents.length); // 1x invalidation + 1x adapters notified
+
+ CDOViewInvalidationEvent viewInvalidationEvent = (CDOViewInvalidationEvent)transactionEvents[0];
+ assertEquals(1, viewInvalidationEvent.getDirtyObjects().size());
+ assertEquals(1, viewInvalidationEvent.getRevisionDeltas().size());
+ assertEquals(0, viewInvalidationEvent.getDetachedObjects().size());
+
+ CDORevisionDelta delta = viewInvalidationEvent.getRevisionDeltas().get(resource);
+ assertEquals(1, delta.getFeatureDeltas().size());
+
+ CDOListFeatureDelta listDelta = (CDOListFeatureDelta)delta.getFeatureDeltas().get(0);
+ assertEquals(2, listDelta.getListChanges().size());
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void testSyncProgressEvents() throws Exception
+ {
+ InternalSynchronizableRepository clone = getRepository();
+ waitForOnline(clone);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ {
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
+
+ for (int i = 0; i < 100; i++)
+ {
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+ }
+
+ masterTransaction.close();
+ }
+
+ final int[] workPercent = { 0 };
+ TestListener listener = new TestListener()
+ {
+ @Override
+ public void notifyEvent(IEvent event)
+ {
+ super.notifyEvent(event);
+ if (event instanceof ProgressEvent)
+ {
+ ProgressEvent e = (ProgressEvent)event;
+ workPercent[0] = (int)e.getWorkPercent();
+ msg(e.getTask() + ": " + workPercent[0] + " percent");
+ }
+ }
+ };
+
+ clone.getSynchronizer().addListener(listener);
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ assertEquals(100, workPercent[0]);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
index 5e989f20eb..eba5ffeef9 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
@@ -1,571 +1,571 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lob.CDOBlob;
-import org.eclipse.emf.cdo.common.lob.CDOClob;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.server.syncing.OfflineClone;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.bundle.OM;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model3.File;
-import org.eclipse.emf.cdo.tests.model3.Image;
-import org.eclipse.emf.cdo.tests.util.TestListener;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-@CleanRepositoriesBefore
-public class OfflineTest extends AbstractSyncingTest
-{
- public void testMasterCommits_ArrivalInClone() throws Exception
- {
- CDOSession session = openSession("master");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- // 2 * Root resource + folder + resource + company
- int expectedRevisions = 2 + 1 + 1 + 1;
-
- resource.getContents().add(company);
- long timeStamp = transaction.commit().getTimeStamp();
- checkRevisions(getRepository(), timeStamp, expectedRevisions);
-
- for (int i = 0; i < 10; i++)
- {
- company.setName("Test" + i);
- timeStamp = transaction.commit().getTimeStamp();
- expectedRevisions += 1; // Changed company
- checkRevisions(getRepository(), timeStamp, expectedRevisions);
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().add(getModel1Factory().createCategory());
- timeStamp = transaction.commit().getTimeStamp();
- expectedRevisions += 2; // Changed company + new category
- checkRevisions(getRepository(), timeStamp, expectedRevisions);
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().remove(0);
- timeStamp = transaction.commit().getTimeStamp();
- expectedRevisions += 2; // Changed company + detached category
- checkRevisions(getRepository(), timeStamp, expectedRevisions);
- }
-
- session.close();
- }
-
- protected void masterCommits_NotificationsFromClone() throws Exception
- {
- CDOSession masterSession = openSession("master");
- CDOTransaction transaction = masterSession.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- TestListener listener = new TestListener();
- CDOSession cloneSession = openSession();
- cloneSession.addListener(listener);
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- resource.getContents().add(company);
- long timeStamp = transaction.commit().getTimeStamp();
- assertEquals(true, cloneSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
- checkEvent(listener, 1, 3, 1, 0);
-
- for (int i = 0; i < 10; i++)
- {
- company.setName("Test" + i);
- timeStamp = transaction.commit().getTimeStamp();
- assertEquals(true, cloneSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
- checkEvent(listener, 0, 0, 1, 0);
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().add(getModel1Factory().createCategory());
- timeStamp = transaction.commit().getTimeStamp();
- assertEquals(true, cloneSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
- checkEvent(listener, 0, 1, 1, 0);
- }
-
- for (int i = 0; i < 10; i++)
- {
- company.getCategories().remove(0);
- timeStamp = transaction.commit().getTimeStamp();
- assertEquals(true, cloneSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
- checkEvent(listener, 0, 0, 1, 1);
- }
-
- cloneSession.close();
- masterSession.close();
- }
-
- public void testClientCommits() throws Exception
- {
- InternalRepository clone = getRepository();
- InternalRepository master = getRepository("master");
-
- TestListener listener = new TestListener();
- CDOSession masterSession = openSession(master.getName());
- masterSession.addListener(listener);
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- CDOSession cloneSession = openSession();
- waitForOnline(cloneSession.getRepositoryInfo());
-
- CDOTransaction transaction = cloneSession.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(company);
- transaction.commit();
-
- IEvent[] events = listener.getEvents();
- assertEquals(1, events.length);
-
- checkRevision(company, master, "master");
- checkRevision(company, clone, "clone");
- }
-
- public void testDisconnectAndSyncAddition() throws Exception
- {
- TestListener listener = new TestListener();
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- {
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.createResource("/master/resource");
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.commit();
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.commit();
-
- masterTransaction.close();
- masterSession.addListener(listener);
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- }
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(company);
- transaction.commit();
-
- IEvent[] events = listener.getEvents();
- assertEquals(1, events.length);
- }
-
- public void testDisconnectAndSyncChange() throws Exception
- {
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- {
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.createResource("/master/resource");
-
- Company comp = getModel1Factory().createCompany();
- masterResource.getContents().add(comp);
- masterTransaction.commit();
-
- comp.setName("MODIFICATION");
- masterTransaction.commit();
- masterTransaction.close();
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource("/master/resource");
-
- Company company = (Company)resource.getContents().get(0);
- assertEquals("MODIFICATION", company.getName());
- }
-
- public void testDisconnectAndSyncRemoval() throws Exception
- {
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- {
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.createResource("/master/resource");
-
- Company comp = getModel1Factory().createCompany();
- masterResource.getContents().add(comp);
- masterTransaction.commit();
-
- masterResource.getContents().remove(comp);
- masterTransaction.commit();
- masterTransaction.close();
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource("/master/resource");
-
- assertEquals(0, resource.getContents().size());
- }
-
- public void testDisconnectAndCommit() throws Exception
- {
- OfflineClone clone = (OfflineClone)getRepository();
- waitForOnline(clone);
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(company);
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(true, commitInfo.getBranch().isLocal());
- assertEquals(true, transaction.getBranch().isLocal());
- }
-
- public void testDisconnectAndCommitAndMerge() throws Exception
- {
- OfflineClone clone = (OfflineClone)getRepository();
- waitForOnline(clone);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.commit();
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- resource.getContents().add(getModel1Factory().createCompany());
- CDOCommitInfo commitInfo = transaction.commit();
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
-
- DefaultCDOMerger.PerFeature.ManyValued merger = new DefaultCDOMerger.PerFeature.ManyValued();
-
- transaction.setBranch(session.getBranchManager().getMainBranch());
- transaction.merge(commitInfo, merger);
-
- assertEquals(1, transaction.getNewObjects().size());
- CDOObject offlineCompany = transaction.getNewObjects().values().iterator().next();
- if (getRepositoryConfig().getIDGenerationLocation() != IDGenerationLocation.CLIENT)
- {
- assertEquals(CDOID.Type.TEMP_OBJECT, offlineCompany.cdoID().getType());
- }
-
- commitInfo = transaction.commit();
- assertEquals(CDOID.Type.OBJECT, offlineCompany.cdoID().getType());
- }
-
- /**
- * @since 4.0
- */
- public void _testDisconnectAndCommitAndMergeWithNewPackages() throws Exception
- {
- OfflineClone clone = (OfflineClone)getRepository();
- waitForOnline(clone);
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(company);
- CDOCommitInfo commitInfo = transaction.commit();
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
-
- transaction.setBranch(session.getBranchManager().getMainBranch());
- transaction.merge(commitInfo, new DefaultCDOMerger.PerFeature.ManyValued());
-
- transaction.commit();
- }
-
- public void testManyCommitInfos_Initial() throws Exception
- {
- OfflineClone clone = (OfflineClone)getRepository();
- waitForOnline(clone);
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction transaction = masterSession.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- for (int i = 0; i < 10; i++)
- {
- Company company = getModel1Factory().createCompany();
- company.setName("Company" + i);
- resource.getContents().add(company);
- }
-
- transaction.setCommitComment("Creation");
- long timeStamp = transaction.commit().getTimeStamp();
- msg(timeStamp);
-
- for (int k = 0; k < 10; k++)
- {
- sleep(SLEEP_MILLIS);
- for (int i = 0; i < 10; i++)
- {
- Company company = (Company)resource.getContents().get(i);
- company.setName("Company" + i + "_" + transaction.getBranch().getID() + "_" + k);
- }
-
- transaction.setCommitComment("Modification");
- timeStamp = transaction.commit().getTimeStamp();
- msg(timeStamp);
- }
-
- masterSession.close();
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
-
- final List<CDOCommitInfo> result = new ArrayList<CDOCommitInfo>();
- CDOSession session = openSession();
- session.getCommitInfoManager().getCommitInfos(null, 0L, 0L, new CDOCommitInfoHandler()
- {
- public void handleCommitInfo(CDOCommitInfo commitInfo)
- {
- result.add(commitInfo);
- commitInfo.getNewPackageUnits();
- }
- });
-
- for (CDOCommitInfo commitInfo : result)
- {
- System.out.println("-----> " + commitInfo);
- }
-
- assertEquals(12, result.size());
- }
-
- /**
- * See bug 364548.
- */
- public void testEmptyCommit() throws Exception
- {
- InternalRepository master = getRepository("master");
-
- TestListener listener = new TestListener();
- CDOSession masterSession = openSession(master.getName());
- masterSession.addListener(listener);
-
- CDOSession cloneSession = openSession();
- waitForOnline(cloneSession.getRepositoryInfo());
-
- CDOTransaction transaction = cloneSession.openTransaction();
- transaction.commit();
- }
-
- public void _testDisconnectAndSyncBLOB() throws Exception
- {
- TestListener listener = new TestListener();
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- {
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.createResource("/master/resource");
-
- InputStream inputStream = null;
-
- try
- {
- inputStream = OM.BUNDLE.getInputStream("copyright.txt");
- CDOBlob blob = new CDOBlob(inputStream);
-
- Image image = getModel3Factory().createImage();
- image.setWidth(320);
- image.setHeight(200);
- image.setData(blob);
-
- masterResource.getContents().add(image);
- }
- finally
- {
- IOUtil.close(inputStream);
- }
-
- masterTransaction.commit();
- masterTransaction.close();
- masterSession.addListener(listener);
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource("/master/resource");
-
- Image image = (Image)resource.getContents().get(0);
-
- InputStream fromDisk = null;
-
- try
- {
- fromDisk = OM.BUNDLE.getInputStream("copyright.txt");
- IOUtil.equals(fromDisk, image.getData().getContents());
- }
- finally
- {
- IOUtil.close(fromDisk);
- }
- }
-
- public void _testDisconnectAndSyncCLOB() throws Exception
- {
- TestListener listener = new TestListener();
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- {
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.createResource("/master/resource");
-
- InputStream inputStream = null;
-
- try
- {
- inputStream = OM.BUNDLE.getInputStream("copyright.txt");
- CDOClob clob = new CDOClob(new InputStreamReader(inputStream));
-
- File file = getModel3Factory().createFile();
- file.setName("copyright.txt");
- file.setData(clob);
-
- masterResource.getContents().add(file);
- }
- finally
- {
- IOUtil.close(inputStream);
- }
-
- try
- {
- inputStream = OM.BUNDLE.getInputStream("copyright.txt");
- CDOClob clob = new CDOClob(new InputStreamReader(inputStream));
-
- File file = getModel3Factory().createFile();
- file.setName("plugin.properties");
- file.setData(clob);
-
- masterResource.getContents().add(file);
- }
- finally
- {
- IOUtil.close(inputStream);
- }
-
- masterTransaction.commit();
- masterTransaction.close();
- masterSession.addListener(listener);
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource("/master/resource");
-
- File file = (File)resource.getContents().get(0);
-
- InputStream fromDisk = null;
-
- try
- {
- fromDisk = OM.BUNDLE.getInputStream("copyright.txt");
- IOUtil.equals(new InputStreamReader(fromDisk), file.getData().getContents());
- }
- finally
- {
- IOUtil.close(fromDisk);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lob.CDOBlob;
+import org.eclipse.emf.cdo.common.lob.CDOClob;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.server.syncing.OfflineClone;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.bundle.OM;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model3.File;
+import org.eclipse.emf.cdo.tests.model3.Image;
+import org.eclipse.emf.cdo.tests.util.TestListener;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+@CleanRepositoriesBefore
+public class OfflineTest extends AbstractSyncingTest
+{
+ public void testMasterCommits_ArrivalInClone() throws Exception
+ {
+ CDOSession session = openSession("master");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ // 2 * Root resource + folder + resource + company
+ int expectedRevisions = 2 + 1 + 1 + 1;
+
+ resource.getContents().add(company);
+ long timeStamp = transaction.commit().getTimeStamp();
+ checkRevisions(getRepository(), timeStamp, expectedRevisions);
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.setName("Test" + i);
+ timeStamp = transaction.commit().getTimeStamp();
+ expectedRevisions += 1; // Changed company
+ checkRevisions(getRepository(), timeStamp, expectedRevisions);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().add(getModel1Factory().createCategory());
+ timeStamp = transaction.commit().getTimeStamp();
+ expectedRevisions += 2; // Changed company + new category
+ checkRevisions(getRepository(), timeStamp, expectedRevisions);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().remove(0);
+ timeStamp = transaction.commit().getTimeStamp();
+ expectedRevisions += 2; // Changed company + detached category
+ checkRevisions(getRepository(), timeStamp, expectedRevisions);
+ }
+
+ session.close();
+ }
+
+ protected void masterCommits_NotificationsFromClone() throws Exception
+ {
+ CDOSession masterSession = openSession("master");
+ CDOTransaction transaction = masterSession.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ TestListener listener = new TestListener();
+ CDOSession cloneSession = openSession();
+ cloneSession.addListener(listener);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ resource.getContents().add(company);
+ long timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, cloneSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 1, 3, 1, 0);
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.setName("Test" + i);
+ timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, cloneSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 0, 0, 1, 0);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().add(getModel1Factory().createCategory());
+ timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, cloneSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 0, 1, 1, 0);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().remove(0);
+ timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, cloneSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 0, 0, 1, 1);
+ }
+
+ cloneSession.close();
+ masterSession.close();
+ }
+
+ public void testClientCommits() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ InternalRepository master = getRepository("master");
+
+ TestListener listener = new TestListener();
+ CDOSession masterSession = openSession(master.getName());
+ masterSession.addListener(listener);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ CDOSession cloneSession = openSession();
+ waitForOnline(cloneSession.getRepositoryInfo());
+
+ CDOTransaction transaction = cloneSession.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(company);
+ transaction.commit();
+
+ IEvent[] events = listener.getEvents();
+ assertEquals(1, events.length);
+
+ checkRevision(company, master, "master");
+ checkRevision(company, clone, "clone");
+ }
+
+ public void testDisconnectAndSyncAddition() throws Exception
+ {
+ TestListener listener = new TestListener();
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ {
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.createResource("/master/resource");
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.commit();
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.commit();
+
+ masterTransaction.close();
+ masterSession.addListener(listener);
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ }
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(company);
+ transaction.commit();
+
+ IEvent[] events = listener.getEvents();
+ assertEquals(1, events.length);
+ }
+
+ public void testDisconnectAndSyncChange() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ {
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.createResource("/master/resource");
+
+ Company comp = getModel1Factory().createCompany();
+ masterResource.getContents().add(comp);
+ masterTransaction.commit();
+
+ comp.setName("MODIFICATION");
+ masterTransaction.commit();
+ masterTransaction.close();
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource("/master/resource");
+
+ Company company = (Company)resource.getContents().get(0);
+ assertEquals("MODIFICATION", company.getName());
+ }
+
+ public void testDisconnectAndSyncRemoval() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ {
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.createResource("/master/resource");
+
+ Company comp = getModel1Factory().createCompany();
+ masterResource.getContents().add(comp);
+ masterTransaction.commit();
+
+ masterResource.getContents().remove(comp);
+ masterTransaction.commit();
+ masterTransaction.close();
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource("/master/resource");
+
+ assertEquals(0, resource.getContents().size());
+ }
+
+ public void testDisconnectAndCommit() throws Exception
+ {
+ OfflineClone clone = (OfflineClone)getRepository();
+ waitForOnline(clone);
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(company);
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(true, commitInfo.getBranch().isLocal());
+ assertEquals(true, transaction.getBranch().isLocal());
+ }
+
+ public void testDisconnectAndCommitAndMerge() throws Exception
+ {
+ OfflineClone clone = (OfflineClone)getRepository();
+ waitForOnline(clone);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.commit();
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+
+ DefaultCDOMerger.PerFeature.ManyValued merger = new DefaultCDOMerger.PerFeature.ManyValued();
+
+ transaction.setBranch(session.getBranchManager().getMainBranch());
+ transaction.merge(commitInfo, merger);
+
+ assertEquals(1, transaction.getNewObjects().size());
+ CDOObject offlineCompany = transaction.getNewObjects().values().iterator().next();
+ if (getRepositoryConfig().getIDGenerationLocation() != IDGenerationLocation.CLIENT)
+ {
+ assertEquals(CDOID.Type.TEMP_OBJECT, offlineCompany.cdoID().getType());
+ }
+
+ commitInfo = transaction.commit();
+ assertEquals(CDOID.Type.OBJECT, offlineCompany.cdoID().getType());
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void _testDisconnectAndCommitAndMergeWithNewPackages() throws Exception
+ {
+ OfflineClone clone = (OfflineClone)getRepository();
+ waitForOnline(clone);
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(company);
+ CDOCommitInfo commitInfo = transaction.commit();
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+
+ transaction.setBranch(session.getBranchManager().getMainBranch());
+ transaction.merge(commitInfo, new DefaultCDOMerger.PerFeature.ManyValued());
+
+ transaction.commit();
+ }
+
+ public void testManyCommitInfos_Initial() throws Exception
+ {
+ OfflineClone clone = (OfflineClone)getRepository();
+ waitForOnline(clone);
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction transaction = masterSession.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ for (int i = 0; i < 10; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company" + i);
+ resource.getContents().add(company);
+ }
+
+ transaction.setCommitComment("Creation");
+ long timeStamp = transaction.commit().getTimeStamp();
+ msg(timeStamp);
+
+ for (int k = 0; k < 10; k++)
+ {
+ sleep(SLEEP_MILLIS);
+ for (int i = 0; i < 10; i++)
+ {
+ Company company = (Company)resource.getContents().get(i);
+ company.setName("Company" + i + "_" + transaction.getBranch().getID() + "_" + k);
+ }
+
+ transaction.setCommitComment("Modification");
+ timeStamp = transaction.commit().getTimeStamp();
+ msg(timeStamp);
+ }
+
+ masterSession.close();
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+
+ final List<CDOCommitInfo> result = new ArrayList<CDOCommitInfo>();
+ CDOSession session = openSession();
+ session.getCommitInfoManager().getCommitInfos(null, 0L, 0L, new CDOCommitInfoHandler()
+ {
+ public void handleCommitInfo(CDOCommitInfo commitInfo)
+ {
+ result.add(commitInfo);
+ commitInfo.getNewPackageUnits();
+ }
+ });
+
+ for (CDOCommitInfo commitInfo : result)
+ {
+ System.out.println("-----> " + commitInfo);
+ }
+
+ assertEquals(12, result.size());
+ }
+
+ /**
+ * See bug 364548.
+ */
+ public void testEmptyCommit() throws Exception
+ {
+ InternalRepository master = getRepository("master");
+
+ TestListener listener = new TestListener();
+ CDOSession masterSession = openSession(master.getName());
+ masterSession.addListener(listener);
+
+ CDOSession cloneSession = openSession();
+ waitForOnline(cloneSession.getRepositoryInfo());
+
+ CDOTransaction transaction = cloneSession.openTransaction();
+ transaction.commit();
+ }
+
+ public void _testDisconnectAndSyncBLOB() throws Exception
+ {
+ TestListener listener = new TestListener();
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ {
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.createResource("/master/resource");
+
+ InputStream inputStream = null;
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOBlob blob = new CDOBlob(inputStream);
+
+ Image image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+ image.setData(blob);
+
+ masterResource.getContents().add(image);
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+
+ masterTransaction.commit();
+ masterTransaction.close();
+ masterSession.addListener(listener);
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource("/master/resource");
+
+ Image image = (Image)resource.getContents().get(0);
+
+ InputStream fromDisk = null;
+
+ try
+ {
+ fromDisk = OM.BUNDLE.getInputStream("copyright.txt");
+ IOUtil.equals(fromDisk, image.getData().getContents());
+ }
+ finally
+ {
+ IOUtil.close(fromDisk);
+ }
+ }
+
+ public void _testDisconnectAndSyncCLOB() throws Exception
+ {
+ TestListener listener = new TestListener();
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ {
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.createResource("/master/resource");
+
+ InputStream inputStream = null;
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOClob clob = new CDOClob(new InputStreamReader(inputStream));
+
+ File file = getModel3Factory().createFile();
+ file.setName("copyright.txt");
+ file.setData(clob);
+
+ masterResource.getContents().add(file);
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOClob clob = new CDOClob(new InputStreamReader(inputStream));
+
+ File file = getModel3Factory().createFile();
+ file.setName("plugin.properties");
+ file.setData(clob);
+
+ masterResource.getContents().add(file);
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+
+ masterTransaction.commit();
+ masterTransaction.close();
+ masterSession.addListener(listener);
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource("/master/resource");
+
+ File file = (File)resource.getContents().get(0);
+
+ InputStream fromDisk = null;
+
+ try
+ {
+ fromDisk = OM.BUNDLE.getInputStream("copyright.txt");
+ IOUtil.equals(new InputStreamReader(fromDisk), file.getData().getContents());
+ }
+ finally
+ {
+ IOUtil.close(fromDisk);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java
index dcf8b81d4b..78864b04f3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java
@@ -1,39 +1,39 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance;
-
-import org.eclipse.emf.cdo.tests.bundle.OM;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-import org.eclipse.emf.cdo.tests.performance.framework.PerformanceTestSuite;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public abstract class AllPerformanceTests extends PerformanceTestSuite
-{
- public AllPerformanceTests()
- {
- }
-
- public AllPerformanceTests(int runsPerTestCase)
- {
- super(runsPerTestCase);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- testClasses.addAll(getTestClasses(OM.BUNDLE, "org.eclipse.emf.cdo.tests.performance"));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance;
+
+import org.eclipse.emf.cdo.tests.bundle.OM;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+import org.eclipse.emf.cdo.tests.performance.framework.PerformanceTestSuite;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AllPerformanceTests extends PerformanceTestSuite
+{
+ public AllPerformanceTests()
+ {
+ }
+
+ public AllPerformanceTests(int runsPerTestCase)
+ {
+ super(runsPerTestCase);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.addAll(getTestClasses(OM.BUNDLE, "org.eclipse.emf.cdo.tests.performance"));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTestsMemStore.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTestsMemStore.java
index feded15c70..c51b8fb50e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTestsMemStore.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTestsMemStore.java
@@ -1,52 +1,52 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance;
-
-import org.eclipse.emf.cdo.tests.bundle.OM;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllPerformanceTestsMemStore extends AllPerformanceTests
-{
- public static Test suite()
- {
- return new AllPerformanceTestsMemStore().getTestSuite(AllPerformanceTestsMemStore.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MEM, JVM, NATIVE);
- addScenario(parent, COMBINED, MEM_AUDITS, JVM, NATIVE);
- addScenario(parent, COMBINED, MEM_BRANCHES, JVM, NATIVE);
- addScenario(parent, COMBINED, MEM_BRANCHES_UUIDS, JVM, NATIVE);
-
- addScenario(parent, COMBINED, MEM, JVM, LEGACY);
- addScenario(parent, COMBINED, MEM_AUDITS, JVM, LEGACY);
- addScenario(parent, COMBINED, MEM_BRANCHES, JVM, LEGACY);
-
- addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- testClasses.addAll(getTestClasses(OM.BUNDLE, "org.eclipse.emf.cdo.tests.performance"));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance;
+
+import org.eclipse.emf.cdo.tests.bundle.OM;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllPerformanceTestsMemStore extends AllPerformanceTests
+{
+ public static Test suite()
+ {
+ return new AllPerformanceTestsMemStore().getTestSuite(AllPerformanceTestsMemStore.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM, JVM, NATIVE);
+ addScenario(parent, COMBINED, MEM_AUDITS, JVM, NATIVE);
+ addScenario(parent, COMBINED, MEM_BRANCHES, JVM, NATIVE);
+ addScenario(parent, COMBINED, MEM_BRANCHES_UUIDS, JVM, NATIVE);
+
+ addScenario(parent, COMBINED, MEM, JVM, LEGACY);
+ addScenario(parent, COMBINED, MEM_AUDITS, JVM, LEGACY);
+ addScenario(parent, COMBINED, MEM_BRANCHES, JVM, LEGACY);
+
+ addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.addAll(getTestClasses(OM.BUNDLE, "org.eclipse.emf.cdo.tests.performance"));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeletePerformanceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeletePerformanceTest.java
index c591291773..f0be4eb72b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeletePerformanceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeletePerformanceTest.java
@@ -1,117 +1,117 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.performance.framework.PerformanceTest;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import java.util.Random;
-
-/**
- * @author Stefan Winkler
- */
-public class DeletePerformanceTest extends PerformanceTest
-{
- private static final int AMOUNT_ELEMENTS = 10000;
-
- private Random random = new Random();
-
- private Company initModel() throws CommitException
- {
- msg("Initializing model ...");
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("res"));
-
- Company company = getModel1Factory().createCompany();
-
- for (int i = 0; i < AMOUNT_ELEMENTS; i++)
- {
- Category cat = getModel1Factory().createCategory();
- cat.setName(Integer.toString(i));
- company.getCategories().add(cat);
- }
-
- resource.getContents().add(company);
- msg("Committing model ...");
- transaction.commit();
- msg("Done.");
-
- return company;
- }
-
- @CleanRepositoriesBefore
- public void _testDeleteRandom() throws Exception
- {
- Company company = initModel();
- CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView();
-
- msg("Starting to remove elements ...");
-
- for (int i = 0; i < AMOUNT_ELEMENTS / 4; i++)
- {
- int currentSize = AMOUNT_ELEMENTS - i;
- int indexToRemove = random.nextInt(currentSize - 1);
-
- company.getCategories().remove(indexToRemove);
-
- startProbing();
- transaction.commit();
- stopProbing();
- }
- }
-
- @CleanRepositoriesBefore
- public void testDeleteEveryOther() throws Exception
- {
- Company company = initModel();
- CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView();
-
- msg("Starting to remove elements ...");
-
- for (int i = 0; i < AMOUNT_ELEMENTS / 4; i++)
- {
- int indexToRemove = AMOUNT_ELEMENTS / 2 - i;
-
- company.getCategories().remove(indexToRemove);
-
- startProbing();
- transaction.commit();
- stopProbing();
- }
- }
-
- @CleanRepositoriesBefore
- public void _testDeleteAtBeginning() throws Exception
- {
- Company company = initModel();
- CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView();
-
- msg("Starting to remove elements ...");
-
- for (int i = 0; i < AMOUNT_ELEMENTS / 4; i++)
- {
- int indexToRemove = 0;
-
- company.getCategories().remove(indexToRemove);
-
- startProbing();
- transaction.commit();
- stopProbing();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.performance.framework.PerformanceTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import java.util.Random;
+
+/**
+ * @author Stefan Winkler
+ */
+public class DeletePerformanceTest extends PerformanceTest
+{
+ private static final int AMOUNT_ELEMENTS = 10000;
+
+ private Random random = new Random();
+
+ private Company initModel() throws CommitException
+ {
+ msg("Initializing model ...");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+
+ Company company = getModel1Factory().createCompany();
+
+ for (int i = 0; i < AMOUNT_ELEMENTS; i++)
+ {
+ Category cat = getModel1Factory().createCategory();
+ cat.setName(Integer.toString(i));
+ company.getCategories().add(cat);
+ }
+
+ resource.getContents().add(company);
+ msg("Committing model ...");
+ transaction.commit();
+ msg("Done.");
+
+ return company;
+ }
+
+ @CleanRepositoriesBefore
+ public void _testDeleteRandom() throws Exception
+ {
+ Company company = initModel();
+ CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView();
+
+ msg("Starting to remove elements ...");
+
+ for (int i = 0; i < AMOUNT_ELEMENTS / 4; i++)
+ {
+ int currentSize = AMOUNT_ELEMENTS - i;
+ int indexToRemove = random.nextInt(currentSize - 1);
+
+ company.getCategories().remove(indexToRemove);
+
+ startProbing();
+ transaction.commit();
+ stopProbing();
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testDeleteEveryOther() throws Exception
+ {
+ Company company = initModel();
+ CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView();
+
+ msg("Starting to remove elements ...");
+
+ for (int i = 0; i < AMOUNT_ELEMENTS / 4; i++)
+ {
+ int indexToRemove = AMOUNT_ELEMENTS / 2 - i;
+
+ company.getCategories().remove(indexToRemove);
+
+ startProbing();
+ transaction.commit();
+ stopProbing();
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void _testDeleteAtBeginning() throws Exception
+ {
+ Company company = initModel();
+ CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView();
+
+ msg("Starting to remove elements ...");
+
+ for (int i = 0; i < AMOUNT_ELEMENTS / 4; i++)
+ {
+ int indexToRemove = 0;
+
+ company.getCategories().remove(indexToRemove);
+
+ startProbing();
+ transaction.commit();
+ stopProbing();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java
index 452320129c..7b57e2362a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java
@@ -1,382 +1,382 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-
-import org.junit.AfterClass;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Martin Fluegge
- */
-@Requires("excluded")
-public class MartinsPerformanceTest extends AbstractCDOTest
-{
- protected static EClass mapContainerEClass;
-
- private static Map<String, TimeTaker> results = new HashMap<String, TimeTaker>();
-
- public void testSimpleTestNoCommit() throws Exception
- {
- TimeTaker t = start("testSimpleTestNoCommit");
-
- getModel1Factory().createCustomer();
- for (int i = 0; i < 50000; i++)
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setCity("Barovia");
- customer.setName("Strahd von Zarovich");
- customer.setStreet("Necromancer Road 5");
-
- for (int c = 0; c < 50; c++)
- {
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setCustomer(customer);
- salesOrder.setId(c);
- }
- }
-
- finish(t);
- msg(t.getTiming());
- }
-
- public void testSimpleTestWithCommit() throws Exception
- {
- TimeTaker t = start("testBasicCommitPerformance");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- getModel1Factory().createCustomer();
- for (int i = 0; i < 500; i++)
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setCity("Barovia");
- customer.setName("Strahd von Zarovich");
- customer.setStreet("Necromancer Road 5");
-
- for (int c = 0; c < 5; c++)
- {
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setCustomer(customer);
- salesOrder.setId(c);
- resource.getContents().add(salesOrder);
- }
-
- resource.getContents().add(customer);
- }
-
- transaction.commit();
-
- finish(t);
- msg(t.getTiming());
- }
-
- // public void testDynamicPerformance() throws Exception
- // {
- //
- // TimeTaker t = start("testDynamicPerformance");
- // CDOSession session = openSession();
- // CDOTransaction transaction = session.openTransaction();
- // EPackage dynamicMapEPackge = createPackage();
- // EFactory dynamicMapEFactoryInstance = dynamicMapEPackge.getEFactoryInstance();
- //
- // CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- // for (int i = 0; i < 5000; i++)
- // {
- //
- // EObject mapContainer = dynamicMapEFactoryInstance
- // .create((EClass)dynamicMapEPackge.getEClassifier("MapContainer"));
- //
- // resource.getContents().add(mapContainer);
- //
- // }
- // transaction.commit();
- //
- // finish(t);
- // }
-
- public void testLoadAnStoreDataPerformance() throws Exception
- {
- TimeTaker t = start("testLoadAnStoreDataPerformance");
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- getModel1Factory().createCustomer();
- for (int i = 0; i < 500; i++)
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setCity("Barovia");
- customer.setName("Strahd von Zarovich");
- customer.setStreet("Necromancer Road 5");
-
- for (int c = 0; c < 5; c++)
- {
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setCustomer(customer);
- salesOrder.setId(c);
- resource.getContents().add(salesOrder);
- }
-
- resource.getContents().add(customer);
- }
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- int i = 0;
- for (EObject o : resource.getContents())
- {
- if (o instanceof Customer)
- {
- Customer customer = (Customer)o;
- customer.setCity("Dargaard");
- customer.setName("Lord Soth");
- customer.setStreet("Death Knight Alley 7");
-
- for (SalesOrder salesOrder : customer.getSalesOrders())
- {
- salesOrder.setId(salesOrder.getId() + 1);
- }
-
- i++;
- }
- }
-
- assertEquals(500, i);
-
- transaction.commit();
- session.close();
- }
-
- finish(t);
- msg(t.getTiming());
- }
-
- public void testLoadAnStoreDataPreAddPerformance() throws Exception
- {
- TimeTaker t = start("testLoadAnStoreDataPreAddPerformance");
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- getModel1Factory().createCustomer();
- for (int i = 0; i < 500; i++)
- {
- Customer customer = getModel1Factory().createCustomer();
- resource.getContents().add(customer);
- customer.setCity("Barovia");
- customer.setName("Strahd von Zarovich");
- customer.setStreet("Necromancer Road 5");
-
- for (int c = 0; c < 5; c++)
- {
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- resource.getContents().add(salesOrder);
- salesOrder.setCustomer(customer);
- salesOrder.setId(c);
- }
- }
-
- transaction.commit();
- session.close();
- }
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/test1"));
-
- int i = 0;
- for (EObject o : resource.getContents())
- {
- if (o instanceof Customer)
- {
- Customer customer = (Customer)o;
- customer.setCity("Dargaard");
- customer.setName("Lord Soth");
- customer.setStreet("Death Knight Alley 7");
-
- for (SalesOrder salesOrder : customer.getSalesOrders())
- {
- salesOrder.setId(salesOrder.getId() + 1);
- }
-
- i++;
- }
- }
-
- assertEquals(500, i);
-
- transaction.commit();
- session.close();
- }
-
- finish(t);
- msg(t.getTiming());
- }
-
- public void testAddRemove() throws Exception
- {
- TimeTaker t = start("testAddRemove");
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- for (int i = 0; i < 100; i++)
- {
- Customer customer = getModel1Factory().createCustomer();
- customer.setName("Azalin Rex");
- customer.setCity("Darkon");
-
- resource.getContents().add(customer);
- transaction.commit();
-
- resource.getContents().remove(resource.getContents().size() - 1);
- transaction.commit();
-
- resource.getContents().add(customer);
- transaction.commit();
- }
-
- finish(t);
- msg(t.getTiming());
- }
-
- public EPackage createPackage()
- {
- EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
- EcorePackage theCorePackage = EcorePackage.eINSTANCE;
-
- mapContainerEClass = theCoreFactory.createEClass();
- mapContainerEClass.setName("MapContainer");
-
- EPackage dynamicMapEPackage = theCoreFactory.createEPackage();
- dynamicMapEPackage.setName("DynamicMapPackage");
- dynamicMapEPackage.setNsPrefix("dynamicmap");
- dynamicMapEPackage.setNsURI("http:///org.mftech.examples.emf.dynamic.map");
- dynamicMapEPackage.getEClassifiers().add(mapContainerEClass);
-
- EStructuralFeature name = theCoreFactory.createEAttribute();
- name.setName("name");
- name.setEType(theCorePackage.getEString());
-
- mapContainerEClass.getEStructuralFeatures().add(name);
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(dynamicMapEPackage);
- }
-
- return dynamicMapEPackage;
- }
-
- private TimeTaker start(String testName)
- {
- TimeTaker t = new TimeTaker();
- results.put(testName, t);
- t.setStart(System.currentTimeMillis());
- return t;
- }
-
- private void finish(TimeTaker t)
- {
- t.setEnd(System.currentTimeMillis());
- }
-
- /**
- * @author Martin Fluegge
- */
- private static class TimeTaker
- {
- private long start;
-
- private long end;
-
- public void setStart(long start)
- {
- this.start = start;
- }
-
- public void setEnd(long end)
- {
- this.end = end;
- }
-
- public long getTiming()
- {
- return end - start;
- }
- }
-
- // A fake because afterClass does not seem to work :(
- @AfterClass
- public void testTearDown() throws IOException
- {
- String ext = "NATIVE";
- if (isConfig(LEGACY))
- {
- ext = "LEGACY";
- }
-
- String location = System.getProperty("user.home") + "/cdo_Performance_" + ext + "_" + new Date().getTime() + ".csv";
- System.out.println("Writing performance results to: " + location);
- File file = new File(location);
- FileWriter fileWriter = new FileWriter(file);
-
- try
- {
- StringBuffer stringBuffer = new StringBuffer();
- for (String key : results.keySet())
- {
- stringBuffer.append(key + ";" + results.get(key).getTiming() + "\n");
- }
-
- fileWriter.write(stringBuffer.toString());
- }
- finally
- {
- IOUtil.close(fileWriter);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+
+import org.junit.AfterClass;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Martin Fluegge
+ */
+@Requires("excluded")
+public class MartinsPerformanceTest extends AbstractCDOTest
+{
+ protected static EClass mapContainerEClass;
+
+ private static Map<String, TimeTaker> results = new HashMap<String, TimeTaker>();
+
+ public void testSimpleTestNoCommit() throws Exception
+ {
+ TimeTaker t = start("testSimpleTestNoCommit");
+
+ getModel1Factory().createCustomer();
+ for (int i = 0; i < 50000; i++)
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setCity("Barovia");
+ customer.setName("Strahd von Zarovich");
+ customer.setStreet("Necromancer Road 5");
+
+ for (int c = 0; c < 50; c++)
+ {
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setCustomer(customer);
+ salesOrder.setId(c);
+ }
+ }
+
+ finish(t);
+ msg(t.getTiming());
+ }
+
+ public void testSimpleTestWithCommit() throws Exception
+ {
+ TimeTaker t = start("testBasicCommitPerformance");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ getModel1Factory().createCustomer();
+ for (int i = 0; i < 500; i++)
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setCity("Barovia");
+ customer.setName("Strahd von Zarovich");
+ customer.setStreet("Necromancer Road 5");
+
+ for (int c = 0; c < 5; c++)
+ {
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setCustomer(customer);
+ salesOrder.setId(c);
+ resource.getContents().add(salesOrder);
+ }
+
+ resource.getContents().add(customer);
+ }
+
+ transaction.commit();
+
+ finish(t);
+ msg(t.getTiming());
+ }
+
+ // public void testDynamicPerformance() throws Exception
+ // {
+ //
+ // TimeTaker t = start("testDynamicPerformance");
+ // CDOSession session = openSession();
+ // CDOTransaction transaction = session.openTransaction();
+ // EPackage dynamicMapEPackge = createPackage();
+ // EFactory dynamicMapEFactoryInstance = dynamicMapEPackge.getEFactoryInstance();
+ //
+ // CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ // for (int i = 0; i < 5000; i++)
+ // {
+ //
+ // EObject mapContainer = dynamicMapEFactoryInstance
+ // .create((EClass)dynamicMapEPackge.getEClassifier("MapContainer"));
+ //
+ // resource.getContents().add(mapContainer);
+ //
+ // }
+ // transaction.commit();
+ //
+ // finish(t);
+ // }
+
+ public void testLoadAnStoreDataPerformance() throws Exception
+ {
+ TimeTaker t = start("testLoadAnStoreDataPerformance");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ getModel1Factory().createCustomer();
+ for (int i = 0; i < 500; i++)
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setCity("Barovia");
+ customer.setName("Strahd von Zarovich");
+ customer.setStreet("Necromancer Road 5");
+
+ for (int c = 0; c < 5; c++)
+ {
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setCustomer(customer);
+ salesOrder.setId(c);
+ resource.getContents().add(salesOrder);
+ }
+
+ resource.getContents().add(customer);
+ }
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ int i = 0;
+ for (EObject o : resource.getContents())
+ {
+ if (o instanceof Customer)
+ {
+ Customer customer = (Customer)o;
+ customer.setCity("Dargaard");
+ customer.setName("Lord Soth");
+ customer.setStreet("Death Knight Alley 7");
+
+ for (SalesOrder salesOrder : customer.getSalesOrders())
+ {
+ salesOrder.setId(salesOrder.getId() + 1);
+ }
+
+ i++;
+ }
+ }
+
+ assertEquals(500, i);
+
+ transaction.commit();
+ session.close();
+ }
+
+ finish(t);
+ msg(t.getTiming());
+ }
+
+ public void testLoadAnStoreDataPreAddPerformance() throws Exception
+ {
+ TimeTaker t = start("testLoadAnStoreDataPreAddPerformance");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ getModel1Factory().createCustomer();
+ for (int i = 0; i < 500; i++)
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ resource.getContents().add(customer);
+ customer.setCity("Barovia");
+ customer.setName("Strahd von Zarovich");
+ customer.setStreet("Necromancer Road 5");
+
+ for (int c = 0; c < 5; c++)
+ {
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ resource.getContents().add(salesOrder);
+ salesOrder.setCustomer(customer);
+ salesOrder.setId(c);
+ }
+ }
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("/test1"));
+
+ int i = 0;
+ for (EObject o : resource.getContents())
+ {
+ if (o instanceof Customer)
+ {
+ Customer customer = (Customer)o;
+ customer.setCity("Dargaard");
+ customer.setName("Lord Soth");
+ customer.setStreet("Death Knight Alley 7");
+
+ for (SalesOrder salesOrder : customer.getSalesOrders())
+ {
+ salesOrder.setId(salesOrder.getId() + 1);
+ }
+
+ i++;
+ }
+ }
+
+ assertEquals(500, i);
+
+ transaction.commit();
+ session.close();
+ }
+
+ finish(t);
+ msg(t.getTiming());
+ }
+
+ public void testAddRemove() throws Exception
+ {
+ TimeTaker t = start("testAddRemove");
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+ for (int i = 0; i < 100; i++)
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("Azalin Rex");
+ customer.setCity("Darkon");
+
+ resource.getContents().add(customer);
+ transaction.commit();
+
+ resource.getContents().remove(resource.getContents().size() - 1);
+ transaction.commit();
+
+ resource.getContents().add(customer);
+ transaction.commit();
+ }
+
+ finish(t);
+ msg(t.getTiming());
+ }
+
+ public EPackage createPackage()
+ {
+ EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
+ EcorePackage theCorePackage = EcorePackage.eINSTANCE;
+
+ mapContainerEClass = theCoreFactory.createEClass();
+ mapContainerEClass.setName("MapContainer");
+
+ EPackage dynamicMapEPackage = theCoreFactory.createEPackage();
+ dynamicMapEPackage.setName("DynamicMapPackage");
+ dynamicMapEPackage.setNsPrefix("dynamicmap");
+ dynamicMapEPackage.setNsURI("http:///org.mftech.examples.emf.dynamic.map");
+ dynamicMapEPackage.getEClassifiers().add(mapContainerEClass);
+
+ EStructuralFeature name = theCoreFactory.createEAttribute();
+ name.setName("name");
+ name.setEType(theCorePackage.getEString());
+
+ mapContainerEClass.getEStructuralFeatures().add(name);
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(dynamicMapEPackage);
+ }
+
+ return dynamicMapEPackage;
+ }
+
+ private TimeTaker start(String testName)
+ {
+ TimeTaker t = new TimeTaker();
+ results.put(testName, t);
+ t.setStart(System.currentTimeMillis());
+ return t;
+ }
+
+ private void finish(TimeTaker t)
+ {
+ t.setEnd(System.currentTimeMillis());
+ }
+
+ /**
+ * @author Martin Fluegge
+ */
+ private static class TimeTaker
+ {
+ private long start;
+
+ private long end;
+
+ public void setStart(long start)
+ {
+ this.start = start;
+ }
+
+ public void setEnd(long end)
+ {
+ this.end = end;
+ }
+
+ public long getTiming()
+ {
+ return end - start;
+ }
+ }
+
+ // A fake because afterClass does not seem to work :(
+ @AfterClass
+ public void testTearDown() throws IOException
+ {
+ String ext = "NATIVE";
+ if (isConfig(LEGACY))
+ {
+ ext = "LEGACY";
+ }
+
+ String location = System.getProperty("user.home") + "/cdo_Performance_" + ext + "_" + new Date().getTime() + ".csv";
+ System.out.println("Writing performance results to: " + location);
+ File file = new File(location);
+ FileWriter fileWriter = new FileWriter(file);
+
+ try
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+ for (String key : results.keySet())
+ {
+ stringBuffer.append(key + ";" + results.get(key).getTiming() + "\n");
+ }
+
+ fileWriter.write(stringBuffer.toString());
+ }
+ finally
+ {
+ IOUtil.close(fileWriter);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceRecordAnalyzer.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceRecordAnalyzer.java
index 74f756b3c4..c33d2b1708 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceRecordAnalyzer.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceRecordAnalyzer.java
@@ -1,21 +1,21 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance.framework;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public interface IPerformanceRecordAnalyzer
-{
- public void analyze(List<PerformanceRecord> performanceRecords);
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance.framework;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IPerformanceRecordAnalyzer
+{
+ public void analyze(List<PerformanceRecord> performanceRecords);
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceRecord.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceRecord.java
index 17b65b6a76..78329a40b1 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceRecord.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceRecord.java
@@ -1,91 +1,91 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance.framework;
-
-import org.eclipse.emf.cdo.tests.config.IScenario;
-
-/**
- * @author Eike Stepper
- */
-public class PerformanceRecord
-{
- private final IScenario scenario;
-
- private final String testName;
-
- private final String testCaseName;
-
- private final long[] probes;
-
- public PerformanceRecord(IScenario scenario, String testName, String testCaseName, int runs)
- {
- this.scenario = scenario;
- this.testName = testName;
- this.testCaseName = testCaseName;
- probes = new long[runs];
- }
-
- public IScenario getScenario()
- {
- return scenario;
- }
-
- public String getTestName()
- {
- return testName;
- }
-
- public String getTestCaseName()
- {
- return testCaseName;
- }
-
- public long[] getProbes()
- {
- return probes;
- }
-
- public long getDurationSum()
- {
- long durationSum = 0L;
- for (long probe : probes)
- {
- durationSum += probe;
- }
-
- return durationSum;
- }
-
- public long getDurationAvg()
- {
- return getDurationSum() / probes.length;
- }
-
- public long getDurationMin()
- {
- long durationMin = Long.MAX_VALUE;
- for (long probe : probes)
- {
- durationMin = Math.min(durationMin, probe);
- }
- return durationMin;
- }
-
- public long getDurationMax()
- {
- long durationMax = Long.MIN_VALUE;
- for (long probe : probes)
- {
- durationMax = Math.max(durationMax, probe);
- }
- return durationMax;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance.framework;
+
+import org.eclipse.emf.cdo.tests.config.IScenario;
+
+/**
+ * @author Eike Stepper
+ */
+public class PerformanceRecord
+{
+ private final IScenario scenario;
+
+ private final String testName;
+
+ private final String testCaseName;
+
+ private final long[] probes;
+
+ public PerformanceRecord(IScenario scenario, String testName, String testCaseName, int runs)
+ {
+ this.scenario = scenario;
+ this.testName = testName;
+ this.testCaseName = testCaseName;
+ probes = new long[runs];
+ }
+
+ public IScenario getScenario()
+ {
+ return scenario;
+ }
+
+ public String getTestName()
+ {
+ return testName;
+ }
+
+ public String getTestCaseName()
+ {
+ return testCaseName;
+ }
+
+ public long[] getProbes()
+ {
+ return probes;
+ }
+
+ public long getDurationSum()
+ {
+ long durationSum = 0L;
+ for (long probe : probes)
+ {
+ durationSum += probe;
+ }
+
+ return durationSum;
+ }
+
+ public long getDurationAvg()
+ {
+ return getDurationSum() / probes.length;
+ }
+
+ public long getDurationMin()
+ {
+ long durationMin = Long.MAX_VALUE;
+ for (long probe : probes)
+ {
+ durationMin = Math.min(durationMin, probe);
+ }
+ return durationMin;
+ }
+
+ public long getDurationMax()
+ {
+ long durationMax = Long.MIN_VALUE;
+ for (long probe : probes)
+ {
+ durationMax = Math.max(durationMax, probe);
+ }
+ return durationMax;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTest.java
index 34cd1707d3..f0aa3ce749 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTest.java
@@ -1,89 +1,89 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance.framework;
-
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-
-/**
- * @author Stefan Winkler
- */
-public abstract class PerformanceTest extends AbstractCDOTest
-{
- private static final long NOT_PROBING = -1;
-
- private PerformanceTestSuite suite;
-
- private long probe;
-
- private long startTimeMillis;
-
- public PerformanceTest()
- {
- }
-
- void setSuite(PerformanceTestSuite suite)
- {
- this.suite = suite;
- }
-
- protected final void startProbing()
- {
- assertEquals("Already probing", NOT_PROBING, startTimeMillis);
- startTimeMillis = System.currentTimeMillis();
-
- if (probe == NOT_PROBING)
- {
- probe = 0L;
- }
- }
-
- protected final void stopProbing()
- {
- if (startTimeMillis == NOT_PROBING)
- {
- fail("Not probing");
- }
-
- long stopTimeMillis = System.currentTimeMillis();
- probe += stopTimeMillis - startTimeMillis;
-
- startTimeMillis = NOT_PROBING;
- }
-
- @Override
- public void runBare() throws Throwable
- {
- runBareBasic();
-
- int runsPerTestCase = suite.getRunsPerTestCase();
- PerformanceRecord performanceRecord = suite.createPerformanceRecord(getScenario(), getClass().getName(), getName(),
- runsPerTestCase);
-
- for (int i = 0; i < runsPerTestCase; i++)
- {
- runBareBasic();
-
- if (probe == NOT_PROBING)
- {
- fail("No probe");
- }
-
- performanceRecord.getProbes()[i] = probe;
- }
- }
-
- private void runBareBasic() throws Throwable
- {
- probe = NOT_PROBING;
- startTimeMillis = NOT_PROBING;
- super.runBare();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance.framework;
+
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+
+/**
+ * @author Stefan Winkler
+ */
+public abstract class PerformanceTest extends AbstractCDOTest
+{
+ private static final long NOT_PROBING = -1;
+
+ private PerformanceTestSuite suite;
+
+ private long probe;
+
+ private long startTimeMillis;
+
+ public PerformanceTest()
+ {
+ }
+
+ void setSuite(PerformanceTestSuite suite)
+ {
+ this.suite = suite;
+ }
+
+ protected final void startProbing()
+ {
+ assertEquals("Already probing", NOT_PROBING, startTimeMillis);
+ startTimeMillis = System.currentTimeMillis();
+
+ if (probe == NOT_PROBING)
+ {
+ probe = 0L;
+ }
+ }
+
+ protected final void stopProbing()
+ {
+ if (startTimeMillis == NOT_PROBING)
+ {
+ fail("Not probing");
+ }
+
+ long stopTimeMillis = System.currentTimeMillis();
+ probe += stopTimeMillis - startTimeMillis;
+
+ startTimeMillis = NOT_PROBING;
+ }
+
+ @Override
+ public void runBare() throws Throwable
+ {
+ runBareBasic();
+
+ int runsPerTestCase = suite.getRunsPerTestCase();
+ PerformanceRecord performanceRecord = suite.createPerformanceRecord(getScenario(), getClass().getName(), getName(),
+ runsPerTestCase);
+
+ for (int i = 0; i < runsPerTestCase; i++)
+ {
+ runBareBasic();
+
+ if (probe == NOT_PROBING)
+ {
+ fail("No probe");
+ }
+
+ performanceRecord.getProbes()[i] = probe;
+ }
+ }
+
+ private void runBareBasic() throws Throwable
+ {
+ probe = NOT_PROBING;
+ startTimeMillis = NOT_PROBING;
+ super.runBare();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTestSuite.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTestSuite.java
index a73f555ee5..f552cf53b4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTestSuite.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTestSuite.java
@@ -1,77 +1,77 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance.framework;
-
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public abstract class PerformanceTestSuite extends ConfigTestSuite
-{
- public static final int DEFAULT_RUNS_PER_TEST_CASE = 10;
-
- private final List<PerformanceRecord> performanceRecords = new ArrayList<PerformanceRecord>();
-
- private final int runsPerTestCase;
-
- public PerformanceTestSuite(int runsPerTestCase)
- {
- this.runsPerTestCase = runsPerTestCase;
- }
-
- public PerformanceTestSuite()
- {
- this(DEFAULT_RUNS_PER_TEST_CASE);
- }
-
- public int getRunsPerTestCase()
- {
- return runsPerTestCase;
- }
-
- protected PerformanceRecord createPerformanceRecord(IScenario scenario, String testName, String testCaseName, int runs)
- {
- PerformanceRecord performanceRecord = new PerformanceRecord(scenario, testName, testCaseName, runs);
- performanceRecords.add(performanceRecord);
- return performanceRecord;
- }
-
- protected IPerformanceRecordAnalyzer createPerformanceRecordAnalyzer()
- {
- return new PrintStreamPerformanceRecordAnalyzer();
- }
-
- @Override
- protected void prepareTest(ConfigTest configTest)
- {
- super.prepareTest(configTest);
- if (configTest instanceof PerformanceTest)
- {
- PerformanceTest performanceTest = (PerformanceTest)configTest;
- performanceTest.setSuite(this);
- }
- }
-
- @Override
- protected void mainSuiteFinished()
- {
- super.mainSuiteFinished();
-
- IPerformanceRecordAnalyzer performanceRecordAnalyzer = createPerformanceRecordAnalyzer();
- performanceRecordAnalyzer.analyze(performanceRecords);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance.framework;
+
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class PerformanceTestSuite extends ConfigTestSuite
+{
+ public static final int DEFAULT_RUNS_PER_TEST_CASE = 10;
+
+ private final List<PerformanceRecord> performanceRecords = new ArrayList<PerformanceRecord>();
+
+ private final int runsPerTestCase;
+
+ public PerformanceTestSuite(int runsPerTestCase)
+ {
+ this.runsPerTestCase = runsPerTestCase;
+ }
+
+ public PerformanceTestSuite()
+ {
+ this(DEFAULT_RUNS_PER_TEST_CASE);
+ }
+
+ public int getRunsPerTestCase()
+ {
+ return runsPerTestCase;
+ }
+
+ protected PerformanceRecord createPerformanceRecord(IScenario scenario, String testName, String testCaseName, int runs)
+ {
+ PerformanceRecord performanceRecord = new PerformanceRecord(scenario, testName, testCaseName, runs);
+ performanceRecords.add(performanceRecord);
+ return performanceRecord;
+ }
+
+ protected IPerformanceRecordAnalyzer createPerformanceRecordAnalyzer()
+ {
+ return new PrintStreamPerformanceRecordAnalyzer();
+ }
+
+ @Override
+ protected void prepareTest(ConfigTest configTest)
+ {
+ super.prepareTest(configTest);
+ if (configTest instanceof PerformanceTest)
+ {
+ PerformanceTest performanceTest = (PerformanceTest)configTest;
+ performanceTest.setSuite(this);
+ }
+ }
+
+ @Override
+ protected void mainSuiteFinished()
+ {
+ super.mainSuiteFinished();
+
+ IPerformanceRecordAnalyzer performanceRecordAnalyzer = createPerformanceRecordAnalyzer();
+ performanceRecordAnalyzer.analyze(performanceRecords);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamPerformanceRecordAnalyzer.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamPerformanceRecordAnalyzer.java
index f36024a3c8..ae68db11f4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamPerformanceRecordAnalyzer.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamPerformanceRecordAnalyzer.java
@@ -1,77 +1,77 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance.framework;
-
-import org.eclipse.emf.cdo.tests.config.IScenario;
-
-import java.io.PrintStream;
-import java.text.MessageFormat;
-import java.util.List;
-
-/**
- * A performance record analyzer that prints directly to a {@link PrintStream}, such as {@link System#out}.
- *
- * @author Stefan Winkler
- */
-public class PrintStreamPerformanceRecordAnalyzer implements IPerformanceRecordAnalyzer
-{
- private PrintStream out;
-
- public PrintStreamPerformanceRecordAnalyzer(PrintStream out)
- {
- this.out = out;
- }
-
- public PrintStreamPerformanceRecordAnalyzer()
- {
- this(System.out);
- }
-
- public void analyze(List<PerformanceRecord> performanceRecords)
- {
- printHeader();
-
- for (PerformanceRecord performanceRecord : performanceRecords)
- {
- printRecord(performanceRecord);
- }
- }
-
- protected void printHeader()
- {
- String recordString = MessageFormat.format("{0};{1};{2};{3};{4};{5};{6}", //
- "ContainerConfig", //
- "RepositoryConfig", //
- "SessionConfig", //
- "ModelConfig", //
- "Test name", //
- "Test Case Name", //
- "Average Duration");
-
- out.println(recordString);
- }
-
- protected void printRecord(PerformanceRecord performanceRecord)
- {
- IScenario scenario = performanceRecord.getScenario();
-
- String recordString = MessageFormat.format("{0};{1};{2};{3};{4};{5};{6};{7};{8}", //
- scenario.getContainerConfig().getName(), //
- scenario.getRepositoryConfig().getName(), //
- scenario.getSessionConfig().getName(), //
- scenario.getModelConfig().getName(), //
- performanceRecord.getTestName(), //
- performanceRecord.getTestCaseName(), //
- performanceRecord.getDurationAvg(), performanceRecord.getDurationMin(), performanceRecord.getDurationMax());
-
- out.println(recordString);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance.framework;
+
+import org.eclipse.emf.cdo.tests.config.IScenario;
+
+import java.io.PrintStream;
+import java.text.MessageFormat;
+import java.util.List;
+
+/**
+ * A performance record analyzer that prints directly to a {@link PrintStream}, such as {@link System#out}.
+ *
+ * @author Stefan Winkler
+ */
+public class PrintStreamPerformanceRecordAnalyzer implements IPerformanceRecordAnalyzer
+{
+ private PrintStream out;
+
+ public PrintStreamPerformanceRecordAnalyzer(PrintStream out)
+ {
+ this.out = out;
+ }
+
+ public PrintStreamPerformanceRecordAnalyzer()
+ {
+ this(System.out);
+ }
+
+ public void analyze(List<PerformanceRecord> performanceRecords)
+ {
+ printHeader();
+
+ for (PerformanceRecord performanceRecord : performanceRecords)
+ {
+ printRecord(performanceRecord);
+ }
+ }
+
+ protected void printHeader()
+ {
+ String recordString = MessageFormat.format("{0};{1};{2};{3};{4};{5};{6}", //
+ "ContainerConfig", //
+ "RepositoryConfig", //
+ "SessionConfig", //
+ "ModelConfig", //
+ "Test name", //
+ "Test Case Name", //
+ "Average Duration");
+
+ out.println(recordString);
+ }
+
+ protected void printRecord(PerformanceRecord performanceRecord)
+ {
+ IScenario scenario = performanceRecord.getScenario();
+
+ String recordString = MessageFormat.format("{0};{1};{2};{3};{4};{5};{6};{7};{8}", //
+ scenario.getContainerConfig().getName(), //
+ scenario.getRepositoryConfig().getName(), //
+ scenario.getSessionConfig().getName(), //
+ scenario.getModelConfig().getName(), //
+ performanceRecord.getTestName(), //
+ performanceRecord.getTestCaseName(), //
+ performanceRecord.getDurationAvg(), performanceRecord.getDurationMin(), performanceRecord.getDurationMax());
+
+ out.println(recordString);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/ProbeCollector.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/ProbeCollector.java
index 3a5640e665..75d2c1f923 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/ProbeCollector.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/ProbeCollector.java
@@ -1,73 +1,73 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.performance.framework;
-
-import org.eclipse.emf.cdo.tests.config.IScenario;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Stefan Winkler
- */
-public class ProbeCollector
-{
- private final List<PerformanceRecord> performanceRecords = new ArrayList<PerformanceRecord>();
-
- protected PerformanceRecord createPerformanceRecord(IScenario scenario, String testName, String testCaseName, int runs)
- {
- PerformanceRecord performanceRecord = new PerformanceRecord(scenario, testName, testCaseName, runs);
- performanceRecords.add(performanceRecord);
- return performanceRecord;
- }
-
- /**
- * @author Eike Stepper
- */
- public static class PerformanceRecord
- {
- private final IScenario scenario;
-
- private final String testName;
-
- private final String testCaseName;
-
- private final long[] probes;
-
- public PerformanceRecord(IScenario scenario, String testName, String testCaseName, int runs)
- {
- this.scenario = scenario;
- this.testName = testName;
- this.testCaseName = testCaseName;
- probes = new long[runs];
- }
-
- public IScenario getScenario()
- {
- return scenario;
- }
-
- public String getTestName()
- {
- return testName;
- }
-
- public String getTestCaseName()
- {
- return testCaseName;
- }
-
- public long[] getProbes()
- {
- return probes;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.performance.framework;
+
+import org.eclipse.emf.cdo.tests.config.IScenario;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Stefan Winkler
+ */
+public class ProbeCollector
+{
+ private final List<PerformanceRecord> performanceRecords = new ArrayList<PerformanceRecord>();
+
+ protected PerformanceRecord createPerformanceRecord(IScenario scenario, String testName, String testCaseName, int runs)
+ {
+ PerformanceRecord performanceRecord = new PerformanceRecord(scenario, testName, testCaseName, runs);
+ performanceRecords.add(performanceRecord);
+ return performanceRecord;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class PerformanceRecord
+ {
+ private final IScenario scenario;
+
+ private final String testName;
+
+ private final String testCaseName;
+
+ private final long[] probes;
+
+ public PerformanceRecord(IScenario scenario, String testName, String testCaseName, int runs)
+ {
+ this.scenario = scenario;
+ this.testName = testName;
+ this.testCaseName = testCaseName;
+ probes = new long[runs];
+ }
+
+ public IScenario getScenario()
+ {
+ return scenario;
+ }
+
+ public String getTestName()
+ {
+ return testName;
+ }
+
+ public String getTestCaseName()
+ {
+ return testCaseName;
+ }
+
+ public long[] getProbes()
+ {
+ return probes;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java
index 6ccc7d85b9..8a867f1b8d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java
@@ -1,424 +1,424 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.revisioncache;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.internal.db.cache.DBRevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.tests.model1.impl.AddressImpl;
-import org.eclipse.emf.cdo.tests.model1.impl.CompanyImpl;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-import org.eclipse.net4j.util.tests.ConcurrentRunner;
-
-import java.util.List;
-
-/**
- * An abstract superclass that may be subclassed to test behaviour common to all CDORevisionCaches
- *
- * @author Andre Dietisheim
- * @see CDORevisionCache
- * @see DBRevisionCache
- * @see DerbyDBRevisionCacheTest
- * @see H2DBRevisionCacheTest
- * @see DefaultRevisionCacheTest
- */
-public abstract class AbstractCDORevisionCacheTest extends AbstractOMTest
-{
- private static final String RESOURCE_PATH = "/res1";
-
- private static final int MAX_THREADS = 10;
-
- private static final CDOBranch BRANCH = null;
-
- private static final CDOBranchPoint BRANCH_POINT = BRANCH.getHead();
-
- private CDOResource resource;
-
- private InternalCDORevisionCache revisionCache;
-
- private CDOSession session;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
-
- Session sessionHolder = new Session();
- LifecycleUtil.activate(sessionHolder);
- session = sessionHolder.getSession(Model1Package.eINSTANCE);
- resource = createResource();
- revisionCache = createRevisionCache(session);
- LifecycleUtil.activate(revisionCache);
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- LifecycleUtil.deactivate(session);
- LifecycleUtil.deactivate(revisionCache);
- super.doTearDown();
- }
-
- public void testAddedRevisionIsGettable()
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- InternalCDORevision cdoRevision = company.cdoRevision();
- addRevision(cdoRevision);
-
- CDOID id = CDOUtil.getCDOObject(company).cdoID();
- CDORevision fetchedCDORevision = revisionCache.getRevision(id, BRANCH_POINT);
- assertEquals(true, CDOIDUtil.equals(cdoRevision.getID(), fetchedCDORevision.getID()));
- }
-
- private void addRevision(CDORevision revision)
- {
- revisionCache.addRevision(revision);
- }
-
- public void testGetRevisionReturnsLatestVersion() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- InternalCDORevision firstRevision = company.cdoRevision();
- addRevision(firstRevision);
-
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision secondRevision = company.cdoRevision();
- assertEquals(2, secondRevision.getVersion());
- addRevision(secondRevision);
-
- CDORevision fetchedCDORevision = revisionCache.getRevision(company.cdoID(), BRANCH_POINT);
- assertEquals(2, fetchedCDORevision.getVersion());
- }
-
- public void testAddedRevisionIsNotRevised() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- InternalCDORevision firstRevision = company.cdoRevision();
- addRevision(firstRevision);
-
- CDOID id = company.cdoID();
- CDORevision fetchedRevision = revisionCache.getRevision(id, BRANCH_POINT);
- assertEquals(true, fetchedRevision.getRevised() == 0);
- }
-
- public void testFormerVersionIsGettable() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- InternalCDORevision firstRevision = company.cdoRevision();
- addRevision(firstRevision);
-
- // add new version
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision secondRevision = company.cdoRevision();
- addRevision(secondRevision);
-
- // fetch older version and check version and ID equality
- CDOID id = company.cdoID();
- CDORevision fetchedRevision = revisionCache.getRevisionByVersion(id, BRANCH.getVersion(firstRevision.getVersion()));
- assertNotNull(fetchedRevision);
- assertEquals(true, firstRevision.getID().equals(fetchedRevision.getID()));
- assertEquals(true, firstRevision.getVersion() == fetchedRevision.getVersion());
- }
-
- public void testAddRevisionUpdatesRevisedTimeStampOfLastRevision() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- CDOID id = company.cdoID();
-
- InternalCDORevision firstVersion = company.cdoRevision();
- addRevision(firstVersion);
-
- CDORevision fetchedRevision = revisionCache.getRevision(id, BRANCH_POINT);
- assertEquals(true, fetchedRevision.getRevised() == 0);
-
- // add new version
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision secondVersion = company.cdoRevision();
- addRevision(secondVersion);
-
- // fetch older version and check revised timestamp
- fetchedRevision = revisionCache.getRevisionByVersion(id, BRANCH.getVersion(firstVersion.getVersion()));
- assertEquals(true, fetchedRevision.getRevised() != 0);
- assertEquals(true, fetchedRevision.getRevised() < secondVersion.getTimeStamp());
- assertEquals(true, fetchedRevision.getRevised() == firstVersion.getRevised());
- }
-
- public void testTheFormerRevisionOf2VersionsMayBeFetchedByTimestamp() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- CDOID id = CDOUtil.getCDOObject(company).cdoID();
- InternalCDORevision firstRevision = company.cdoRevision();
- addRevision(firstRevision);
-
- // add new version
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision secondRevision = company.cdoRevision();
- addRevision(secondRevision);
-
- // add new version
- company.setName("CDO");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision thirdRevision = company.cdoRevision();
- addRevision(thirdRevision);
-
- // fetch version by timstamp check version and ID equality
- CDORevision fetchedRevision = revisionCache.getRevision(id, BRANCH_POINT);
- assertEquals(true, secondRevision.getID().equals(fetchedRevision.getID()));
- assertEquals(true, secondRevision.getVersion() == fetchedRevision.getVersion());
- }
-
- public void testGiven3ObjectsOf2TypesGetRevisionsReturns2Versions() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- addRevision(company.cdoRevision());
-
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- addRevision(company.cdoRevision());
-
- AddressImpl address = (AddressImpl)Model1Factory.eINSTANCE.createAddress();
- address.setStreet("Eigerplatz 4");
- resource.getContents().add(address);
- ((CDOTransaction)company.cdoView()).commit();
- addRevision(address.cdoRevision());
-
- List<CDORevision> revisionList = revisionCache.getCurrentRevisions();
- assertEquals(2, revisionList.size());
- }
-
- public void testReturnsRemovedVersionWhenRemoving() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- InternalCDORevision firstVersion = company.cdoRevision();
- addRevision(firstVersion);
-
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision secondVersion = company.cdoRevision();
- addRevision(secondVersion);
-
- CDORevision removedRevision = revisionCache.removeRevision(firstVersion.getID(), firstVersion.getBranch()
- .getVersion(firstVersion.getVersion()));
- assertNotNull(removedRevision);
- assertEqualRevisions(firstVersion, removedRevision);
- }
-
- public void testRemovedRevisionIsRemovedFromCache() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- InternalCDORevision firstVersion = company.cdoRevision();
- addRevision(firstVersion);
-
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision secondVersion = company.cdoRevision();
- addRevision(secondVersion);
-
- revisionCache.removeRevision(secondVersion.getID(), secondVersion.getBranch()
- .getVersion(secondVersion.getVersion()));
- assertNull(revisionCache.getRevisionByVersion(secondVersion.getID(), BRANCH.getVersion(secondVersion.getVersion())));
- }
-
- public void testRemoveSecondRevisionResultsInNoActiveRevision() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- InternalCDORevision firstVersion = company.cdoRevision();
- addRevision(firstVersion);
-
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision secondVersion = company.cdoRevision();
- addRevision(secondVersion);
-
- revisionCache.removeRevision(secondVersion.getID(), secondVersion.getBranch()
- .getVersion(secondVersion.getVersion()));
- CDORevision fetchedRevision = revisionCache.getRevision(firstVersion.getID(), BRANCH_POINT);
- assertNull(fetchedRevision);
- }
-
- public void testRemovedRevisionIsNotGettableByTimeStamp() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- InternalCDORevision firstVersion = company.cdoRevision();
- addRevision(firstVersion);
-
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision secondVersion = company.cdoRevision();
- addRevision(secondVersion);
-
- revisionCache.removeRevision(firstVersion.getID(), firstVersion);
- CDORevision fetchedRevision = revisionCache.getRevision(firstVersion.getID(), BRANCH_POINT);
- assertNull(fetchedRevision);
- }
-
- public void testClearedCacheDoesNotContainAnyRevisions() throws Exception
- {
- CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
- InternalCDORevision firstVersion = company.cdoRevision();
- addRevision(firstVersion);
-
- company.setName("Andre");
- ((CDOTransaction)company.cdoView()).commit();
- InternalCDORevision secondVersion = company.cdoRevision();
- addRevision(secondVersion);
-
- revisionCache.clear();
- CDORevision fetchedRevision = revisionCache.getRevisionByVersion(firstVersion.getID(),
- BRANCH.getVersion(firstVersion.getVersion()));
- assertNull(fetchedRevision);
-
- fetchedRevision = revisionCache.getRevisionByVersion(secondVersion.getID(),
- BRANCH.getVersion(secondVersion.getVersion()));
- assertNull(fetchedRevision);
- }
-
- public void testConcurrentAccess() throws Throwable
- {
- Runnable[] testCases = new Runnable[] {
-
- new Runnable()
- {
- public void run()
- {
- // transactions are not thread safe, open a new one, this is probably a bug
- // CDOObject company = createCompanyInResource("Puzzle", (CDOTransaction)resource.cdoView());
- CDOObject company = createCompanyInResource("Puzzle", session.openTransaction());
- CDORevision revision = company.cdoRevision();
- addRevision(revision);
- CDORevision fetchedRevision = revisionCache.getRevision(revision.getID(), BRANCH_POINT);
- assertNotNull(fetchedRevision != null);
- }
- } //
-
- , new Runnable()
- {
- public void run()
- {
- CDOObject company = createCompanyInResource("Puzzle", session.openTransaction());
- CDORevision revision = company.cdoRevision();
- addRevision(revision);
- CDORevision fetchedRevision = revisionCache.getRevisionByVersion(revision.getID(),
- BRANCH.getVersion(revision.getVersion()));
- assertEquals(revision.getVersion(), fetchedRevision.getVersion());
- assertEquals(revision.getTimeStamp(), fetchedRevision.getTimeStamp());
- }
- } //
-
- , new Runnable()
- {
- public void run()
- {
- CDOObject company = createCompanyInResource("Puzzle", session.openTransaction());
- CDORevision revision = company.cdoRevision();
- addRevision(revision);
- revisionCache.removeRevision(revision.getID(), revision);
- }
- } //
-
- , new Runnable()
- {
- public void run()
- {
- revisionCache.getCurrentRevisions();
- }
- } //
-
- , new Runnable()
- {
- public void run()
- {
- CDOObject company = createCompanyInResource("Puzzle", session.openTransaction());
- CDORevision revision = company.cdoRevision();
- addRevision(revision);
- CDORevision fetchedRevision = revisionCache.getRevision(revision.getID(), BRANCH_POINT);
- assertEquals(revision.getVersion(), fetchedRevision.getVersion());
- assertEquals(revision.getTimeStamp(), fetchedRevision.getTimeStamp());
- revisionCache.removeRevision(revision.getID(), revision);
- }
- } };
-
- ConcurrentRunner.run(testCases, MAX_THREADS, 50);
- }
-
- private void assertEqualRevisions(CDORevision thisRevision, CDORevision thatRevision)
- {
- assertEquals(thisRevision.getVersion(), thatRevision.getVersion());
- assertEquals(thisRevision.getTimeStamp(), thatRevision.getTimeStamp());
- assertEquals(thisRevision.getRevised(), thatRevision.getRevised());
- }
-
- private CDOObject createCompanyInResource(String name)
- {
- CDOTransaction transaction = (CDOTransaction)resource.cdoView();
- return createCompanyInResource(name, transaction);
- }
-
- private CDOObject createCompanyInResource(String name, CDOTransaction transaction)
- {
- Company company = Model1Factory.eINSTANCE.createCompany();
- company.setName(name);
- resource.getContents().add(company);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- return CDOUtil.getCDOObject(company);
- }
-
- private CDOResource createResource()
- {
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(RESOURCE_PATH);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- return resource;
- }
-
- protected abstract InternalCDORevisionCache createRevisionCache(CDOSession session) throws Exception;
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.revisioncache;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.internal.db.cache.DBRevisionCache;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model1.impl.AddressImpl;
+import org.eclipse.emf.cdo.tests.model1.impl.CompanyImpl;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+import org.eclipse.net4j.util.tests.ConcurrentRunner;
+
+import java.util.List;
+
+/**
+ * An abstract superclass that may be subclassed to test behaviour common to all CDORevisionCaches
+ *
+ * @author Andre Dietisheim
+ * @see CDORevisionCache
+ * @see DBRevisionCache
+ * @see DerbyDBRevisionCacheTest
+ * @see H2DBRevisionCacheTest
+ * @see DefaultRevisionCacheTest
+ */
+public abstract class AbstractCDORevisionCacheTest extends AbstractOMTest
+{
+ private static final String RESOURCE_PATH = "/res1";
+
+ private static final int MAX_THREADS = 10;
+
+ private static final CDOBranch BRANCH = null;
+
+ private static final CDOBranchPoint BRANCH_POINT = BRANCH.getHead();
+
+ private CDOResource resource;
+
+ private InternalCDORevisionCache revisionCache;
+
+ private CDOSession session;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+
+ Session sessionHolder = new Session();
+ LifecycleUtil.activate(sessionHolder);
+ session = sessionHolder.getSession(Model1Package.eINSTANCE);
+ resource = createResource();
+ revisionCache = createRevisionCache(session);
+ LifecycleUtil.activate(revisionCache);
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ LifecycleUtil.deactivate(session);
+ LifecycleUtil.deactivate(revisionCache);
+ super.doTearDown();
+ }
+
+ public void testAddedRevisionIsGettable()
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ InternalCDORevision cdoRevision = company.cdoRevision();
+ addRevision(cdoRevision);
+
+ CDOID id = CDOUtil.getCDOObject(company).cdoID();
+ CDORevision fetchedCDORevision = revisionCache.getRevision(id, BRANCH_POINT);
+ assertEquals(true, CDOIDUtil.equals(cdoRevision.getID(), fetchedCDORevision.getID()));
+ }
+
+ private void addRevision(CDORevision revision)
+ {
+ revisionCache.addRevision(revision);
+ }
+
+ public void testGetRevisionReturnsLatestVersion() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ InternalCDORevision firstRevision = company.cdoRevision();
+ addRevision(firstRevision);
+
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision secondRevision = company.cdoRevision();
+ assertEquals(2, secondRevision.getVersion());
+ addRevision(secondRevision);
+
+ CDORevision fetchedCDORevision = revisionCache.getRevision(company.cdoID(), BRANCH_POINT);
+ assertEquals(2, fetchedCDORevision.getVersion());
+ }
+
+ public void testAddedRevisionIsNotRevised() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ InternalCDORevision firstRevision = company.cdoRevision();
+ addRevision(firstRevision);
+
+ CDOID id = company.cdoID();
+ CDORevision fetchedRevision = revisionCache.getRevision(id, BRANCH_POINT);
+ assertEquals(true, fetchedRevision.getRevised() == 0);
+ }
+
+ public void testFormerVersionIsGettable() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ InternalCDORevision firstRevision = company.cdoRevision();
+ addRevision(firstRevision);
+
+ // add new version
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision secondRevision = company.cdoRevision();
+ addRevision(secondRevision);
+
+ // fetch older version and check version and ID equality
+ CDOID id = company.cdoID();
+ CDORevision fetchedRevision = revisionCache.getRevisionByVersion(id, BRANCH.getVersion(firstRevision.getVersion()));
+ assertNotNull(fetchedRevision);
+ assertEquals(true, firstRevision.getID().equals(fetchedRevision.getID()));
+ assertEquals(true, firstRevision.getVersion() == fetchedRevision.getVersion());
+ }
+
+ public void testAddRevisionUpdatesRevisedTimeStampOfLastRevision() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ CDOID id = company.cdoID();
+
+ InternalCDORevision firstVersion = company.cdoRevision();
+ addRevision(firstVersion);
+
+ CDORevision fetchedRevision = revisionCache.getRevision(id, BRANCH_POINT);
+ assertEquals(true, fetchedRevision.getRevised() == 0);
+
+ // add new version
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision secondVersion = company.cdoRevision();
+ addRevision(secondVersion);
+
+ // fetch older version and check revised timestamp
+ fetchedRevision = revisionCache.getRevisionByVersion(id, BRANCH.getVersion(firstVersion.getVersion()));
+ assertEquals(true, fetchedRevision.getRevised() != 0);
+ assertEquals(true, fetchedRevision.getRevised() < secondVersion.getTimeStamp());
+ assertEquals(true, fetchedRevision.getRevised() == firstVersion.getRevised());
+ }
+
+ public void testTheFormerRevisionOf2VersionsMayBeFetchedByTimestamp() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ CDOID id = CDOUtil.getCDOObject(company).cdoID();
+ InternalCDORevision firstRevision = company.cdoRevision();
+ addRevision(firstRevision);
+
+ // add new version
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision secondRevision = company.cdoRevision();
+ addRevision(secondRevision);
+
+ // add new version
+ company.setName("CDO");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision thirdRevision = company.cdoRevision();
+ addRevision(thirdRevision);
+
+ // fetch version by timstamp check version and ID equality
+ CDORevision fetchedRevision = revisionCache.getRevision(id, BRANCH_POINT);
+ assertEquals(true, secondRevision.getID().equals(fetchedRevision.getID()));
+ assertEquals(true, secondRevision.getVersion() == fetchedRevision.getVersion());
+ }
+
+ public void testGiven3ObjectsOf2TypesGetRevisionsReturns2Versions() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ addRevision(company.cdoRevision());
+
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ addRevision(company.cdoRevision());
+
+ AddressImpl address = (AddressImpl)Model1Factory.eINSTANCE.createAddress();
+ address.setStreet("Eigerplatz 4");
+ resource.getContents().add(address);
+ ((CDOTransaction)company.cdoView()).commit();
+ addRevision(address.cdoRevision());
+
+ List<CDORevision> revisionList = revisionCache.getCurrentRevisions();
+ assertEquals(2, revisionList.size());
+ }
+
+ public void testReturnsRemovedVersionWhenRemoving() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ InternalCDORevision firstVersion = company.cdoRevision();
+ addRevision(firstVersion);
+
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision secondVersion = company.cdoRevision();
+ addRevision(secondVersion);
+
+ CDORevision removedRevision = revisionCache.removeRevision(firstVersion.getID(), firstVersion.getBranch()
+ .getVersion(firstVersion.getVersion()));
+ assertNotNull(removedRevision);
+ assertEqualRevisions(firstVersion, removedRevision);
+ }
+
+ public void testRemovedRevisionIsRemovedFromCache() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ InternalCDORevision firstVersion = company.cdoRevision();
+ addRevision(firstVersion);
+
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision secondVersion = company.cdoRevision();
+ addRevision(secondVersion);
+
+ revisionCache.removeRevision(secondVersion.getID(), secondVersion.getBranch()
+ .getVersion(secondVersion.getVersion()));
+ assertNull(revisionCache.getRevisionByVersion(secondVersion.getID(), BRANCH.getVersion(secondVersion.getVersion())));
+ }
+
+ public void testRemoveSecondRevisionResultsInNoActiveRevision() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ InternalCDORevision firstVersion = company.cdoRevision();
+ addRevision(firstVersion);
+
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision secondVersion = company.cdoRevision();
+ addRevision(secondVersion);
+
+ revisionCache.removeRevision(secondVersion.getID(), secondVersion.getBranch()
+ .getVersion(secondVersion.getVersion()));
+ CDORevision fetchedRevision = revisionCache.getRevision(firstVersion.getID(), BRANCH_POINT);
+ assertNull(fetchedRevision);
+ }
+
+ public void testRemovedRevisionIsNotGettableByTimeStamp() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ InternalCDORevision firstVersion = company.cdoRevision();
+ addRevision(firstVersion);
+
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision secondVersion = company.cdoRevision();
+ addRevision(secondVersion);
+
+ revisionCache.removeRevision(firstVersion.getID(), firstVersion);
+ CDORevision fetchedRevision = revisionCache.getRevision(firstVersion.getID(), BRANCH_POINT);
+ assertNull(fetchedRevision);
+ }
+
+ public void testClearedCacheDoesNotContainAnyRevisions() throws Exception
+ {
+ CompanyImpl company = (CompanyImpl)createCompanyInResource("Puzzle");
+ InternalCDORevision firstVersion = company.cdoRevision();
+ addRevision(firstVersion);
+
+ company.setName("Andre");
+ ((CDOTransaction)company.cdoView()).commit();
+ InternalCDORevision secondVersion = company.cdoRevision();
+ addRevision(secondVersion);
+
+ revisionCache.clear();
+ CDORevision fetchedRevision = revisionCache.getRevisionByVersion(firstVersion.getID(),
+ BRANCH.getVersion(firstVersion.getVersion()));
+ assertNull(fetchedRevision);
+
+ fetchedRevision = revisionCache.getRevisionByVersion(secondVersion.getID(),
+ BRANCH.getVersion(secondVersion.getVersion()));
+ assertNull(fetchedRevision);
+ }
+
+ public void testConcurrentAccess() throws Throwable
+ {
+ Runnable[] testCases = new Runnable[] {
+
+ new Runnable()
+ {
+ public void run()
+ {
+ // transactions are not thread safe, open a new one, this is probably a bug
+ // CDOObject company = createCompanyInResource("Puzzle", (CDOTransaction)resource.cdoView());
+ CDOObject company = createCompanyInResource("Puzzle", session.openTransaction());
+ CDORevision revision = company.cdoRevision();
+ addRevision(revision);
+ CDORevision fetchedRevision = revisionCache.getRevision(revision.getID(), BRANCH_POINT);
+ assertNotNull(fetchedRevision != null);
+ }
+ } //
+
+ , new Runnable()
+ {
+ public void run()
+ {
+ CDOObject company = createCompanyInResource("Puzzle", session.openTransaction());
+ CDORevision revision = company.cdoRevision();
+ addRevision(revision);
+ CDORevision fetchedRevision = revisionCache.getRevisionByVersion(revision.getID(),
+ BRANCH.getVersion(revision.getVersion()));
+ assertEquals(revision.getVersion(), fetchedRevision.getVersion());
+ assertEquals(revision.getTimeStamp(), fetchedRevision.getTimeStamp());
+ }
+ } //
+
+ , new Runnable()
+ {
+ public void run()
+ {
+ CDOObject company = createCompanyInResource("Puzzle", session.openTransaction());
+ CDORevision revision = company.cdoRevision();
+ addRevision(revision);
+ revisionCache.removeRevision(revision.getID(), revision);
+ }
+ } //
+
+ , new Runnable()
+ {
+ public void run()
+ {
+ revisionCache.getCurrentRevisions();
+ }
+ } //
+
+ , new Runnable()
+ {
+ public void run()
+ {
+ CDOObject company = createCompanyInResource("Puzzle", session.openTransaction());
+ CDORevision revision = company.cdoRevision();
+ addRevision(revision);
+ CDORevision fetchedRevision = revisionCache.getRevision(revision.getID(), BRANCH_POINT);
+ assertEquals(revision.getVersion(), fetchedRevision.getVersion());
+ assertEquals(revision.getTimeStamp(), fetchedRevision.getTimeStamp());
+ revisionCache.removeRevision(revision.getID(), revision);
+ }
+ } };
+
+ ConcurrentRunner.run(testCases, MAX_THREADS, 50);
+ }
+
+ private void assertEqualRevisions(CDORevision thisRevision, CDORevision thatRevision)
+ {
+ assertEquals(thisRevision.getVersion(), thatRevision.getVersion());
+ assertEquals(thisRevision.getTimeStamp(), thatRevision.getTimeStamp());
+ assertEquals(thisRevision.getRevised(), thatRevision.getRevised());
+ }
+
+ private CDOObject createCompanyInResource(String name)
+ {
+ CDOTransaction transaction = (CDOTransaction)resource.cdoView();
+ return createCompanyInResource(name, transaction);
+ }
+
+ private CDOObject createCompanyInResource(String name, CDOTransaction transaction)
+ {
+ Company company = Model1Factory.eINSTANCE.createCompany();
+ company.setName(name);
+ resource.getContents().add(company);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ return CDOUtil.getCDOObject(company);
+ }
+
+ private CDOResource createResource()
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(RESOURCE_PATH);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ return resource;
+ }
+
+ protected abstract InternalCDORevisionCache createRevisionCache(CDOSession session) throws Exception;
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractDBRevisionCacheTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractDBRevisionCacheTest.java
index db5c6ad861..2e77573998 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractDBRevisionCacheTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractDBRevisionCacheTest.java
@@ -1,83 +1,83 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.revisioncache;
-
-import org.eclipse.emf.cdo.common.db.CDOCommonDBUtil;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-import javax.sql.DataSource;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * @author Andre Dietisheim
- */
-public abstract class AbstractDBRevisionCacheTest extends AbstractCDORevisionCacheTest
-{
- private DataSource dataSource;
-
- @Override
- protected InternalCDORevisionCache createRevisionCache(CDOSession session) throws Exception
- {
- DataSource dataSource = getDataSource();
-
- clearDb(dataSource);
-
- CDORevisionCache revisionCache = CDOCommonDBUtil.createDBCache(//
- getAdapter() //
- , DBUtil.createConnectionProvider(dataSource)//
- , CDOListFactory.DEFAULT//
- , session.getPackageRegistry() //
- , ((InternalCDOSession)session).getRevisionManager().getFactory());
- LifecycleUtil.activate(revisionCache);
- return (InternalCDORevisionCache)revisionCache;
- }
-
- private DataSource getDataSource()
- {
- if (dataSource == null)
- {
- dataSource = createDataSource();
- }
-
- return dataSource;
- }
-
- private void clearDb(DataSource dataSource) throws SQLException
- {
- Connection connection = dataSource.getConnection();
- try
- {
- dropAllTables(connection);
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-
- protected abstract DataSource createDataSource();
-
- protected abstract void dropAllTables(Connection connection);
-
- protected abstract IDBAdapter getAdapter();
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.revisioncache;
+
+import org.eclipse.emf.cdo.common.db.CDOCommonDBUtil;
+import org.eclipse.emf.cdo.common.revision.CDOListFactory;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
+
+import javax.sql.DataSource;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * @author Andre Dietisheim
+ */
+public abstract class AbstractDBRevisionCacheTest extends AbstractCDORevisionCacheTest
+{
+ private DataSource dataSource;
+
+ @Override
+ protected InternalCDORevisionCache createRevisionCache(CDOSession session) throws Exception
+ {
+ DataSource dataSource = getDataSource();
+
+ clearDb(dataSource);
+
+ CDORevisionCache revisionCache = CDOCommonDBUtil.createDBCache(//
+ getAdapter() //
+ , DBUtil.createConnectionProvider(dataSource)//
+ , CDOListFactory.DEFAULT//
+ , session.getPackageRegistry() //
+ , ((InternalCDOSession)session).getRevisionManager().getFactory());
+ LifecycleUtil.activate(revisionCache);
+ return (InternalCDORevisionCache)revisionCache;
+ }
+
+ private DataSource getDataSource()
+ {
+ if (dataSource == null)
+ {
+ dataSource = createDataSource();
+ }
+
+ return dataSource;
+ }
+
+ private void clearDb(DataSource dataSource) throws SQLException
+ {
+ Connection connection = dataSource.getConnection();
+ try
+ {
+ dropAllTables(connection);
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ protected abstract DataSource createDataSource();
+
+ protected abstract void dropAllTables(Connection connection);
+
+ protected abstract IDBAdapter getAdapter();
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AllTestsCDORevisionCache.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AllTestsCDORevisionCache.java
index 09622505d9..d32452177b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AllTestsCDORevisionCache.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AllTestsCDORevisionCache.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.revisioncache;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Andre Dietisheim
- */
-public class AllTestsCDORevisionCache
-{
- public static Test suite()
- {
- TestSuite suite = new TestSuite("Tests for CDORevisionCache"); //$NON-NLS-1$
-
- // $JUnit-BEGIN$
- suite.addTestSuite(DerbyDBRevisionCacheTest.class);
- suite.addTestSuite(H2DBRevisionCacheTest.class);
- suite.addTestSuite(DefaultRevisionCacheTest.class);
- // $JUnit-END$
-
- return suite;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.revisioncache;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class AllTestsCDORevisionCache
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Tests for CDORevisionCache"); //$NON-NLS-1$
+
+ // $JUnit-BEGIN$
+ suite.addTestSuite(DerbyDBRevisionCacheTest.class);
+ suite.addTestSuite(H2DBRevisionCacheTest.class);
+ suite.addTestSuite(DefaultRevisionCacheTest.class);
+ // $JUnit-END$
+
+ return suite;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DefaultRevisionCacheTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DefaultRevisionCacheTest.java
index 48b8164f8c..20e9744ab7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DefaultRevisionCacheTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DefaultRevisionCacheTest.java
@@ -1,33 +1,33 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.revisioncache;
-
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.session.CDORepositoryInfo;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-/**
- * @author Andre Dietisheim
- */
-public class DefaultRevisionCacheTest extends AbstractCDORevisionCacheTest
-{
- @Override
- protected InternalCDORevisionCache createRevisionCache(CDOSession session) throws Exception
- {
- CDORepositoryInfo repositoryInfo = session.getRepositoryInfo();
- boolean supportingAudits = repositoryInfo.isSupportingAudits();
- boolean supportingBranches = repositoryInfo.isSupportingBranches();
-
- return (InternalCDORevisionCache)CDORevisionUtil.createRevisionCache(supportingAudits, supportingBranches);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.revisioncache;
+
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.session.CDORepositoryInfo;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class DefaultRevisionCacheTest extends AbstractCDORevisionCacheTest
+{
+ @Override
+ protected InternalCDORevisionCache createRevisionCache(CDOSession session) throws Exception
+ {
+ CDORepositoryInfo repositoryInfo = session.getRepositoryInfo();
+ boolean supportingAudits = repositoryInfo.isSupportingAudits();
+ boolean supportingBranches = repositoryInfo.isSupportingBranches();
+
+ return (InternalCDORevisionCache)CDORevisionUtil.createRevisionCache(supportingAudits, supportingBranches);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DerbyDBRevisionCacheTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DerbyDBRevisionCacheTest.java
index c48d95cae5..65d41dd773 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DerbyDBRevisionCacheTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/DerbyDBRevisionCacheTest.java
@@ -1,59 +1,59 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.revisioncache;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter;
-import org.eclipse.net4j.util.io.TMPUtil;
-
-import javax.sql.DataSource;
-
-import java.io.File;
-import java.sql.Connection;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Andre Dietisheim
- */
-public class DerbyDBRevisionCacheTest extends AbstractDBRevisionCacheTest
-{
- private static final String DB_NAME = TMPUtil.getTempFolder().getAbsolutePath() //
- + File.separatorChar //
- + "derbyDBRevisionCacheTest";
-
- @Override
- public DataSource createDataSource()
- {
- Map<Object, Object> properties = new HashMap<Object, Object>();
- properties.put("class", "org.apache.derby.jdbc.EmbeddedDataSource");
- properties.put("databaseName", DB_NAME);
- properties.put("createDatabase", "create");
- return DBUtil.createDataSource(properties);
- }
-
- /**
- * Drop all table on a given derby database.
- */
- @Override
- public void dropAllTables(Connection connection)
- {
- DBUtil.dropAllTables(connection, DB_NAME);
- }
-
- @Override
- public IDBAdapter getAdapter()
- {
- return new EmbeddedDerbyAdapter();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.revisioncache;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter;
+import org.eclipse.net4j.util.io.TMPUtil;
+
+import javax.sql.DataSource;
+
+import java.io.File;
+import java.sql.Connection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class DerbyDBRevisionCacheTest extends AbstractDBRevisionCacheTest
+{
+ private static final String DB_NAME = TMPUtil.getTempFolder().getAbsolutePath() //
+ + File.separatorChar //
+ + "derbyDBRevisionCacheTest";
+
+ @Override
+ public DataSource createDataSource()
+ {
+ Map<Object, Object> properties = new HashMap<Object, Object>();
+ properties.put("class", "org.apache.derby.jdbc.EmbeddedDataSource");
+ properties.put("databaseName", DB_NAME);
+ properties.put("createDatabase", "create");
+ return DBUtil.createDataSource(properties);
+ }
+
+ /**
+ * Drop all table on a given derby database.
+ */
+ @Override
+ public void dropAllTables(Connection connection)
+ {
+ DBUtil.dropAllTables(connection, DB_NAME);
+ }
+
+ @Override
+ public IDBAdapter getAdapter()
+ {
+ return new EmbeddedDerbyAdapter();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/H2DBRevisionCacheTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/H2DBRevisionCacheTest.java
index 655a733250..dee1d3550a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/H2DBRevisionCacheTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/H2DBRevisionCacheTest.java
@@ -1,51 +1,51 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.revisioncache;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.h2.H2Adapter;
-
-import org.h2.jdbcx.JdbcDataSource;
-
-import javax.sql.DataSource;
-
-import java.sql.Connection;
-
-/**
- * @author Andre Dietisheim
- */
-public class H2DBRevisionCacheTest extends AbstractDBRevisionCacheTest
-{
- /**
- * Drop all table on a given h2 database.
- */
- @Override
- public void dropAllTables(Connection connection)
- {
- DBUtil.dropAllTables(connection, null);
- }
-
- @Override
- public IDBAdapter getAdapter()
- {
- return new H2Adapter();
- }
-
- @Override
- protected DataSource createDataSource()
- {
- JdbcDataSource dataSource = new JdbcDataSource();
- dataSource.setURL("jdbc:h2:" + createTempFolder("h2db").getAbsolutePath());
- return dataSource;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.revisioncache;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.h2.H2Adapter;
+
+import org.h2.jdbcx.JdbcDataSource;
+
+import javax.sql.DataSource;
+
+import java.sql.Connection;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class H2DBRevisionCacheTest extends AbstractDBRevisionCacheTest
+{
+ /**
+ * Drop all table on a given h2 database.
+ */
+ @Override
+ public void dropAllTables(Connection connection)
+ {
+ DBUtil.dropAllTables(connection, null);
+ }
+
+ @Override
+ public IDBAdapter getAdapter()
+ {
+ return new H2Adapter();
+ }
+
+ @Override
+ protected DataSource createDataSource()
+ {
+ JdbcDataSource dataSource = new JdbcDataSource();
+ dataSource.setURL("jdbc:h2:" + createTempFolder("h2db").getAbsolutePath());
+ return dataSource;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/Session.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/Session.java
index 03a149fab6..16c02e7263 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/Session.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/Session.java
@@ -1,152 +1,152 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.revisioncache;
-
-import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
-import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
-import org.eclipse.emf.cdo.server.CDOServerUtil;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.mem.IMEMStore;
-import org.eclipse.emf.cdo.server.mem.MEMStoreUtil;
-import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.jvm.IJVMAcceptor;
-import org.eclipse.net4j.jvm.IJVMConnector;
-import org.eclipse.net4j.jvm.JVMUtil;
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-import org.eclipse.emf.ecore.EPackage;
-
-/**
- * A class that holds a single CDOSession. It starts an IRepository that uses a memstore and a client that connects to
- * it by JVM transport
- *
- * @author Andre Dietisheim
- */
-public class Session extends Lifecycle
-{
- private static final String CONNECTOR_NAME = "server1";
-
- private static final String REPO_NAME = "repo1";
-
- private IManagedContainer serverContainer;
-
- private IJVMAcceptor acceptor;
-
- private IMEMStore store;
-
- private IRepository repository;
-
- private IManagedContainer clientContainer;
-
- private IJVMConnector connector;
-
- private CDOSession session;
-
- public Session()
- {
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- createRepository(REPO_NAME);
- session = createSession();
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- super.doDeactivate();
- LifecycleUtil.deactivate(session);
- LifecycleUtil.deactivate(connector);
- LifecycleUtil.deactivate(repository);
- LifecycleUtil.deactivate(acceptor);
- LifecycleUtil.deactivate(clientContainer);
- LifecycleUtil.deactivate(serverContainer);
- }
-
- /**
- * Returns the session held by this class and registers the given packages to it.
- *
- * @param ePackages
- * the e packages
- * @return the session
- * @see CDOSession
- */
- public CDOSession getSession(EPackage... ePackages)
- {
- CDOSession session = getSession();
- for (EPackage ePackage : ePackages)
- {
- session.getPackageRegistry().putEPackage(ePackage);
- }
-
- return session;
- }
-
- /**
- * Returns the session this class holds.
- *
- * @return the session
- */
- public CDOSession getSession()
- {
- CheckUtil.checkState(session != null, "Session not activated!");
- return session;
- }
-
- private CDOSession createSession()
- {
- clientContainer = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(clientContainer);
- JVMUtil.prepareContainer(clientContainer);
- CDONet4jUtil.prepareContainer(clientContainer);
- LifecycleUtil.activate(clientContainer);
-
- // Create configuration
- CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
- connector = JVMUtil.getConnector(clientContainer, CONNECTOR_NAME);
- configuration.setConnector(connector);
- configuration.setRepositoryName(REPO_NAME);
-
- return configuration.openNet4jSession();
- }
-
- /**
- * Creates the repository for this session holder. It initializes the acceptor and store used within this session
- * holder
- *
- * @param repositoryName
- * the repository name
- */
- protected void createRepository(String repositoryName)
- {
- serverContainer = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(serverContainer); // Register Net4j factories
- JVMUtil.prepareContainer(serverContainer);
- CDONet4jServerUtil.prepareContainer(serverContainer);
- LifecycleUtil.activate(serverContainer);
-
- acceptor = JVMUtil.getAcceptor(serverContainer, CONNECTOR_NAME);
- store = MEMStoreUtil.createMEMStore();
- repository = CDOServerUtil.createRepository(repositoryName, store, null);
- CDOServerUtil.addRepository(serverContainer, repository);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.revisioncache;
+
+import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
+import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
+import org.eclipse.emf.cdo.server.CDOServerUtil;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.mem.IMEMStore;
+import org.eclipse.emf.cdo.server.mem.MEMStoreUtil;
+import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
+import org.eclipse.emf.cdo.session.CDOSession;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.jvm.IJVMAcceptor;
+import org.eclipse.net4j.jvm.IJVMConnector;
+import org.eclipse.net4j.jvm.JVMUtil;
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ * A class that holds a single CDOSession. It starts an IRepository that uses a memstore and a client that connects to
+ * it by JVM transport
+ *
+ * @author Andre Dietisheim
+ */
+public class Session extends Lifecycle
+{
+ private static final String CONNECTOR_NAME = "server1";
+
+ private static final String REPO_NAME = "repo1";
+
+ private IManagedContainer serverContainer;
+
+ private IJVMAcceptor acceptor;
+
+ private IMEMStore store;
+
+ private IRepository repository;
+
+ private IManagedContainer clientContainer;
+
+ private IJVMConnector connector;
+
+ private CDOSession session;
+
+ public Session()
+ {
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ createRepository(REPO_NAME);
+ session = createSession();
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ super.doDeactivate();
+ LifecycleUtil.deactivate(session);
+ LifecycleUtil.deactivate(connector);
+ LifecycleUtil.deactivate(repository);
+ LifecycleUtil.deactivate(acceptor);
+ LifecycleUtil.deactivate(clientContainer);
+ LifecycleUtil.deactivate(serverContainer);
+ }
+
+ /**
+ * Returns the session held by this class and registers the given packages to it.
+ *
+ * @param ePackages
+ * the e packages
+ * @return the session
+ * @see CDOSession
+ */
+ public CDOSession getSession(EPackage... ePackages)
+ {
+ CDOSession session = getSession();
+ for (EPackage ePackage : ePackages)
+ {
+ session.getPackageRegistry().putEPackage(ePackage);
+ }
+
+ return session;
+ }
+
+ /**
+ * Returns the session this class holds.
+ *
+ * @return the session
+ */
+ public CDOSession getSession()
+ {
+ CheckUtil.checkState(session != null, "Session not activated!");
+ return session;
+ }
+
+ private CDOSession createSession()
+ {
+ clientContainer = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(clientContainer);
+ JVMUtil.prepareContainer(clientContainer);
+ CDONet4jUtil.prepareContainer(clientContainer);
+ LifecycleUtil.activate(clientContainer);
+
+ // Create configuration
+ CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
+ connector = JVMUtil.getConnector(clientContainer, CONNECTOR_NAME);
+ configuration.setConnector(connector);
+ configuration.setRepositoryName(REPO_NAME);
+
+ return configuration.openNet4jSession();
+ }
+
+ /**
+ * Creates the repository for this session holder. It initializes the acceptor and store used within this session
+ * holder
+ *
+ * @param repositoryName
+ * the repository name
+ */
+ protected void createRepository(String repositoryName)
+ {
+ serverContainer = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(serverContainer); // Register Net4j factories
+ JVMUtil.prepareContainer(serverContainer);
+ CDONet4jServerUtil.prepareContainer(serverContainer);
+ LifecycleUtil.activate(serverContainer);
+
+ acceptor = JVMUtil.getAcceptor(serverContainer, CONNECTOR_NAME);
+ store = MEMStoreUtil.createMEMStore();
+ repository = CDOServerUtil.createRepository(repositoryName, store, null);
+ CDOServerUtil.addRepository(serverContainer, repository);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java
index 363490fd64..e67406d64e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java
@@ -1,71 +1,71 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Simon McDuff
- */
-public class TestAdapter implements Adapter
-{
- private List<Notification> notifications = new ArrayList<Notification>();
-
- private Notifier notifier;
-
- public TestAdapter()
- {
- }
-
- public Notifier getTarget()
- {
- return notifier;
- }
-
- public Notification[] getNotifications()
- {
- synchronized (notifications)
- {
- return notifications.toArray(new Notification[notifications.size()]);
- }
- }
-
- public void clearNotifications()
- {
- synchronized (notifications)
- {
- notifications.clear();
- }
- }
-
- public boolean isAdapterForType(Object type)
- {
- return false;
- }
-
- public void notifyChanged(Notification notification)
- {
- synchronized (notifications)
- {
- notifications.add(notification);
- }
- }
-
- public void setTarget(Notifier newTarget)
- {
- notifier = newTarget;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.util;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Simon McDuff
+ */
+public class TestAdapter implements Adapter
+{
+ private List<Notification> notifications = new ArrayList<Notification>();
+
+ private Notifier notifier;
+
+ public TestAdapter()
+ {
+ }
+
+ public Notifier getTarget()
+ {
+ return notifier;
+ }
+
+ public Notification[] getNotifications()
+ {
+ synchronized (notifications)
+ {
+ return notifications.toArray(new Notification[notifications.size()]);
+ }
+ }
+
+ public void clearNotifications()
+ {
+ synchronized (notifications)
+ {
+ notifications.clear();
+ }
+ }
+
+ public boolean isAdapterForType(Object type)
+ {
+ return false;
+ }
+
+ public void notifyChanged(Notification notification)
+ {
+ synchronized (notifications)
+ {
+ notifications.add(notification);
+ }
+ }
+
+ public void setTarget(Notifier newTarget)
+ {
+ notifier = newTarget;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestEMFUtil.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestEMFUtil.java
index 4d16c4f48e..e55d70dfa6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestEMFUtil.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestEMFUtil.java
@@ -1,229 +1,229 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import org.eclipse.net4j.util.io.IORuntimeException;
-
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EPackage.Registry;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public final class TestEMFUtil
-{
- public static List<EObject> loadMultiple(String fileName, ResourceSet resourceSet)
- {
- Resource resource = resourceSet.getResource(URI.createURI(fileName), true);
- return resource.getContents();
- }
-
- public static EObject load(String fileName, ResourceSet resourceSet)
- {
- return loadMultiple(fileName, resourceSet).get(0);
- }
-
- /**
- * returns the first node of the resource content
- */
- public static EObject loadXMI(String fileName, EPackage... ePackages)
- {
- ResourceSet resourceSet = newXMIResourceSet(ePackages);
- return load(fileName, resourceSet);
- }
-
- public static EObject loadXMI(String fileName, EPackage.Registry packageRegistry)
- {
- ResourceSet resourceSet = newXMIResourceSet();
- resourceSet.setPackageRegistry(packageRegistry);
- return load(fileName, resourceSet);
- }
-
- public static List<EObject> loadXMIMultiple(String fileName, EPackage.Registry packageRegistry)
- {
- ResourceSet resourceSet = newXMIResourceSet();
- resourceSet.setPackageRegistry(packageRegistry);
- return loadMultiple(fileName, resourceSet);
- }
-
- public static List<EObject> loadXMIMultiple(String fileName, EPackage... ePackages)
- {
- ResourceSet resourceSet = newXMIResourceSet(ePackages);
- return loadMultiple(fileName, resourceSet);
- }
-
- public static EPackage loadEcore(String fileName, EPackage.Registry packageRegistry)
- {
- return (EPackage)load(fileName, newEcoreResourceSet(packageRegistry));
- }
-
- public static EPackage loadEcore(String fileName)
- {
- return (EPackage)load(fileName, newEcoreResourceSet());
- }
-
- public static void save(String fileName, EObject root, ResourceSet resourceSet)
- {
- save(fileName, Collections.singletonList(root), resourceSet);
- }
-
- public static void save(String fileName, List<EObject> roots, ResourceSet resourceSet)
- {
- URI uri = URI.createURI(fileName);
- Resource resource = resourceSet.createResource(uri);
-
- Collection<EObject> copiedRoots = EcoreUtil.copyAll(roots);
- resource.getContents().addAll(copiedRoots);
-
- try
- {
- resource.save(null);
- }
- catch (IOException ex)
- {
- throw new IORuntimeException(ex);
- }
- }
-
- public static void saveXMI(String fileName, EObject root)
- {
- save(fileName, root, newXMIResourceSet());
- }
-
- public static void saveXMI(String fileName, List<EObject> roots)
- {
- save(fileName, roots, newXMIResourceSet());
- }
-
- public static void saveEcore(String fileName, EObject root)
- {
- save(fileName, root, newEcoreResourceSet());
- }
-
- public static ResourceSet newXMIResourceSet(EPackage... ePackages)
- {
- ResourceSet resourceSet = newResourceSet(new XMIResourceFactoryImpl());
- if (ePackages != null && ePackages.length != 0)
- {
- Registry packageRegistry = resourceSet.getPackageRegistry();
- for (EPackage ePackage : ePackages)
- {
- packageRegistry.put(ePackage.getNsURI(), ePackage);
- }
- }
-
- return resourceSet;
- }
-
- public static ResourceSet newEcoreResourceSet()
- {
- return newEcoreResourceSet(EPackage.Registry.INSTANCE);
- }
-
- public static ResourceSet newResourceSet(Resource.Factory resourceFactory)
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory);
- return resourceSet;
- }
-
- public static ResourceSet newEcoreResourceSet(EPackage.Registry packageRegistry)
- {
- ResourceSet resourceSet = newResourceSet(new EcoreResourceFactoryImpl());
- resourceSet.setPackageRegistry(packageRegistry);
- return resourceSet;
- }
-
- public static int countAllContents(EObject eObject)
- {
- int count = 0;
- for (TreeIterator<EObject> it = eObject.eAllContents(); it.hasNext(); it.next())
- {
- ++count;
- }
-
- return count;
- }
-
- public static EClass[] getConcreteClasses(EPackage ePackage)
- {
- List<EClass> result = new ArrayList<EClass>(0);
- for (EClassifier classifier : ePackage.getEClassifiers())
- {
- if (classifier instanceof EClass)
- {
- EClass eClass = (EClass)classifier;
- if (!eClass.isAbstract() && !eClass.isInterface())
- {
- result.add(eClass);
- }
- }
- }
-
- return result.toArray(new EClass[result.size()]);
- }
-
- public static boolean isMany(EStructuralFeature eFeature)
- {
- return eFeature.isMany();
- }
-
- public static boolean isReference(EStructuralFeature eFeature)
- {
- return eFeature instanceof EReference;
- }
-
- public static boolean isContainment(EStructuralFeature eFeature)
- {
- if (isReference(eFeature))
- {
- EReference ref = (EReference)eFeature;
- return ref.isContainment();
- }
-
- return false;
- }
-
- public static void registerPackage(EPackage ePackage, EPackage.Registry... packageRegistries)
- {
- ePackage.getClass(); // Initialize package in standalone mode
- if (packageRegistries == null || packageRegistries.length == 0)
- {
- EPackage.Registry[] globalRegistry = { EPackage.Registry.INSTANCE };
- packageRegistries = globalRegistry;
- }
-
- for (EPackage.Registry packageRegistry : packageRegistries)
- {
- packageRegistry.put(ePackage.getNsURI(), ePackage);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Victor Roldan Betancort - maintenance
+ */
+package org.eclipse.emf.cdo.tests.util;
+
+import org.eclipse.net4j.util.io.IORuntimeException;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public final class TestEMFUtil
+{
+ public static List<EObject> loadMultiple(String fileName, ResourceSet resourceSet)
+ {
+ Resource resource = resourceSet.getResource(URI.createURI(fileName), true);
+ return resource.getContents();
+ }
+
+ public static EObject load(String fileName, ResourceSet resourceSet)
+ {
+ return loadMultiple(fileName, resourceSet).get(0);
+ }
+
+ /**
+ * returns the first node of the resource content
+ */
+ public static EObject loadXMI(String fileName, EPackage... ePackages)
+ {
+ ResourceSet resourceSet = newXMIResourceSet(ePackages);
+ return load(fileName, resourceSet);
+ }
+
+ public static EObject loadXMI(String fileName, EPackage.Registry packageRegistry)
+ {
+ ResourceSet resourceSet = newXMIResourceSet();
+ resourceSet.setPackageRegistry(packageRegistry);
+ return load(fileName, resourceSet);
+ }
+
+ public static List<EObject> loadXMIMultiple(String fileName, EPackage.Registry packageRegistry)
+ {
+ ResourceSet resourceSet = newXMIResourceSet();
+ resourceSet.setPackageRegistry(packageRegistry);
+ return loadMultiple(fileName, resourceSet);
+ }
+
+ public static List<EObject> loadXMIMultiple(String fileName, EPackage... ePackages)
+ {
+ ResourceSet resourceSet = newXMIResourceSet(ePackages);
+ return loadMultiple(fileName, resourceSet);
+ }
+
+ public static EPackage loadEcore(String fileName, EPackage.Registry packageRegistry)
+ {
+ return (EPackage)load(fileName, newEcoreResourceSet(packageRegistry));
+ }
+
+ public static EPackage loadEcore(String fileName)
+ {
+ return (EPackage)load(fileName, newEcoreResourceSet());
+ }
+
+ public static void save(String fileName, EObject root, ResourceSet resourceSet)
+ {
+ save(fileName, Collections.singletonList(root), resourceSet);
+ }
+
+ public static void save(String fileName, List<EObject> roots, ResourceSet resourceSet)
+ {
+ URI uri = URI.createURI(fileName);
+ Resource resource = resourceSet.createResource(uri);
+
+ Collection<EObject> copiedRoots = EcoreUtil.copyAll(roots);
+ resource.getContents().addAll(copiedRoots);
+
+ try
+ {
+ resource.save(null);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
+ }
+
+ public static void saveXMI(String fileName, EObject root)
+ {
+ save(fileName, root, newXMIResourceSet());
+ }
+
+ public static void saveXMI(String fileName, List<EObject> roots)
+ {
+ save(fileName, roots, newXMIResourceSet());
+ }
+
+ public static void saveEcore(String fileName, EObject root)
+ {
+ save(fileName, root, newEcoreResourceSet());
+ }
+
+ public static ResourceSet newXMIResourceSet(EPackage... ePackages)
+ {
+ ResourceSet resourceSet = newResourceSet(new XMIResourceFactoryImpl());
+ if (ePackages != null && ePackages.length != 0)
+ {
+ Registry packageRegistry = resourceSet.getPackageRegistry();
+ for (EPackage ePackage : ePackages)
+ {
+ packageRegistry.put(ePackage.getNsURI(), ePackage);
+ }
+ }
+
+ return resourceSet;
+ }
+
+ public static ResourceSet newEcoreResourceSet()
+ {
+ return newEcoreResourceSet(EPackage.Registry.INSTANCE);
+ }
+
+ public static ResourceSet newResourceSet(Resource.Factory resourceFactory)
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory);
+ return resourceSet;
+ }
+
+ public static ResourceSet newEcoreResourceSet(EPackage.Registry packageRegistry)
+ {
+ ResourceSet resourceSet = newResourceSet(new EcoreResourceFactoryImpl());
+ resourceSet.setPackageRegistry(packageRegistry);
+ return resourceSet;
+ }
+
+ public static int countAllContents(EObject eObject)
+ {
+ int count = 0;
+ for (TreeIterator<EObject> it = eObject.eAllContents(); it.hasNext(); it.next())
+ {
+ ++count;
+ }
+
+ return count;
+ }
+
+ public static EClass[] getConcreteClasses(EPackage ePackage)
+ {
+ List<EClass> result = new ArrayList<EClass>(0);
+ for (EClassifier classifier : ePackage.getEClassifiers())
+ {
+ if (classifier instanceof EClass)
+ {
+ EClass eClass = (EClass)classifier;
+ if (!eClass.isAbstract() && !eClass.isInterface())
+ {
+ result.add(eClass);
+ }
+ }
+ }
+
+ return result.toArray(new EClass[result.size()]);
+ }
+
+ public static boolean isMany(EStructuralFeature eFeature)
+ {
+ return eFeature.isMany();
+ }
+
+ public static boolean isReference(EStructuralFeature eFeature)
+ {
+ return eFeature instanceof EReference;
+ }
+
+ public static boolean isContainment(EStructuralFeature eFeature)
+ {
+ if (isReference(eFeature))
+ {
+ EReference ref = (EReference)eFeature;
+ return ref.isContainment();
+ }
+
+ return false;
+ }
+
+ public static void registerPackage(EPackage ePackage, EPackage.Registry... packageRegistries)
+ {
+ ePackage.getClass(); // Initialize package in standalone mode
+ if (packageRegistries == null || packageRegistries.length == 0)
+ {
+ EPackage.Registry[] globalRegistry = { EPackage.Registry.INSTANCE };
+ packageRegistries = globalRegistry;
+ }
+
+ for (EPackage.Registry packageRegistry : packageRegistries)
+ {
+ packageRegistry.put(ePackage.getNsURI(), ePackage);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener2.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener2.java
index 9fbd1d1e69..ff71d9716e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener2.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener2.java
@@ -1,123 +1,123 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.Assert;
-
-/**
- * @author Caspar De Groot
- */
-public class TestListener2 implements IListener
-{
- private final static long DEFAULT_TIMEOUT = 3000; // 3 seconds
-
- private List<IEvent> events = new LinkedList<IEvent>();
-
- private Class<? extends IEvent> eventClass;
-
- private long timeout;
-
- private String name;
-
- public TestListener2(Class<? extends IEvent> eventClass)
- {
- this(eventClass, null);
- }
-
- public TestListener2(Class<? extends IEvent> eventClass, String name)
- {
- this.eventClass = eventClass;
- this.name = name;
- timeout = DEFAULT_TIMEOUT;
- }
-
- public synchronized void notifyEvent(IEvent event)
- {
- if (eventClass == null || eventClass.isAssignableFrom(event.getClass()))
- {
- events.add(event);
- notify();
- }
- }
-
- public List<IEvent> getEvents()
- {
- return events;
- }
-
- public void setTimeout(long timeout)
- {
- this.timeout = timeout;
- }
-
- public synchronized void waitFor(int n, long timeout)
- {
- long t = 0;
-
- while (events.size() < n)
- {
- if (timeout <= 0)
- {
- Assert.fail("Timed out");
- }
-
- try
- {
- t = System.currentTimeMillis();
- wait(timeout);
- }
- catch (InterruptedException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- timeout -= System.currentTimeMillis() - t;
- }
- }
-
- public void waitFor(int i)
- {
- waitFor(i, timeout);
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder(TestListener2.class.getSimpleName());
- builder.append('[');
- if (name != null)
- {
- builder.append("name=\"");
- builder.append(name);
- builder.append('\"');
- }
-
- if (eventClass != null)
- {
- if (builder.charAt(builder.length() - 1) != '[')
- {
- builder.append(';');
- }
- builder.append("eventClass=");
- builder.append(eventClass.getSimpleName());
- }
-
- builder.append(']');
- return builder.toString();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.util;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+/**
+ * @author Caspar De Groot
+ */
+public class TestListener2 implements IListener
+{
+ private final static long DEFAULT_TIMEOUT = 3000; // 3 seconds
+
+ private List<IEvent> events = new LinkedList<IEvent>();
+
+ private Class<? extends IEvent> eventClass;
+
+ private long timeout;
+
+ private String name;
+
+ public TestListener2(Class<? extends IEvent> eventClass)
+ {
+ this(eventClass, null);
+ }
+
+ public TestListener2(Class<? extends IEvent> eventClass, String name)
+ {
+ this.eventClass = eventClass;
+ this.name = name;
+ timeout = DEFAULT_TIMEOUT;
+ }
+
+ public synchronized void notifyEvent(IEvent event)
+ {
+ if (eventClass == null || eventClass.isAssignableFrom(event.getClass()))
+ {
+ events.add(event);
+ notify();
+ }
+ }
+
+ public List<IEvent> getEvents()
+ {
+ return events;
+ }
+
+ public void setTimeout(long timeout)
+ {
+ this.timeout = timeout;
+ }
+
+ public synchronized void waitFor(int n, long timeout)
+ {
+ long t = 0;
+
+ while (events.size() < n)
+ {
+ if (timeout <= 0)
+ {
+ Assert.fail("Timed out");
+ }
+
+ try
+ {
+ t = System.currentTimeMillis();
+ wait(timeout);
+ }
+ catch (InterruptedException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ timeout -= System.currentTimeMillis() - t;
+ }
+ }
+
+ public void waitFor(int i)
+ {
+ waitFor(i, timeout);
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder(TestListener2.class.getSimpleName());
+ builder.append('[');
+ if (name != null)
+ {
+ builder.append("name=\"");
+ builder.append(name);
+ builder.append('\"');
+ }
+
+ if (eventClass != null)
+ {
+ if (builder.charAt(builder.length() - 1) != '[')
+ {
+ builder.append(';');
+ }
+ builder.append("eventClass=");
+ builder.append(eventClass.getSimpleName());
+ }
+
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java
index d6a41099ff..1d84f3e1dd 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java
@@ -1,116 +1,116 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchImpl;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.StubCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-
-/**
- * @author Eike Stepper
- */
-public final class TestRevision extends StubCDORevision
-{
- private CDOID id;
-
- private CDOBranchPoint branchPoint;
-
- private int version;
-
- private long revised;
-
- public TestRevision(EClass eClass, long id, int version, long created, long revised)
- {
- super(eClass);
- this.id = CDOIDUtil.createLong(id);
- branchPoint = new CDOBranchImpl(null, CDOBranch.MAIN_BRANCH_ID, CDOBranch.MAIN_BRANCH_NAME, null).getPoint(created);
- this.version = version;
- this.revised = revised;
- }
-
- public TestRevision(EClass eClass, long id, int version, long created)
- {
- this(eClass, id, version, created, CDORevision.UNSPECIFIED_DATE);
- }
-
- public TestRevision(EClass eClass, long id)
- {
- this(eClass, id, 0, CDORevision.UNSPECIFIED_DATE);
- }
-
- @Override
- public CDOID getID()
- {
- return id;
- }
-
- @Override
- public void setID(CDOID id)
- {
- this.id = id;
- }
-
- @Override
- public CDOBranch getBranch()
- {
- return branchPoint.getBranch();
- }
-
- @Override
- public long getTimeStamp()
- {
- return branchPoint.getTimeStamp();
- }
-
- @Override
- public void setBranchPoint(CDOBranchPoint branchPoint)
- {
- this.branchPoint = CDOBranchUtil.copyBranchPoint(branchPoint);
- }
-
- @Override
- public int getVersion()
- {
- return version;
- }
-
- @Override
- public void setVersion(int version)
- {
- this.version = version;
- }
-
- @Override
- public long getRevised()
- {
- return revised;
- }
-
- @Override
- public void setRevised(long revised)
- {
- this.revised = revised;
- }
-
- @Override
- public InternalCDORevision copy()
- {
- return new TestRevision(getEClass(), CDOIDUtil.getLong(id), version, branchPoint.getTimeStamp(), revised);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.util;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.internal.common.branch.CDOBranchImpl;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.StubCDORevision;
+
+import org.eclipse.emf.ecore.EClass;
+
+/**
+ * @author Eike Stepper
+ */
+public final class TestRevision extends StubCDORevision
+{
+ private CDOID id;
+
+ private CDOBranchPoint branchPoint;
+
+ private int version;
+
+ private long revised;
+
+ public TestRevision(EClass eClass, long id, int version, long created, long revised)
+ {
+ super(eClass);
+ this.id = CDOIDUtil.createLong(id);
+ branchPoint = new CDOBranchImpl(null, CDOBranch.MAIN_BRANCH_ID, CDOBranch.MAIN_BRANCH_NAME, null).getPoint(created);
+ this.version = version;
+ this.revised = revised;
+ }
+
+ public TestRevision(EClass eClass, long id, int version, long created)
+ {
+ this(eClass, id, version, created, CDORevision.UNSPECIFIED_DATE);
+ }
+
+ public TestRevision(EClass eClass, long id)
+ {
+ this(eClass, id, 0, CDORevision.UNSPECIFIED_DATE);
+ }
+
+ @Override
+ public CDOID getID()
+ {
+ return id;
+ }
+
+ @Override
+ public void setID(CDOID id)
+ {
+ this.id = id;
+ }
+
+ @Override
+ public CDOBranch getBranch()
+ {
+ return branchPoint.getBranch();
+ }
+
+ @Override
+ public long getTimeStamp()
+ {
+ return branchPoint.getTimeStamp();
+ }
+
+ @Override
+ public void setBranchPoint(CDOBranchPoint branchPoint)
+ {
+ this.branchPoint = CDOBranchUtil.copyBranchPoint(branchPoint);
+ }
+
+ @Override
+ public int getVersion()
+ {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version)
+ {
+ this.version = version;
+ }
+
+ @Override
+ public long getRevised()
+ {
+ return revised;
+ }
+
+ @Override
+ public void setRevised(long revised)
+ {
+ this.revised = revised;
+ }
+
+ @Override
+ public InternalCDORevision copy()
+ {
+ return new TestRevision(getEClass(), CDOIDUtil.getLong(id), version, branchPoint.getTimeStamp(), revised);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java
index 3838072365..ba74c0a01d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java
@@ -1,126 +1,126 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
-import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
-
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.event.IListener;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class TestRevisionManager extends CDORevisionManagerImpl
-{
- private Object lock = new Object();
-
- private long getRevisionsDelay;
-
- private int loadCounter;
-
- private int additionalCounter;
-
- public TestRevisionManager()
- {
- }
-
- public void setGetRevisionsDelay(long millis)
- {
- synchronized (lock)
- {
- getRevisionsDelay = millis;
- }
- }
-
- @Override
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
- int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics)
- {
- if (getRevisionsDelay > 0)
- {
- long start = System.currentTimeMillis();
- for (;;)
- {
- ConcurrencyUtil.sleep(1L);
- synchronized (lock)
- {
- if (System.currentTimeMillis() > start + getRevisionsDelay)
- {
- break;
- }
- }
- }
- }
-
- return super.getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics);
- }
-
- @Override
- public void addListener(IListener listener)
- {
- super.addListener(listener);
- }
-
- public void resetLoadCounter()
- {
- synchronized (lock)
- {
- loadCounter = 0;
- }
- }
-
- public int getLoadCounter()
- {
- synchronized (lock)
- {
- return loadCounter;
- }
- }
-
- public void resetAdditionalCounter()
- {
- synchronized (lock)
- {
- additionalCounter = 0;
- }
- }
-
- public int getAdditionalCounter()
- {
- synchronized (lock)
- {
- return additionalCounter;
- }
- }
-
- @Override
- protected List<InternalCDORevision> loadRevisions(List<RevisionInfo> infosToLoad, CDOBranchPoint branchPoint,
- int referenceChunk, int prefetchDepth)
- {
- List<InternalCDORevision> result = super.loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth);
-
- synchronized (lock)
- {
- additionalCounter += result == null ? 0 : result.size();
- loadCounter += infosToLoad.size();
- }
-
- return result;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.util;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
+import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
+
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.event.IListener;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class TestRevisionManager extends CDORevisionManagerImpl
+{
+ private Object lock = new Object();
+
+ private long getRevisionsDelay;
+
+ private int loadCounter;
+
+ private int additionalCounter;
+
+ public TestRevisionManager()
+ {
+ }
+
+ public void setGetRevisionsDelay(long millis)
+ {
+ synchronized (lock)
+ {
+ getRevisionsDelay = millis;
+ }
+ }
+
+ @Override
+ public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
+ int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics)
+ {
+ if (getRevisionsDelay > 0)
+ {
+ long start = System.currentTimeMillis();
+ for (;;)
+ {
+ ConcurrencyUtil.sleep(1L);
+ synchronized (lock)
+ {
+ if (System.currentTimeMillis() > start + getRevisionsDelay)
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ return super.getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics);
+ }
+
+ @Override
+ public void addListener(IListener listener)
+ {
+ super.addListener(listener);
+ }
+
+ public void resetLoadCounter()
+ {
+ synchronized (lock)
+ {
+ loadCounter = 0;
+ }
+ }
+
+ public int getLoadCounter()
+ {
+ synchronized (lock)
+ {
+ return loadCounter;
+ }
+ }
+
+ public void resetAdditionalCounter()
+ {
+ synchronized (lock)
+ {
+ additionalCounter = 0;
+ }
+ }
+
+ public int getAdditionalCounter()
+ {
+ synchronized (lock)
+ {
+ return additionalCounter;
+ }
+ }
+
+ @Override
+ protected List<InternalCDORevision> loadRevisions(List<RevisionInfo> infosToLoad, CDOBranchPoint branchPoint,
+ int referenceChunk, int prefetchDepth)
+ {
+ List<InternalCDORevision> result = super.loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth);
+
+ synchronized (lock)
+ {
+ additionalCounter += result == null ? 0 : result.size();
+ loadCounter += infosToLoad.size();
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java
index 1317251a9b..bd54bb870b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java
@@ -1,107 +1,107 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
-import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
-import org.eclipse.emf.cdo.view.CDOFetchRuleManager;
-
-import org.eclipse.net4j.util.event.Notifier;
-
-/**
- * @author Eike Stepper
- */
-public abstract class TestSessionConfiguration extends Notifier implements CDOSessionConfiguration
-{
- public boolean isSessionOpen()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isActivateOnOpen()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setActivateOnOpen(boolean activateOnOpen)
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOAuthenticator getAuthenticator()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isPassiveUpdateEnabled()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setPassiveUpdateEnabled(boolean passiveUpdateEnabled)
- {
- throw new UnsupportedOperationException();
- }
-
- public PassiveUpdateMode getPassiveUpdateMode()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setPassiveUpdateMode(PassiveUpdateMode passiveUpdateMode)
- {
- throw new UnsupportedOperationException();
- }
-
- public LockNotificationMode getLockNotificationMode()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setLockNotificationMode(LockNotificationMode mode)
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOSession.ExceptionHandler getExceptionHandler()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setExceptionHandler(CDOSession.ExceptionHandler exceptionHandler)
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOIDGenerator getIDGenerator()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setIDGenerator(CDOIDGenerator idGenerator)
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOFetchRuleManager getFetchRuleManager()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setFetchRuleManager(CDOFetchRuleManager fetchRuleManager)
- {
- throw new UnsupportedOperationException();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.util;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
+import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
+import org.eclipse.emf.cdo.view.CDOFetchRuleManager;
+
+import org.eclipse.net4j.util.event.Notifier;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class TestSessionConfiguration extends Notifier implements CDOSessionConfiguration
+{
+ public boolean isSessionOpen()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isActivateOnOpen()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setActivateOnOpen(boolean activateOnOpen)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOAuthenticator getAuthenticator()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isPassiveUpdateEnabled()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setPassiveUpdateEnabled(boolean passiveUpdateEnabled)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PassiveUpdateMode getPassiveUpdateMode()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setPassiveUpdateMode(PassiveUpdateMode passiveUpdateMode)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public LockNotificationMode getLockNotificationMode()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setLockNotificationMode(LockNotificationMode mode)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOSession.ExceptionHandler getExceptionHandler()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setExceptionHandler(CDOSession.ExceptionHandler exceptionHandler)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOIDGenerator getIDGenerator()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setIDGenerator(CDOIDGenerator idGenerator)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOFetchRuleManager getFetchRuleManager()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setFetchRuleManager(CDOFetchRuleManager fetchRuleManager)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionManager.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionManager.java
index b82316fa14..77aefd9b09 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionManager.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionManager.java
@@ -1,71 +1,71 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.internal.server.SessionManager;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-
-import java.util.concurrent.CountDownLatch;
-
-/**
- * @author Caspar De Groot
- */
-public class TestSessionManager extends SessionManager
-{
- /**
- * Prevents other threads from changing/resetting the commitNotificationDelay while we are just about to execute the
- * delay.
- */
- private Object lock = new Object();
-
- private long commitNotificationDelay;
-
- /**
- * Allows tests to wait until the delay is about to commence
- */
- private CountDownLatch delayLatch;
-
- public void setCommitNotificationDelay(long millis)
- {
- synchronized (lock)
- {
- commitNotificationDelay = millis;
- if (commitNotificationDelay > 0)
- {
- delayLatch = new CountDownLatch(1);
- }
- }
- }
-
- public CountDownLatch getDelayLatch()
- {
- return delayLatch;
- }
-
- @Override
- public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo)
- {
- synchronized (lock)
- {
- if (commitNotificationDelay != 0)
- {
- delayLatch.countDown();
- Thread.yield();
- ConcurrencyUtil.sleep(commitNotificationDelay);
- }
- }
-
- super.sendCommitNotification(sender, commitInfo);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.util;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.internal.server.SessionManager;
+import org.eclipse.emf.cdo.spi.server.InternalSession;
+
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * @author Caspar De Groot
+ */
+public class TestSessionManager extends SessionManager
+{
+ /**
+ * Prevents other threads from changing/resetting the commitNotificationDelay while we are just about to execute the
+ * delay.
+ */
+ private Object lock = new Object();
+
+ private long commitNotificationDelay;
+
+ /**
+ * Allows tests to wait until the delay is about to commence
+ */
+ private CountDownLatch delayLatch;
+
+ public void setCommitNotificationDelay(long millis)
+ {
+ synchronized (lock)
+ {
+ commitNotificationDelay = millis;
+ if (commitNotificationDelay > 0)
+ {
+ delayLatch = new CountDownLatch(1);
+ }
+ }
+ }
+
+ public CountDownLatch getDelayLatch()
+ {
+ return delayLatch;
+ }
+
+ @Override
+ public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo)
+ {
+ synchronized (lock)
+ {
+ if (commitNotificationDelay != 0)
+ {
+ delayLatch.countDown();
+ Thread.yield();
+ ConcurrencyUtil.sleep(commitNotificationDelay);
+ }
+ }
+
+ super.sendCommitNotification(sender, commitInfo);
+ }
+}

Back to the top