[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/notifications ...

Manik Surtani msurtani at jboss.com
Wed Jan 3 17:51:58 EST 2007


  User: msurtani
  Date: 07/01/03 17:51:58

  Modified:    tests/functional/org/jboss/cache/notifications  
                        RemoteCacheListenerTest.java
  Added:       tests/functional/org/jboss/cache/notifications  
                        RemoteCacheListenerOptimisticTest.java
  Log:
  Added UTs, updated
  
  Revision  Changes    Path
  1.8       +36 -105   JBossCache/tests/functional/org/jboss/cache/notifications/RemoteCacheListenerTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RemoteCacheListenerTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/notifications/RemoteCacheListenerTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- RemoteCacheListenerTest.java	3 Jan 2007 17:50:30 -0000	1.7
  +++ RemoteCacheListenerTest.java	3 Jan 2007 22:51:58 -0000	1.8
  @@ -50,11 +50,6 @@
   
      protected boolean optLocking = false;
   
  -   public RemoteCacheListenerTest(String s)
  -   {
  -      super(s);
  -   }
  -
      private Cache cache, cache1;
      private TransactionManager tm;
      private EventLog eventLog = new EventLog();
  @@ -97,11 +92,11 @@
         data.put("key", "value");
   
         //expected
  -      List<Event> expected = new ArrayList<Event>();
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_CREATED, fqn, true, false, null));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_CREATED, fqn, false, false, null));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, true, false, Collections.emptyMap()));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, false, false, data));
  +      List<CacheListenerEvent> expected = new ArrayList<CacheListenerEvent>();
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_CREATED, fqn, true, false, null));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_CREATED, fqn, false, false, null));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, true, false, Collections.emptyMap()));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, false, false, data));
   
         assertEquals(expected, eventLog.events);
         assertEquals("value", cache.get(fqn, "key"));
  @@ -124,9 +119,9 @@
         newData.put("key", "value2");
   
         //expected
  -      List<RemoteCacheListenerTest.Event> expected = new ArrayList<RemoteCacheListenerTest.Event>();
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, true, false, oldData));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, false, false, newData));
  +      List<CacheListenerEvent> expected = new ArrayList<CacheListenerEvent>();
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, true, false, oldData));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, false, false, newData));
   
         assertEquals(expected, eventLog.events);
      }
  @@ -149,9 +144,9 @@
         cache.removeNode(fqn);
   
         //expected
  -      List<RemoteCacheListenerTest.Event> expected = new ArrayList<RemoteCacheListenerTest.Event>();
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_REMOVED, fqn, true, false, oldData));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_REMOVED, fqn, false, false, null));
  +      List<CacheListenerEvent> expected = new ArrayList<CacheListenerEvent>();
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_REMOVED, fqn, true, false, oldData));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_REMOVED, fqn, false, false, null));
   
         assertEquals(expected, eventLog.events);
   
  @@ -179,9 +174,9 @@
         newData.put("key", "value");
   
         //expected
  -      List<RemoteCacheListenerTest.Event> expected = new ArrayList<RemoteCacheListenerTest.Event>();
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, true, false, oldData));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, false, false, newData));
  +      List<CacheListenerEvent> expected = new ArrayList<CacheListenerEvent>();
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, true, false, oldData));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, false, false, newData));
   
         assertEquals(expected, eventLog.events);
      }
  @@ -201,11 +196,11 @@
         cache.put(fqn, oldData);
   
         //expected
  -      List<RemoteCacheListenerTest.Event> expected = new ArrayList<RemoteCacheListenerTest.Event>();
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_CREATED, fqn, true, false, null));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_CREATED, fqn, false, false, null));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, true, false, Collections.emptyMap()));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, false, false, oldData));
  +      List<CacheListenerEvent> expected = new ArrayList<CacheListenerEvent>();
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_CREATED, fqn, true, false, null));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_CREATED, fqn, false, false, null));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, true, false, Collections.emptyMap()));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, false, false, oldData));
   
         assertEquals(expected, eventLog.events);
      }
  @@ -226,11 +221,11 @@
         cache.move(n1.getFqn(), n2.getFqn());
         //expected
         Fqn newFqn = new Fqn(newParent, fqn.getLastElement());
  -      List<RemoteCacheListenerTest.Event> expected = new ArrayList<RemoteCacheListenerTest.Event>();
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, true, false, null));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, newFqn, true, false, null));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, false, false, null));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, newFqn, false, false, null));
  +      List<CacheListenerEvent> expected = new ArrayList<CacheListenerEvent>();
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, true, false, null));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, newFqn, true, false, null));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, false, false, null));
  +      expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, newFqn, false, false, null));
      }
   
      // -- now the transactional ones
  @@ -250,11 +245,11 @@
         data.put("key", "value");
   
         //expected
  -      List<RemoteCacheListenerTest.Event> expected = new ArrayList<RemoteCacheListenerTest.Event>();
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_CREATED, fqn, true, false, null));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_CREATED, fqn, false, false, null));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, true, false, Collections.emptyMap()));
  -      expected.add(new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, false, false, data));
  +      List<CacheListenerEvent> expected = new ArrayList<CacheListenerEvent>();
  +      expected.add(new CacheListenerEvent(RemoteCacheListenerTest.ListenerMethod.NODE_CREATED, fqn, true, false, null));
  +      expected.add(new CacheListenerEvent(RemoteCacheListenerTest.ListenerMethod.NODE_CREATED, fqn, false, false, null));
  +      expected.add(new CacheListenerEvent(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, true, false, Collections.emptyMap()));
  +      expected.add(new CacheListenerEvent(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, false, false, data));
   
         assertEquals(expected, eventLog.events);
         assertEquals("value", cache.get(fqn, "key"));
  @@ -364,37 +359,35 @@
   
      public static class EventLog extends AbstractCacheListener
      {
  -      public final List<RemoteCacheListenerTest.Event> events = new ArrayList<RemoteCacheListenerTest.Event>();
  +      public final List<CacheListenerEvent> events = new ArrayList<CacheListenerEvent>();
   
         public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
         {
  -         RemoteCacheListenerTest.Event e = new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_CREATED, fqn, pre, isLocal, null);
  +         CacheListenerEvent e = new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_CREATED, fqn, pre, isLocal, null);
            events.add(e);
         }
   
         public void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
         {
  -         RemoteCacheListenerTest.Event e = new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_REMOVED, fqn, pre, isLocal, data);
  +         CacheListenerEvent e = new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_REMOVED, fqn, pre, isLocal, data);
            events.add(e);
         }
   
         public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType modType, Map data)
         {
  -         RemoteCacheListenerTest.Event e = new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, pre, isLocal, data);
  +         CacheListenerEvent e = new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, pre, isLocal, data);
            events.add(e);
         }
   
         public void nodeVisited(Fqn fqn, boolean pre)
         {
  -         RemoteCacheListenerTest.Event e = new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_VISITED, fqn, pre, false, null);
  +         CacheListenerEvent e = new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_VISITED, fqn, pre, false, null);
            events.add(e);
         }
   
  -      public void nodeMoved(Fqn from, Fqn to, boolean pre)
  +      public void nodeMoved(Fqn from, Fqn to, boolean pre, boolean isLocal)
         {
  -         RemoteCacheListenerTest.Event e = new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MOVED, from, pre, false, null);
  -         events.add(e);
  -         e = new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MOVED, to, pre, false, null);
  +         CacheListenerEvent e = new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MOVED, from, to, pre, isLocal);
            events.add(e);
         }
   
  @@ -406,66 +399,4 @@
                    '}';
         }
      }
  -
  -
  -   public static class Event
  -   {
  -      RemoteCacheListenerTest.ListenerMethod methodName;
  -      Fqn fqn;
  -      boolean pre;
  -      boolean local;
  -      Map data;
  -
  -      public Event(RemoteCacheListenerTest.ListenerMethod methodName, Fqn fqn, boolean pre, boolean local, Map data)
  -      {
  -         this.methodName = methodName;
  -         this.fqn = fqn;
  -         this.pre = pre;
  -         this.local = local;
  -         this.data = data;
  -      }
  -
  -      public String toString()
  -      {
  -         return "Event{" +
  -                 "methodName=" + methodName +
  -                 ", fqn=" + fqn +
  -                 ", pre=" + pre +
  -                 ", local=" + local +
  -                 ", data=" + data +
  -                 '}';
  -      }
  -
  -      public boolean equals(Object o)
  -      {
  -         if (this == o) return true;
  -         if (o == null || getClass() != o.getClass()) return false;
  -
  -         final RemoteCacheListenerTest.Event event = (RemoteCacheListenerTest.Event) o;
  -
  -         if (local != event.local) return false;
  -         if (pre != event.pre) return false;
  -         if (data != null ? !data.equals(event.data) : event.data != null) return false;
  -         if (fqn != null ? !fqn.equals(event.fqn) : event.fqn != null) return false;
  -         if (methodName != event.methodName) return false;
  -
  -         return true;
  -      }
  -
  -      public int hashCode()
  -      {
  -         int result;
  -         result = (methodName != null ? methodName.hashCode() : 0);
  -         result = 29 * result + (fqn != null ? fqn.hashCode() : 0);
  -         result = 29 * result + (pre ? 1 : 0);
  -         result = 29 * result + (local ? 1 : 0);
  -         result = 29 * result + (data != null ? data.hashCode() : 0);
  -         return result;
  -      }
  -   }
  -
  -   public enum ListenerMethod
  -   {
  -      NODE_CREATED, NODE_REMOVED, NODE_VISITED, NODE_MODIFIED, NODE_MOVED
  -   }
   }
  
  
  
  1.1      date: 2007/01/03 22:51:58;  author: msurtani;  state: Exp;JBossCache/tests/functional/org/jboss/cache/notifications/RemoteCacheListenerOptimisticTest.java
  
  Index: RemoteCacheListenerOptimisticTest.java
  ===================================================================
  package org.jboss.cache.notifications;
  
  /**
   * optimistic counterpart of {@link org.jboss.cache.notifications.RemoteCacheListenerTest}
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public class RemoteCacheListenerOptimisticTest extends RemoteCacheListenerTest
  {
     public RemoteCacheListenerOptimisticTest()
     {
        optLocking = true;
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list