<commit_before>/*
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2007-2013 Pentaho
// All Rights Reserved.
*/
package mondrian.util;

import junit.framework.TestCase;

import java.util.Random;
import java.util.concurrent.*;

/**
 * Testcase for {@link BlockingHashMap}.
 *
 * @author mcampbell
 */
public class BlockingHashMapTest extends TestCase {

    private final Random random = new Random(new Random().nextLong());
    private static final int SLEEP_TIME = 100;

    /**
     * Validates values put in the BlockingHashMap by one thread
     * can be correctly retrieved by another thread.
     * Also verifies get operations can happen concurrently, in
     * that total time to get all values synchronously would (on average) be
     * 50 milliseconds * 100 Getters, and the test will fail if duration
     * is greater than 2 seconds.<commit_msg>[MONDRIAN-1471]  Modified test to use Util.createRandom(-1) to for deterministic results.<commit_after>/*
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2007-2013 Pentaho
// All Rights Reserved.
*/
package mondrian.util;

import junit.framework.TestCase;
import mondrian.olap.Util;

import java.util.Random;
import java.util.concurrent.*;

/**
 * Testcase for {@link BlockingHashMap}.
 *
 * @author mcampbell
 */
public class BlockingHashMapTest extends TestCase {

    private final Random random = Util.createRandom(-1);
    private static final int SLEEP_TIME = 100;

    /**
     * Validates values put in the BlockingHashMap by one thread
     * can be correctly retrieved by another thread.
     * Also verifies get operations can happen concurrently, in
     * that total time to get all values synchronously would (on average) be
     * 50 milliseconds * 100 Getters, and the test will fail if duration
     * is greater than 2 seconds.
{'fraction_non_alphanumeric': 0.08742676881478144, 'fraction_numerical': 0.021631365479945923, 'mean_word_length': 3.4223107569721116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2885878', 'n_tokens_mistral': 642, 'n_tokens_neox': 594, 'n_words': 256}