### Eclipse Workspace Patch 1.0 #P oak-run Index: src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java =================================================================== --- src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java (revision 1485166) +++ src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java (working copy) @@ -84,6 +84,7 @@ new WikipediaImport(wikipedia.value(options)), new CreateNodesBenchmark(), new ManyNodes(), + new ReadStatusTestSingleACL(), ReadManyTest.linear("LinearReadEmpty", 1, ReadManyTest.EMPTY), ReadManyTest.linear("LinearReadFiles", 1, ReadManyTest.FILES), ReadManyTest.linear("LinearReadNodes", 1, ReadManyTest.NODES), Index: src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java =================================================================== --- src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java (revision 1485223) +++ src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java (working copy) @@ -236,6 +236,26 @@ throw new RuntimeException(e); } } + + /** + * Returns a new session for the given user + * that will be automatically closed once + * all the iterations of this test have been executed. + * + * @param credentials the user credentials + * @return user session + */ + protected Session login(Credentials credentials) { + try { + Session session = repository.login(credentials); + sessions.add(session); + return session; + } catch (RepositoryException e) { + throw new RuntimeException(e); + } + } + + /** * Returns a new writer session that will be automatically closed once Index: src/main/java/org/apache/jackrabbit/oak/benchmark/ReadStatusTestSingleACL.java =================================================================== --- src/main/java/org/apache/jackrabbit/oak/benchmark/ReadStatusTestSingleACL.java (revision 0) +++ src/main/java/org/apache/jackrabbit/oak/benchmark/ReadStatusTestSingleACL.java (revision 0) @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.oak.benchmark; + +import java.security.Principal; + +import javax.jcr.Node; +import javax.jcr.NodeIterator; +import javax.jcr.Session; +import javax.jcr.SimpleCredentials; +import javax.jcr.security.AccessControlManager; +import org.apache.jackrabbit.api.JackrabbitSession; +import org.apache.jackrabbit.api.security.user.User; +import org.apache.jackrabbit.api.security.user.UserManager; +import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; +import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; +import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants; + +public class ReadStatusTestSingleACL extends AbstractTest{ + + private Session reader; + private String userId = "test"; + private Principal userPrincipal; + + @Override + protected void beforeSuite() throws Exception { + + Session writer = loginWriter(); + + UserManager userManager = ((JackrabbitSession) writer).getUserManager(); + User user = userManager.createUser(userId, userId); + userPrincipal = user.getPrincipal(); + AccessControlManager acm = writer.getAccessControlManager(); + JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acm, "/"); + acl.addEntry(userPrincipal, AccessControlUtils.privilegesFromNames(acm, PrivilegeConstants.JCR_READ), true); + acl.addEntry(userPrincipal, AccessControlUtils.privilegesFromNames(acm, PrivilegeConstants.JCR_READ_ACCESS_CONTROL), true); + acm.setPolicy("/", acl); + + Node a = writer.getRootNode().addNode("a"); + for (int i = 0; i < 10000; i++){ + a.addNode("node" + i); + } + writer.save(); + + reader = login(new SimpleCredentials(userId, userId.toCharArray())); + } + + @Override + protected void runTest() throws Exception { + NodeIterator iterator = reader.getNode("/a").getNodes(); + long size = iterator.getSize(); + if (size == -1) { + for (size = 0; iterator.hasNext(); size++) { + iterator.nextNode(); + } + } + } + }