<commit_before>/*
 * Copyright 2014-2017 Real Logic Ltd.
 *
 * Licensed 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 io.aeron.archiver;

import io.aeron.*;
import io.aeron.archiver.client.ArchiveClient;
import io.aeron.archiver.codecs.ControlResponseCode;
import io.aeron.logbuffer.FragmentHandler;
import org.agrona.concurrent.UnsafeBuffer;
import org.junit.Assert;

import java.io.*;
import java.util.concurrent.locks.LockSupport;
import java.util.function.BooleanSupplier;

import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

public class TestUtil
{
    public static final int TIMEOUT = 5000;
    public static final boolean DEBUG = false;
    public static final int SLEEP_TIME_NS = 5000;

    public static File makeTempDir() throws IOException
    {
        final File tempDirForTest = File.createTempFile("archiver", "tmp");
        // we really need a temp dir, not a file... delete and remake!
        Assert.assertTrue(tempDirForTest.delete());
        Assert.assertTrue(tempDirForTest.mkdir());

        return tempDirForTest;
    }

    public static void printf(final String s, final Object... args)
    {
        if (DEBUG)
        {
            System.out.printf(s, args);
        }
    }

    public static void println(final String s)
    {
        if (DEBUG)
        {
            System.out.println(s);
        }
    }

    public static void waitForOk(final ArchiveClient client, final Subscription reply, final long correlationId)
    {
        waitFor(() -> client.pollResponses(reply, new FailResponseListener()
        {
            public void onResponse(final long correlationId, final ControlResponseCode code, final String errorMessage)
            {
                assertThat(code, is(ControlResponseCode.OK));
                assertThat(errorMessage, isEmptyOrNullString());
                assertThat(correlationId, is(correlationId));
            }
        }, 1) != 0);
    }
<commit_msg>[Java] spacing<commit_after>/*
 * Copyright 2014-2017 Real Logic Ltd.
 *
 * Licensed 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 io.aeron.archiver;

import io.aeron.Publication;
import io.aeron.Subscription;
import io.aeron.archiver.client.ArchiveClient;
import io.aeron.archiver.codecs.ControlResponseCode;
import io.aeron.logbuffer.FragmentHandler;
import org.agrona.concurrent.UnsafeBuffer;
import org.junit.Assert;

import java.io.File;
import java.io.IOException;
import java.util.concurrent.locks.LockSupport;
import java.util.function.BooleanSupplier;

import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

public class TestUtil
{
    public static final int TIMEOUT = 5000;
    public static final boolean DEBUG = false;
    public static final int SLEEP_TIME_NS = 5000;

    public static File makeTempDir() throws IOException
    {
        final File tempDirForTest = File.createTempFile("archiver", "tmp");
        // we really need a temp dir, not a file... delete and remake!
        Assert.assertTrue(tempDirForTest.delete());
        Assert.assertTrue(tempDirForTest.mkdir());

        return tempDirForTest;
    }

    public static void printf(final String s, final Object... args)
    {
        if (DEBUG)
        {
            System.out.printf(s, args);
        }
    }

    public static void println(final String s)
    {
        if (DEBUG)
        {
            System.out.println(s);
        }
    }

    public static void waitForOk(final ArchiveClient client, final Subscription reply, final long correlationId)
    {
        waitFor(() -> client.pollResponses(reply, new FailResponseListener()
        {
            public void onResponse(final long correlationId, final ControlResponseCode code, final String errorMessage)
            {
                assertThat("Error message: " + errorMessage, code, is(ControlResponseCode.OK));
                assertThat(errorMessage, isEmptyOrNullString());
                assertThat(correlationId, is(correlationId));
            }
        }, 1) != 0);
    }

{'fraction_non_alphanumeric': 0.08934642992066491, 'fraction_numerical': 0.00831129580657348, 'mean_word_length': 3.0512624330527927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3137827', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1421, 'n_words': 456}