Author: mir
Date: Sat Feb 13 12:48:37 2010
New Revision: 909808
URL: http://svn.apache.org/viewvc?rev=909808&view=rev
Log:
CLEREZZA-122: fixed bug
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java?rev=909808&r1=909807&r2=909808&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
Sat Feb 13 12:48:37 2010
@@ -102,8 +102,13 @@
private void checkExistence(HierarchyNode node) throws
NodeDoesNotExistException {
if (!getRoots().contains(node)) {
- CollectionNode parent = node.getParent();
- UriRef nodeUri = node.getNode();
+ CollectionNode parent;
+ UriRef nodeUri = node.getNode();
+ try {
+ parent = node.getParent();
+ } catch(IllegalArgumentException ex){
+ throw new NodeDoesNotExistException(nodeUri);
+ }
if (!parent.getMembersRdf().contains(nodeUri)) {
throw new NodeDoesNotExistException(nodeUri);
}
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java?rev=909808&r1=909807&r2=909808&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
Sat Feb 13 12:48:37 2010
@@ -49,6 +49,8 @@
private UriRef fooResource = new
UriRef("http://localhost:8282/foo/resource");
private UriRef fooResource2 = new
UriRef("http://localhost:8282/foo/resource2");
private UriRef fooResource3 = new
UriRef("http://localhost:8282/foo/resource3");
+ private UriRef fooTest = new UriRef("http://localhost:8282/foo/test/");
+ private UriRef fooTestResource4 = new
UriRef("http://localhost:8282/foo/test/resource4");
private UriRef fooFolder1 = new
UriRef("http://localhost:8282/foo/folder1/");
private UriRef bar = new UriRef("http://localhost:8282/bar/");
private UriRef barResource = new
UriRef("http://localhost:8282/bar/resource");
@@ -58,6 +60,7 @@
private UriRef newRootTest = new UriRef("http://newRoot/test/");
private UriRef newRoot2Resource = new
UriRef("http://newRoot2/resource");
private UriRef newRoot2 = new UriRef("http://newRoot2/");
+
@Test
public void listPositionTest() throws Exception{
@@ -98,7 +101,7 @@
exceptionThrown = false;
try {
fooFolder1Node = (CollectionNode)
hierarchyService.getHierarchyNode(fooFolder1);
- } catch(RuntimeException e) {
+ } catch(NodeDoesNotExistException e) {
exceptionThrown = true;
}
Assert.assertTrue(exceptionThrown);
@@ -112,6 +115,17 @@
Assert.assertTrue(exceptionThrown);
}
+ @Test
+ public void nonCollectionNodeCreation() throws Exception{
+ HierarchyService hierarchyService = getHierarchyService();
+ HierarchyNode fooTestResource4Node = hierarchyService.
+ createNonCollectionNode(fooTestResource4, 0);
+ CollectionNode fooTestNode = fooTestResource4Node.getParent();
+ Assert.assertEquals(fooTest, fooTestNode.getNode());
+ CollectionNode fooNode = fooTestNode.getParent();
+ Assert.assertEquals(foo, fooNode.getNode());
+ }
+
@Test
public void nonCollectionMoveTest() throws Exception{
HierarchyService hierarchyService = getHierarchyService();