|
|
Choosing A Webhost: |
svn commit: r426130 - in /lenya/trunk/src: modules-core/observation-impl/ja: msg#00200cms.lenya.cvs
Author: andreas Date: Thu Jul 27 09:35:12 2006 New Revision: 426130 URL: http://svn.apache.org/viewvc?rev=426130&view=rev Log: Fixed notification for deleted documents 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 lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.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=426130&r1=426129&r2=426130&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 09:35:12 2006 @@ -28,6 +28,7 @@ import org.apache.lenya.cms.cocoon.source.SourceUtil; import org.apache.lenya.cms.publication.Document; import org.apache.lenya.cms.publication.DocumentFactory; +import org.apache.lenya.cms.publication.DocumentManager; import org.apache.lenya.cms.publication.DocumentUtil; import org.apache.lenya.cms.publication.Publication; import org.apache.lenya.cms.publication.PublicationUtil; @@ -55,7 +56,7 @@ // check if it works if only the allListener is registered registry.registerListener(allListener); - testListener(doc, allListener); + testChanged(doc, allListener); registry.registerListener(docListener, doc); Exception e = null; @@ -67,8 +68,8 @@ } assertNotNull(e); - testListener(doc, docListener); - testListener(doc, allListener); + testChanged(doc, docListener); + testChanged(doc, allListener); } finally { @@ -80,7 +81,7 @@ } - protected void testListener(Document doc, TestListener listener) throws Exception { + protected void testChanged(Document doc, TestListener listener) throws Exception { listener.reset(); NamespaceHelper xml = new NamespaceHelper("http://apache.org/lenya/test", "", "test"); doc.getRepositoryNode().lock(); @@ -90,13 +91,38 @@ doc.setMimeType(""); doc.setMimeType(mimeType); - assertFalse(listener.wasNotified()); - + assertFalse(listener.wasChanged()); doc.getRepositoryNode().getSession().commit(); - Thread.currentThread().sleep(100); + assertTrue(listener.wasChanged()); + } + + protected void testRemoved(Document doc, TestListener listener) throws Exception { + listener.reset(); + + DocumentManager docManager = null; + try { + docManager = (DocumentManager) getManager().lookup(DocumentManager.ROLE); + Document target = doc.getIdentityMap().get(doc.getPublication(), doc.getArea(), "/testTarget", doc.getLanguage()); + docManager.move(doc, target); + + assertFalse(listener.wasRemoved()); + doc.getRepositoryNode().getSession().commit(); + Thread.currentThread().sleep(100); + assertTrue(listener.wasRemoved()); + + docManager.move(target, doc); + assertFalse(listener.wasChanged()); + doc.getRepositoryNode().getSession().commit(); + Thread.currentThread().sleep(100); + assertTrue(listener.wasChanged()); + } + finally { + if (docManager != null) { + getManager().release(docManager); + } + } - 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=426130&r1=426129&r2=426130&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 09:35:12 2006 @@ -5,18 +5,28 @@ public class TestListener implements RepositoryListener { - private boolean notified = false; + private boolean changed = false; + private boolean removed = false; public void documentChanged(RepositoryEvent event) { - this.notified = true; + this.changed = true; } - public boolean wasNotified() { - return this.notified; + public boolean wasChanged() { + return this.changed; + } + + public boolean wasRemoved() { + return this.removed; } public void reset() { - this.notified = false; + this.changed = false; + this.removed = false; + } + + public void documentRemoved(RepositoryEvent event) { + this.removed = true; } } Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java?rev=426130&r1=426129&r2=426130&view=diff ============================================================================== --- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java (original) +++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java Thu Jul 27 09:35:12 2006 @@ -234,7 +234,7 @@ Node node = getDocumentNode(); for (Iterator i = this.listeners.iterator(); i.hasNext(); ) { NodeListener listener = (NodeListener) i.next(); - listener.nodeChanged(node, getSession().getIdentity()); + listener.nodeRemoved(node, getSession().getIdentity()); } } catch (Exception e) {
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | svn commit: r426129 - /lenya/trunk/src/impl/java/org/apache/lenya/cms/observation/ObservationManager.java, andreas |
|---|---|
| Next by Date: | svn commit: r426145 - /lenya/trunk/src/pubs/default/sitemap.xmap, chestnut |
| Previous by Thread: | svn commit: r426129 - /lenya/trunk/src/impl/java/org/apache/lenya/cms/observation/ObservationManager.java, andreas |
| Next by Thread: | svn commit: r426145 - /lenya/trunk/src/pubs/default/sitemap.xmap, chestnut |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |