You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2005/03/23 13:27:17 UTC
svn commit: r158756 - in
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api:
RepositoryLoginTest.java TestAll.java lock/LockTest.java
version/VersionHistoryTest.java
Author: mreutegg
Date: Wed Mar 23 04:27:15 2005
New Revision: 158756
URL: http://svn.apache.org/viewcvs?view=rev&rev=158756
Log:
Additional test cases for locking, versioning and repository login.
Added:
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RepositoryLoginTest.java (with props)
Modified:
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RepositoryLoginTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RepositoryLoginTest.java?view=auto&rev=158756
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RepositoryLoginTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RepositoryLoginTest.java Wed Mar 23 04:27:15 2005
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Session;
+
+/**
+ * <code>RepositoryLoginTest</code> tests the login methods of a repository.
+ *
+ * @test
+ * @sources RepositoryLoginTest.java
+ * @executeClass org.apache.jackrabbit.test.api.RepositoryLoginTest
+ * @keywords level1
+ */
+public class RepositoryLoginTest extends AbstractJCRTest {
+
+ private Credentials credentials;
+ private String workspaceName;
+ private Repository repository;
+
+ /**
+ * Sets up the fixture for the test cases.
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ credentials = helper.getReadOnlyCredentials();
+ workspaceName = superuser.getWorkspace().getName();
+ repository = helper.getRepository();
+ }
+
+ /**
+ * Tests if {@link javax.jcr.Repository#login(Credentials credentials, String workspaceName)}
+ * throws a {@link javax.jcr.NoSuchWorkspaceException}
+ * if no workspace of the requested name is existing.
+ */
+ public void testNoSuchWorkspaceException()
+ throws RepositoryException {
+
+ Session session = helper.getReadOnlySession();
+ String name;
+ try {
+ name = getNonExistingWorkspaceName(session);
+ } finally {
+ session.logout();
+ }
+
+ try {
+ helper.getRepository().login(credentials, name);
+ fail("login with a not available workspace name must throw a " +
+ "NoSuchWorkspaceException");
+ } catch (NoSuchWorkspaceException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if {@link javax.jcr.Repository#login(Credentials credentials, String workspaceName)}
+ * does return a session, i. e. not null.
+ */
+ public void testSignatureCredentialsAndWorkspaceName()
+ throws RepositoryException {
+
+ Session s = repository.login(credentials, workspaceName);
+ try {
+ assertNotNull("Repository.login(Credentials credentials, " +
+ "String workspaceName) must not return null",
+ s);
+ } finally {
+ s.logout();
+ }
+ }
+
+ /**
+ * Tests if {@link javax.jcr.Repository#login(Credentials credentials)} does
+ * return a session, i. e. not null.
+ */
+ public void testSignatureCredentials()
+ throws RepositoryException {
+
+ Session s = repository.login(credentials);
+ try {
+ assertNotNull("Repository.login(Credentials credentials) " +
+ "must not return null",
+ s);
+ } finally {
+ s.logout();
+ }
+ }
+
+ /**
+ * Tests if {@link javax.jcr.Repository#login(Credentials credentials, String workspaceName)}
+ * does return a session, i. e. not null.
+ */
+ public void testSignatureWorkspaceName()
+ throws RepositoryException {
+
+ Session s = repository.login(workspaceName);
+ try {
+ assertNotNull("Repository.login(String workspaceName) " +
+ "must not return null",
+ s);
+ } finally {
+ s.logout();
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RepositoryLoginTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java?view=diff&r1=158755&r2=158756
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java Wed Mar 23 04:27:15 2005
@@ -119,6 +119,7 @@
suite.addTestSuite(WorkspaceMoveTest.class);
suite.addTestSuite(WorkspaceMoveVersionableTest.class);
+ suite.addTestSuite(RepositoryLoginTest.class);
suite.addTestSuite(ImpersonateTest.class);
suite.addTestSuite(CheckPermissionTest.class);
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java?view=diff&r1=158755&r2=158756
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java Wed Mar 23 04:27:15 2005
@@ -310,6 +310,30 @@
}
/**
+ * Test Lock.isDeep()
+ */
+ public void testIsDeep() throws RepositoryException {
+ // create two lockable nodes
+ Node n1 = testRootNode.addNode(nodeName1, testNodeType);
+ n1.addMixin(mixLockable);
+ Node n2 = testRootNode.addNode(nodeName2, testNodeType);
+ n2.addMixin(mixLockable);
+ testRootNode.save();
+
+ // lock node 1 "undeeply"
+ Lock lock1 = n1.lock(false, true);
+ assertFalse("Lock.isDeep() must be false if the lock has not been set " +
+ "as not deep",
+ lock1.isDeep());
+
+ // lock node 2 "deeply"
+ Lock lock2 = n2.lock(true, true);
+ assertTrue("Lock.isDeep() must be true if the lock has been set " +
+ "as deep",
+ lock2.isDeep());
+ }
+
+ /**
* Test locks are released when session logs out
*/
public void testLogout() throws Exception {
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java?view=diff&r1=158755&r2=158756
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java Wed Mar 23 04:27:15 2005
@@ -30,6 +30,7 @@
import javax.jcr.StringValue;
import javax.jcr.Value;
import javax.jcr.PropertyType;
+import javax.jcr.PathNotFoundException;
import javax.jcr.version.VersionHistory;
import javax.jcr.version.VersionIterator;
@@ -98,6 +99,22 @@
}
/**
+ * Test if initially auto-created root version does not provide any state
+ * information
+ */
+ public void testAutocreatedRootVersionHasNoState() throws
+ RepositoryException {
+
+ Version rootVersion = vHistory.getRootVersion();
+ try {
+ rootVersion.getNode(jcrFrozenNode);
+ fail("The root vesion must not store any state information.");
+ } catch (PathNotFoundException e) {
+ // success
+ }
+ }
+
+ /**
* The version history must initially contain two versions (root version +
* first test version).
*
@@ -818,4 +835,4 @@
// should do nothing and return quietly
vHistory.update(workspaceName);
}
-}
\ No newline at end of file
+}