<commit_before>/*
 * 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;

import org.apache.jackrabbit.test.AbstractJCRTest;

import javax.jcr.Repository;
import javax.jcr.Node;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Session;
import javax.jcr.RepositoryException;
import javax.jcr.SimpleCredentials;
import javax.jcr.observation.Event;
import javax.jcr.version.VersionException;
import javax.jcr.version.Version;
import javax.jcr.lock.Lock;
import javax.transaction.UserTransaction;
import javax.transaction.RollbackException;
import java.io.PrintWriter;
import java.io.PrintStream;

/**
 * <code>XATest</code> contains the test cases for the methods
 * inside {@link org.apache.jackrabbit.core.XASession}.
 */
public class XATest extends AbstractJCRTest {

    /**
     * Other superuser.
     */
    private Session otherSuperuser;

    /**
     * {@inheritDoc}
     */
    protected void setUp() throws Exception {
        super.setUp();

        otherSuperuser = helper.getSuperuserSession();
    }

    /**
     * {@inheritDoc}
     */
    protected void tearDown() throws Exception {
        if (otherSuperuser != null) {
            otherSuperuser.logout();
        }
        super.tearDown();
    }

    /**
     * @see junit.framework#runTest
     *
     * Make sure that tested repository supports transactions
     */
    protected void runTest() throws Throwable {
        Repository rep = helper.getRepository();
        if (isSupported(Repository.OPTION_TRANSACTIONS_SUPPORTED)) {
            super.runTest();
        }
    }
<commit_msg>JCR-485: TCK does not clean 2nd workspace during AbstractJCRTest.setUp()<commit_after>/*
 * 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;

import org.apache.jackrabbit.test.AbstractJCRTest;

import javax.jcr.Repository;
import javax.jcr.Node;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Session;
import javax.jcr.RepositoryException;
import javax.jcr.SimpleCredentials;
import javax.jcr.NodeIterator;
import javax.jcr.observation.Event;
import javax.jcr.version.VersionException;
import javax.jcr.version.Version;
import javax.jcr.lock.Lock;
import javax.transaction.UserTransaction;
import javax.transaction.RollbackException;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;

/**
 * <code>XATest</code> contains the test cases for the methods
 * inside {@link org.apache.jackrabbit.core.XASession}.
 */
public class XATest extends AbstractJCRTest {

    /**
     * Other superuser.
     */
    private Session otherSuperuser;

    /**
     * {@inheritDoc}
     */
    protected void setUp() throws Exception {
        super.setUp();

        otherSuperuser = helper.getSuperuserSession();

        // clean testroot on second workspace
        Session s2 = helper.getSuperuserSession(workspaceName);
        Node root = s2.getRootNode();
        if (root.hasNode(testPath)) {
            // clean test root
            Node testRootNode = root.getNode(testPath);
            for (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
                children.nextNode().remove();
            }
        } else {
            // create nodes to testPath
            StringTokenizer names = new StringTokenizer(testPath, "/");
            Node currentNode = root;
            while (names.hasMoreTokens()) {
                String name = names.nextToken();
                if (currentNode.hasNode(name)) {
                    currentNode = currentNode.getNode(name);
                } else {
                    currentNode = currentNode.addNode(name, testNodeType);
                }
            }
        }
        root.save();

    }

    /**
     * {@inheritDoc}
     */
    protected void tearDown() throws Exception {
        if (otherSuperuser != null) {
            otherSuperuser.logout();
        }
        super.tearDown();
    }

    /**
     * @see junit.framework#runTest
     *
     * Make sure that tested repository supports transactions
     */
    protected void runTest() throws Throwable {
        Repository rep = helper.getRepository();
        if (isSupported(Repository.OPTION_TRANSACTIONS_SUPPORTED)) {
            super.runTest();
        }
    }

{'fraction_non_alphanumeric': 0.09218263576617088, 'fraction_numerical': 0.002421307506053269, 'mean_word_length': 2.8604806408544725, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2368964', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1514, 'n_words': 475}