<commit_before>/*
 * The contents of this file are subject to the license and copyright
 * detailed in the LICENSE and NOTICE files at the root of the source
 * tree and available online at
 *
 *     http://duracloud.org/license/
 */
package org.duracloud.mill.workman;

import java.io.File;
import java.util.Arrays;
import java.util.List;

import org.duracloud.account.db.repo.DuracloudAccountRepo;
import org.duracloud.common.queue.TaskQueue;
import org.duracloud.common.queue.local.LocalTaskQueue;
import org.duracloud.common.queue.task.NoopTask;
import org.duracloud.common.queue.task.Task;
import org.duracloud.contentindex.client.ContentIndexClient;
import org.duracloud.mill.config.ConfigurationManager;
import org.duracloud.mill.credentials.CredentialsRepo;
import org.duracloud.mill.credentials.file.ConfigFileCredentialRepo;
import org.duracloud.mill.dup.DuplicationPolicyManager;
import org.duracloud.mill.dup.repo.LocalDuplicationPolicyRepo;
import org.duracloud.mill.workman.spring.AppConfig;
import org.duracloud.mill.workman.spring.WorkmanConfigurationManager;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * This class tests a round trip for processing Noop Tasks, from task creation
 * to task processing.
 * 
 * @author <NAME> Date: Oct 24, 2013
 */
public class NoopProcessorLocalRoundTripTest {

    private final static LocalTaskQueue LOW_PRIORITY_QUEUE = new LocalTaskQueue();
    private final static LocalTaskQueue HIGH_PRIORITY_QUEUE = new LocalTaskQueue();
    private final static LocalTaskQueue AUDIT_QUEUE = new LocalTaskQueue();
    private final static LocalTaskQueue BIT_ERROR_QUEUE = new LocalTaskQueue();
    private final static LocalTaskQueue DUPLICATION_QUEUE = new LocalTaskQueue();
    private final static LocalTaskQueue DEAD_LETTER_QUEUE = new LocalTaskQueue();

    private ApplicationContext context;

    @Configuration
    @ComponentScan(basePackages={"org.duracloud.mill"})
    public static class TestAppConfig extends AppConfig {

        /* (non-Javadoc)
         * @see org.duracloud.mill.workman.spring.AppConfig#taskQueues(org.duracloud.mill.workman.spring.WorkmanConfigurationManager)
         */
        @Override
        public List<TaskQueue> createTaskQueues(WorkmanConfigurationManager configurationManager) {
            return Arrays.asList(new TaskQueue[] { HIGH_PRIORITY_QUEUE,
                                                   LOW_PRIORITY_QUEUE });
        }
        
        /* (non-Javadoc)
         * @see org.duracloud.mill.workman.spring.AppConfig#contentIndexClient(org.duracloud.mill.workman.spring.WorkmanConfigurationManager)
         */
        @Override
        public ContentIndexClient contentIndexClient(WorkmanConfigurationManager config) {
            return null;
        }
        
        /* (non-Javadoc)
         * @see org.duracloud.mill.workman.spring.AppConfig#deadLetterQueue(org.duracloud.mill.workman.spring.WorkmanConfigurationManager)
         */
        @Override
        public TaskQueue deadLetterQueue(WorkmanConfigurationManager configurationManager) {
            return DEAD_LETTER_QUEUE;
        }
        
        @Override
        public CredentialsRepo credentialRepo(
                ConfigurationManager configurationManager,
                DuracloudAccountRepo accountRepo) {
            return new ConfigFileCredentialRepo();
        }

        @Override
        public TaskQueue auditQueue(WorkmanConfigurationManager configurationManager) {
            return AUDIT_QUEUE;
        }
        
        /* (non-Javadoc)
         * @see org.duracloud.mill.workman.spring.AppConfig#bitErrorQueue(org.duracloud.mill.workman.spring.WorkmanConfigurationManager)
         */
        @Override
        public TaskQueue bitErrorQueue(WorkmanConfigurationManager configurationManager) {
            return BIT_ERROR_QUEUE;
        }
        
        /* (non-Javadoc)
         * @see org.duracloud.mill.workman.spring.AppConfig#duplicationTaskQueue(org.duracloud.mill.workman.spring.WorkmanConfigurationManager)
         */
        @Override
        public TaskQueue duplicationQueue(WorkmanConfigurationManager configurationManager) {
            return DUPLICATION_QUEUE;
        }
        
        /* (non-Javadoc)
         * @see org.duracloud.mill.workman.spring.AppConfig#duplicationPolicyManager(org.duracloud.mill.workman.spring.WorkmanConfigurationManager)
         */
        @Override
        public DuplicationPolicyManager duplicationPolicyManager(WorkmanConfigurationManager configurationManager) {
            return new DuplicationPolicyManager(new LocalDuplicationPolicyRepo(System.getProperty("java.io.tmpdir")));
        }
    }
    /**
     * @throws java.lang.Exception
     */
    @Before
    public void setUp() throws Exception {
        File testProperties = new File("src/test/resources/workman-test.properties");
        Assert.assertTrue(testProperties.exists());
        System.setProperty(ConfigurationManager.WORK_DIRECTORY_PATH_KEY, "target");
        System.setProperty(ConfigurationManager.DURACLOUD_MILL_CONFIG_FILE_KEY, testProperties.getAbsolutePath());
        System.setProperty(TaskWorkerManager.MIN_WAIT_BEFORE_TAKE_KEY, "1");

        context = new AnnotationConfigApplicationContext(TestAppConfig.class);
    }

