Author: jason.greene(a)jboss.com
Date: 2009-02-04 12:33:49 -0500 (Wed, 04 Feb 2009)
New Revision: 7644
Modified:
core/trunk/src/main/java/org/jboss/cache/config/Option.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
Log:
Revert 7635, 7643 and 7642
Modified: core/trunk/src/main/java/org/jboss/cache/config/Option.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Option.java 2009-02-04 17:01:56 UTC
(rev 7643)
+++ core/trunk/src/main/java/org/jboss/cache/config/Option.java 2009-02-04 17:33:49 UTC
(rev 7644)
@@ -27,7 +27,6 @@
* Used to override characteristics of specific calls to the cache. The javadocs of each
of the setters below detail functionality and behaviour.
*
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
* @since 1.3.0
*/
public class Option implements Cloneable
@@ -50,7 +49,6 @@
private int lockAcquisitionTimeout = -1;
private boolean suppressPersistence;
- private boolean suppressEventNotification;
/**
* @since 1.4.0
@@ -272,8 +270,6 @@
", skipDataGravitation=" + skipDataGravitation +
", forceAsynchronous=" + forceAsynchronous +
", forceSynchronous=" + forceSynchronous +
- ", suppressPersistence=" + suppressPersistence +
- ", suppressEventNotification=" + suppressEventNotification +
'}';
}
@@ -324,7 +320,6 @@
if (forceSynchronous != option.forceSynchronous) return false;
if (lockAcquisitionTimeout != option.lockAcquisitionTimeout) return false;
if (suppressPersistence != option.suppressPersistence) return false;
- if (suppressEventNotification != option.suppressEventNotification) return false;
return true;
}
@@ -343,7 +338,6 @@
result = 29 * result + (forceSynchronous ? 0 : 1);
result = 29 * result + (lockAcquisitionTimeout);
result = 29 * result + (suppressPersistence ? 0 : 1);
- result = 29 * result + (suppressEventNotification ? 0 : 1);
return result;
}
@@ -363,7 +357,6 @@
this.forceSynchronous = false;
this.lockAcquisitionTimeout = -1;
this.suppressPersistence = false;
- this.suppressEventNotification = false;
}
/**
@@ -482,29 +475,4 @@
{
this.suppressPersistence = suppressPersistence;
}
-
- /**
- * Get whether event notifications for this invocation will be suppresed. By
- * default is false which means that corresponding events are sent depending
- * on the type of invocation.
- *
- * @return true, if event notification will be suppressed for this invocation.
- */
- public boolean isSuppressEventNotification()
- {
- return suppressEventNotification;
- }
-
- /**
- * Set whether event notifications should be suppressed for this particular
- * cache or transaction invocation.
- *
- * @param suppressEventNotification <code>true</code> if event
notification
- * should be skipped; <code>false</code> if
events
- * should be notified if there're any listeners.
- */
- public void setSuppressEventNotification(boolean suppressEventNotification)
- {
- this.suppressEventNotification = suppressEventNotification;
- }
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2009-02-04
17:01:56 UTC (rev 7643)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2009-02-04
17:33:49 UTC (rev 7644)
@@ -74,7 +74,6 @@
*
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
* @author <a href="mailto:stevew@jofti.com">Steve Woodcock
(stevew(a)jofti.com)</a>
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
*/
public class TxInterceptor extends BaseTransactionalContextInterceptor
{
@@ -922,9 +921,6 @@
{
// this should ideally be set in beforeCompletion(), after compacting the
list.
if (modifications == null) modifications =
transactionContext.getModifications();
-// Option transactionalOptions = transactionContext.getOption();
-// Option originalOptions = ctx.getOptionOverrides();
-//
transactionalOptions.setSuppressEventNotification(originalOptions.isSuppressEventNotification());
ctx.setOptionOverrides(transactionContext.getOption());
}
if (tx != null) transactions.remove(tx);
@@ -1055,7 +1051,6 @@
// set any transaction wide options as current for this thread, caching original
options that would then be reset
originalOptions = ctx.getOptionOverrides();
transactionalOptions = transactionContext.getOption();
-//
transactionalOptions.setSuppressEventNotification(originalOptions.isSuppressEventNotification());
ctx.setOptionOverrides(transactionalOptions);
try
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2009-02-04
17:01:56 UTC (rev 7643)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2009-02-04
17:33:49 UTC (rev 7644)
@@ -64,7 +64,6 @@
* Helper class that handles all notifications to registered listeners.
*
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
*/
@NonVolatile
public class NotifierImpl implements Notifier
@@ -308,7 +307,7 @@
public void notifyNodeCreated(Fqn fqn, boolean pre, InvocationContext ctx)
{
- if (!nodeCreatedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeCreatedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -327,7 +326,7 @@
public void notifyNodeModified(Fqn fqn, boolean pre,
NodeModifiedEvent.ModificationType modificationType, Map data, InvocationContext ctx)
{
- if (!nodeModifiedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeModifiedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -354,7 +353,7 @@
public void notifyNodeRemoved(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- if (!nodeRemovedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeRemovedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -375,7 +374,7 @@
public void notifyNodeVisited(Fqn fqn, boolean pre, InvocationContext ctx)
{
- if (!nodeVisitedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeVisitedListeners.isEmpty())
{
Transaction tx = ctx.getTransaction();
InvocationContext backup = resetInvocationContext(ctx);
@@ -392,7 +391,7 @@
public void notifyNodeMoved(Fqn originalFqn, Fqn newFqn, boolean pre,
InvocationContext ctx)
{
- if (!nodeMovedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeMovedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -412,7 +411,7 @@
public void notifyNodeEvicted(final Fqn fqn, final boolean pre, InvocationContext
ctx)
{
- if (!nodeEvictedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeEvictedListeners.isEmpty())
{
final boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -431,7 +430,7 @@
public void notifyNodeInvalidated(final Fqn fqn, final boolean pre, InvocationContext
ctx)
{
- if (!nodeInvalidatedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeInvalidatedListeners.isEmpty())
{
final boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -450,7 +449,7 @@
public void notifyNodeLoaded(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- if (!nodeLoadedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeLoadedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -471,7 +470,7 @@
public void notifyNodeActivated(Fqn fqn, boolean pre, Map data, InvocationContext
ctx)
{
- if (!nodeActivatedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeActivatedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -492,7 +491,7 @@
public void notifyNodePassivated(Fqn fqn, boolean pre, Map data, InvocationContext
ctx)
{
- if (!nodePassivatedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodePassivatedListeners.isEmpty())
{
Map dataCopy = copy(data, useMarshalledValueMaps);
Transaction tx = ctx.getTransaction();
@@ -568,7 +567,7 @@
public void notifyTransactionCompleted(Transaction transaction, boolean successful,
InvocationContext ctx)
{
- if (!transactionCompletedListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!transactionCompletedListeners.isEmpty())
{
boolean isOriginLocal = ctx.isOriginLocal();
InvocationContext backup = resetInvocationContext(ctx);
@@ -585,7 +584,7 @@
public void notifyTransactionRegistered(Transaction transaction, InvocationContext
ctx)
{
- if (!transactionRegisteredListeners.isEmpty() &&
!ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!transactionRegisteredListeners.isEmpty())
{
boolean isOriginLocal = ctx.isOriginLocal();
InvocationContext backup = resetInvocationContext(ctx);
Modified:
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2009-02-04
17:01:56 UTC (rev 7643)
+++
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2009-02-04
17:33:49 UTC (rev 7644)
@@ -78,7 +78,7 @@
byte[] bytes = marshaller.objectToByteBuffer("Hello");
ObjectInputStream in = new MarshalledValueInputStream(new
ByteArrayInputStream(bytes));
- assertEquals("Version header short should be '31'", 31,
in.readShort());
+ assertEquals("Version header short should be '30'", 30,
in.readShort());
}
public void testVersionHeader210() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2009-02-04
17:01:56 UTC (rev 7643)
+++
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2009-02-04
17:33:49 UTC (rev 7644)
@@ -12,7 +12,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Option;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.notifications.event.Event;
import static org.jboss.cache.notifications.event.Event.Type.*;
@@ -39,7 +38,6 @@
* exercises the new CacheListener annotation.
*
* @since 2.0.0
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
*/
@Test(groups = "functional", sequential = true, testName =
"notifications.CacheListenerTest")
public class CacheListenerTest
@@ -70,7 +68,6 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- clearSuppressEventNotification();
Transaction t = tm.getTransaction();
if (t != null)
tm.rollback();
@@ -81,53 +78,32 @@
// simple tests first
- public void testCreation()
+ public void testCreation() throws Exception
{
- creation(false);
- eventLog.events.clear();
- creation(true);
- }
-
- protected void creation(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value");
Map<Object, Object> data = new HashMap<Object, Object>();
data.put("key", "value");
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false,
null, NODE_CREATED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false,
null, NODE_CREATED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn,
null, true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, null, true, null,
false, null, NODE_MODIFIED));
+ if (optLocking)
{
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null,
false, null, NODE_CREATED));
- expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null,
false, null, NODE_CREATED));
- expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn,
null, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, null, true, null,
false, null, NODE_MODIFIED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
- assertEquals("value", cache.get(fqn, "key"));
+ assertEquals("value", cache.get(fqn, "key"));
}
- public void testOnlyModification()
+ public void testOnlyModification() throws Exception
{
- onlyModification(false);
- eventLog.events.clear();
- onlyModification(true);
- }
-
- protected void onlyModification(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
cache.put(fqn, "key", "value");
Map<Object, Object> oldData = new HashMap<Object, Object>();
@@ -138,42 +114,28 @@
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value2");
Map<Object, Object> newData = new HashMap<Object, Object>();
newData.put("key", "value2");
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, oldData, fqn, null, true, null,
false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, newData, fqn, null, true, null,
false, null, NODE_MODIFIED));
+ if (optLocking)
{
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, PUT_DATA, oldData, fqn, null, true,
null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, newData, fqn, null, true,
null, false, null, NODE_MODIFIED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected.size(), eventLog.events.size());
assertEquals(expected, eventLog.events);
}
- public void testOnlyRemoval()
+ public void testOnlyRemoval() throws Exception
{
- onlyRemoval(false);
- eventLog.events.clear();
- onlyRemoval(true);
- }
-
- protected void onlyRemoval(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
cache.put(fqn, "key", "value");
Map<Object, Object> oldData = new HashMap<Object, Object>();
@@ -186,25 +148,18 @@
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.removeNode(fqn);
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, oldData, fqn, null, true, null,
false, null, NODE_REMOVED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false,
null, NODE_REMOVED));
+ if (optLocking)
{
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, oldData, fqn, null, true, null,
false, null, NODE_REMOVED));
- expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null,
false, null, NODE_REMOVED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
@@ -213,42 +168,22 @@
assertNull("Should be null", cache.getRoot().getChild(fqn));
}
- public void testNonexistentRemove()
+ public void testNonexistentRemove() throws Exception
{
- nonexistentRemove(false);
- eventLog.events.clear();
- nonexistentRemove(true);
- }
-
- protected void nonexistentRemove(boolean supressEventNotification)
- {
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.removeNode("/does/not/exist");
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+
+ if (optLocking)
{
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
}
- public void testRemoveData()
+ public void testRemoveData() throws Exception
{
- removeData(false);
- eventLog.events.clear();
- removeData(true);
- }
-
- protected void removeData(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
cache.put(fqn, "key", "value");
cache.put(fqn, "key2", "value2");
@@ -261,10 +196,6 @@
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.remove(fqn, "key2");
Map<Object, Object> removedData = new HashMap<Object, Object>();
removedData.put("key2", "value2");
@@ -272,17 +203,14 @@
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, REMOVE_DATA, oldData, fqn, null, true,
null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, REMOVE_DATA, removedData, fqn, null, true,
null, false, null, NODE_MODIFIED));
+ if (optLocking)
{
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, REMOVE_DATA, oldData, fqn, null, true,
null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, REMOVE_DATA, removedData, fqn, null,
true, null, false, null, NODE_MODIFIED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
@@ -290,13 +218,6 @@
public void testPutMap() throws Exception
{
- putMap(false);
- eventLog.events.clear();
- putMap(true);
- }
-
- protected void putMap(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
Map<Object, Object> oldData = new HashMap<Object, Object>();
oldData.put("key", "value");
@@ -307,27 +228,20 @@
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, oldData);
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null,
false, null, NODE_CREATED));
- expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null,
false, null, NODE_CREATED));
- expected.add(new EventImpl(true, cache, PUT_MAP, Collections.emptyMap(), fqn,
null, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_MAP, oldData, fqn, null, true,
null, false, null, NODE_MODIFIED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false,
null, NODE_CREATED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false,
null, NODE_CREATED));
+ expected.add(new EventImpl(true, cache, PUT_MAP, Collections.emptyMap(), fqn, null,
true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_MAP, oldData, fqn, null, true, null,
false, null, NODE_MODIFIED));
+ if (optLocking)
+ {
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
@@ -335,13 +249,6 @@
public void testMove()
{
- move(false);
- eventLog.events.clear();
- move(true);
- }
-
- protected void move(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
Fqn newParent = Fqn.fromString("/a");
cache.put(fqn, "key", "value");
@@ -352,26 +259,19 @@
eventLog.events.clear();// clear events
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.move(n1.getFqn(), n2.getFqn());
//expected
Fqn newFqn = Fqn.fromRelativeElements(newParent, fqn.getLastElement());
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, null, true, newFqn,
false, null, NODE_MOVED));
- expected.add(new EventImpl(false, cache, null, null, fqn, null, true, newFqn,
false, null, NODE_MOVED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, null, true, newFqn, false,
null, NODE_MOVED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, null, true, newFqn,
false, null, NODE_MOVED));
+ if (optLocking)
+ {
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null,
true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
@@ -381,138 +281,63 @@
public void testTxNonexistentRemove() throws Exception
{
- txNonexistentRemove(false);
- eventLog.events.clear();
-// txNonexistentRemove(true);
- }
-
- protected void txNonexistentRemove(boolean supressEventNotification) throws Exception
- {
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
cache.removeNode("/does/not/exist");
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false,
null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
}
-
+
public void testTxCreationCommit() throws Exception
{
- txCreationCommit(false);
- eventLog.events.clear();
-// txCreationCommit(true);
- }
-
- protected void txCreationCommit(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value");
//expected
Map<Object, Object> data = new HashMap<Object, Object>();
data.put("key", "value");
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false,
null, NODE_CREATED));
- expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false,
null, NODE_CREATED));
- expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn,
tx, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, tx, true, null,
false, null, NODE_MODIFIED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false,
null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false,
null, NODE_CREATED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false,
null, NODE_CREATED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn, tx,
true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, tx, true, null,
false, null, NODE_MODIFIED));
assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
assertEquals("value", cache.get(fqn, "key"));
}
public void testTxCreationRollback() throws Exception
{
- txCreationRollback(false);
- eventLog.events.clear();
-// txCreationRollback(true);
- }
-
- protected void txCreationRollback(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value");
//expected
Map<Object, Object> data = new HashMap<Object, Object>();
data.put("key", "value");
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false,
null, NODE_CREATED));
- expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false,
null, NODE_CREATED));
- expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn,
tx, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, tx, true, null,
false, null, NODE_MODIFIED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false,
null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false,
null, NODE_CREATED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false,
null, NODE_CREATED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn, tx,
true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, tx, true, null,
false, null, NODE_MODIFIED));
assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.rollback();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null,
false, null, TRANSACTION_COMPLETED));
- }
- assertEquals(expected, eventLog.events);
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false,
null, TRANSACTION_COMPLETED));
+ assertEquals(expected, eventLog.events);
}
public void testTxOnlyModification() throws Exception
{
- txOnlyModification(false);
- eventLog.events.clear();
-// txOnlyModification(true);
- }
-
- protected void txOnlyModification(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
cache.put(fqn, "key", "value");
Map<Object, Object> oldData = new HashMap<Object, Object>();
@@ -523,51 +348,26 @@
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value2");
Map<Object, Object> newData = new HashMap<Object, Object>();
newData.put("key", "value2");
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, PUT_DATA, oldData, fqn, tx, true, null,
false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, newData, fqn, tx, true, null,
false, null, NODE_MODIFIED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false,
null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, oldData, fqn, tx, true, null,
false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, newData, fqn, tx, true, null,
false, null, NODE_MODIFIED));
assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
- }
+ }
public void testTxOnlyRemoval() throws Exception
{
- txOnlyRemoval(false);
- eventLog.events.clear();
-// txOnlyRemoval(true);
- }
-
- protected void txOnlyRemoval(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
cache.put(fqn, "key", "value");
Map<Object, Object> oldData = new HashMap<Object, Object>();
@@ -580,36 +380,19 @@
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.removeNode(fqn);
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, oldData, fqn, tx, true, null,
false, null, NODE_REMOVED));
- expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false,
null, NODE_REMOVED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false,
null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, oldData, fqn, tx, true, null, false,
null, NODE_REMOVED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false,
null, NODE_REMOVED));
+
assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
// test that the node has in fact been removed.
assertNull("Should be null", cache.getRoot().getChild(fqn));
@@ -617,13 +400,6 @@
public void testTxRemoveData() throws Exception
{
- txRemoveData(false);
- eventLog.events.clear();
-// txRemoveData(true);
- }
-
- protected void txRemoveData(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
cache.put(fqn, "key", "value");
cache.put(fqn, "key2", "value2");
@@ -636,38 +412,20 @@
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.remove(fqn, "key2");
Map<Object, Object> removedData = new HashMap<Object, Object>();
removedData.put("key2", "value2");
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, REMOVE_DATA, oldData, fqn, tx, true,
null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, REMOVE_DATA, removedData, fqn, tx,
true, null, false, null, NODE_MODIFIED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false,
null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, REMOVE_DATA, oldData, fqn, tx, true, null,
false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, REMOVE_DATA, removedData, fqn, tx, true,
null, false, null, NODE_MODIFIED));
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
assertEquals(expected, eventLog.events);
@@ -700,64 +458,4 @@
expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
}
-
- protected void txMove(boolean supressEventNotification) throws Exception
- {
- assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
- Fqn newParent = Fqn.fromString("/a");
- cache.put(fqn, "key", "value");
- cache.put(newParent, "key", "value");
-
- Node<Object, Object> n1 = cache.getRoot().getChild(fqn);
- Node<Object, Object> n2 = cache.getRoot().getChild(newParent);
- eventLog.events.clear();// clear events
- assertEquals("Event log should be empty", Collections.emptyList(),
eventLog.events);
-
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
- tm.begin();
- Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
- cache.move(n1.getFqn(), n2.getFqn());
- //expected
- Fqn newFqn = Fqn.fromRelativeElements(newParent, fqn.getLastElement());
- List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null,
false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, newFqn,
false, null, NODE_MOVED));
- expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, newFqn,
false, null, NODE_MOVED));
- }
-
- assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
- tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true,
null, TRANSACTION_COMPLETED));
- }
- assertEquals(expected, eventLog.events);
- }
-
- protected void setSuppressEventNotification()
- {
- Option option = new Option();
- option.setSuppressEventNotification(true);
- cache.getInvocationContext().setOptionOverrides(option);
- }
-
- protected void clearSuppressEventNotification()
- {
- Option option = new Option();
- option.setSuppressEventNotification(false);
- cache.getInvocationContext().setOptionOverrides(option);
- }
}