summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2013-02-28 10:31:40 (EST)
committerChristian W. Damus2013-02-28 10:31:40 (EST)
commitc2af5677d6e9512af59c331833279f6f404f1321 (patch)
treef4397aa973c4353a34c88af7ab8d126949208bc2
parente395b11c8abe2b7fd3c18a3196c52c76b166267a (diff)
downloadcdo-c2af5677d6e9512af59c331833279f6f404f1321.zip
cdo-c2af5677d6e9512af59c331833279f6f404f1321.tar.gz
cdo-c2af5677d6e9512af59c331833279f6f404f1321.tar.bz2
[381395] [Legacy] NPE when removing an adapter after CDO view closed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=381395
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381395_Test.java88
1 files changed, 88 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381395_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381395_Test.java
new file mode 100644
index 0000000..7e5a14e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381395_Test.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2004 - 2013 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Esteban Dugueperoux - initial API and implementation
+ * Christian W. Damus (CEA) - add test case for view closure
+ */
+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.config.impl.ConfigTest.CleanRepositoriesBefore;
+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.common.notify.Adapter;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+
+/**
+ * @author Esteban Dugueperoux
+ */
+@CleanRepositoriesBefore
+@Requires(IModelConfig.CAPABILITY_LEGACY)
+public class Bugzilla_381395_Test extends AbstractCDOTest
+{
+
+ public void testAdapterRemoveAfterCDOServerShutdown() throws Exception
+ {
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ Adapter adapter = new AdapterImpl();
+ company.eAdapters().add(adapter);
+
+ getScenario().tearDown();
+
+ try
+ {
+ company.eAdapters().remove(adapter);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ fail("Exception in removal of adapter.");
+ }
+ }
+
+ public void testAdapterRemoveAfterCDOViewClosed() throws Exception
+ {
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ Adapter adapter = new AdapterImpl();
+ company.eAdapters().add(adapter);
+
+ transaction.close();
+
+ try
+ {
+ company.eAdapters().remove(adapter);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ fail("Exception in removal of adapter.");
+ }
+ }
+
+}