Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2011-07-12 12:46:12 -0400
committerMartin Fluegge2011-07-12 12:46:12 -0400
commita7dca8749a796c0e7fbe678922d52e44db5b94ee (patch)
tree0e4495fa1eeac9b82a7f6ce1085a8bf866cfbf8c
parentb60ce23d40163785d0c6d09a0e4ca2a85867fdc7 (diff)
downloadcdo-a7dca8749a796c0e7fbe678922d52e44db5b94ee.tar.gz
cdo-a7dca8749a796c0e7fbe678922d52e44db5b94ee.tar.xz
cdo-a7dca8749a796c0e7fbe678922d52e44db5b94ee.zip
[337886] [Legacy] Bugzilla_305527_Test.testAvoidReferencingDifferentViews() fails in Legacy
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337886
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_305527_Test.java55
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java23
2 files changed, 9 insertions, 69 deletions
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 b9b510f29a..32900b0b0f 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
@@ -15,16 +15,10 @@ 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.tests.mango.MangoValueList;
-import org.eclipse.emf.cdo.tests.model1.Category;
-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;
-
/**
* @author Martin Fluegge
* @since 4.0
@@ -33,7 +27,6 @@ public class Bugzilla_305527_Test extends AbstractCDOTest
{
public void testAvoidReferencingDifferentViews() throws CommitException
{
- skipConfig(LEGACY);
skipUnlessAuditing();
final CDOSession session = openSession();
long commitTime;
@@ -71,53 +64,7 @@ public class Bugzilla_305527_Test extends AbstractCDOTest
catch (IllegalArgumentException expected)
{
// SUCCESS
+ expected.printStackTrace();
}
}
-
- /**
- * Martin: What's this test supposed to test?
- */
- public void _testOppositeSettingValidation() throws CommitException
- {
- CDOSession openSession = openSession();
- CDOTransaction transaction1 = openSession.openTransaction();
- CDOResource resource1 = transaction1.createResource(getResourcePath("test"));
-
- Customer customer1 = getModel1Factory().createCustomer();
- Customer customer2 = getModel1Factory().createCustomer();
- SalesOrder salesOrder1 = getModel1Factory().createSalesOrder();
- salesOrder1.setCustomer(customer1);
-
- resource1.getContents().add(customer1);
- resource1.getContents().add(customer2);
- resource1.getContents().add(salesOrder1);
-
- Category createCategory = getModel1Factory().createCategory();
-
- resource1.getContents().add(createCategory);
- resource1.getContents().add(getModel1Factory().createProduct1());
- transaction1.commit();
-
- CDOTransaction transaction2 = openSession.openTransaction();
- CDOResource resource2 = transaction2.getResource(getResourcePath("test"));
-
- SalesOrder salesOrderFound = (SalesOrder)resource2.getContents().get(2);
- resource2.getContents().add(salesOrderFound);
-
- assertEquals(CDOUtil.getCDOObject(salesOrder1).cdoID(), CDOUtil.getCDOObject(salesOrderFound).cdoID());
- assertEquals(CDOUtil.getCDOObject(salesOrder1).cdoID(),
- CDOUtil.getCDOObject(salesOrderFound.getCustomer().getSalesOrders().get(0)).cdoID());
-
- assertNotSame(CDOUtil.getCDOObject(salesOrderFound).cdoView(), CDOUtil.getCDOObject(customer2).cdoView());
-
- // Expecting exception here
- salesOrderFound.setCustomer(customer2);
-
- EList<SalesOrder> salesOrders = salesOrderFound.getCustomer().getSalesOrders();
-
- // Model consistency is broken
- assertEquals(true, salesOrders.size() == 1);
- assertEquals(CDOUtil.getCDOObject(salesOrderFound).cdoID(), CDOUtil.getCDOObject(salesOrders.get(0)).cdoID());
- fail("Should not allow to mix elements from the different view");
- }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
index bfa2d97394..0dc8f09eb0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
@@ -932,24 +932,17 @@ public abstract class AbstractCDOView extends Lifecycle implements InternalCDOVi
}
else
{
- try
+ InternalCDOObject object = (InternalCDOObject)EcoreUtil.getAdapter(
+ ((InternalEObject)potentialObject).eAdapters(), CDOLegacyAdapter.class);
+ if (object != null)
{
- InternalCDOObject object = (InternalCDOObject)EcoreUtil.getAdapter(
- ((InternalEObject)potentialObject).eAdapters(), CDOLegacyAdapter.class);
- if (object != null)
+ CDOID id = getID(object, onlyPersistedID);
+ if (id != null)
{
- CDOID id = getID(object, onlyPersistedID);
- if (id != null)
- {
- return id;
- }
-
- potentialObject = object;
+ return id;
}
- }
- catch (Throwable ex)
- {
- OM.LOG.warn(ex);
+
+ potentialObject = object;
}
}
}

Back to the top