summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-01-29 06:18:46 (EST)
committerEike Stepper2008-01-29 06:18:46 (EST)
commit2a9b4b469fbe567d7df2af7db196d996e982d77a (patch)
treee71293e92a6555992e6c5575e25ec57cd7edfad4
parent8b3a505531ad6d24be837d132ee50d7d94296195 (diff)
downloadcdo-2a9b4b469fbe567d7df2af7db196d996e982d77a.zip
cdo-2a9b4b469fbe567d7df2af7db196d996e982d77a.tar.gz
cdo-2a9b4b469fbe567d7df2af7db196d996e982d77a.tar.bz2
[204890] Implement detach
https://bugs.eclipse.org/bugs/show_bug.cgi?id=204890
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java52
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java48
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java54
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java181
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOState.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java63
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java3
11 files changed, 245 insertions, 196 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 833fbff..7d63bf4 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
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.server.CDOServerUtil;
import org.eclipse.emf.cdo.server.IRepository;
@@ -86,13 +87,13 @@ public abstract class AbstractCDOTest extends AbstractTransportTest
protected static void assertTransient(CDOObject object)
{
assertTrue(FSMUtil.isTransient(object));
- assertEquals(null, object.cdoID());
- assertEquals(null, object.cdoRevision());
- assertEquals(null, object.cdoView());
+ // assertEquals(null, object.cdoID());
+ // assertEquals(null, object.cdoRevision());
+ // assertEquals(null, object.cdoView());
assertEquals(object.eResource(), object.cdoResource());
}
- protected static void assertNotTransient(CDOObject object)
+ protected static void assertNotTransient(CDOObject object, CDOView view)
{
assertFalse(FSMUtil.isTransient(object));
assertNotNull(object.cdoID());
@@ -101,23 +102,25 @@ public abstract class AbstractCDOTest extends AbstractTransportTest
assertNotNull(object.cdoResource());
assertNotNull(object.eResource());
assertEquals(object.eResource(), object.cdoResource());
+ assertEquals(view, object.cdoView());
+ assertEquals(object, view.getObject(object.cdoID(), false));
}
- protected static void assertNew(CDOObject object)
+ protected static void assertNew(CDOObject object, CDOView view)
{
- assertNotTransient(object);
+ assertNotTransient(object, view);
assertEquals(CDOState.NEW, object.cdoState());
}
- protected static void assertDirty(CDOObject object)
+ protected static void assertDirty(CDOObject object, CDOView view)
{
- assertNotTransient(object);
+ assertNotTransient(object, view);
assertEquals(CDOState.DIRTY, object.cdoState());
}
- protected static void assertClean(CDOObject object)
+ protected static void assertClean(CDOObject object, CDOView view)
{
- assertNotTransient(object);
+ assertNotTransient(object, view);
assertEquals(CDOState.CLEAN, object.cdoState());
}
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 e9bd142..e4fcba9 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
@@ -24,6 +24,7 @@ public class AllTests
// $JUnit-BEGIN$
suite.addTestSuite(InitialTest.class);
+ suite.addTestSuite(StateMachineTest.class);
suite.addTestSuite(ResourceTest.class);
suite.addTestSuite(ContainmentTest.class);
suite.addTestSuite(InvalidationTest.class);
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 36e5f31..35b72f8 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
@@ -74,9 +74,9 @@ public class ContainmentTest extends AbstractCDOTest
msg("Committing");
transaction.commit();
- assertClean(resource);
- assertClean(company);
- assertClean(supplier);
+ assertClean(resource, transaction);
+ assertClean(company, transaction);
+ assertClean(supplier, transaction);
assertContent(resource, company);
assertContent(company, supplier);
}
@@ -118,11 +118,11 @@ public class ContainmentTest extends AbstractCDOTest
msg("Committing");
transaction.commit();
- assertClean(resource);
- assertClean(company);
- assertClean(category1);
- assertClean(category2);
- assertClean(category3);
+ assertClean(resource, transaction);
+ assertClean(company, transaction);
+ assertClean(category1, transaction);
+ assertClean(category2, transaction);
+ assertClean(category3, transaction);
assertContent(resource, company);
assertContent(company, category1);
assertContent(category1, category2);
@@ -177,25 +177,25 @@ public class ContainmentTest extends AbstractCDOTest
EList<EObject> contents = resource.getContents();
Company company = (Company)contents.get(0);
- assertClean(company);
- assertClean(resource);
+ assertClean(company, transaction);
+ assertClean(resource, transaction);
assertContent(resource, company);
Category category1 = company.getCategories().get(0);
- assertClean(category1);
- assertClean(company);
+ assertClean(category1, transaction);
+ assertClean(company, transaction);
assertContent(company, category1);
Category category2 = category1.getCategories().get(0);
- assertClean(category2);
- assertClean(category1);
+ assertClean(category2, transaction);
+ assertClean(category1, transaction);
assertContent(category1, category2);
Category category3 = category2.getCategories().get(0);
- assertClean(category3);
- assertClean(category2);
+ assertClean(category3, transaction);
+ assertClean(category2, transaction);
assertContent(category2, category3);
- assertClean(category3);
+ assertClean(category3, transaction);
}
public void testSeparateSession() throws Exception
@@ -249,24 +249,24 @@ public class ContainmentTest extends AbstractCDOTest
EList<EObject> contents = resource.getContents();
Company company = (Company)contents.get(0);
- assertClean(company);
- assertClean(resource);
+ assertClean(company, transaction);
+ assertClean(resource, transaction);
assertContent(resource, company);
Category category1 = company.getCategories().get(0);
- assertClean(category1);
- assertClean(company);
+ assertClean(category1, transaction);
+ assertClean(company, transaction);
assertContent(company, category1);
Category category2 = category1.getCategories().get(0);
- assertClean(category2);
- assertClean(category1);
+ assertClean(category2, transaction);
+ assertClean(category1, transaction);
assertContent(category1, category2);
Category category3 = category2.getCategories().get(0);
- assertClean(category3);
- assertClean(category2);
+ assertClean(category3, transaction);
+ assertClean(category2, transaction);
assertContent(category2, category3);
- assertClean(category3);
+ assertClean(category3, transaction);
}
}
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 8ee4607..02c92ff 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
@@ -79,25 +79,25 @@ public class CrossReferenceTest extends AbstractCDOTest
EList<EObject> contents = resourceB.getContents();
Company companyB = (Company)contents.get(0);
- assertClean(companyB);
- assertClean(resourceB);
+ assertClean(companyB, viewB);
+ assertClean(resourceB, viewB);
assertContent(resourceB, companyB);
Customer customerB = companyB.getCustomers().get(0);
- assertClean(customerB);
- assertClean(companyB);
+ assertClean(customerB, viewB);
+ assertClean(companyB, viewB);
assertContent(companyB, customerB);
SalesOrder salesOrder1B = companyB.getSalesOrders().get(0);
- assertClean(salesOrder1B);
- assertClean(companyB);
+ assertClean(salesOrder1B, viewB);
+ assertClean(companyB, viewB);
assertContent(companyB, salesOrder1B);
SalesOrder salesOrder2B = companyB.getSalesOrders().get(1);
- assertClean(salesOrder2B);
- assertClean(companyB);
+ assertClean(salesOrder2B, viewB);
+ assertClean(companyB, viewB);
assertContent(companyB, salesOrder2B);
- assertClean(salesOrder2B);
+ assertClean(salesOrder2B, viewB);
assertEquals(2, customerB.getSalesOrders().size());
}
@@ -154,25 +154,25 @@ public class CrossReferenceTest extends AbstractCDOTest
EList<EObject> contents = resourceB.getContents();
Company companyB = (Company)contents.get(0);
- assertClean(companyB);
- assertClean(resourceB);
+ assertClean(companyB, viewB);
+ assertClean(resourceB, viewB);
assertContent(resourceB, companyB);
Customer customerB = companyB.getCustomers().get(0);
- assertClean(customerB);
- assertClean(companyB);
+ assertClean(customerB, viewB);
+ assertClean(companyB, viewB);
assertContent(companyB, customerB);
SalesOrder salesOrder1B = customerB.getSalesOrders().get(0);
- assertClean(salesOrder1B);
- assertClean(companyB);
+ assertClean(salesOrder1B, viewB);
+ assertClean(companyB, viewB);
assertContent(companyB, salesOrder1B);
SalesOrder salesOrder2B = customerB.getSalesOrders().get(1);
- assertClean(salesOrder2B);
- assertClean(companyB);
+ assertClean(salesOrder2B, viewB);
+ assertClean(companyB, viewB);
assertContent(companyB, salesOrder2B);
- assertClean(salesOrder2B);
+ assertClean(salesOrder2B, viewB);
}
public void testTwoResources() throws Exception
@@ -244,19 +244,19 @@ public class CrossReferenceTest extends AbstractCDOTest
EList<EObject> contents = resource1B.getContents();
Company company1B = (Company)contents.get(0);
- assertClean(company1B);
- assertClean(resource1B);
+ assertClean(company1B, viewB);
+ assertClean(resource1B, viewB);
assertContent(resource1B, company1B);
Customer customerB = company1B.getCustomers().get(0);
- assertClean(customerB);
- assertClean(company1B);
+ assertClean(customerB, viewB);
+ assertClean(company1B, viewB);
assertContent(company1B, customerB);
SalesOrder salesOrder1B = customerB.getSalesOrders().get(0);
- assertClean(salesOrder1B);
+ assertClean(salesOrder1B, viewB);
SalesOrder salesOrder2B = customerB.getSalesOrders().get(1);
- assertClean(salesOrder2B);
+ assertClean(salesOrder2B, viewB);
}
}
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 175bc1d..6bb65cd 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
@@ -139,7 +139,7 @@ public class InitialTest extends AbstractCDOTest
msg("Creating resource");
CDOResource resource = transaction.createResource("/test1");
- assertNew(resource);
+ assertNew(resource, transaction);
assertEquals(URI.createURI("cdo:/test1"), resource.getURI());
ResourceSet expected = transaction.getResourceSet();
ResourceSet actual = resource.getResourceSet();
@@ -165,7 +165,7 @@ public class InitialTest extends AbstractCDOTest
CDOTransaction transaction = session.openTransaction(resourceSet);
msg("Verifying resource");
- assertNew(resource);
+ assertNew(resource, transaction);
assertEquals(uri, resource.getURI());
assertEquals(transaction.getResourceSet(), resource.getResourceSet());
}
@@ -213,7 +213,7 @@ public class InitialTest extends AbstractCDOTest
CDOTransaction transaction = session.openTransaction(resourceSet);
msg("Verifying resource");
- assertNew(resource);
+ assertNew(resource, transaction);
assertEquals(uri, resource.getURI());
assertEquals(transaction.getResourceSet(), resource.getResourceSet());
@@ -224,8 +224,8 @@ public class InitialTest extends AbstractCDOTest
msg("Verifying supplier");
Supplier s = (Supplier)contents.get(0);
- assertNew(supplier);
- assertNew(resource);
+ assertNew(supplier, transaction);
+ assertNew(resource, transaction);
assertEquals(supplier, s);
assertEquals(resource, s.cdoResource());
assertEquals(null, s.eContainer());
@@ -253,7 +253,7 @@ public class InitialTest extends AbstractCDOTest
msg("Adding supplier");
contents.add(supplier);
- assertNew(supplier);
+ assertNew(supplier, transaction);
assertEquals(transaction, supplier.cdoView());
assertEquals(resource, supplier.cdoResource());
assertEquals(resource, supplier.eResource());
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 85e8358..5ed5141 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
@@ -83,25 +83,25 @@ public class InvalidationTest extends AbstractCDOTest
EList<EObject> contents = resourceB.getContents();
final Company companyB = (Company)contents.get(0);
- assertClean(companyB);
- assertClean(resourceB);
+ assertClean(companyB, view);
+ assertClean(resourceB, view);
assertContent(resourceB, companyB);
final Category category1B = companyB.getCategories().get(0);
- assertClean(category1B);
- assertClean(companyB);
+ assertClean(category1B, view);
+ assertClean(companyB, view);
assertContent(companyB, category1B);
final Category category2B = category1B.getCategories().get(0);
- assertClean(category2B);
- assertClean(category1B);
+ assertClean(category2B, view);
+ assertClean(category1B, view);
assertContent(category1B, category2B);
final Category category3B = category2B.getCategories().get(0);
- assertClean(category3B);
- assertClean(category2B);
+ assertClean(category3B, view);
+ assertClean(category2B, view);
assertContent(category2B, category3B);
- assertClean(category3B);
+ assertClean(category3B, view);
// ************************************************************* //
@@ -179,25 +179,25 @@ public class InvalidationTest extends AbstractCDOTest
EList<EObject> contents = resourceB.getContents();
final Company companyB = (Company)contents.get(0);
- assertClean(companyB);
- assertClean(resourceB);
+ assertClean(companyB, viewB);
+ assertClean(resourceB, viewB);
assertContent(resourceB, companyB);
final Category category1B = companyB.getCategories().get(0);
- assertClean(category1B);
- assertClean(companyB);
+ assertClean(category1B, viewB);
+ assertClean(companyB, viewB);
assertContent(companyB, category1B);
final Category category2B = category1B.getCategories().get(0);
- assertClean(category2B);
- assertClean(category1B);
+ assertClean(category2B, viewB);
+ assertClean(category1B, viewB);
assertContent(category1B, category2B);
final Category category3B = category2B.getCategories().get(0);
- assertClean(category3B);
- assertClean(category2B);
+ assertClean(category3B, viewB);
+ assertClean(category2B, viewB);
assertContent(category2B, category3B);
- assertClean(category3B);
+ assertClean(category3B, viewB);
// ************************************************************* //
@@ -293,25 +293,25 @@ public class InvalidationTest extends AbstractCDOTest
EList<EObject> contents = resourceB.getContents();
final Company companyB = (Company)contents.get(0);
- assertClean(companyB);
- assertClean(resourceB);
+ assertClean(companyB, viewB);
+ assertClean(resourceB, viewB);
assertContent(resourceB, companyB);
final Category category1B = companyB.getCategories().get(0);
- assertClean(category1B);
- assertClean(companyB);
+ assertClean(category1B, viewB);
+ assertClean(companyB, viewB);
assertContent(companyB, category1B);
final Category category2B = category1B.getCategories().get(0);
- assertClean(category2B);
- assertClean(category1B);
+ assertClean(category2B, viewB);
+ assertClean(category1B, viewB);
assertContent(category1B, category2B);
final Category category3B = category2B.getCategories().get(0);
- assertClean(category3B);
- assertClean(category2B);
+ assertClean(category3B, viewB);
+ assertClean(category2B, viewB);
assertContent(category2B, category3B);
- assertClean(category3B);
+ assertClean(category3B, viewB);
// ************************************************************* //
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 88665fc..187e2e9 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
@@ -36,13 +36,15 @@ public class StateMachineTest extends AbstractCDOTest
{
private static final long TIMESTAMP = 12345678L;
- public void test__TRANSIENT__ATTACH() throws Exception
+ // ///////////////////////////////////////////////////
+
+ public void test_TRANSIENT_with_ATTACH() throws Exception
{
// Attach resource
CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource("/test1");
- assertNew(resource);
+ assertNew(resource, transaction);
assertEquals(URI.createURI("cdo:/test1"), resource.getURI());
assertEquals(transaction.getResourceSet(), resource.getResourceSet());
@@ -51,7 +53,7 @@ public class StateMachineTest extends AbstractCDOTest
supplier.setName("Stepper");
assertTransient(supplier);
resource.getContents().add(supplier);
- assertNew(supplier);
+ assertNew(supplier, transaction);
assertEquals(transaction, supplier.cdoView());
assertEquals(resource, supplier.cdoResource());
assertEquals(resource, supplier.eResource());
@@ -78,14 +80,14 @@ public class StateMachineTest extends AbstractCDOTest
assertTransient(p2);
assertTransient(p3);
resource.getContents().add(cat1);
- assertNew(cat1);
- assertNew(cat2);
- assertNew(p1);
- assertNew(p2);
- assertNew(p3);
+ assertNew(cat1, transaction);
+ assertNew(cat2, transaction);
+ assertNew(p1, transaction);
+ assertNew(p2, transaction);
+ assertNew(p3, transaction);
}
- public void test__TRANSIENT__DETACH() throws Exception
+ public void test_TRANSIENT_with_DETACH() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
@@ -101,7 +103,7 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__TRANSIENT__READ() throws Exception
+ public void test_TRANSIENT_with_READ() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
@@ -109,7 +111,7 @@ public class StateMachineTest extends AbstractCDOTest
CDOStateMachine.INSTANCE.read((InternalCDOObject)supplier);
}
- public void test__TRANSIENT__WRITE() throws Exception
+ public void test_TRANSIENT_with_WRITE() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
@@ -117,7 +119,7 @@ public class StateMachineTest extends AbstractCDOTest
CDOStateMachine.INSTANCE.write((InternalCDOObject)supplier);
}
- public void test__TRANSIENT__INVALIDATE() throws Exception
+ public void test_TRANSIENT_with_INVALIDATE() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
@@ -133,7 +135,7 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__TRANSIENT__RELOAD() throws Exception
+ public void test_TRANSIENT_with_RELOAD() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
@@ -142,7 +144,7 @@ public class StateMachineTest extends AbstractCDOTest
assertTransient(supplier);
}
- public void test__TRANSIENT__COMMIT() throws Exception
+ public void test_TRANSIENT_with_COMMIT() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
@@ -158,7 +160,7 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__TRANSIENT__ROLLBACK() throws Exception
+ public void test_TRANSIENT_with_ROLLBACK() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
@@ -187,11 +189,13 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__PREPARED_ATTACH__ATTACH() throws Exception
+ // ///////////////////////////////////////////////////
+
+ public void test_PREPARED_with_ATTACH() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
- ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED_ATTACH);
+ ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED);
try
{
attach(supplier);
@@ -202,11 +206,11 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__PREPARED_ATTACH__DETACH() throws Exception
+ public void test_PREPARED_with_DETACH() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
- ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED_ATTACH);
+ ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED);
try
{
CDOStateMachine.INSTANCE.detach((InternalCDOObject)supplier);
@@ -218,20 +222,20 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__PREPARED_ATTACH__READ() throws Exception
+ public void test_PREPARED_with_READ() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
- ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED_ATTACH);
+ ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED);
CDOStateMachine.INSTANCE.read((InternalCDOObject)supplier);
- assertEquals(CDOState.PREPARED_ATTACH, supplier.cdoState());
+ assertEquals(CDOState.PREPARED, supplier.cdoState());
}
- public void test__PREPARED_ATTACH__WRITE() throws Exception
+ public void test_PREPARED_with_WRITE() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
- ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED_ATTACH);
+ ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED);
try
{
CDOStateMachine.INSTANCE.write((InternalCDOObject)supplier);
@@ -243,11 +247,11 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__PREPARED_ATTACH__INVALIDATE() throws Exception
+ public void test_PREPARED_with_INVALIDATE() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
- ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED_ATTACH);
+ ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED);
try
{
CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)supplier, TIMESTAMP);
@@ -259,11 +263,11 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__PREPARED_ATTACH__RELOAD() throws Exception
+ public void test_PREPARED_with_RELOAD() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
- ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED_ATTACH);
+ ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED);
try
{
reload(supplier);
@@ -275,11 +279,11 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__PREPARED_ATTACH__COMMIT() throws Exception
+ public void test_PREPARED_with_COMMIT() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
- ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED_ATTACH);
+ ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED);
try
{
CDOStateMachine.INSTANCE.commit((InternalCDOObject)supplier, new CommitTransactionResult(TIMESTAMP));
@@ -291,11 +295,11 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__PREPARED_ATTACH__ROLLBACK() throws Exception
+ public void test_PREPARED_with_ROLLBACK() throws Exception
{
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
supplier.setName("Stepper");
- ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED_ATTACH);
+ ((InternalCDOObject)supplier).cdoInternalSetState(CDOState.PREPARED);
try
{
CDOStateMachine.INSTANCE.rollback((InternalCDOObject)supplier, false);
@@ -307,166 +311,199 @@ public class StateMachineTest extends AbstractCDOTest
}
}
- public void test__NEW__ATTACH() throws Exception
+ // ///////////////////////////////////////////////////
+
+ public void test_NEW_with_ATTACH() throws Exception
{
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+ assertNew(resource, transaction);
+
+ Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
+ supplier.setName("Stepper");
+ resource.getContents().add(supplier); // ATTACH
+ assertNew(supplier, transaction);
}
- public void test__NEW__DETACH() throws Exception
+ public void _test_NEW_with_DETACH() throws Exception
{
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+ assertNew(resource, transaction);
+
+ Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
+ supplier.setName("Stepper");
+ resource.getContents().add(supplier); // ATTACH
+ assertNew(supplier, transaction);
+
+ CDOStateMachine.INSTANCE.detach((InternalCDOObject)supplier);
+ assertTransient(supplier);
}
- public void test__NEW__READ() throws Exception
+ public void test_NEW_with_READ() throws Exception
{
}
- public void test__NEW__WRITE() throws Exception
+ public void test_NEW_with_WRITE() throws Exception
{
}
- public void test__NEW__INVALIDATE() throws Exception
+ public void test_NEW_with_INVALIDATE() throws Exception
{
}
- public void test__NEW__RELOAD() throws Exception
+ public void test_NEW_with_RELOAD() throws Exception
{
}
- public void test__NEW__COMMIT() throws Exception
+ public void test_NEW_with_COMMIT() throws Exception
{
}
- public void test__NEW__ROLLBACK() throws Exception
+ public void test_NEW_with_ROLLBACK() throws Exception
{
}
- public void test__CLEAN__ATTACH() throws Exception
+ // ///////////////////////////////////////////////////
+
+ public void test_CLEAN_with_ATTACH() throws Exception
{
}
- public void test__CLEAN__DETACH() throws Exception
+ public void test_CLEAN_with_DETACH() throws Exception
{
}
- public void test__CLEAN__READ() throws Exception
+ public void test_CLEAN_with_READ() throws Exception
{
}
- public void test__CLEAN__WRITE() throws Exception
+ public void test_CLEAN_with_WRITE() throws Exception
{
}
- public void test__CLEAN__INVALIDATE() throws Exception
+ public void test_CLEAN_with_INVALIDATE() throws Exception
{
}
- public void test__CLEAN__RELOAD() throws Exception
+ public void test_CLEAN_with_RELOAD() throws Exception
{
}
- public void test__CLEAN__COMMIT() throws Exception
+ public void test_CLEAN_with_COMMIT() throws Exception
{
}
- public void test__CLEAN__ROLLBACK() throws Exception
+ public void test_CLEAN_with_ROLLBACK() throws Exception
{
}
- public void test__DIRTY__ATTACH() throws Exception
+ // ///////////////////////////////////////////////////
+
+ public void test_DIRTY_with_ATTACH() throws Exception
{
}
- public void test__DIRTY__DETACH() throws Exception
+ public void test_DIRTY_with_DETACH() throws Exception
{
}
- public void test__DIRTY__READ() throws Exception
+ public void test_DIRTY_with_READ() throws Exception
{
}
- public void test__DIRTY__WRITE() throws Exception
+ public void test_DIRTY_with_WRITE() throws Exception
{
}
- public void test__DIRTY__INVALIDATE() throws Exception
+ public void test_DIRTY_with_INVALIDATE() throws Exception
{
}
- public void test__DIRTY__RELOAD() throws Exception
+ public void test_DIRTY_with_RELOAD() throws Exception
{
}
- public void test__DIRTY__COMMIT() throws Exception
+ public void test_DIRTY_with_COMMIT() throws Exception
{
}
- public void test__DIRTY__ROLLBACK() throws Exception
+ public void test_DIRTY_with_ROLLBACK() throws Exception
{
}
- public void test__PROXY__ATTACH() throws Exception
+ // ///////////////////////////////////////////////////
+
+ public void test_PROXY_with_ATTACH() throws Exception
{
}
- public void test__PROXY__DETACH() throws Exception
+ public void test_PROXY_with_DETACH() throws Exception
{
}
- public void test__PROXY__READ() throws Exception
+ public void test_PROXY_with_READ() throws Exception
{
}
- public void test__PROXY__WRITE() throws Exception
+ public void test_PROXY_with_WRITE() throws Exception
{
}
- public void test__PROXY__INVALIDATE() throws Exception
+ public void test_PROXY_with_INVALIDATE() throws Exception
{
}
- public void test__PROXY__RELOAD() throws Exception
+ public void test_PROXY_with_RELOAD() throws Exception
{
}
- public void test__PROXY__COMMIT() throws Exception
+ public void test_PROXY_with_COMMIT() throws Exception
{
}
- public void test__PROXY__ROLLBACK() throws Exception
+ public void test_PROXY_with_ROLLBACK() throws Exception
{
}
- public void test__CONFLICT__ATTACH() throws Exception
+ // ///////////////////////////////////////////////////
+
+ public void test_CONFLICT_with_ATTACH() throws Exception
{
}
- public void test__CONFLICT__DETACH() throws Exception
+ public void test_CONFLICT_with_DETACH() throws Exception
{
}
- public void test__CONFLICT__READ() throws Exception
+ public void test_CONFLICT_with_READ() throws Exception
{
}
- public void test__CONFLICT__WRITE() throws Exception
+ public void test_CONFLICT_with_WRITE() throws Exception
{
}
- public void test__CONFLICT__INVALIDATE() throws Exception
+ public void test_CONFLICT_with_INVALIDATE() throws Exception
{
}
- public void test__CONFLICT__RELOAD() throws Exception
+ public void test_CONFLICT_with_RELOAD() throws Exception
{
}
- public void test__CONFLICT__COMMIT() throws Exception
+ public void test_CONFLICT_with_COMMIT() throws Exception
{
}
- public void test__CONFLICT__ROLLBACK() throws Exception
+ public void test_CONFLICT_with_ROLLBACK() throws Exception
{
}
+ // ///////////////////////////////////////////////////
+
@Override
protected boolean useJVMTransport()
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOState.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOState.java
index 7641fba..da60ec4 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOState.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOState.java
@@ -15,5 +15,5 @@ package org.eclipse.emf.cdo;
*/
public enum CDOState
{
- TRANSIENT, NEW, CLEAN, DIRTY, PROXY, CONFLICT, PREPARED_ATTACH
+ TRANSIENT, NEW, CLEAN, DIRTY, PROXY, CONFLICT, PREPARED
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index 2ee44c7..925c1d9 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -64,7 +64,8 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
{
super(CDOState.class, CDOEvent.class);
- init(CDOState.TRANSIENT, CDOEvent.ATTACH, new PrepareAttachTransition());
+ init(CDOState.TRANSIENT, CDOEvent.PREPARE, new PrepareTransition());
+ init(CDOState.TRANSIENT, CDOEvent.ATTACH, FAIL);
init(CDOState.TRANSIENT, CDOEvent.DETACH, FAIL);
init(CDOState.TRANSIENT, CDOEvent.READ, IGNORE);
init(CDOState.TRANSIENT, CDOEvent.WRITE, IGNORE);
@@ -73,17 +74,19 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
init(CDOState.TRANSIENT, CDOEvent.COMMIT, FAIL);
init(CDOState.TRANSIENT, CDOEvent.ROLLBACK, FAIL);
- init(CDOState.PREPARED_ATTACH, CDOEvent.ATTACH, new FinalizeAttachTransition());
- init(CDOState.PREPARED_ATTACH, CDOEvent.DETACH, FAIL);
- init(CDOState.PREPARED_ATTACH, CDOEvent.READ, IGNORE);
- init(CDOState.PREPARED_ATTACH, CDOEvent.WRITE, FAIL);
- init(CDOState.PREPARED_ATTACH, CDOEvent.INVALIDATE, FAIL);
- init(CDOState.PREPARED_ATTACH, CDOEvent.RELOAD, FAIL);
- init(CDOState.PREPARED_ATTACH, CDOEvent.COMMIT, FAIL);
- init(CDOState.PREPARED_ATTACH, CDOEvent.ROLLBACK, FAIL);
-
+ init(CDOState.PREPARED, CDOEvent.PREPARE, FAIL);
+ init(CDOState.PREPARED, CDOEvent.ATTACH, new AttachTransition());
+ init(CDOState.PREPARED, CDOEvent.DETACH, FAIL);
+ init(CDOState.PREPARED, CDOEvent.READ, IGNORE);
+ init(CDOState.PREPARED, CDOEvent.WRITE, FAIL);
+ init(CDOState.PREPARED, CDOEvent.INVALIDATE, FAIL);
+ init(CDOState.PREPARED, CDOEvent.RELOAD, FAIL);
+ init(CDOState.PREPARED, CDOEvent.COMMIT, FAIL);
+ init(CDOState.PREPARED, CDOEvent.ROLLBACK, FAIL);
+
+ init(CDOState.NEW, CDOEvent.PREPARE, FAIL);
init(CDOState.NEW, CDOEvent.ATTACH, FAIL);
- init(CDOState.NEW, CDOEvent.DETACH, FAIL);
+ init(CDOState.NEW, CDOEvent.DETACH, IGNORE);
init(CDOState.NEW, CDOEvent.READ, IGNORE);
init(CDOState.NEW, CDOEvent.WRITE, IGNORE);
init(CDOState.NEW, CDOEvent.INVALIDATE, FAIL);
@@ -91,8 +94,9 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
init(CDOState.NEW, CDOEvent.COMMIT, new CommitTransition());
init(CDOState.NEW, CDOEvent.ROLLBACK, FAIL);
+ init(CDOState.CLEAN, CDOEvent.PREPARE, FAIL);
init(CDOState.CLEAN, CDOEvent.ATTACH, FAIL);
- init(CDOState.CLEAN, CDOEvent.DETACH, FAIL);
+ init(CDOState.CLEAN, CDOEvent.DETACH, IGNORE);
init(CDOState.CLEAN, CDOEvent.READ, IGNORE);
init(CDOState.CLEAN, CDOEvent.WRITE, new WriteTransition());
init(CDOState.CLEAN, CDOEvent.INVALIDATE, new InvalidateTransition());
@@ -100,8 +104,9 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
init(CDOState.CLEAN, CDOEvent.COMMIT, FAIL);
init(CDOState.CLEAN, CDOEvent.ROLLBACK, FAIL);
+ init(CDOState.DIRTY, CDOEvent.PREPARE, FAIL);
init(CDOState.DIRTY, CDOEvent.ATTACH, FAIL);
- init(CDOState.DIRTY, CDOEvent.DETACH, FAIL);
+ init(CDOState.DIRTY, CDOEvent.DETACH, IGNORE);
init(CDOState.DIRTY, CDOEvent.READ, IGNORE);
init(CDOState.DIRTY, CDOEvent.WRITE, new RewriteTransition());
init(CDOState.DIRTY, CDOEvent.INVALIDATE, new ConflictTransition());
@@ -109,8 +114,9 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
init(CDOState.DIRTY, CDOEvent.COMMIT, new CommitTransition());
init(CDOState.DIRTY, CDOEvent.ROLLBACK, new RollbackTransition());
- init(CDOState.PROXY, CDOEvent.ATTACH, new LoadResourceTransition());
- init(CDOState.PROXY, CDOEvent.DETACH, new DetachTransition());
+ init(CDOState.PROXY, CDOEvent.PREPARE, new LoadResourceTransition());// Resources start in PROXY instead TRANSIENT
+ init(CDOState.PROXY, CDOEvent.ATTACH, IGNORE);// Resources must not FAIL
+ init(CDOState.PROXY, CDOEvent.DETACH, IGNORE);
init(CDOState.PROXY, CDOEvent.READ, new LoadTransition(false));
init(CDOState.PROXY, CDOEvent.WRITE, new LoadTransition(true));
init(CDOState.PROXY, CDOEvent.INVALIDATE, IGNORE);
@@ -118,6 +124,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
init(CDOState.PROXY, CDOEvent.COMMIT, FAIL);
init(CDOState.PROXY, CDOEvent.ROLLBACK, FAIL);
+ init(CDOState.CONFLICT, CDOEvent.PREPARE, FAIL);
init(CDOState.CONFLICT, CDOEvent.ATTACH, IGNORE);
init(CDOState.CONFLICT, CDOEvent.DETACH, IGNORE);
init(CDOState.CONFLICT, CDOEvent.READ, IGNORE);
@@ -134,18 +141,18 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
data.resource = resource;
data.view = view;
- // Phase 1: TRANSIENT --> PREPARED_ATTACH
+ // Phase 1: TRANSIENT --> PREPARED
if (TRACER.isEnabled())
{
- TRACER.format("ATTACH: {0} --> {1}", object, view);
+ TRACER.format("PREPARE: {0} --> {1}", object, view);
}
- process(object, CDOEvent.ATTACH, data);
+ process(object, CDOEvent.PREPARE, data);
- // Phase 2: PREPARED_ATTACH --> NEW
+ // Phase 2: PREPARED --> NEW
if (TRACER.isEnabled())
{
- TRACER.format("FINALIZE_ATTACH: {0} --> {1}", object, view);
+ TRACER.format("ATTACH: {0} --> {1}", object, view);
}
process(object, CDOEvent.ATTACH, null);
@@ -195,7 +202,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
for (InternalCDOObject object : objects)
{
CDOState state = object.cdoState();
- if (state != CDOState.TRANSIENT && state != CDOState.PREPARED_ATTACH && state != CDOState.NEW
+ if (state != CDOState.TRANSIENT && state != CDOState.PREPARED && state != CDOState.NEW
&& state != CDOState.CONFLICT)
{
if (view == null)
@@ -332,8 +339,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
/**
* @author Eike Stepper
*/
- private final class PrepareAttachTransition implements
- ITransition<CDOState, CDOEvent, InternalCDOObject, ResourceAndView>
+ private final class PrepareTransition implements ITransition<CDOState, CDOEvent, InternalCDOObject, ResourceAndView>
{
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, ResourceAndView data)
{
@@ -345,7 +351,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
object.cdoInternalSetID(id);
object.cdoInternalSetResource(data.resource);
object.cdoInternalSetView(data.view);
- changeState(object, CDOState.PREPARED_ATTACH);
+ changeState(object, CDOState.PREPARED);
// Create new revision
InternalCDORevision revision = (InternalCDORevision)CDORevisionUtil
@@ -362,7 +368,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
for (Iterator<InternalCDOObject> it = FSMUtil.iterator(object.eContents(), transaction); it.hasNext();)
{
InternalCDOObject content = it.next();
- INSTANCE.process(content, CDOEvent.ATTACH, data);
+ INSTANCE.process(content, CDOEvent.PREPARE, data);
}
}
}
@@ -370,7 +376,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
/**
* @author Eike Stepper
*/
- private final class FinalizeAttachTransition implements ITransition<CDOState, CDOEvent, InternalCDOObject, Object>
+ private final class AttachTransition implements ITransition<CDOState, CDOEvent, InternalCDOObject, Object>
{
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object NULL)
{
@@ -394,8 +400,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
{
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object NULL)
{
- // TODO Implement method DetachTransition.execute()
- throw new UnsupportedOperationException("Not yet implemented");
+ // object.cdoInternalSetState(CDOState.TRANSIENT);
}
}
@@ -622,5 +627,5 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
*/
enum CDOEvent
{
- ATTACH, DETACH, READ, WRITE, INVALIDATE, RELOAD, COMMIT, ROLLBACK
+ PREPARE, ATTACH, DETACH, READ, WRITE, INVALIDATE, RELOAD, COMMIT, ROLLBACK
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 462e883..6b98524 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -734,6 +734,8 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
catch (RuntimeException ex)
{
+ OM.LOG.error(ex);
+
try
{
((InternalCDOObject)cdoResource).cdoInternalSetState(CDOState.NEW);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index f1c6926..288c2da 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -74,7 +74,8 @@ public final class FSMUtil
public static boolean isTransient(CDOObject object)
{
CDOState state = object.cdoState();
- return state == CDOState.TRANSIENT || state == CDOState.PREPARED_ATTACH;
+ return state == CDOState.TRANSIENT || state == CDOState.PREPARED;
+ // TODO || state == CDOState.PROXY && object instanceof CDOResource;
}
/**