@@ -314,38 +314,9 @@ public XltWebClient(final BrowserVersion browserVersion, final boolean javaScrip
314314 cssMode = CssMode .getMode (props .getProperty ("com.xceptance.xlt.css.download.images" ));
315315
316316 // JavaScript
317- if (javaScriptEngineEnabled )
318- {
319- // setup JavaScript engine
320- int optimizationLevel = props .getProperty ("com.xceptance.xlt.js.compiler.optimizationLevel" , -1 );
321- if (optimizationLevel < -1 || optimizationLevel > 9 )
322- {
323- XltLogger .runTimeLogger .warn ("Property 'com.xceptance.xlt.js.compiler.optimizationLevel' is set to an invalid value. Will use -1 instead." );
324- optimizationLevel = -1 ;
325- }
326-
327- final boolean takeMeasurements = props .getProperty ("com.xceptance.xlt.js.takeMeasurements" , false );
328-
329- setJavaScriptEngine (new XltJavaScriptEngine (this , optimizationLevel , takeMeasurements ));
330- getOptions ().setJavaScriptEnabled (props .getProperty ("com.xceptance.xlt.javaScriptEnabled" , false ));
331- getOptions ().setThrowExceptionOnScriptError (props .getProperty ("com.xceptance.xlt.stopTestOnJavaScriptErrors" , false ));
332-
333- // setup JavaScript debugger
334- if (props .getProperty ("com.xceptance.xlt.js.debugger.enabled" , false ))
335- {
336- setJavaScriptDebuggerEnabled (true );
337-
338- // create JS beautifying response processor only when needed
339- if (props .getProperty ("com.xceptance.xlt.js.debugger.beautifyDownloadedJavaScript" , true ))
340- {
341- jsBeautifier = new JSBeautifingResponseProcessor ();
342- }
343- }
344- }
345- else
346- {
347- getOptions ().setJavaScriptEnabled (false );
348- }
317+ getOptions ().setJavaScriptEnabled (props .getProperty ("com.xceptance.xlt.javaScriptEnabled" , false ));
318+ getOptions ().setThrowExceptionOnScriptError (props .getProperty ("com.xceptance.xlt.stopTestOnJavaScriptErrors" , false ));
319+ configureJavaScriptEngine (props );
349320
350321 // default user authentication
351322 final String userName = props .getProperty ("com.xceptance.xlt.auth.userName" );
@@ -448,36 +419,30 @@ public XltWebClient(final BrowserVersion browserVersion, final boolean javaScrip
448419 getOptions ().setHistorySizeLimit (historySizeLimit );
449420
450421 // set web connection
451- final WebConnection underlyingWebConnection ;
452- if (props .getProperty ("com.xceptance.xlt.http.offline" , false ))
453- {
454- // we are in offline mode and return fixed responses
455- underlyingWebConnection = new XltOfflineWebConnection ();
456- }
457- else
458- {
459- final String client = props .getProperty ("com.xceptance.xlt.http.client" );
460- final boolean collectTargetIpAddress = ((XltPropertiesImpl ) props ).collectUsedIpAddress ();
461- if ("okhttp3" .equals (client ))
462- {
463- final boolean http2Enabled = props .getProperty ("com.xceptance.xlt.http.client.okhttp3.http2Enabled" , true );
464- underlyingWebConnection = new OkHttp3WebConnection (this , http2Enabled , collectTargetIpAddress );
465- }
466- else
467- {
468- // the default connection
469- underlyingWebConnection = new XltApacheHttpWebConnection (this , collectTargetIpAddress );
470- }
471- }
422+ configureWebConnection (props );
472423
473- XltLogger .runTimeLogger .debug ("Using web connection class: " + underlyingWebConnection .getClass ().getName ());
424+ // load key/trust material for client/server authentication
425+ configureKeyStore (props );
426+ configureTrustStore (props );
427+ }
474428
475- final XltHttpWebConnection connection = new XltHttpWebConnection (this , underlyingWebConnection );
476- setWebConnection (connection );
429+ /**
430+ * {@inheritDoc}
431+ */
432+ @ Override
433+ public void reset ()
434+ {
435+ super .reset ();
477436
478- // load key/trust material for client/server authentication
479- setUpKeyStore (props );
480- setUpTrustStore (props );
437+ final XltProperties props = XltProperties .getInstance ();
438+
439+ // create a new instance of "our" JavaScript engine if needed
440+ configureJavaScriptEngine (props );
441+
442+ // create a new instance of "our" web connection
443+ configureWebConnection (props );
444+
445+ pageLocalCache .clear ();
481446 }
482447
483448 /**
@@ -2059,14 +2024,86 @@ else if (s.equals("resync"))
20592024 }
20602025 }
20612026
2027+ /**
2028+ * Sets up the JavaScript engine to be used by this web client.
2029+ *
2030+ * @param props
2031+ * the configuration
2032+ */
2033+ private void configureJavaScriptEngine (final XltProperties props )
2034+ {
2035+ if (isJavaScriptEngineEnabled ())
2036+ {
2037+ // setup JavaScript engine
2038+ int optimizationLevel = props .getProperty ("com.xceptance.xlt.js.compiler.optimizationLevel" , -1 );
2039+ if (optimizationLevel < -1 || optimizationLevel > 9 )
2040+ {
2041+ XltLogger .runTimeLogger .warn ("Property 'com.xceptance.xlt.js.compiler.optimizationLevel' is set to an invalid value. Will use -1 instead." );
2042+ optimizationLevel = -1 ;
2043+ }
2044+
2045+ final boolean takeMeasurements = props .getProperty ("com.xceptance.xlt.js.takeMeasurements" , false );
2046+
2047+ setJavaScriptEngine (new XltJavaScriptEngine (this , optimizationLevel , takeMeasurements ));
2048+
2049+ // setup JavaScript debugger
2050+ if (props .getProperty ("com.xceptance.xlt.js.debugger.enabled" , false ))
2051+ {
2052+ setJavaScriptDebuggerEnabled (true );
2053+
2054+ // create JS beautifying response processor only when needed
2055+ if (props .getProperty ("com.xceptance.xlt.js.debugger.beautifyDownloadedJavaScript" , true ))
2056+ {
2057+ jsBeautifier = new JSBeautifingResponseProcessor ();
2058+ }
2059+ }
2060+ }
2061+ }
2062+
2063+ /**
2064+ * Sets up the web connection to be used by this web client.
2065+ *
2066+ * @param props
2067+ * the configuration
2068+ */
2069+ private void configureWebConnection (final XltProperties props )
2070+ {
2071+ final WebConnection underlyingWebConnection ;
2072+ if (props .getProperty ("com.xceptance.xlt.http.offline" , false ))
2073+ {
2074+ // we are in offline mode and return fixed responses
2075+ underlyingWebConnection = new XltOfflineWebConnection ();
2076+ }
2077+ else
2078+ {
2079+ final String client = props .getProperty ("com.xceptance.xlt.http.client" );
2080+ final boolean collectTargetIpAddress = ((XltPropertiesImpl ) props ).collectUsedIpAddress ();
2081+ if ("okhttp3" .equals (client ))
2082+ {
2083+ final boolean http2Enabled = props .getProperty ("com.xceptance.xlt.http.client.okhttp3.http2Enabled" , true );
2084+ underlyingWebConnection = new OkHttp3WebConnection (this , http2Enabled , collectTargetIpAddress );
2085+ }
2086+ else
2087+ {
2088+ // the default connection
2089+ underlyingWebConnection = new XltApacheHttpWebConnection (this , collectTargetIpAddress );
2090+ }
2091+ }
2092+
2093+ XltLogger .runTimeLogger .debug ("Using web connection class: " + underlyingWebConnection .getClass ().getName ());
2094+
2095+ final XltHttpWebConnection connection = new XltHttpWebConnection (this , underlyingWebConnection );
2096+ setWebConnection (connection );
2097+ }
2098+
20622099 /**
20632100 * Sets up the key store with the client key to be used by this web client. The store is read from a file specified
20642101 * in the test suite configuration.
20652102 *
20662103 * @param props
20672104 * the configuration
20682105 */
2069- private void setUpKeyStore (final XltProperties props )
2106+ private void configureKeyStore (final XltProperties props )
20702107 {
20712108 final String storeFilePath = props .getProperty ("com.xceptance.xlt.tls.keyStore.file" );
20722109 if (StringUtils .isNotBlank (storeFilePath ))
@@ -2086,7 +2123,7 @@ private void setUpKeyStore(final XltProperties props)
20862123 * @param props
20872124 * the configuration
20882125 */
2089- private void setUpTrustStore (final XltProperties props )
2126+ private void configureTrustStore (final XltProperties props )
20902127 {
20912128 final String storeFilePath = props .getProperty ("com.xceptance.xlt.tls.trustStore.file" );
20922129 if (StringUtils .isNotBlank (storeFilePath ))
0 commit comments