<commit_before>package com.alibaba.dcm.tool;

import com.alibaba.support.junit.conditional.AboveJava8;
import com.alibaba.support.junit.conditional.ConditionalIgnoreRule;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import static org.junit.Assert.*;

/**
 * @author <NAME> (<EMAIL> at g<EMAIL> dot <EMAIL>)
 */
public class DcmToolTest {
    @Rule
    public final ConditionalIgnoreRule rule = new ConditionalIgnoreRule();

    File outputFile;
    String outputFilePath;

    String agentFilePath;

    @Before
    public void setUp() throws Exception {
        outputFile = new File("target/output.log");
        FileUtils.deleteQuietly(outputFile);
        FileUtils.touch(outputFile);
        assertTrue(outputFile.length() == 0);

        outputFilePath = outputFile.getCanonicalPath();
        System.out.println("Prepared output file: " + outputFilePath);

        setAgentFilePath();
        assertNotNull(agentFilePath);
        System.out.println("Found agent file: " + agentFilePath);
    }

    public void setAgentFilePath() throws Exception {
        // find agent jar file from dcm lib project
        File dcmLibProjectDir = new File("../library");
        if (!dcmLibProjectDir.exists()) {
            dcmLibProjectDir = new File("library");
        }
        if (dcmLibProjectDir.exists()) {
            File dcmLibProjectTargetDir = new File(dcmLibProjectDir, "target");
            if (dcmLibProjectTargetDir.exists()) {
                System.out.println("Found target dir: " + dcmLibProjectTargetDir);
            }
<commit_msg>improve agent jar file search logic in test<commit_after>package com.alibaba.dcm.tool;

import com.alibaba.support.junit.conditional.AboveJava8;
import com.alibaba.support.junit.conditional.ConditionalIgnoreRule;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import static org.junit.Assert.*;

/**
 * @author <NAME> (<EMAIL>ratlee at gmail dot com)
 */
public class DcmToolTest {
    @Rule
    public final ConditionalIgnoreRule rule = new ConditionalIgnoreRule();

    File outputFile;
    String outputFilePath;

    String agentFilePath;

    @Before
    public void setUp() throws Exception {
        outputFile = new File("target/output.log");
        FileUtils.deleteQuietly(outputFile);
        FileUtils.touch(outputFile);
        assertTrue(outputFile.length() == 0);

        outputFilePath = outputFile.getCanonicalPath();
        System.out.println("Prepared output file: " + outputFilePath);

        setAgentFilePath();
        assertNotNull(agentFilePath);
        System.out.println("Found agent file: " + agentFilePath);
    }

    public void setAgentFilePath() throws Exception {
        // find agent jar file from dcm lib project
        File dcmLibProjectDir = new File("library");
        if (!dcmLibProjectDir.exists()) {
            dcmLibProjectDir = new File("../library");
        }
        if (!dcmLibProjectDir.exists()) {
            dcmLibProjectDir = new File("../../library");
        }
        if (dcmLibProjectDir.exists()) {
            File dcmLibProjectTargetDir = new File(dcmLibProjectDir, "target");
            if (dcmLibProjectTargetDir.exists()) {
                System.out.println("Found target dir: " + dcmLibProjectTargetDir);
            }

{'fraction_non_alphanumeric': 0.11108100785694934, 'fraction_numerical': 0.001083717149823896, 'mean_word_length': 3.125139664804469, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1214443', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1026, 'n_words': 236}