You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2012/08/27 22:13:23 UTC
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/...
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<String, Object> props = new HashMap<String, Object>();
+ 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<String, Object> authInfo = Collections.<String, Object> singletonMap(
+ JcrResourceConstants.AUTHENTICATION_INFO_SESSION, session);
+ resourceResolver = resFac.getResourceResolver(authInfo);
+ }
+ }
+
+ public void testPerformance() throws Exception {
+ Helper helper = new Helper();
+
+ List<AbstractTest> tests = new ArrayList<AbstractTest>();
+ 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 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>13</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling-performance-tests</artifactId>
+ <packaging>pom</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <name>Apache Sling Performance Tests</name>
+ <description>
+ Performance tests for the Apache Sling project
+ </description>
+
+ <properties>
+ <junit.version>4.8.2</junit.version>
+ </properties>
+
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/sling/trunk/performance
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/sling/trunk/performance
+ </developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/trunk/performance</url>
+ </scm>
+
+ <modules>
+ <module>base</module>
+ <module>jcr-resource-2.0.10</module>
+ <module>jcr-resource-2.1.0</module>
+ <module>jcr-resource-2.2.0</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Xms256m -Xmx1024m -XX:MaxPermSize=512m</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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 @@
<module>contrib</module>
</modules>
</profile>
+ <!-- Profile for including performan tests -->
+ <profile>
+ <id>withPerformanceTest</id>
+ <modules>
+ <module>performance</module>
+ </modules>
+ </profile>
</profiles>
</project>