<commit_before>package org.dilzio.ripphttp.util;

import static org.junit.Assert.*;

import java.io.InputStream;

import org.dilzio.riphttp.util.ApplicationParams;
import org.dilzio.riphttp.util.ParamEnum;
import org.junit.Test;

public class ApplicationParamsFactoryTest {

	private static final String TESTFILE1 = "./src/test/resources/org/dilzio/rippinhttp/util/testprops1.properties";

	@Test
	public void hydrateWithParams() {
		ApplicationParamsFactory _underTest = ApplicationParamsFactory.getInstance();
		String path = TESTFILE1;
		boolean overlayEnvVars = false;
		ApplicationParams params = _underTest.newParams(path, overlayEnvVars);
		assertEquals(12345, params.getIntParam(ParamEnum.LISTEN_PORT));
		assertEquals(44, params.getIntParam(ParamEnum.WORKER_COUNT));
		assertEquals(7998, params.getIntParam(ParamEnum.RING_BUFFER_SIZE));
	}
	
	@Test
	public void hydrateWithParamsOveralayTrue() {
		ApplicationParamsFactory _underTest = ApplicationParamsFactory.getInstance();
		String path = TESTFILE1;
		boolean overlayEnvVars = true;
		ApplicationParams params = _underTest.newParams(path, overlayEnvVars);
		assertEquals(12345, params.getIntParam(ParamEnum.LISTEN_PORT));
		assertEquals(44, params.getIntParam(ParamEnum.WORKER_COUNT));
		assertEquals(7998, params.getIntParam(ParamEnum.RING_BUFFER_SIZE));
	}
	
	@Test
	public void hydrateWithParamsEnvOverride() {
	    System.setProperty("LISTEN_PORT", "6666");
		ApplicationParamsFactory _underTest = ApplicationParamsFactory.getInstance();
		String path = TESTFILE1;
		boolean overlayEnvVars = true;
		ApplicationParams params = _underTest.newParams(path, overlayEnvVars);
		assertEquals(6666, params.getIntParam(ParamEnum.LISTEN_PORT));
		assertEquals(44, params.getIntParam(ParamEnum.WORKER_COUNT));
		assertEquals(7998, params.getIntParam(ParamEnum.RING_BUFFER_SIZE));
	    System.clearProperty("LISTEN_PORT");
	}
}
<commit_msg>add test<commit_after>package org.dilzio.ripphttp.util;

import static org.junit.Assert.*;

import java.io.InputStream;

import org.dilzio.riphttp.util.ApplicationParams;
import org.dilzio.riphttp.util.ParamEnum;
import org.junit.Test;

public class ApplicationParamsFactoryTest {

	private static final String TESTFILE1 = "./src/test/resources/org/dilzio/rippinhttp/util/testprops1.properties";

	@Test
	public void hydrateWithParams() {
		ApplicationParamsFactory _underTest = ApplicationParamsFactory.getInstance();
		String path = TESTFILE1;
		boolean overlayEnvVars = false;
		ApplicationParams params = _underTest.newParams(path, overlayEnvVars);
		assertEquals(12345, params.getIntParam(ParamEnum.LISTEN_PORT));
		assertEquals(44, params.getIntParam(ParamEnum.WORKER_COUNT));
		assertEquals(7998, params.getIntParam(ParamEnum.RING_BUFFER_SIZE));
	}
	
	@Test
	public void hydrateWithParamsOveralayTrue() {
		ApplicationParamsFactory _underTest = ApplicationParamsFactory.getInstance();
		String path = TESTFILE1;
		boolean overlayEnvVars = true;
		ApplicationParams params = _underTest.newParams(path, overlayEnvVars);
		assertEquals(12345, params.getIntParam(ParamEnum.LISTEN_PORT));
		assertEquals(44, params.getIntParam(ParamEnum.WORKER_COUNT));
		assertEquals(7998, params.getIntParam(ParamEnum.RING_BUFFER_SIZE));
	}
	
	@Test
	public void hydrateWithParamsEnvOverride() {
	    System.setProperty("LISTEN_PORT", "6666");
		ApplicationParamsFactory _underTest = ApplicationParamsFactory.getInstance();
		String path = TESTFILE1;
		boolean overlayEnvVars = true;
		ApplicationParams params = _underTest.newParams(path, overlayEnvVars);
		assertEquals(6666, params.getIntParam(ParamEnum.LISTEN_PORT));
		assertEquals(44, params.getIntParam(ParamEnum.WORKER_COUNT));
		assertEquals(7998, params.getIntParam(ParamEnum.RING_BUFFER_SIZE));
	    System.clearProperty("LISTEN_PORT");
	}
	
	@Test
	public void hydrateFromEnvironment() {
	    System.setProperty("LISTEN_PORT", "6666");
	    System.setProperty("USE_SSL", "true");
	    System.setProperty("SERVER_NAME", "UnitTest");
		ApplicationParamsFactory _underTest = ApplicationParamsFactory.getInstance();
		ApplicationParams params = _underTest.newParamsFromEnvironment();
		assertEquals(6666, params.getIntParam(ParamEnum.LISTEN_PORT));
		assertEquals(true, params.getBoolParam(ParamEnum.USE_SSL));
		assertEquals("UnitTest", params.getStringParam(ParamEnum.SERVER_NAME));
	    System.clearProperty("LISTEN_PORT");
	    System.clearProperty("USE_SSL");
	    System.clearProperty("SERVER_NAME");
	}
}

{'fraction_non_alphanumeric': 0.10512129380053908, 'fraction_numerical': 0.02021563342318059, 'mean_word_length': 6.784965034965035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7061269', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1308, 'n_words': 214}