<commit_before>package org.broad.igv.gs.dm;

import org.broad.igv.Globals;
import org.broad.igv.PreferenceManager;
import org.broad.igv.gs.GSUtils;
import org.broad.igv.util.HttpUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.util.List;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.fail;

/**
 * @author <NAME>
 * @date 1/16/12
 */
public class DMUtilsTest {


    @Before
    public void setup() {
        Globals.setTesting(true);
        GSUtils.clearGSToken();
        HttpUtils.getInstance().setAuthenticator(new GSTestAuthenticator());
    }

    @After
    public void teardown() {
        //       HttpUtils.getInstance().resetAuthenticator();
    }

    @Test
    public void testListPeronsalDirectory() throws Exception {

        URL defaultURL = new URL(PreferenceManager.getInstance().get(PreferenceManager.GENOME_SPACE_DM_SERVER) +
                DMUtils.PERSONAL_DIRECTORY);
        GSDirectoryListing dirListing = DMUtils.getDirectoryListing(defaultURL);
        assertNotNull("Directory listing", dirListing);

        List<GSFileMetadata> gsFiles = dirListing.getContents();

        //Search for known test file
        boolean found = false;
        final String testFileName = "Broad.080528.subtypes.seg.gz";
        for (GSFileMetadata fileMetadata : gsFiles) {
            if (fileMetadata.getName().equals(testFileName)) {
                found = true;
                String path = "/Home/igvtest/" + testFileName;
                assertEquals("Test file path", path, fileMetadata.getPath());
            }
        }
        if (!found) {
            fail("Test file not found: " + testFileName);
        }
    }

    @Test
    public void testGetDirectoryListing() throws Exception {
        // TODO -- test for arbitrary directory
    }
<commit_msg>Fix typo in method name<commit_after>/*
 * Copyright (c) 2007-2012 The Broad Institute, Inc.
 * SOFTWARE COPYRIGHT NOTICE
 * This software and its documentation are the copyright of the Broad Institute, Inc. All rights are reserved.
 *
 * This software is supplied without any warranty or guaranteed support whatsoever. The Broad Institute is not responsible for its use, misuse, or functionality.
 *
 * This software is licensed under the terms of the GNU Lesser General Public License (LGPL),
 * Version 2.1 which is available at http://www.opensource.org/licenses/lgpl-2.1.php.
 */

package org.broad.igv.gs.dm;

import org.broad.igv.Globals;
import org.broad.igv.PreferenceManager;
import org.broad.igv.gs.GSUtils;
import org.broad.igv.util.HttpUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.util.List;

import static junit.framework.Assert.*;

/**
 * @author <NAME>
 * @date 1/16/12
 */
public class DMUtilsTest {


    @Before
    public void setup() {
        Globals.setTesting(true);
        GSUtils.clearGSToken();
        HttpUtils.getInstance().setAuthenticator(new GSTestAuthenticator());
    }

    @After
    public void teardown() {
        //       HttpUtils.getInstance().resetAuthenticator();
    }

    @Test
    public void testListPersonalDirectory() throws Exception {

        URL defaultURL = new URL(PreferenceManager.getInstance().get(PreferenceManager.GENOME_SPACE_DM_SERVER) +
                DMUtils.PERSONAL_DIRECTORY);
        GSDirectoryListing dirListing = DMUtils.getDirectoryListing(defaultURL);
        assertNotNull("Directory listing", dirListing);

        List<GSFileMetadata> gsFiles = dirListing.getContents();

        //Search for known test file
        boolean found = false;
        final String testFileName = "Broad.080528.subtypes.seg.gz";
        for (GSFileMetadata fileMetadata : gsFiles) {
            if (fileMetadata.getName().equals(testFileName)) {
                found = true;
                String path = "/Home/igvtest/" + testFileName;
                assertEquals("Test file path", path, fileMetadata.getPath());
            }
        }
        if (!found) {
            fail("Test file not found: " + testFileName);
        }
    }

    @Test
    public void testGetDirectoryListing() throws Exception {
        // TODO -- test for arbitrary directory
    }

{'fraction_non_alphanumeric': 0.10243793334824423, 'fraction_numerical': 0.0076045627376425855, 'mean_word_length': 2.868512110726644, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '4503183', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1246, 'n_words': 311}