[exo-jcr-commits] exo-jcr SVN: r1342 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/impl/dataflow/persistent and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jan 11 08:55:28 EST 2010
Author: sergiykarpenko
Date: 2010-01-11 08:55:28 -0500 (Mon, 11 Jan 2010)
New Revision: 1342
Added:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestMultipleListenersNotifying.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
Log:
EXOJCR-376: TestMultipleListenersNotifying added
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-11 12:35:47 UTC (rev 1341)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-11 13:55:28 UTC (rev 1342)
@@ -198,7 +198,6 @@
{
try
{
-
transactionManager.begin();
transactionManager.setTransactionTimeout(20);
cache.beginTransaction();
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestMultipleListenersNotifying.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestMultipleListenersNotifying.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestMultipleListenersNotifying.java 2010-01-11 13:55:28 UTC (rev 1342)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.dataflow.persistent;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
+import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
+import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a>
+ * @version $Id: TestMultipleListenersNotifying.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestMultipleListenersNotifying extends TestCase
+{
+
+ class TestDataManager extends WorkspacePersistentDataManager
+ {
+ public TestDataManager()
+ {
+ super(null, new SystemDataContainerHolder(null));
+ }
+ }
+
+ class Counter
+ {
+ int count = 0;
+
+ synchronized public void increment()
+ {
+ count++;
+ }
+
+ public int getCount()
+ {
+ return count;
+ }
+
+ public void reset()
+ {
+ count = 0;
+ }
+ }
+
+ class TestTxAwareListener implements ItemsPersistenceListener
+ {
+ boolean isTXAware;
+
+ Counter count;
+
+ public TestTxAwareListener(boolean isTXAware, Counter count)
+ {
+ this.isTXAware = isTXAware;
+ this.count = count;
+ }
+
+ public boolean isTXAware()
+ {
+ return isTXAware;
+ }
+
+ public void onSaveItems(ItemStateChangesLog itemStates)
+ {
+ count.increment();
+ }
+ }
+
+ public void testMultipleListenersNotify() throws Exception
+ {
+ int listTransCount = 27;
+ int listNotTransCount = 10;
+ TestDataManager mgr = new TestDataManager();
+
+ Counter countTrans = new Counter();
+ Counter countNotTrans = new Counter();
+ // set listeners
+ for (int i = 0; i < listTransCount; i++)
+ {
+ mgr.addItemPersistenceListener(new TestTxAwareListener(true, countTrans));
+ }
+ for (int i = 0; i < listNotTransCount; i++)
+ {
+ mgr.addItemPersistenceListener(new TestTxAwareListener(false, countNotTrans));
+ }
+
+ mgr.notifySaveItems(null, true);
+ assertEquals(listTransCount, countTrans.getCount());
+ assertEquals(0, countNotTrans.getCount());
+
+ countTrans.reset();
+ countNotTrans.reset();
+
+ mgr.notifySaveItems(null, false);
+ assertEquals(0, countTrans.getCount());
+ assertEquals(listNotTransCount, countNotTrans.getCount());
+ }
+}
More information about the exo-jcr-commits
mailing list