[exo-jcr-commits] exo-jcr SVN: r511 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Nov 9 09:25:45 EST 2009
Author: nzamosenchuk
Date: 2009-11-09 09:25:45 -0500 (Mon, 09 Nov 2009)
New Revision: 511
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
Log:
EXOJCR-204:Observation loader test updated.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java 2009-11-09 14:20:47 UTC (rev 510)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java 2009-11-09 14:25:45 UTC (rev 511)
@@ -24,12 +24,14 @@
import org.exoplatform.services.jcr.core.NamespaceAccessor;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.core.observation.ListenerCriteria;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerRegistry;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Modification.ModificationType;
@@ -40,6 +42,7 @@
import java.util.Map;
import javax.jcr.NamespaceException;
+import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.observation.Event;
import javax.jcr.observation.EventIterator;
@@ -115,15 +118,123 @@
assertEquals(lf.createJCRPath(node1path).getAsString(false), event.getPath());
}
+ public void testRemoveNode() throws Exception
+ {
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ NodeData newNode =
+ new TransientNodeData(node1path, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList());
+ DummyListener listener = new DummyListener();
+ registry.addEventListener(listener, new ListenerCriteria(Event.NODE_REMOVED, lf.parseAbsPath("/")
+ .getInternalPath(), true, null, null, false, "asd"));
+
+ List<Modification> modifications = new ArrayList<Modification>();
+ modifications.add(removeNode(newNode));
+ loader.put(modifications);
+ assertEquals(1, listener.eventList.size());
+ Event event = listener.eventList.get(0);
+ assertEquals(Event.NODE_REMOVED, event.getType());
+ assertEquals(lf.createJCRPath(node1path).getAsString(false), event.getPath());
+ }
+
+ public void testAddProperty() throws Exception
+ {
+ QPath prop1path = QPath.parse("[]:1[]node:1[]property:1");
+ PropertyData newProperty =
+ new TransientPropertyData(prop1path, "PropertyUUID", 0, PropertyType.UNDEFINED, Constants.SYSTEM_UUID, false);
+
+ DummyListener listener = new DummyListener();
+ registry.addEventListener(listener, new ListenerCriteria(Event.PROPERTY_ADDED, lf.parseAbsPath("/")
+ .getInternalPath(), true, null, null, false, "asd"));
+
+ List<Modification> modifications = new ArrayList<Modification>();
+ modifications.add(addProperty(newProperty));
+ loader.put(modifications);
+ assertEquals(1, listener.eventList.size());
+ Event event = listener.eventList.get(0);
+ assertEquals(Event.PROPERTY_ADDED, event.getType());
+ assertEquals(lf.createJCRPath(prop1path).getAsString(false), event.getPath());
+ }
+
+ public void testUpdateProperty() throws Exception
+ {
+ QPath prop1path = QPath.parse("[]:1[]node:1[]property:1");
+ PropertyData newProperty =
+ new TransientPropertyData(prop1path, "PropertyUUID", 0, PropertyType.UNDEFINED, Constants.SYSTEM_UUID, false);
+
+ DummyListener listener = new DummyListener();
+ registry.addEventListener(listener, new ListenerCriteria(Event.PROPERTY_CHANGED, lf.parseAbsPath("/")
+ .getInternalPath(), true, null, null, false, "asd"));
+
+ List<Modification> modifications = new ArrayList<Modification>();
+ modifications.add(updateProperty(newProperty));
+ loader.put(modifications);
+ assertEquals(1, listener.eventList.size());
+ Event event = listener.eventList.get(0);
+ assertEquals(Event.PROPERTY_CHANGED, event.getType());
+ assertEquals(lf.createJCRPath(prop1path).getAsString(false), event.getPath());
+ }
+
+ public void testRemoveProperty() throws Exception
+ {
+ QPath prop1path = QPath.parse("[]:1[]node:1[]property:1");
+ PropertyData newProperty =
+ new TransientPropertyData(prop1path, "PropertyUUID", 0, PropertyType.UNDEFINED, Constants.SYSTEM_UUID, false);
+
+ DummyListener listener = new DummyListener();
+ registry.addEventListener(listener, new ListenerCriteria(Event.PROPERTY_REMOVED, lf.parseAbsPath("/")
+ .getInternalPath(), true, null, null, false, "asd"));
+
+ List<Modification> modifications = new ArrayList<Modification>();
+ modifications.add(removeProperty(newProperty));
+ loader.put(modifications);
+ assertEquals(1, listener.eventList.size());
+ Event event = listener.eventList.get(0);
+ assertEquals(Event.PROPERTY_REMOVED, event.getType());
+ assertEquals(lf.createJCRPath(prop1path).getAsString(false), event.getPath());
+ }
+
public Modification addNode(NodeData data)
{
- // add in NODES
String fqn = "/" + JBossCacheStorage.NODES + "/" + data.getIdentifier();
return new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
(Object)data);
- //node.put(ITEM_DATA, data);
}
+ public Modification removeNode(NodeData data)
+ {
+ String fqn = "/" + JBossCacheStorage.NODES + "/" + data.getIdentifier();
+ return new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
+ (Object)data);
+ }
+
+ public Modification addProperty(PropertyData data)
+ {
+ String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
+ return new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
+ (Object)data);
+ }
+
+ public Modification updateProperty(PropertyData data)
+ {
+ String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
+ Modification modification =
+ new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
+ (Object)data);
+ modification.setOldValue(data);
+ return modification;
+ }
+
+ public Modification removeProperty(PropertyData data)
+ {
+ String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
+ Modification modification =
+ new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
+ (Object)data);
+ modification.setOldValue(data);
+ return modification;
+ }
+
@Override
protected void tearDown() throws Exception
{
More information about the exo-jcr-commits
mailing list