<commit_before>package asia.gkc.vneedu.storage;

import asia.gkc.vneedu.utils.BaseTest;
import org.junit.Test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

import static org.junit.Assert.*;

/**
 * Created by jakes on 4/9/16.
 */
public class StorageFactoryTest extends BaseTest {
    private File createTextFile() throws Exception {
        String testFile = this.getClass().getResource("/").getFile() + "the-file-name.txt";
        PrintWriter writer = new PrintWriter(testFile, "UTF-8");
        writer.println("The first line");
        writer.println("The second line");
        writer.close();
        return new File(testFile);
    }

    @Test
    public void getStorage() throws Exception {
        Storage storage = StorageFactory.getStorage("qiniu");

        assertNotNull(storage);

        String path = storage.uploadFile(createTextFile(), "/hello/haha.txt");

        logger.debug(path);

        assertTrue(path != null && path.length() > 0);
    }

}<commit_msg>add test for storage factory<commit_after>package asia.gkc.vneedu.storage;

import asia.gkc.vneedu.utils.BaseTest;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;
import java.io.PrintWriter;

import static org.junit.Assert.*;

/**
 * Created by jakes on 4/9/16.
 */
public class StorageFactoryTest extends BaseTest {
    private final String tmp = "/hello/haha.txt";

    @Autowired
    private Storage storage;

    private File createTextFile() throws Exception {
        String testFile = this.getClass().getResource("/").getFile() + "the-file-name.txt";
        PrintWriter writer = new PrintWriter(testFile, "UTF-8");
        writer.println("The first line");
        writer.println("The second line");
        writer.close();
        return new File(testFile);
    }

    @Test
    public void getStorage() throws Exception {
        assertNotNull(storage);

        String path = storage.uploadFile(createTextFile(), tmp);

        logger.debug(path);

        assertTrue(path != null && path.length() > 0);
    }

    @Test
    public void deleteFile() {
        assertNotNull(storage);

        storage.deleteFile(tmp);
    }
}
{'fraction_non_alphanumeric': 0.12489082969432315, 'fraction_numerical': 0.005240174672489083, 'mean_word_length': 3.1353790613718413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7321637', 'n_tokens_mistral': 669, 'n_tokens_neox': 657, 'n_words': 156}