jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r637157 [2/2] - in /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core: ./ integration/ integration/random/ integration/random/operation/ integration/random/task/
Date Fri, 14 Mar 2008 16:50:01 GMT
Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/XATransaction.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/XATransaction.java?rev=637157&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/XATransaction.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/XATransaction.java
Fri Mar 14 09:49:56 2008
@@ -0,0 +1,49 @@
+/*
+ * 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.core.integration.random.operation;
+
+import org.apache.jackrabbit.core.UserTransactionImpl;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
+
+import javax.jcr.NodeIterator;
+import javax.jcr.Session;
+
+/**
+ * <code>XATransaction</code> wraps an operation with a XA transaction.
+ */
+public class XATransaction extends Operation {
+
+    private static final Logger log = LoggerFactory.getLogger(XATransaction.class);
+
+    private final Operation op;
+
+    public XATransaction(Session s, Operation op) {
+        super(s, "/");
+        this.op = op;
+    }
+
+    public NodeIterator execute() throws Exception {
+        UserTransactionImpl tx = new UserTransactionImpl(getSession());
+        log.info("begin transaction");
+        tx.begin();
+        NodeIterator it = op.execute();
+        log.info("commit transaction");
+        tx.commit();
+        return it;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/XATransaction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java?rev=637157&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java
Fri Mar 14 09:49:56 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.core.integration.random.task;
+
+import org.apache.jackrabbit.core.integration.random.operation.Operation;
+import org.apache.jackrabbit.core.integration.random.operation.OperationFactory;
+
+import javax.jcr.NodeIterator;
+
+/**
+ * <code>ContentOperationsTask</code> performs random content operations.
+ */
+public class ContentOperationsTask extends RandomOperationsTask {
+
+    public ContentOperationsTask(int numLevels, int nodesPerLevel, long end) {
+        super(new String[0], numLevels, nodesPerLevel, end);
+    }
+
+    protected Operation getRandomOperations(OperationFactory f,
+                                            NodeIterator randomNodes)
+            throws Exception {
+        return f.randomContentOperations(randomNodes, 3, 10);
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java?rev=637157&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java
Fri Mar 14 09:49:56 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.core.integration.random.task;
+
+import org.apache.jackrabbit.core.AbstractConcurrencyTest;
+import org.apache.jackrabbit.core.integration.random.operation.Operation;
+import org.apache.jackrabbit.core.integration.random.operation.OperationFactory;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * <code>ContentOperationsTask</code> base class for random operation tasks.
+ */
+public abstract class RandomOperationsTask implements AbstractConcurrencyTest.Task {
+
+    private final String[] mixins;
+
+    private final int numLevels;
+
+    private final int nodesPerLevel;
+
+    private final long end;
+
+    private boolean useXA = false;
+
+    public RandomOperationsTask(String mixins[], int numLevels, int nodesPerLevel, long end)
{
+        this.mixins = mixins;
+        this.numLevels = numLevels;
+        this.nodesPerLevel = nodesPerLevel;
+        this.end = end;
+    }
+
+    public void execute(Session session, Node test) throws RepositoryException {
+        try {
+            OperationFactory f = new OperationFactory(session);
+            // create nodes
+            f.createNodes(test.getPath(), numLevels, nodesPerLevel, mixins).execute();
+            // save nodes
+            f.save(test.getPath()).execute();
+
+            NodeIterator nodes = f.getRandomNodes(f.traverseNodes(test.getPath()));
+            while (end > System.currentTimeMillis()) {
+                Operation op = f.runInSequence(new Operation[]{
+                    getRandomOperations(f, nodes),
+                    f.save("/")
+                });
+                if (isUseXA()) {
+                    op = f.runInTransaction(op);
+                }
+                op.execute();
+            }
+            test.remove();
+            session.save();
+        } catch (Exception e) {
+            throw new RepositoryException(e);
+        }
+    }
+
+    protected abstract Operation getRandomOperations(OperationFactory f,
+                                                     NodeIterator randomNodes)
+            throws Exception;
+
+    public boolean isUseXA() {
+        return useXA;
+    }
+
+    public void setUseXA(boolean useXA) {
+        this.useXA = useXA;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java?rev=637157&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java
Fri Mar 14 09:49:56 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.core.integration.random.task;
+
+import org.apache.jackrabbit.core.integration.random.operation.Operation;
+import org.apache.jackrabbit.core.integration.random.operation.OperationFactory;
+
+import javax.jcr.NodeIterator;
+
+/**
+ * <code>VersionOperationsTask</code> performs random version operations.
+ */
+public class VersionOperationsTask extends RandomOperationsTask {
+
+    public VersionOperationsTask(int numLevels, int nodesPerLevel, long end) {
+        super(new String[]{"mix:versionable"}, numLevels, nodesPerLevel, end);
+    }
+
+    protected Operation getRandomOperations(OperationFactory f,
+                                            NodeIterator randomNodes)
+            throws Exception {
+        return f.randomVersionOperations(randomNodes, 3, 10);
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message