    /**
     * @throws java.lang.Exception
     */
    @After
    public void tearDown() throws Exception {
        context = null;
    }
<commit_msg>fixes broken NoopProcessorLocalRoundTripTest<commit_after>/*
 * The contents of this file are subject to the license and copyright
 * detailed in the LICENSE and NOTICE files at the root of the source
 * tree and available online at
 *
 *     http://duracloud.org/license/
 */
package org.duracloud.mill.workman;

import java.io.File;
import java.util.Arrays;
import java.util.List;

import org.duracloud.account.db.repo.DuracloudAccountRepo;
import org.duracloud.common.queue.TaskQueue;
import org.duracloud.common.queue.local.LocalTaskQueue;
import org.duracloud.common.queue.task.NoopTask;
import org.duracloud.common.queue.task.Task;
import org.duracloud.mill.bit.BitIntegrityCheckTaskProcessorFactory;
import org.duracloud.mill.bit.BitIntegrityReportTaskProcessorFactory;
import org.duracloud.mill.common.storageprovider.StorageProviderFactory;
import org.duracloud.mill.config.ConfigurationManager;
import org.duracloud.mill.credentials.CredentialsRepo;
import org.duracloud.mill.credentials.file.ConfigFileCredentialRepo;
import org.duracloud.mill.dup.DuplicationPolicyManager;
import org.duracloud.mill.dup.DuplicationTaskProcessorFactory;
import org.duracloud.mill.dup.repo.LocalDuplicationPolicyRepo;
import org.duracloud.mill.noop.NoopTaskProcessorFactory;
import org.duracloud.mill.workman.spring.WorkmanConfigurationManager;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * This class tests a round trip for processing Noop Tasks, from task creation
 * to task processing.
 * 
 * @author <NAME> Date: Oct 24, 2013
 */
public class NoopProcessorLocalRoundTripTest {

    private final static LocalTaskQueue HIGH_PRIORITY_QUEUE = new LocalTaskQueue();
    private final static LocalTaskQueue LOW_PRIORITY_QUEUE = new LocalTaskQueue();

    private final static LocalTaskQueue DEAD_LETTER_QUEUE = new LocalTaskQueue();

    private ApplicationContext context;

    @Configuration
    public static class TestAppConfig  {

 
        @Bean(initMethod="init", destroyMethod="destroy")
        public TaskWorkerManager taskWorkerManager(RootTaskProcessorFactory factory,
                                                    TaskQueue deadLetterQueue) {
            return new TaskWorkerManager(Arrays.asList(new TaskQueue[] {
                    HIGH_PRIORITY_QUEUE, LOW_PRIORITY_QUEUE }),
                    deadLetterQueue, new TaskWorkerFactoryImpl(factory,
                            deadLetterQueue));
        }
        
        @Bean
        public RootTaskProcessorFactory 
                    rootTaskProcessorFactory(File workDir) {

            RootTaskProcessorFactory factory = new RootTaskProcessorFactory();
            factory.addTaskProcessorFactory(new NoopTaskProcessorFactory(null,
                    workDir));

            return factory;
        }
        
        @Bean
        public TaskQueue deadLetterQueue() {
            return DEAD_LETTER_QUEUE;
        }
        
        
        

        @Bean
        public File workDir() {
            WorkmanConfigurationManager configurationManager = new WorkmanConfigurationManager();
            return new File(configurationManager.getWorkDirectoryPath());
        }
    }
    /**
     * @throws java.lang.Exception
     */
    @Before
    public void setUp() throws Exception {
        File testProperties = new File("src/test/resources/workman-test.properties");
        Assert.assertTrue(testProperties.exists());
        System.setProperty(ConfigurationManager.WORK_DIRECTORY_PATH_KEY, "target");
        System.setProperty(ConfigurationManager.DURACLOUD_MILL_CONFIG_FILE_KEY, testProperties.getAbsolutePath());
        System.setProperty(TaskWorkerManager.MIN_WAIT_BEFORE_TAKE_KEY, "1");

        context = new AnnotationConfigApplicationContext(TestAppConfig.class);
    }

    /**
     * @throws java.lang.Exception
     */
    @After
    public void tearDown() throws Exception {
        context = null;
    }

{'fraction_non_alphanumeric': 0.0808874738831957, 'fraction_numerical': 0.0013928962292309222, 'mean_word_length': 3.3914373088685017, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2374888', 'n_tokens_mistral': 2748, 'n_tokens_neox': 2714, 'n_words': 504}