Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 00CABD5C7 for ; Mon, 27 Aug 2012 20:14:13 +0000 (UTC) Received: (qmail 65989 invoked by uid 500); 27 Aug 2012 20:14:12 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 65944 invoked by uid 500); 27 Aug 2012 20:14:12 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 65936 invoked by uid 99); 27 Aug 2012 20:14:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Aug 2012 20:14:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Aug 2012 20:14:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 14CE22388A5B; Mon, 27 Aug 2012 20:13:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1377819 [2/2] - in /sling/trunk: ./ performance/ performance/base/ performance/base/src/ performance/base/src/main/ performance/base/src/main/java/ performance/base/src/main/java/org/ performance/base/src/main/java/org/apache/ performance/... Date: Mon, 27 Aug 2012 20:13:23 -0000 To: commits@sling.apache.org From: justin@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120827201325.14CE22388A5B@eris.apache.org> Added: sling/trunk/performance/jcr-resource-2.2.0/src/test/java/org/apache/sling/performance/PerformanceTest.java URL: http://svn.apache.org/viewvc/sling/trunk/performance/jcr-resource-2.2.0/src/test/java/org/apache/sling/performance/PerformanceTest.java?rev=1377819&view=auto ============================================================================== --- sling/trunk/performance/jcr-resource-2.2.0/src/test/java/org/apache/sling/performance/PerformanceTest.java (added) +++ sling/trunk/performance/jcr-resource-2.2.0/src/test/java/org/apache/sling/performance/PerformanceTest.java Mon Aug 27 20:13:21 2012 @@ -0,0 +1,141 @@ +/* + * 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.sling.performance; + +import static org.mockito.Mockito.mock; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.jcr.NamespaceRegistry; +import javax.jcr.Session; + +import junitx.util.PrivateAccessor; + +import org.apache.sling.api.SlingConstants; +import org.apache.sling.api.resource.QueriableResourceProvider; +import org.apache.sling.api.resource.ResourceProvider; +import org.apache.sling.api.resource.ResourceProviderFactory; +import org.apache.sling.api.resource.ResourceResolver; +import org.apache.sling.jcr.api.SlingRepository; +import org.apache.sling.jcr.resource.JcrResourceConstants; +import org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory; +import org.apache.sling.performance.tests.ResolveWith10000AliasTest; +import org.apache.sling.performance.tests.ResolveWith10000VanityPathTest; +import org.apache.sling.performance.tests.ResolveWith1000AliasTest; +import org.apache.sling.performance.tests.ResolveWith1000VanityPathTest; +import org.apache.sling.performance.tests.ResolveWith30000AliasTest; +import org.apache.sling.performance.tests.ResolveWith30000VanityPathTest; +import org.apache.sling.performance.tests.ResolveWith5000AliasTest; +import org.apache.sling.performance.tests.ResolveWith5000VanityPathTest; +import org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl; +import org.apache.sling.resourceresolver.impl.mapping.MapEntries; +import org.apache.sling.resourceresolver.impl.mapping.Mapping; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.service.event.Event; +import org.osgi.service.event.EventAdmin; + +public class PerformanceTest extends AbstractPerformanceTest { + + private class Helper implements TestHelper { + + private MapEntries mapEntries; + + private ResourceResolver resourceResolver; + + public void dispose() { + mapEntries.dispose(); + } + + public ResourceResolver getResourceResolver() { + return resourceResolver; + } + + public void init(String rootPath, Session session, SlingRepository repository) throws Exception { + ResourceResolverFactoryImpl resFac = new ResourceResolverFactoryImpl(); + + JcrResourceProviderFactory providerFactory = new JcrResourceProviderFactory(); + PrivateAccessor.setField(providerFactory, "repository", repository); + + Map props = new HashMap(); + props.put(Constants.SERVICE_ID, -1l); + props.put(ResourceProviderFactory.PROPERTY_REQUIRED, true); + props.put(ResourceProvider.ROOTS, "/"); + props.put(QueriableResourceProvider.LANGUAGES, new String[] { "xpath", "sql" }); + + try { + PrivateAccessor.invoke(resFac, "bindResourceProviderFactory", new Class[] { ResourceProviderFactory.class, + Map.class }, new Object[] { providerFactory, props }); + } catch (Throwable e) { + throw new Exception(e); + } + + // setup mappings + PrivateAccessor.setField(resFac, "mappings", new Mapping[] { new Mapping("/-/"), new Mapping(rootPath + "/-/") }); + + // ensure namespace mangling + PrivateAccessor.setField(resFac, "mangleNamespacePrefixes", true); + + // setup mapping root + PrivateAccessor.setField(resFac, "mapRoot", "/etc/map"); + + final EventAdmin mockVoidEA = new EventAdmin() { + + public void postEvent(Event event) { + // nothing to do + } + + public void sendEvent(Event event) { + // nothing to do + } + }; + + mapEntries = new MapEntries(resFac, mock(BundleContext.class), mockVoidEA); + PrivateAccessor.setField(resFac, "mapEntries", mapEntries); + + try { + NamespaceRegistry nsr = session.getWorkspace().getNamespaceRegistry(); + nsr.registerNamespace(SlingConstants.NAMESPACE_PREFIX, JcrResourceConstants.SLING_NAMESPACE_URI); + } catch (Exception e) { + // don't care for now + } + + Map authInfo = Collections. singletonMap( + JcrResourceConstants.AUTHENTICATION_INFO_SESSION, session); + resourceResolver = resFac.getResourceResolver(authInfo); + } + } + + public void testPerformance() throws Exception { + Helper helper = new Helper(); + + List tests = new ArrayList(); + tests.add(new ResolveWith1000VanityPathTest(helper)); + tests.add(new ResolveWith5000VanityPathTest(helper)); + tests.add(new ResolveWith10000VanityPathTest(helper)); + //tests.add(new ResolveWith30000VanityPathTest(helper)); + tests.add(new ResolveWith1000AliasTest(helper)); + tests.add(new ResolveWith5000AliasTest(helper)); + tests.add(new ResolveWith10000AliasTest(helper)); + //tests.add(new ResolveWith30000AliasTest(helper)); + testPerformance("jcr.resource-2.2.0", tests); + } +} Propchange: sling/trunk/performance/jcr-resource-2.2.0/src/test/java/org/apache/sling/performance/PerformanceTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/performance/jcr-resource-2.2.0/src/test/java/org/apache/sling/performance/PerformanceTest.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Rev URL Added: sling/trunk/performance/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/performance/pom.xml?rev=1377819&view=auto ============================================================================== --- sling/trunk/performance/pom.xml (added) +++ sling/trunk/performance/pom.xml Mon Aug 27 20:13:21 2012 @@ -0,0 +1,74 @@ + + + + + 4.0.0 + + + org.apache.sling + sling + 13 + ../parent/pom.xml + + + org.apache.sling + sling-performance-tests + pom + 0.0.1-SNAPSHOT + + Apache Sling Performance Tests + + Performance tests for the Apache Sling project + + + + 4.8.2 + + + + + scm:svn:http://svn.apache.org/repos/asf/sling/trunk/performance + + + scm:svn:https://svn.apache.org/repos/asf/sling/trunk/performance + + http://svn.apache.org/viewvc/sling/trunk/performance + + + + base + jcr-resource-2.0.10 + jcr-resource-2.1.0 + jcr-resource-2.2.0 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + -Xms256m -Xmx1024m -XX:MaxPermSize=512m + + + + + + Propchange: sling/trunk/performance/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Modified: sling/trunk/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/pom.xml?rev=1377819&r1=1377818&r2=1377819&view=diff ============================================================================== --- sling/trunk/pom.xml (original) +++ sling/trunk/pom.xml Mon Aug 27 20:13:21 2012 @@ -245,6 +245,13 @@ contrib + + + withPerformanceTest + + performance + +