You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2010/08/09 16:51:48 UTC

svn commit: r983662 - /jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SimpleSearchTest.java

Author: jukka
Date: Mon Aug  9 14:51:48 2010
New Revision: 983662

URL: http://svn.apache.org/viewvc?rev=983662&view=rev
Log:
JCR-2695: Jackrabbit performance test suite

Add a simple search performance test

Added:
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SimpleSearchTest.java   (with props)

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SimpleSearchTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SimpleSearchTest.java?rev=983662&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SimpleSearchTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SimpleSearchTest.java Mon Aug  9 14:51:48 2010
@@ -0,0 +1,74 @@
+/*
+ * 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.benchmark;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+
+public class SimpleSearchTest extends PerformanceTest {
+
+    private static final int NODE_COUNT = 100;
+
+    private Session session;
+
+    private Node root;
+
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+
+        root = session.getRootNode().addNode("testroot", "nt:unstructured");
+        for (int i = 0; i < NODE_COUNT; i++) {
+            Node node = root.addNode("node" + i, "nt:unstructured");
+            for (int j = 0; j < NODE_COUNT; j++) {
+                Node child = node.addNode("node" + j, "nt:unstructured");
+                child.setProperty("testcount", j);
+            }
+            session.save();
+        }
+    }
+
+    public void runTest() throws Exception {
+        QueryManager manager = session.getWorkspace().getQueryManager();
+        for (int i = 0; i < NODE_COUNT; i++) {
+            Query query =
+                manager.createQuery("//*[@testcount=" + i + "]", Query.XPATH);
+            NodeIterator iterator = query.execute().getNodes();
+            while (iterator.hasNext()) {
+                Node node = iterator.nextNode();
+                if (node.getProperty("testcount").getLong() != i) {
+                    throw new Exception("Invalid test result: " + node.getPath());
+                }
+            }
+        }
+    }
+
+    public void afterSuite() throws RepositoryException {
+        for (int i = 0; i < NODE_COUNT; i++) {
+            root.getNode("node" + i).remove();
+            session.save();
+        }
+
+        root.remove();
+        session.save();
+        session.logout();
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SimpleSearchTest.java
------------------------------------------------------------------------------
    svn:eol-style = native