@Override protected HTTPSampleResult sample(java.net.URL u, String method, boolean areFollowingRedirect, int depth) { HTTPSampleResult sample = super.sample(u, method, areFollowingRedirect, depth); sample.setSampleLabel(queryGenerator.getQueryId()); if (getArguments().getArgumentsAsMap().get(QueryOptions.COUNT).equalsIgnoreCase("true")) { String str = sample.getResponseDataAsString(); sample.setResponseMessage(str.substring(str.lastIndexOf("[") + 1, str.indexOf("]"))); } return sample; }
/** * Populates the provided HTTPSampleResult with details from the Exception. * Does not create a new instance, so should not be used directly to add a subsample. * * @param e * Exception representing the error. * @param res * SampleResult to be modified * @return the modified sampling result containing details of the Exception. */ protected HTTPSampleResult errorResult(Throwable e, HTTPSampleResult res) { res.setSampleLabel(res.getSampleLabel()); res.setDataType(SampleResult.TEXT); ByteArrayOutputStream text = new ByteArrayOutputStream(200); e.printStackTrace(new PrintStream(text)); // NOSONAR Stacktrace will be used in the response res.setResponseData(text.toByteArray()); res.setResponseCode(NON_HTTP_RESPONSE_CODE+": " + e.getClass().getName()); res.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE+": " + e.getMessage()); res.setSuccessful(false); return res; }
/** * Create HTTPSampleResult filling url, method and SampleLabel. * Monitor field is computed calling isMonitor() * @param url URL * @param method HTTP Method * @return {@link HTTPSampleResult} */ protected HTTPSampleResult createSampleResult(URL url, String method) { HTTPSampleResult res = new HTTPSampleResult(); res.setSampleLabel(this.testElement.getName()); res.setHTTPMethod(method); res.setURL(url); return res; }
res.setSampleLabel(url.toString()); InputStream is = null; res.sampleStart();
@Override protected HTTPSampleResult sample(URL url, String method, boolean frd, int fd) { HTTPSampleResult res = new HTTPSampleResult(); res.setSampleLabel(url.toExternalForm()); res.sampleStart(); try { setupConnection(url, method, res); activeChannel = channel; execute(method, res); res.sampleEnd(); res.setResponseData(responseData.toByteArray()); return res; } catch(IOException iex) { res.sampleEnd(); lastPort = -1; // force reopen on next sample channel = null; return errorResult(iex, res); } finally { activeChannel = null; JOrphanUtils.closeQuietly(body); body = null; } }
res.setSampleLabel(this.testElement.getName()); res.setURL(url); res.setHTTPMethod(method);
totalRes.setSampleLabel(totalRes.getSampleLabel() + "->" + lastRes.getSampleLabel());