<commit_before>import static net.grinder.script.Grinder.grinder
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
import net.grinder.plugin.http.HTTPRequest
import net.grinder.plugin.http.HTTPPluginControl
import net.grinder.script.GTest
import net.grinder.script.Grinder
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
// import static net.grinder.util.GrinderUtils.* // You can use this if you're using nGrinder after 3.2.3
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith

import java.util.Date
import java.util.List
import java.util.ArrayList

import HTTPClient.Cookie
import HTTPClient.CookieModule
import HTTPClient.HTTPResponse
import HTTPClient.NVPair

/**
 * A simple example using the HTTP plugin that shows the retrieval of a
 * single page via HTTP. 
 * 
 * This script is automatically generated by ngrinder.
 * 
 * @author ${userName}
 */
@RunWith(GrinderRunner)
<#if options??>
	<#assign options = options?eval>
	<#assign method = options["method"]>
	<#assign headers = options["headers"]>
	<#if options["body"]??>
		<#assign body = options["body"]>
	<#else>
		<#assign params = options["params"]>
	</#if>
	<#assign cookies = options["cookies"]>
</#if>
class TestRunner {

	public static GTest test
	public static HTTPRequest request
	public static NVPair[] headers = []
<#if body??>
	public static String body = "${body?j_string?replace("$", "\\$")}"	
<#else>
	public static NVPair[] params = []
</#if>
	public static Cookie[] cookies = []

	@BeforeProcess
	public static void beforeProcess() {
		HTTPPluginControl.getConnectionDefaults().timeout = 6000
		test = new GTest(1, "${name}")
		request = new HTTPRequest()
	<#if headers?? && headers?size != 0>
		// Set header datas
		List<NVPair> headerList = new ArrayList<>()
		<#list headers as header>
		headerList.add(new NVPair("${header["name"]?j_string}", "${header["value"]?j_string?replace("$", "\\$")}"))
		</#list>
		headers = headerList.toArray()
	</#if>
	<#if params?? && params?size != 0>
		// Set param datas
		List<NVPair> paramList = new ArrayList<>()
		<#list params as param>
		paramList.add(new NVPair("${param["name"]?j_string}", "${param["value"]?j_string?replace("$", "\\$")}"))
		</#list>
		params = paramList.toArray()
	</#if>
	<#if cookies?? && cookies?size != 0>
		// Set cookie datas
		List<Cookie> cookieList = new ArrayList<>()
		<#list cookies as cookie>
		cookieList.add(new Cookie("${cookie["name"]?j_string}", "${cookie["value"]?j_string?replace("$", "\\$")}", "${cookie["domain"]?j_string}", "${cookie["path"]?j_string}", new Date(32503647599000L), false))
		</#list>
		cookies = cookieList.toArray()
	</#if>
		grinder.logger.info("before process.");
	}

	@BeforeThread 
	public void beforeThread() {
		test.record(this, "test")
		grinder.statistics.delayReports=true;
		grinder.logger.info("before thread.");
	}
	
	@Before
	public void before() {
		request.setHeaders(headers)
		cookies.each { CookieModule.addCookie(it, HTTPPluginControl.getThreadHTTPClientContext()) }
		grinder.logger.info("before thread. init headers and cookies");
	}

	@Test
	public void test(){
		HTTPResponse result = request.${method?default("GET")}("${url}", <#if body??>body.getBytes()<#else>params</#if>)

		if (result.statusCode == 301 || result.statusCode == 302) {
			grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", result.statusCode); 
		} else {
			assertThat(result.statusCode, is(200));
		}
	}
}<commit_msg>Fix typo (#553)<commit_after>import static net.grinder.script.Grinder.grinder
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
import net.grinder.plugin.http.HTTPRequest
import net.grinder.plugin.http.HTTPPluginControl
import net.grinder.script.GTest
import net.grinder.script.Grinder
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
// import static net.grinder.util.GrinderUtils.* // You can use this if you're using nGrinder after 3.2.3
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith

import java.util.Date
import java.util.List
import java.util.ArrayList

import HTTPClient.Cookie
import HTTPClient.CookieModule
import HTTPClient.HTTPResponse
import HTTPClient.NVPair

/**
 * A simple example using the HTTP plugin that shows the retrieval of a
 * single page via HTTP. 
 * 
 * This script is automatically generated by ngrinder.
 * 
 * @author ${userName}
 */
@RunWith(GrinderRunner)
<#if options??>
	<#assign options = options?eval>
	<#assign method = options["method"]>
	<#assign headers = options["headers"]>
	<#if options["body"]??>
		<#assign body = options["body"]>
	<#else>
		<#assign params = options["params"]>
	</#if>
	<#assign cookies = options["cookies"]>
</#if>
class TestRunner {

	public static GTest test
	public static HTTPRequest request
	public static NVPair[] headers = []
<#if body??>
	public static String body = "${body?j_string?replace("$", "\\$")}"	
<#else>
	public static NVPair[] params = []
</#if>
	public static Cookie[] cookies = []

	@BeforeProcess
	public static void beforeProcess() {
		HTTPPluginControl.getConnectionDefaults().timeout = 6000
		test = new GTest(1, "${name}")
		request = new HTTPRequest()
	<#if headers?? && headers?size != 0>
		// Set header datas
		List<NVPair> headerList = new ArrayList<>()
		<#list headers as header>
		headerList.add(new NVPair("${header["name"]?j_string}", "${header["value"]?j_string?replace("$", "\\$")}"))
		</#list>
		headers = headerList.toArray()
	</#if>
	<#if params?? && params?size != 0>
		// Set param datas
		List<NVPair> paramList = new ArrayList<>()
		<#list params as param>
		paramList.add(new NVPair("${param["name"]?j_string}", "${param["value"]?j_string?replace("$", "\\$")}"))
		</#list>
		params = paramList.toArray()
	</#if>
	<#if cookies?? && cookies?size != 0>
		// Set cookie datas
		List<Cookie> cookieList = new ArrayList<>()
		<#list cookies as cookie>
		cookieList.add(new Cookie("${cookie["name"]?j_string}", "${cookie["value"]?j_string?replace("$", "\\$")}", "${cookie["domain"]?j_string}", "${cookie["path"]?j_string}", new Date(32503647599000L), false))
		</#list>
		cookies = cookieList.toArray()
	</#if>
		grinder.logger.info("before process.");
	}

	@BeforeThread 
	public void beforeThread() {
		test.record(this, "test")
		grinder.statistics.delayReports=true;
		grinder.logger.info("before thread.");
	}
	
	@Before
	public void before() {
		request.setHeaders(headers)
		cookies.each { CookieModule.addCookie(it, HTTPPluginControl.getThreadHTTPClientContext()) }
		grinder.logger.info("before. init headers and cookies");
	}

	@Test
	public void test(){
		HTTPResponse result = request.${method?default("GET")}("${url}", <#if body??>body.getBytes()<#else>params</#if>)

		if (result.statusCode == 301 || result.statusCode == 302) {
			grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", result.statusCode); 
		} else {
			assertThat(result.statusCode, is(200));
		}
	}
}
{'fraction_non_alphanumeric': 0.16678049446796886, 'fraction_numerical': 0.009698128670946592, 'mean_word_length': 5.041254125412541, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 73, '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': '7253111', 'n_tokens_mistral': 2532, 'n_tokens_neox': 2362, 'n_words': 561}