<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jtrim.access;

import java.util.Collections;
import java.util.concurrent.atomic.AtomicInteger;
import org.jtrim.cancel.Cancellation;
import org.jtrim.cancel.CancellationToken;
import org.jtrim.concurrent.CancelableTask;
import org.jtrim.concurrent.SyncTaskExecutor;
import org.jtrim.concurrent.TaskExecutor;
import org.junit.*;
import static org.junit.Assert.*;

/**
 *
 * @author <NAME>
 */
public class ScheduledAccessTokenTest {

    public ScheduledAccessTokenTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of createExecutor method, of class ScheduledAccessToken.
     */
    @Test
    public void testNoBlocking() {
        ScheduledAccessToken<String> token = new ScheduledAccessToken<>(
                AccessTokens.createToken("INDEPENDENT"),
                Collections.<AccessToken<String>>emptySet());

        final AtomicInteger executed = new AtomicInteger(0);
        TaskExecutor executor = token.createExecutor(SyncTaskExecutor.getSimpleExecutor());
        executor.execute(Cancellation.UNCANCELABLE_TOKEN, new CancelableTask() {
            @Override
            public void execute(CancellationToken cancelToken) {
                executed.incrementAndGet();
            }
        }, null);
        assertEquals(1, executed.get());
    }
}
<commit_msg>Added some additional test codes for ScheduledAccessToken.<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jtrim.access;

import java.util.Collections;
import java.util.concurrent.atomic.AtomicInteger;
import org.jtrim.cancel.Cancellation;
import org.jtrim.cancel.CancellationToken;
import org.jtrim.concurrent.*;
import org.junit.*;

import static org.junit.Assert.*;

/**
 *
 * @author <NAME>
 */
public class ScheduledAccessTokenTest {

    public ScheduledAccessTokenTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    private static ScheduledAccessToken<String> createUnblockedToken() {
        return new ScheduledAccessToken<>(
                AccessTokens.createToken("INDEPENDENT"),
                Collections.<AccessToken<String>>emptySet());
    }

    @Test
    public void testNoBlocking() {
        ScheduledAccessToken<String> token = createUnblockedToken();

        final AtomicInteger executed = new AtomicInteger(0);
        TaskExecutor executor = token.createExecutor(SyncTaskExecutor.getSimpleExecutor());
        executor.execute(Cancellation.UNCANCELABLE_TOKEN, new CancelableTask() {
            @Override
            public void execute(CancellationToken cancelToken) {
                executed.incrementAndGet();
            }
        }, null);
        assertEquals(1, executed.get());
    }

    @Test
    public void testNoBlockingCleanup() {
        ScheduledAccessToken<String> token = createUnblockedToken();

        final AtomicInteger executed = new AtomicInteger(0);
        TaskExecutor executor = token.createExecutor(SyncTaskExecutor.getSimpleExecutor());
        executor.execute(Cancellation.UNCANCELABLE_TOKEN, Tasks.noOpCancelableTask(),
                new CleanupTask() {
            @Override
            public void cleanup(boolean canceled, Throwable error) {
                assertFalse(canceled);
                assertNull(error);

                executed.incrementAndGet();
            }
        });
        assertEquals(1, executed.get());
    }

    @Test
    public void testReleaseEventSimplePostRelease() {
        ScheduledAccessToken<String> token = createUnblockedToken();

        final AtomicInteger executed = new AtomicInteger(0);
        token.release();
        token.addReleaseListener(new Runnable() {
            @Override
            public void run() {
                executed.incrementAndGet();
            }
        });
        assertEquals(1, executed.get());
    }

    @Test
    public void testReleaseEventSimplePreRelease() {
        ScheduledAccessToken<String> token = createUnblockedToken();

        final AtomicInteger executed = new AtomicInteger(0);
        token.addReleaseListener(new Runnable() {
            @Override
            public void run() {
                executed.incrementAndGet();
            }
        });
        token.release();
        assertEquals(1, executed.get());
    }

    @Test
    public void testReleaseEventWithTask() {
        ScheduledAccessToken<String> token = createUnblockedToken();

        final AtomicInteger executed = new AtomicInteger(0);
        token.addReleaseListener(new Runnable() {
            @Override
            public void run() {
                executed.incrementAndGet();
            }
        });

        TaskExecutor executor = token.createExecutor(SyncTaskExecutor.getSimpleExecutor());
        executor.execute(Cancellation.UNCANCELABLE_TOKEN, Tasks.noOpCancelableTask(), null);

        token.release();
        assertEquals(1, executed.get());
    }
}

{'fraction_non_alphanumeric': 0.09627043909608672, 'fraction_numerical': 0.002204666544185192, 'mean_word_length': 2.6414715719063544, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '2893847', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1402, 'n_words': 308}