Index: oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/LoginNSTest.java
===================================================================
--- oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/LoginNSTest.java	(revision 0)
+++ oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/LoginNSTest.java	(revision 0)
@@ -0,0 +1,130 @@
+/*
+ * 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.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jcr.Credentials;
+import javax.jcr.NamespaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+public class LoginNSTest extends AbstractTest {
+
+    private final Session[] sessions = new Session[1000];
+
+    private final Map<Long, NamespaceEntry[]> namespaceTable = new HashMap<Long, NamespaceEntry[]>();
+
+    @Override
+    public void setUp(Repository repository, Credentials credentials)
+            throws Exception {
+        super.setUp(repository,
+                new SimpleCredentials("admin", "admin".toCharArray()));
+
+        // register ns
+        namespaceTable.put(1l, new NamespaceEntry[] {
+                new NamespaceEntry("sling",
+                        "http://sling.apache.org/jcr/sling/1.0"),
+                new NamespaceEntry("slingevent",
+                        "http://sling.apache.org/jcr/event/1.0") });
+    }
+
+    @Override
+    public void runTest() throws RepositoryException {
+        for (int i = 0; i < sessions.length; i++) {
+            sessions[i] = getRepository().login(getCredentials(), "default");
+            defineNamespacePrefixes(sessions[i], namespaceTable);
+            
+        }
+    }
+
+    @Override
+    public void afterTest() throws RepositoryException {
+        for (Session session : sessions) {
+            session.logout();
+        }
+    }
+
+    // -----------------------------------------------------------------------------------------------------------
+
+    /**
+     * 
+     * Inspired by sling's Loader class
+     * TODO link to sling source
+     * 
+     */
+    private static void defineNamespacePrefixes(Session session,
+            Map<Long, NamespaceEntry[]> namespaceTable)
+            throws RepositoryException {
+
+        final Iterator<NamespaceEntry[]> iter = namespaceTable.values().iterator();
+        while ( iter.hasNext() ) {
+            final NamespaceEntry[] entries = iter.next();
+            for(int i=0; i<entries.length; i++) {
+
+                // the namespace prefixing is a little bit tricky:
+                String mappedPrefix = null;
+                // first, we check if the namespace is registered with a prefix
+                try {
+                    mappedPrefix = session.getNamespacePrefix(entries[i].namespace);
+                } catch (NamespaceException ne) {
+                    // the namespace is not registered yet, so we should do this
+                    // can we directly use the desired prefix?
+                    mappedPrefix = entries[i].prefix + "_new";
+                    try {
+                        session.getNamespaceURI(entries[i].prefix);
+                    } catch (NamespaceException ne2) {
+                        // as an exception occured we can directly use the new prefix
+                        mappedPrefix = entries[i].prefix;
+                    }
+                    session.getWorkspace().getNamespaceRegistry().registerNamespace(mappedPrefix, entries[i].namespace);
+                }
+                // do we have to remap?
+                if ( mappedPrefix != null && !mappedPrefix.equals(entries[i].prefix ) ) {
+                    // check if the prefix is already used?
+                    String oldUri = null;
+                    try {
+                        oldUri = session.getNamespaceURI(entries[i].prefix);
+                        session.setNamespacePrefix(entries[i].prefix + "_old", oldUri);
+                    } catch (NamespaceException ne) {
+                        // ignore: prefix is not used
+                    }
+                    // finally set prefix
+                    session.setNamespacePrefix(entries[i].prefix, entries[i].namespace);
+                }
+            }
+        }
+    }
+
+    private static class NamespaceEntry {
+
+        public final String prefix;
+        public final String namespace;
+
+        public NamespaceEntry(String p, String n) {
+            this.prefix = p;
+            this.namespace = n;
+        }
+    }
+
+    // -----------------------------------------------------------------------------------------------------------
+
+}

Property changes on: oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/LoginNSTest.java
___________________________________________________________________
Added: svn:eol-style
   + native
Added: svn:keywords
   + Author Date Id Revision Rev URL

Index: oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
===================================================================
--- oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java	(revision 1505637)
+++ oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java	(working copy)
@@ -74,6 +74,7 @@
         };
         Benchmark[] allBenchmarks = new Benchmark[] {
             new LoginTest(),
+            new LoginNSTest(),
             new LoginLogoutTest(),
             new ReadPropertyTest(),
             new SetPropertyTest(),
