<commit_before>package eu.unicate.retroauth;

import android.accounts.OperationCanceledException;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicInteger;

import eu.unicate.retroauth.exceptions.AuthenticationCanceledException;
import eu.unicate.retroauth.strategies.LockingStrategy;
import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import rx.observers.TestSubscriber;
import rx.schedulers.Schedulers;

/**
 * Testing the {@link LockingStrategy}
 * With rx java methods and blocking methods.
 * <p/>
 * Since methods using retrofit.Callback are handled the same as
 * rx java methods (see {@link AuthRestHandler#asyncRequest(Method, Object[])})
 * I see no point in testing the as well
 */
@RunWith(JUnit4.class)
public class LockingStrategyTests {

	/**
	 * Amount of requests executed
	 */
	private static final int REQUEST_AMOUNT = 100;

	/**
	 * Time to wait after the requests started until the tests
	 * will assert their values
	 */
	private static final long TIME_TO_WAIT_FOR_QUEUEING = 300L;

	/**
	 * Time in ms, that a failing request is taking
	 * Since we want to make sure that this requests are queued waiting for the first one
	 * this should be a bigger value. not too big since we want to have quick tests
	 */
	public static final long FAILING_REQUEST_TIME = 20L;

	/**
	 * Time in ms, a successful request is taking
	 * (keep it short, since there are {@link #REQUEST_AMOUNT} of requests executed.)
	 */
	public static final long SUCCESSFUL_REQUEST_TIME = 0L;

	/**
	 * Testcase:
	 * 100 simultaneously called requests are called. all of them are comparable to
	 * retroauth blocking calls (i.e. {@code @Authenticated Object someCall()})
	 * <p/>
	 * After they are started it waits 100ms, to make sure all of the are executed
	 * then checking if all of them returned with a result and completed.
	 * To make sure that there's no lock anymore, there's another request started and
	 * checked for result and completion as well
	 */
	@Test
	public void testBlockingSuccess() throws InterruptedException {
		final LockingStrategy strategy = new LockingStrategy("success-blocking");<commit_msg>more time for test execution<commit_after>package eu.unicate.retroauth;

import android.accounts.OperationCanceledException;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicInteger;

import eu.unicate.retroauth.exceptions.AuthenticationCanceledException;
import eu.unicate.retroauth.strategies.LockingStrategy;
import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import rx.observers.TestSubscriber;
import rx.schedulers.Schedulers;

/**
 * Testing the {@link LockingStrategy}
 * With rx java methods and blocking methods.
 * <p/>
 * Since methods using retrofit.Callback are handled the same as
 * rx java methods (see {@link AuthRestHandler#asyncRequest(Method, Object[])})
 * I see no point in testing the as well
 */
@RunWith(JUnit4.class)
public class LockingStrategyTests {

	/**
	 * Amount of requests executed
	 */
	private static final int REQUEST_AMOUNT = 100;

	/**
	 * Time to wait after the requests started until the tests
	 * will assert their values
	 */
	private static final long TIME_TO_WAIT_FOR_QUEUEING = 500L;

	/**
	 * Time in ms, that a failing request is taking
	 * Since we want to make sure that this requests are queued waiting for the first one
	 * this should be a bigger value. not too big since we want to have quick tests
	 */
	public static final long FAILING_REQUEST_TIME = 20L;

	/**
	 * Time in ms, a successful request is taking
	 * (keep it short, since there are {@link #REQUEST_AMOUNT} of requests executed.)
	 */
	public static final long SUCCESSFUL_REQUEST_TIME = 0L;

	/**
	 * Testcase:
	 * 100 simultaneously called requests are called. all of them are comparable to
	 * retroauth blocking calls (i.e. {@code @Authenticated Object someCall()})
	 * <p/>
	 * After they are started it waits 100ms, to make sure all of the are executed
	 * then checking if all of them returned with a result and completed.
	 * To make sure that there's no lock anymore, there's another request started and
	 * checked for result and completion as well
	 */
	@Test
	public void testBlockingSuccess() throws InterruptedException {
		final LockingStrategy strategy = new LockingStrategy("success-blocking");
{'fraction_non_alphanumeric': 0.07905656256824634, 'fraction_numerical': 0.007425202009172308, 'mean_word_length': 4.344224037339557, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2498324', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1256, 'n_words': 509}