Search in sources :

Example 1 with UpdateEvent

use of org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent in project jackrabbit by apache.

the class UpdateEventFactory method createUpdateOperationWithNullUserId.

/**
     * Create an update operation.
     *
     * @return update operation
     */
public UpdateEvent createUpdateOperationWithNullUserId() {
    NodeState n1 = createNodeState();
    NodeState n2 = createNodeState();
    NodeState n3 = createNodeState();
    PropertyState p1 = createPropertyState(n1.getNodeId(), "{}a");
    PropertyState p2 = createPropertyState(n2.getNodeId(), "{}b");
    ChangeLog changes = new ChangeLog();
    changes.added(n1);
    changes.added(p1);
    changes.deleted(p2);
    changes.modified(n2);
    changes.deleted(n3);
    Session s = new ClusterSession(null);
    List events = new ArrayList();
    events.add(createEventState(n1, Event.NODE_ADDED, "{}n1", s));
    events.add(createEventState(p1, n1, Event.PROPERTY_ADDED, s));
    events.add(createEventState(p2, n2, Event.PROPERTY_REMOVED, s));
    events.add(createEventState(n3, Event.NODE_REMOVED, "{}n3", s));
    return new UpdateEvent(changes, events, System.currentTimeMillis(), "user-data");
}
Also used : NodeState(org.apache.jackrabbit.core.state.NodeState) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ChangeLog(org.apache.jackrabbit.core.state.ChangeLog) PropertyState(org.apache.jackrabbit.core.state.PropertyState) Session(javax.jcr.Session) UpdateEvent(org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent)

Example 2 with UpdateEvent

use of org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent in project jackrabbit by apache.

the class ClusterRecordTest method testUpdateOperation.

/**
     * Test producing and consuming an update.
     * @throws Exception
     */
public void testUpdateOperation() throws Exception {
    UpdateEvent update = factory.createUpdateOperation();
    UpdateEventChannel channel = master.createUpdateChannel(DEFAULT_WORKSPACE);
    channel.updateCreated(update);
    channel.updatePrepared(update);
    channel.updateCommitted(update, null);
    SimpleEventListener listener = new SimpleEventListener();
    slave.createUpdateChannel(DEFAULT_WORKSPACE).setListener(listener);
    slave.sync();
    assertEquals(1, listener.getClusterEvents().size());
    assertEquals(listener.getClusterEvents().get(0), update);
}
Also used : UpdateEvent(org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent)

Example 3 with UpdateEvent

use of org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent in project jackrabbit by apache.

the class UpdateEventFactory method createUpdateOperation.

/**
     * Create an update operation.
     *
     * @return update operation
     */
public UpdateEvent createUpdateOperation() {
    NodeState n1 = createNodeState();
    NodeState n2 = createNodeState();
    NodeState n3 = createNodeState();
    PropertyState p1 = createPropertyState(n1.getNodeId(), "{}a");
    PropertyState p2 = createPropertyState(n2.getNodeId(), "{}b");
    ChangeLog changes = new ChangeLog();
    changes.added(n1);
    changes.added(p1);
    changes.deleted(p2);
    changes.modified(n2);
    changes.deleted(n3);
    List events = new ArrayList();
    events.add(createEventState(n1, Event.NODE_ADDED, "{}n1", session));
    events.add(createEventState(p1, n1, Event.PROPERTY_ADDED, session));
    events.add(createEventState(p2, n2, Event.PROPERTY_REMOVED, session));
    events.add(createEventState(n3, Event.NODE_REMOVED, "{}n3", session));
    return new UpdateEvent(changes, events, System.currentTimeMillis(), "user-data");
}
Also used : NodeState(org.apache.jackrabbit.core.state.NodeState) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ChangeLog(org.apache.jackrabbit.core.state.ChangeLog) PropertyState(org.apache.jackrabbit.core.state.PropertyState) UpdateEvent(org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent)

Example 4 with UpdateEvent

use of org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent in project jackrabbit by apache.

the class ClusterRecordTest method testUpdateOperationWithNullUserId.

/**
     * Test producing and consuming an update with a null userId
     */
public void testUpdateOperationWithNullUserId() throws Exception {
    UpdateEvent update = factory.createUpdateOperationWithNullUserId();
    UpdateEventChannel channel = master.createUpdateChannel(DEFAULT_WORKSPACE);
    channel.updateCreated(update);
    channel.updatePrepared(update);
    channel.updateCommitted(update, null);
    SimpleEventListener listener = new SimpleEventListener();
    slave.createUpdateChannel(DEFAULT_WORKSPACE).setListener(listener);
    slave.sync();
    assertEquals(1, listener.getClusterEvents().size());
    assertEquals(listener.getClusterEvents().get(0), update);
}
Also used : UpdateEvent(org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent)

Aggregations

UpdateEvent (org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ChangeLog (org.apache.jackrabbit.core.state.ChangeLog)2 NodeState (org.apache.jackrabbit.core.state.NodeState)2 PropertyState (org.apache.jackrabbit.core.state.PropertyState)2 Session (javax.jcr.Session)1