<commit_before>/**
 *
 * Contributor(s):
 *     <NAME>: WiSC Enterprises - Modifications to adjudicate Fortify issues
 *        February 26, 2018
 *
*/
package com.occamlab.te;

import static org.junit.Assert.*;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;

import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Element;

import com.occamlab.te.index.Index;
import com.occamlab.te.index.SuiteEntry;
import com.occamlab.te.index.TestEntry;

public class TECoreTest {

    static Index index;
    static RuntimeOptions runOpts;

    @BeforeClass
    public static void setupFixture() throws Exception {
        index = new Index();
        runOpts = new RuntimeOptions();
        runOpts.setLogDir(null);
    }

    @Test
    public void parseXmlWithNullInstruction() throws Throwable {
        URL url = this.getClass().getResource("/article.xml");
        URLConnection urlConn = url.openConnection();
        TECore iut = new TECore(new Engine(), index, runOpts);
        Element result = iut.parse(urlConn, null);
        Element content = (Element) result.getElementsByTagName("content")
                .item(0);
        assertNotNull("Expected content element.", content);
        assertTrue("Expected XML content ", content.hasChildNodes());
    }

    @Test
    public void parseTextWithNullInstruction() throws Throwable {
        URL url = this.getClass().getResource("/jabberwocky.txt");
        URLConnection urlConn = url.openConnection();
        TECore iut = new TECore(new Engine(), index, runOpts);
        Element result = iut.parse(urlConn, null);
        Element content = (Element) result.getElementsByTagName("content")
                .item(0);
        assertNotNull("Expected content element.", content);
        assertTrue("Expected text content starting with 'Twas brillig", content
                .getTextContent().startsWith("'Twas brillig"));
    }

    private Index getTestIndex(File ctlFile) throws Throwable {
        assertTrue(ctlFile.exists());<commit_msg>#528 Fix unit test failures<commit_after>/**
 *
 * Contributor(s):
 *     <NAME>: WiSC Enterprises - Modifications to adjudicate Fortify issues
 *        February 26, 2018
 *
*/
package com.occamlab.te;

import static org.junit.Assert.*;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;

import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Element;

import com.occamlab.te.index.Index;
import com.occamlab.te.index.SuiteEntry;
import com.occamlab.te.index.TestEntry;

public class TECoreTest {

    static Index index;
    static RuntimeOptions runOpts;

    @BeforeClass
    public static void setupFixture() throws Exception {
        index = new Index();
        runOpts = new RuntimeOptions();
        runOpts.setLogDir(null);
        runOpts.setSessionId("s0001");
    }

    @Test
    public void parseXmlWithNullInstruction() throws Throwable {
        URL url = this.getClass().getResource("/article.xml");
        URLConnection urlConn = url.openConnection();
        TECore iut = new TECore(new Engine(), index, runOpts);
        Element result = iut.parse(urlConn, null);
        Element content = (Element) result.getElementsByTagName("content")
                .item(0);
        assertNotNull("Expected content element.", content);
        assertTrue("Expected XML content ", content.hasChildNodes());
    }

    @Test
    public void parseTextWithNullInstruction() throws Throwable {
        URL url = this.getClass().getResource("/jabberwocky.txt");
        URLConnection urlConn = url.openConnection();
        TECore iut = new TECore(new Engine(), index, runOpts);
        Element result = iut.parse(urlConn, null);
        Element content = (Element) result.getElementsByTagName("content")
                .item(0);
        assertNotNull("Expected content element.", content);
        assertTrue("Expected text content starting with 'Twas brillig", content
                .getTextContent().startsWith("'Twas brillig"));
    }

    private Index getTestIndex(File ctlFile) throws Throwable {
        assertTrue(ctlFile.exists());
{'fraction_non_alphanumeric': 0.11095472671827351, 'fraction_numerical': 0.005864414731409805, 'mean_word_length': 3.192723697148476, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6539764', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1196, 'n_words': 300}