You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/07/27 11:30:05 UTC

svn commit: r426015 - in /lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation: ObservationTest.java TestListener.java

Author: andreas
Date: Thu Jul 27 02:30:05 2006
New Revision: 426015

URL: http://svn.apache.org/viewvc?rev=426015&view=rev
Log:
Added failing test for observation manager (only allListener is registered -> no notification), thanks to Josias

Modified:
    lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java
    lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java

Modified: lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java?rev=426015&r1=426014&r2=426015&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java (original)
+++ lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java Thu Jul 27 02:30:05 2006
@@ -16,6 +16,14 @@
  */
 package org.apache.lenya.cms.observation;
 
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.apache.avalon.framework.service.ServiceException;
 import org.apache.lenya.ac.impl.AbstractAccessControlTest;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.lenya.cms.publication.Document;
@@ -23,6 +31,7 @@
 import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationUtil;
+import org.apache.lenya.cms.repository.RepositoryException;
 import org.apache.lenya.cms.repository.RepositoryUtil;
 import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.xml.NamespaceHelper;
@@ -43,8 +52,12 @@
         ObservationRegistry registry = null;
         try {
             registry = (ObservationRegistry) getManager().lookup(ObservationRegistry.ROLE);
-            registry.registerListener(docListener, doc);
+
+            // check if it works if only the allListener is registered
+            registry.registerListener(allListener);
+            testListener(doc, allListener);
             
+            registry.registerListener(docListener, doc);
             Exception e = null;
             try {
                 registry.registerListener(docListener, doc);
@@ -53,8 +66,10 @@
                 e = e1;
             }
             assertNotNull(e);
+
+            testListener(doc, docListener);
+            testListener(doc, allListener);
             
-            registry.registerListener(allListener);
         }
         finally {
             if (registry != null) {
@@ -62,20 +77,21 @@
             }
         }
         
+        
+    }
+
+    protected void testListener(Document doc, TestListener listener) throws Exception {
         NamespaceHelper xml = new NamespaceHelper("http://apache.org/lenya/test", "", "test");
         doc.getRepositoryNode().lock();
         SourceUtil.writeDOM(xml.getDocument(), doc.getSourceURI(), getManager());
         
-        assertFalse(docListener.wasNotified());
-        assertFalse(allListener.wasNotified());
+        assertFalse(listener.wasNotified());
         
         doc.getRepositoryNode().getSession().commit();
         
         Thread.currentThread().sleep(100);
         
-        assertTrue(docListener.wasNotified());
-        assertTrue(allListener.wasNotified());
-        
+        assertTrue(listener.wasNotified());
     }
 
 }

Modified: lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java?rev=426015&r1=426014&r2=426015&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java (original)
+++ lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java Thu Jul 27 02:30:05 2006
@@ -15,4 +15,8 @@
         return this.notified;
     }
     
+    public void reset() {
+        this.notified = false;
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org