diff options
author | Christian W. Damus | 2013-08-31 23:45:21 +0000 |
---|---|---|
committer | Christian W. Damus | 2013-08-31 23:45:21 +0000 |
commit | b29a7843c0874837b93011a2f9d292c18ea2c6ff (patch) | |
tree | 691ea6d74cfa54354fd5c3220fc86f8c1815387e | |
parent | 7a0e02414adcc7db93927658153cd18400e3eeeb (diff) | |
download | cdo-b29a7843c0874837b93011a2f9d292c18ea2c6ff.tar.gz cdo-b29a7843c0874837b93011a2f9d292c18ea2c6ff.tar.xz cdo-b29a7843c0874837b93011a2f9d292c18ea2c6ff.zip |
416298: Reflective access to CDOResourceNode::path
https://bugs.eclipse.org/bugs/show_bug.cgi?id=416298
2 files changed, 88 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_416298_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_416298_Test.java new file mode 100644 index 0000000000..aaec704ee1 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_416298_Test.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 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: + * Christian W. Damus (CEA LIST) - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.bugzilla; + +import static org.eclipse.emf.cdo.eresource.EresourcePackage.Literals.CDO_RESOURCE_NODE__PATH; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +/** + * Bug 416298: Tests that resource nodes provide proper reflective access to the derived 'path' attribute. + * + * @author Christian W. Damus (CEA LIST) + */ +public class Bugzilla_416298_Test extends AbstractCDOTest +{ + public void testGetSetResourcePath() throws Exception + { + CDOSession session = openSession(); + + CDOTransaction transaction = session.openTransaction(); + + CDOResource res = transaction.getOrCreateResource("/path/to/resource.model1"); + + assertEquals("/path/to/resource.model1", res.eGet(CDO_RESOURCE_NODE__PATH)); + + res.eSet(CDO_RESOURCE_NODE__PATH, "/new/folder/resource.model1"); + + assertNotNull(res.getFolder()); + assertEquals("/new/folder", res.getFolder().getPath()); + } + + public void testGetSetFolderPath() throws Exception + { + CDOSession session = openSession(); + + CDOTransaction transaction = session.openTransaction(); + + CDOResourceFolder folder = transaction.getOrCreateResourceFolder("/path/to/folder"); + + assertEquals("/path/to/folder", folder.eGet(CDO_RESOURCE_NODE__PATH)); + + folder.eSet(CDO_RESOURCE_NODE__PATH, "/atRoot"); + + assertNull(folder.getFolder()); + assertEquals("atRoot", folder.getName()); + } + +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java index ddd9534f57..c4b7f36246 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2012 Eike Stepper (Berlin, Germany) and others. + * Copyright (c) 2008-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 @@ -7,6 +7,7 @@ * * Contributors: * Eike Stepper - initial API and implementation + * Christian W. Damus (CEA LIST) - 416298: reflective access to 'path' attribute */ package org.eclipse.emf.cdo.eresource.impl; @@ -255,4 +256,30 @@ public abstract class CDOResourceNodeImpl extends CDOObjectImpl implements CDORe throw new CDOException(MessageFormat.format(Messages.getString("CDOResourceNodeImpl.5"), newPath)); //$NON-NLS-1$ } } + + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case EresourcePackage.CDO_RESOURCE_NODE__PATH: + return getPath(); + default: + return super.eGet(featureID, resolve, coreType); + } + } + + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case EresourcePackage.CDO_RESOURCE_NODE__PATH: + setPath((String)newValue); + break; + default: + super.eSet(featureID, newValue); + break; + } + } } // CDOResourceNodeImpl |