summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-04-07 11:29:49 (EDT)
committerEike Stepper2008-04-07 11:29:49 (EDT)
commitdecf18a8ba3fbae5ff3bac83bdb4aeb686e2be54 (patch)
tree51fad411a98b4dfe5cc0c750511f827af350b5f3
parent1eb79a7648f6ddef23f7f8f141f0761a02336bc4 (diff)
downloadcdo-decf18a8ba3fbae5ff3bac83bdb4aeb686e2be54.zip
cdo-decf18a8ba3fbae5ff3bac83bdb4aeb686e2be54.tar.gz
cdo-decf18a8ba3fbae5ff3bac83bdb4aeb686e2be54.tar.bz2
[225535] [CDO] Registering a package fails if registry contains Proxy packages
https://bugs.eclipse.org/bugs/show_bug.cgi?id=225535
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java54
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java25
2 files changed, 60 insertions, 19 deletions
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 ac9d807..28dc260 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
@@ -14,9 +14,13 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.mango.MangoFactory;
+import org.eclipse.emf.cdo.tests.mango.MangoPackage;
+import org.eclipse.emf.cdo.tests.mango.Value;
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.PurchaseOrder;
import org.eclipse.emf.cdo.tests.model2.Model2Factory;
import org.eclipse.emf.cdo.tests.model2.Model2Package;
import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
@@ -38,7 +42,7 @@ import java.io.IOException;
*/
public class PackageRegistryTest extends AbstractCDOTest
{
- public void __testGeneratedPackage() throws Exception
+ public void testGeneratedPackage() throws Exception
{
{
// Create resource in session 1
@@ -67,7 +71,6 @@ public class PackageRegistryTest extends AbstractCDOTest
public void testCommitTwoPackages() throws Exception
{
{
- // Create resource in session 1
CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, true);
session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);
session.getPackageRegistry().putEPackage(Model2Package.eINSTANCE);
@@ -80,15 +83,44 @@ public class PackageRegistryTest extends AbstractCDOTest
transaction.commit();
}
- // {
- // // Load resource in session 2
- // CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME);
- // CDOTransaction transaction = session.openTransaction();
- // CDOResource res = transaction.getResource("/res");
- //
- // Company company = (Company)res.getContents().get(0);
- // assertEquals("Eike", company.getName());
- // }
+ {
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource("/res");
+
+ SpecialPurchaseOrder specialPurchaseOrder = (SpecialPurchaseOrder)res.getContents().get(0);
+ assertEquals("12345", specialPurchaseOrder.getDiscountCode());
+ }
+ }
+
+ public void testCommitUnrelatedPackage() throws Exception
+ {
+ {
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, true);
+ session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource("/res");
+
+ PurchaseOrder purchaseOrder = Model1Factory.eINSTANCE.createPurchaseOrder();
+ res.getContents().add(purchaseOrder);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME);
+ session.getPackageRegistry().putEPackage(MangoPackage.eINSTANCE);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource("/res");
+
+ Value value = MangoFactory.eINSTANCE.createValue();
+ value.setName("V0");
+ res.getContents().add(value);
+
+ transaction.commit();
+ session.close();
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java
index dbb4887..68e5dc3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java
@@ -259,18 +259,27 @@ public final class EMFUtil
public static String ePackageToString(EPackage ePackage, EPackage.Registry packageRegistry)
{
Resource.Factory resourceFactory = new XMIResourceFactoryImpl();
- ResourceSetImpl resourceSet = new ResourceSetImpl();
+ ResourceSetImpl resourceSet = new ResourceSetImpl()
+ {
+ @Override
+ protected Resource delegatedGetResource(URI uri, boolean loadOnDemand)
+ {
+ System.out.println("\nGET_RESOURCE: " + uri);
+ return delegatedGetResource(uri, loadOnDemand);
+ }
+ };
+
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory);
resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("*", resourceFactory);
Resource packageResource = createPackageResource(resourceSet, ePackage);
- for (Object object : packageRegistry.values())
- {
- if (object != ePackage)
- {
- createPackageResource(resourceSet, (EPackage)object);
- }
- }
+ // for (Object object : packageRegistry.values())
+ // {
+ // if (object != ePackage)
+ // {
+ // createPackageResource(resourceSet, (EPackage)object);
+ // }
+ // }
ByteArrayOutputStream stream = new ByteArrayOutputStream();