[exo-jcr-commits] exo-jcr SVN: r812 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/api/writing and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Nov 23 10:07:11 EST 2009
Author: sergiykarpenko
Date: 2009-11-23 10:07:10 -0500 (Mon, 23 Nov 2009)
New Revision: 812
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestGetReference.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/api/writing/TestNodeReference.java
Log:
EXOJCR-246: TestGetReference added. TestNodeReference updated. JBossCacheStorageConnection fix
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-23 14:43:39 UTC (rev 811)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-23 15:07:10 UTC (rev 812)
@@ -347,13 +347,14 @@
{
// get values from cahce
+ Set<String> remNodes = new HashSet<String>();
+
for (ValueData value : oldData.getValues())
{
- String refNodeUUID;
try
{
- refNodeUUID = ValueDataConvertor.readString(value);
+ remNodes.add(ValueDataConvertor.readString(value));
}
catch (UnsupportedEncodingException e)
{
@@ -365,18 +366,28 @@
// TODO Auto-generated catch block
throw new RepositoryException(e.getMessage(), e);
}
+ }
+ for (String refNodeUUID : remNodes)
+ {
// remove property from referencedNode in $REFS map
Node<Serializable, Object> refParent = refsRoot.getChild(makeNodeFqn(refNodeUUID));
if (refParent != null)
{
- refParent.removeChild(propUUID);
+ if (!refParent.removeChild(propUUID))
+ {
+ throw new RepositoryException("FATAL Reference property was not removed from REFS table of node "
+ + refNodeUUID);
+
+ }
// check is there is no more references
if (refParent.getChildrenNames().size() == 0)
{
- //TODO remove children
- refsRoot.removeChild(makeNodeFqn(refNodeUUID));
+ if (!refsRoot.removeChild(makeNodeFqn(refNodeUUID)))
+ {
+ throw new RepositoryException("FATAL Node record was node removed from REFS table " + refNodeUUID);
+ }
}
}
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/api/writing/TestNodeReference.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/api/writing/TestNodeReference.java 2009-11-23 14:43:39 UTC (rev 811)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/api/writing/TestNodeReference.java 2009-11-23 15:07:10 UTC (rev 812)
@@ -161,7 +161,7 @@
log.debug(testNode1.getPath() + " ref >>> " + p.getPath());
}
- assertEquals(5, testNode1.getReferences().getSize());
+ assertEquals(4, testNode1.getReferences().getSize()); // not 5 because p1_multiple occures onlu once
refs = testNode2.getReferences();
if (log.isDebugEnabled())
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestGetReference.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestGetReference.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestGetReference.java 2009-11-23 15:07:10 UTC (rev 812)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.usecases;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a>
+ * @version $Id: TestGetReference.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestGetReference extends BaseUsecasesTest
+{
+
+ /**
+ * Tests Property.getNode();
+ */
+ public void testReferenceTarget() throws RepositoryException, NotExecutableException
+ {
+ String nodeName1 = "node1";
+ String nodeName2 = "node2";
+ String propertyName1 = "prop1";
+ String testNodeType = "nt:unstructured";
+
+ Node n1 = root.addNode(nodeName1, testNodeType);
+ n1.addMixin("mix:referenceable");
+
+ // with some impls. the mixin type has only affect upon save
+ root.save();
+
+ // make sure the node is now referenceable
+ assertTrue("test node should be mix:referenceable", n1.isNodeType("mix:referenceable"));
+
+ // create references: n2.p1 -> n1
+ Node n2 = root.addNode(nodeName2, testNodeType);
+
+ n2.setProperty(propertyName1, n1);
+ root.save();
+ assertEquals("Wrong reference target.", n2.getProperty(propertyName1).getNode(), n1);
+ n2.remove();
+ root.save();
+
+ assertTrue(n1.getReferences().getSize() == 0);
+ }
+
+}
More information about the exo-jcr-commits
mailing list