Author: nzamosenchuk
Date: 2009-11-19 09:29:05 -0500 (Thu, 19 Nov 2009)
New Revision: 776
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-242: Locking tests moved to another class
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java
(rev 0)
+++
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java 2009-11-19
14:29:05 UTC (rev 776)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import org.exoplatform.services.jcr.impl.core.lock.LockData;
+
+import java.util.List;
+
+import javax.jcr.lock.LockException;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay
Zamosenchuk</a>
+ * @version $Id$
+ *
+ */
+public class JBossCacheStorageConnectionLockTest extends
AbstractJBossCacheStorageConnectionTest
+{
+ public void testAddLock() throws Exception
+ {
+ // ordinary add lock
+ LockData lockData = new LockData("testAddLock", "token's
hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ assertEquals(lockData.getTokenHash(),
conn.getLockData("testAddLock").getTokenHash());
+ }
+
+ public void testAddLockTwice() throws Exception
+ {
+ // ordinary add lock
+ {
+ LockData lockData = new LockData("testAddLockTwice", "token's
hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ assertEquals(lockData.getTokenHash(),
conn.getLockData("testAddLockTwice").getTokenHash());
+ }
+ // try to lock once more
+ try
+ {
+ // add lock to the same node twice
+ LockData lockData = new LockData("testAddLockTwice", "other
token's hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ fail("exception expected, because can't lock node twice");
+ }
+ catch (LockException e)
+ {
+ }
+ }
+
+ public void testRefreshLock() throws Exception
+ {
+ // ordinary add lock
+ {
+ LockData lockData = new LockData("testRefreshLock", "token's
hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ assertEquals(lockData.getTokenHash(),
conn.getLockData("testRefreshLock").getTokenHash());
+ }
+ // try to refresh lock (updates creation time to extend lifetime)
+ // refresh is performed by writing new lock data (only difference is changed
creation time)
+ {
+ LockData lockData = new LockData("testRefreshLock", "token's
hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ assertEquals(lockData.getTokenHash(),
conn.getLockData("testRefreshLock").getTokenHash());
+ }
+ }
+
+ public void testGetLocks() throws Exception
+ {
+ // clean up any existing
+ List<LockData> locks = conn.getLocksData();
+ for (LockData lock : locks)
+ {
+ conn.removeLockData(lock.getNodeIdentifier());
+ }
+ // check empty
+ locks = conn.getLocksData();
+ assertEquals(0, locks.size());
+ // fill
+ int count = 3;
+ for (int i = 0; i < count; i++)
+ {
+ LockData lockData = new LockData("testGetLocks" + i, "token's
hash " + i, true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ }
+ // assert
+ locks = conn.getLocksData();
+ assertEquals(count, locks.size());
+ }
+}
Property changes on:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19
14:22:41 UTC (rev 775)
+++
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19
14:29:05 UTC (rev 776)
@@ -624,75 +624,6 @@
}
- public void testAddLock() throws Exception
- {
- // ordinary add lock
- LockData lockData = new LockData("testAddLock", "token's
hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- assertEquals(lockData.getTokenHash(),
conn.getLockData("testAddLock").getTokenHash());
- }
-
- public void testAddLockTwice() throws Exception
- {
- // ordinary add lock
- {
- LockData lockData = new LockData("testAddLockTwice", "token's
hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- assertEquals(lockData.getTokenHash(),
conn.getLockData("testAddLockTwice").getTokenHash());
- }
- // try to lock once more
- try
- {
- // add lock to the same node twice
- LockData lockData = new LockData("testAddLockTwice", "other
token's hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- fail("exception expected, because can't lock node twice");
- }
- catch (LockException e)
- {
- }
- }
-
- public void testRefreshLock() throws Exception
- {
- // ordinary add lock
- {
- LockData lockData = new LockData("testRefreshLock", "token's
hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- assertEquals(lockData.getTokenHash(),
conn.getLockData("testRefreshLock").getTokenHash());
- }
- // try to refresh lock (updates creation time to extend lifetime)
- // refresh is performed by writing new lock data (only difference is changed
creation time)
- {
- LockData lockData = new LockData("testRefreshLock", "token's
hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- assertEquals(lockData.getTokenHash(),
conn.getLockData("testRefreshLock").getTokenHash());
- }
- }
-
- public void testGetLocks() throws Exception
- {
- // clean up any existing
- List<LockData> locks = conn.getLocksData();
- for (LockData lock : locks)
- {
- conn.removeLockData(lock.getNodeIdentifier());
- }
- // check empty
- locks = conn.getLocksData();
- assertEquals(0, locks.size());
- // fill
- int count = 3;
- for (int i = 0; i < count; i++)
- {
- LockData lockData = new LockData("testGetLocks" + i, "token's
hash " + i, true, true, "owner", 1000);
- conn.addLockData(lockData);
- }
- // assert
- locks = conn.getLocksData();
- assertEquals(count, locks.size());
- }
-
public void testAddNodeFail() throws Exception
{
// add root (/)