### 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 1543460) +++ src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java (working copy) @@ -166,6 +166,7 @@ ReadManyTest.uniform("UniformReadNodes", 1, ReadManyTest.NODES), new ConcurrentCreateNodesTest(), new SequentialCreateNodesTest(), + new GetPoliciesTest(), }; Set argset = Sets.newHashSet(options.nonOptionArguments()); Index: src/main/java/org/apache/jackrabbit/oak/benchmark/GetPoliciesTest.java =================================================================== --- src/main/java/org/apache/jackrabbit/oak/benchmark/GetPoliciesTest.java (revision 0) +++ src/main/java/org/apache/jackrabbit/oak/benchmark/GetPoliciesTest.java (revision 0) @@ -0,0 +1,80 @@ +/* + * 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 static javax.jcr.security.Privilege.JCR_READ; +import static org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils.addAccessControlEntry; + +import javax.jcr.Node; +import javax.jcr.Session; +import javax.jcr.security.AccessControlManager; + +import org.apache.jackrabbit.api.JackrabbitSession; +import org.apache.jackrabbit.core.security.principal.EveryonePrincipal; + +/** + * {@code GetPoliciesTest} implements a performance test, which get policies from the + * repository. + */ +public class GetPoliciesTest extends AbstractTest { + + Session session; + private Node testRoot; + private String path; + private AccessControlManager acm; + + @Override + protected void beforeSuite() throws Exception { + session = loginWriter(); + testRoot = session.getRootNode().addNode( + getClass().getSimpleName() + TEST_ID, "nt:unstructured"); + Node n = testRoot.addNode("node1"); + + path = n.getPath(); + addAccessControlEntry(session, n.getPath(), + EveryonePrincipal.getInstance(), new String[] { JCR_READ }, + true); + + session.save(); + + testRoot = loginWriter().getNode(testRoot.getPath()); + acm = ((JackrabbitSession) testRoot.getSession()).getAccessControlManager(); + + + session.logout(); + } + + @Override + protected void runTest() throws Exception { + for (int i = 0; i < 10000; i++) { + acm.getPolicies(path); + } + + } + + @Override + protected void afterSuite() throws Exception { + Session session = loginWriter(); + session.getNode(testRoot.getPath()).remove(); + testRoot.getSession().logout(); + session.save(); + session.logout(); + } + +}