<commit_before>/*
 * Copyright (c) 2013-2016 Cinchapi Inc.
 *
 * 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 com.cinchapi.concourse.util;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import org.junit.Assert;
import org.junit.Test;

import com.cinchapi.concourse.test.ConcourseBaseTest;

/**
 * Unit tests for {@link FileOps}.
 * 
 * @author <NAME>
 */
public class FileOpsTest extends ConcourseBaseTest {

    @Test(timeout = 10000)
    public void testAwaitChange() throws InterruptedException {
        String file = FileOps.tempFile(Random.getSimpleString(), "foo",
                ".test");
        CountDownLatch latch = new CountDownLatch(1);
        Thread t = new Thread(() -> {
            FileOps.awaitChange(file);
            latch.countDown();
        });
        t.start();
        AtomicBoolean done = new AtomicBoolean(false);
        Thread t2 = new Thread(() -> {
            while (!done.get()) {
                // There is an arbitrary and uncontrollable delay between the
                // time that the path Thread t starting and the
                // FileOps#awaitChange method actually registering the path so
                // we just keep writing to the file so that, eventually, one of<commit_msg>use real temp dir for test<commit_after>/*
 * Copyright (c) 2013-2016 Cinchapi Inc.
 *
 * 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 com.cinchapi.concourse.util;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import org.junit.Assert;
import org.junit.Test;

import com.cinchapi.concourse.test.ConcourseBaseTest;

/**
 * Unit tests for {@link FileOps}.
 * 
 * @author <NAME>
 */
public class FileOpsTest extends ConcourseBaseTest {

    @Test(timeout = 10000)
    public void testAwaitChange() throws InterruptedException {
        String file = FileOps.tempFile(FileOps.tempDir("con"), "foo", ".test");
        CountDownLatch latch = new CountDownLatch(1);
        Thread t = new Thread(() -> {
            FileOps.awaitChange(file);
            latch.countDown();
        });
        t.start();
        AtomicBoolean done = new AtomicBoolean(false);
        Thread t2 = new Thread(() -> {
            while (!done.get()) {
                // There is an arbitrary and uncontrollable delay between the
                // time that the path Thread t starting and the
                // FileOps#awaitChange method actually registering the path so
                // we just keep writing to the file so that, eventually, one of
{'fraction_non_alphanumeric': 0.0928708003277793, 'fraction_numerical': 0.01037967768369298, 'mean_word_length': 2.8792372881355934, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4640400', 'n_tokens_mistral': 993, 'n_tokens_neox': 949, 'n_words': 364}