Author: nzamosenchuk
Date: 2009-11-25 08:08:18 -0500 (Wed, 25 Nov 2009)
New Revision: 858
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLockCleanupOnRestart.java
Log:
EXOJCR-262: Added manual test for checking whether lock-properties are deleted on restart
(startup)
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLockCleanupOnRestart.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLockCleanupOnRestart.java
(rev 0)
+++
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLockCleanupOnRestart.java 2009-11-25
13:08:18 UTC (rev 858)
@@ -0,0 +1,99 @@
+/*
+ * 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.api.lock;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+import org.hsqldb.DatabaseManager;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import javax.jcr.PathNotFoundException;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay
Zamosenchuk</a>
+ * @version $Id$
+ *
+ */
+public class TestLockCleanupOnRestart extends JcrAPIBaseTest
+{
+
+ /*
+ * This test should be performed manually because it requires JCR tearDown and startup
without
+ * cleaning it's content.
+ *
+ * To check whether lock-properties are deleted as expected, first run:
+ * >mvn clean test
-Dtest=org.exoplatform.services.jcr.api.lock.TestLockCleanupOnRestart
+ * then (without clean!) :
+ * >mvn test
-Dtest=org.exoplatform.services.jcr.api.lock.TestLockCleanupOnRestart
+ */
+
+ private static String testNodeName = "LockIt";
+
+ public void testLockCleanUp() throws Exception
+ {
+ log.info("/!\\ This test should be executed twice ('mvn clean test "
+ + "-Dtest=...' and then without 'clean') and separately from
other tests /!\\");
+ NodeImpl node;
+ try
+ {
+ node = (NodeImpl)root.getNode(testNodeName);
+ log.info("Node \"/LockIt\" found, this is correct SECOND
run.");
+ }
+ catch (PathNotFoundException e)
+ {
+ node = (NodeImpl)root.addNode(testNodeName);
+ node.addMixin("mix:lockable");
+ log.info("Node \"/LockIt\" not found, this is probably FIRST run.
If not, "
+ + "ensure that \"clean\" is not invoked in \"maven
test\"!");
+ }
+ session.save();
+ // locking the node with open-scoped deep lock.
+ // no exception should be thrown
+ try
+ {
+ node.lock(true, false);
+ // ok!
+ }
+ catch (Exception e)
+ {
+ fail("Unexpected exception" + e.getStackTrace());
+ }
+ session.logout();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ // super.tearDown in not invoked to prevent DB cleaning
+ // shutdown HSSQLDB :)
+ for (Object uri : DatabaseManager.getDatabaseURIs())
+ {
+ try
+ {
+ Connection c = DriverManager.getConnection("jdbc:hsqldb:" +
uri.toString(), "sa", "");
+ c.createStatement().execute("SHUTDOWN");
+ }
+ catch (Throwable e)
+ {
+ }
+ }
+ }
+}
Property changes on:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLockCleanupOnRestart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native