Java Code Examples for org.apache.jmeter.samplers.SampleResult#setResponseMessage()
The following examples show how to use
org.apache.jmeter.samplers.SampleResult#setResponseMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeEventProducer.java From WeEvent with Apache License 2.0 | 6 votes |
@Override public SampleResult runTest(JavaSamplerContext context) { SampleResult result = new SampleResult(); result.setSampleLabel("producer"); try { result.sampleStart(); SendResult sendResult = this.weEventClient.publish(this.weEvent); result.sampleEnd(); result.setSuccessful(sendResult.getStatus() == SendResult.SendResultStatus.SUCCESS && sendResult.getEventId().length() > 0); result.setResponseMessage(sendResult.getEventId()); result.setResponseHeaders(sendResult.getStatus().toString()); result.setResponseData(sendResult.toString(), Charset.defaultCharset().name()); getNewLogger().info("sendResult:{}", sendResult); } catch (Exception e) { getNewLogger().error("publish exception", e); result.sampleEnd(); result.setSuccessful(false); result.setResponseMessage(e.getMessage()); } return result; }
Example 2
Source File: BlurSamplerClient.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
@Override public SampleResult runTest(JavaSamplerContext context) { SampleResult sampleResult = new SampleResult(); BlurResults blurResults = null; try { BlurQuery blurQuery = getBlurQuery(); sampleResult.sampleStart(); blurResults = _client.query(_table, blurQuery); sampleResult.sampleEnd(); int size = getBytes(blurResults); sampleResult.setBytes(size); sampleResult.setSuccessful(true); sampleResult.setResponseOK(); } catch (Throwable t) { sampleResult.setResponseMessage("Exception " + t.getMessage()); sampleResult.setSuccessful(false); LOG.error("Unknown error.", t); } finally { processResults(blurResults); } return sampleResult; }
Example 3
Source File: HitsPerSecondGuiTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Test public void testAdd_issue48() { System.out.println("add48"); SampleResult res = new SampleResult(); res.setAllThreads(0); res.setThreadName("test 1-2"); res.setResponseMessage(null); SampleResult subres = new SampleResult(); subres.sampleStart(); subres.sampleEnd(); res.sampleStart(); res.addSubResult(subres); try { Thread.sleep(10); } catch (InterruptedException ex) { } HitsPerSecondGui instance = new HitsPerSecondGui(); instance.add(res); }
Example 4
Source File: SendMessage.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
private SampleResult waitResponse(SampleResult res, String recipient) throws InterruptedException, SmackException { long time = 0; do { Iterator<Message> packets = responseMessages.iterator(); Thread.sleep(conn.getPacketReplyTimeout() / 100); // optimistic while (packets.hasNext()) { Packet packet = packets.next(); Message response = (Message) packet; if (XmppStringUtils.parseBareAddress(response.getFrom()).equals(recipient)) { packets.remove(); res.setResponseData(response.toXML().toString().getBytes()); if (response.getError() != null) { res.setSuccessful(false); res.setResponseCode("500"); res.setResponseMessage(response.getError().toString()); } return res; } } time += conn.getPacketReplyTimeout() / 10; Thread.sleep(conn.getPacketReplyTimeout() / 10); } while (time < conn.getPacketReplyTimeout()); throw new SmackException.NoResponseException(); }
Example 5
Source File: JMXMonSampleResultTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
/** * Test of getValue method, of class JMXMonSampleResult. */ @Test public void testGetValue_SampleResult() { System.out.println("getValue"); SampleResult res = new SampleResult(); res.setResponseMessage("0"); double expResult = 0.0; double result = JMXMonSampleResult.getValue(res); assertEquals(expResult, result, 0.0); // TODO review the generated test code and remove the default call to fail. }
Example 6
Source File: AbstractDynamicThreadGroupModel.java From jmeter-plugins with Apache License 2.0 | 5 votes |
protected void saveLogRecord(String marker, String threadName, String arrivalID) { SampleResult res = new SampleResult(); res.sampleStart(); res.setSampleLabel(arrivalID); res.setResponseMessage(marker); res.setThreadName(threadName); res.sampleEnd(); SampleEvent evt = new SampleEvent(res, getName()); logFile.sampleOccurred(evt); }
Example 7
Source File: FortressCreateSession.java From directory-fortress-core with Apache License 2.0 | 5 votes |
/** * Description of the Method * * @param samplerContext Description of the Parameter * @return Description of the Return Value */ public SampleResult runTest( JavaSamplerContext samplerContext ) { SampleResult sampleResult = new SampleResult(); try { sampleResult.sampleStart(); //String message = "FT CreateSession TID: " + getThreadId() + " UID:" + userId + " CTR:" + ctr++; //LOG.info( message ); //System.out.println( message ); assertNotNull( accessMgr ); Session session; User user = new User(); // positive test case: user.setUserId( userId ); user.setPassword( "secret" ); session = accessMgr.createSession( user, false ); assertNotNull( session ); assertTrue( session.isAuthenticated() ); sampleResult.sampleEnd(); sampleResult.setBytes(1); sampleResult.setResponseMessage("test completed TID: " + getThreadId() + " UID: " + userId); sampleResult.setSuccessful(true); } catch ( org.apache.directory.fortress.core.SecurityException se ) { System.out.println( "ThreadId:" + getThreadId() + "Error running test: " + se ); se.printStackTrace(); sampleResult.setSuccessful( false ); } return sampleResult; }
Example 8
Source File: DbMonSampleResultTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
/** * Test of getValue method, of class DbMonSampleResult. */ @Test public void testGetValue_SampleResult() { System.out.println("getValue"); SampleResult res = new SampleResult(); res.setResponseMessage("0"); double expResult = 0.0; double result = DbMonSampleResult.getValue(res); assertEquals(expResult, result, 0.0); // TODO review the generated test code and remove the default call to fail. }
Example 9
Source File: LicenseActivateCheckDeactivate.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override public SampleResult runTest(JavaSamplerContext context) { results = new SampleResult(); results.sampleStart(); licenseID = context.getParameter("LicenseID"); hardwareCode = context.getParameter("HardwareCode"); installCode = context.getParameter("InstallCode"); waitTimeMillis = Integer.valueOf(context.getParameter("WaitSeconds")) * 1000; intervalTimeMillis = Integer.valueOf(context .getParameter("IntervalSeconds")) * 1000; strResult = licenseID + ":\n"; startTime = System.currentTimeMillis(); // 检查许可证状态,应为未激活,然后激活 check(NextAction.ACTIVATE, "不通过"); // 等待两次测试之间的间隔时间 wait(intervalTimeMillis); pastTime = System.currentTimeMillis() - startTime - waitTimeMillis * waitCount - intervalTimeMillis; results.setResponseMessage(strResult + "\n实际耗时(毫秒):" + pastTime); results.sampleEnd(); return results; }
Example 10
Source File: NoOp.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
@Override public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception { long counter = 0; for (Packet packet : incomingPackets) { incomingPackets.remove(packet); SampleResult subRes = new SampleResult(); subRes.setSuccessful(true); subRes.setResponseCode("200"); subRes.setResponseMessage("OK"); subRes.setSampleLabel(packet.getClass().getSimpleName().isEmpty() ? packet.getClass().getName() : packet.getClass().getSimpleName()); subRes.setResponseData(packet.toXML().toString().getBytes()); if ((packet instanceof Presence) && (((Presence) packet).getType() == Presence.Type.error)) { subRes.setSuccessful(false); subRes.setResponseCode("500"); subRes.setResponseMessage(packet.getError().toString()); } else if ((packet instanceof Message) && (((Message) packet).getType() == Message.Type.error)) { subRes.setSuccessful(false); subRes.setResponseCode("500"); subRes.setResponseMessage(packet.getError().toString()); } else if ((packet instanceof IQ) && (((IQ) packet).getType() == IQ.Type.error)) { subRes.setSuccessful(false); subRes.setResponseCode("500"); subRes.setResponseMessage(packet.getError().toString()); } res.addSubResult(subRes); counter++; } res.setResponseData(("Received packets: " + counter).getBytes()); return counter > 0 ? res : null; }
Example 11
Source File: CassandraSampler.java From jmeter-cassandra with Apache License 2.0 | 4 votes |
@Override public SampleResult sample(Entry e) { log.debug("sampling CQL"); SampleResult res = new SampleResult(); res.setSampleLabel(getName()); res.setSamplerData(toString()); res.setDataType(SampleResult.TEXT); res.setContentType("text/plain"); // $NON-NLS-1$ res.setDataEncoding(ENCODING); // Assume we will be successful res.setSuccessful(true); res.setResponseMessageOK(); res.setResponseCodeOK(); res.sampleStart(); Session conn = null; try { if(JOrphanUtils.isBlank(getSessionName())) { throw new IllegalArgumentException("Variable Name must not be null in "+getName()); } try { conn = CassandraConnection.getSession(getSessionName()); } finally { res.latencyEnd(); // use latency to measure connection time } res.setResponseHeaders(conn.toString()); res.setResponseData(execute(conn)); } catch (Exception ex) { res.setResponseMessage(ex.toString()); res.setResponseCode("000"); res.setResponseData(ex.getMessage().getBytes()); res.setSuccessful(false); } // Doesn't apply // finally { // close(conn); // } // TODO: process warnings? Set Code and Message to success? res.sampleEnd(); return res; }
Example 12
Source File: HonoReceiver.java From hono with Eclipse Public License 2.0 | 4 votes |
/** * Takes a sample. * * @param result The result to set the sampler's current statistics on. */ public void sample(final SampleResult result) { synchronized (lock) { long elapsed = 0; result.setResponseCodeOK(); result.setSuccessful(errorCount == 0 && !senderClockNotInSync); result.setSampleCount(messageCount); result.setErrorCount(errorCount); // NOTE: This method does nothing in JMeter 3.3/4.0 result.setBytes(bytesReceived); if (messageCount > 0) { if (sampler.isUseSenderTime() && sampleStart != 0 && errorCount == 0) { // errorCount has to be 0 here - otherwise totalSampleDeliveryTime doesn't have a correct value elapsed = senderClockNotInSync ? -1 : totalSampleDeliveryTime / messageCount; result.setStampAndTime(sampleStart, elapsed); } else if (sampleStart != 0) { elapsed = System.currentTimeMillis() - sampleStart; result.setStampAndTime(sampleStart, elapsed); result.setIdleTime(elapsed); } else { LOGGER.warn("sampleStart hasn't been set - setting elapsed time to 0"); result.setStampAndTime(System.currentTimeMillis(), 0); result.setIdleTime(0); } } else { // empty sample result.setStampAndTime(System.currentTimeMillis(), 0); result.setIdleTime(0); } String responseMessage = ""; if (errorCount == 0) { final String formatString = sampler.isUseSenderTime() ? "{}: received batch of {} messages; average delivery time: {}ms" : "{}: received batch of {} messages in {}ms"; LOGGER.info(formatString, sampler.getThreadName(), messageCount, elapsed); } else { LOGGER.info("{}: received batch of {} messages with {} errors in {}ms", sampler.getThreadName(), messageCount, errorCount, elapsed); responseMessage = "got " + errorCount + " invalid messages"; } if (senderClockNotInSync) { responseMessage = (responseMessage.isEmpty() ? "" : responseMessage + "; ") + "sender clock not in sync"; LOGGER.error("The sender time extracted from at least one of the received messages is newer than the receiver time" + " - sender and receiver clocks are not in sync. Consider deactivating usage of the sender time."); } result.setResponseMessage(responseMessage); // reset all fields totalSampleDeliveryTime = 0; senderClockNotInSync = false; bytesReceived = 0; messageCount = 0; errorCount = 0; sampleStart = 0; } }
Example 13
Source File: HonoSender.java From hono with Eclipse Public License 2.0 | 4 votes |
/** * Publishes multiple messages to Hono. * * @param sampleResult The result object representing the combined outcome of the samples. * @param messageCount The number of messages to send * @param deviceId The identifier if the device to send a message for. * @param waitForDeliveryResult A flag indicating whether to wait for the result of the send operation. */ public void send(final SampleResult sampleResult, final int messageCount, final String deviceId, final boolean waitForDeliveryResult) { final long sampleStart = System.currentTimeMillis(); long addedSendDurations = 0; boolean isSuccessful = true; String firstResponseErrorMessage = ""; String firstResponseErrorCode = ""; long sentBytes = 0; int errorCount = 0; for (int i = 0; i < messageCount; i++) { final SampleResult subResult = new SampleResult(); subResult.setDataType(SampleResult.TEXT); subResult.setResponseOK(); subResult.setResponseCodeOK(); subResult.setSampleLabel(sampleResult.getSampleLabel()); // send the message send(subResult, deviceId, waitForDeliveryResult); // can't call sampleResult.addSubResult(subResult) here - this would prevent a later invocation of sampleResult.setStampAndTime() sampleResult.addRawSubResult(subResult); if (!subResult.isSuccessful()) { isSuccessful = false; errorCount++; if (firstResponseErrorMessage.isEmpty()) { firstResponseErrorMessage = subResult.getResponseMessage(); firstResponseErrorCode = subResult.getResponseCode(); } } sentBytes += subResult.getSentBytes(); addedSendDurations += subResult.getTime(); } sampleResult.setSuccessful(isSuccessful); final String responseMessage = MessageFormat.format("BatchResult {0}/{1}/{2}", sampler.getEndpoint(), sampler.getTenant(), deviceId); if (isSuccessful) { sampleResult.setResponseMessage(responseMessage); } else { sampleResult.setResponseMessage(responseMessage + ": " + errorCount + " errors - first: " + firstResponseErrorMessage); sampleResult.setResponseCode(firstResponseErrorCode); } sampleResult.setSentBytes(sentBytes); sampleResult.setSampleCount(messageCount); sampleResult.setErrorCount(errorCount); // NOTE: This method does nothing in JMeter 3.3/4.0 final long averageElapsedTimePerMessage = addedSendDurations / messageCount; sampleResult.setStampAndTime(sampleStart, averageElapsedTimePerMessage); }
Example 14
Source File: HonoSender.java From hono with Eclipse Public License 2.0 | 4 votes |
/** * Publishes a message to Hono. * * @param sampleResult The result object representing the outcome of the sample. * @param deviceId The identifier if the device to send a message for. * @param waitForDeliveryResult A flag indicating whether to wait for the result of the send operation. */ public void send(final SampleResult sampleResult, final String deviceId, final boolean waitForDeliveryResult) { final String endpoint = sampler.getEndpoint(); final String tenant = sampler.getTenant(); final Future<DownstreamSender> senderFuture = getSender(endpoint, tenant); final CompletableFuture<SampleResult> tracker = new CompletableFuture<>(); final Promise<ProtonDelivery> deliveryTracker = Promise.promise(); deliveryTracker.future() .onComplete(s -> { if (s.succeeded()) { sampleResult.setResponseMessage(MessageFormat.format("{0}/{1}/{2}", endpoint, tenant, deviceId)); sampleResult.setSentBytes(payload.length); sampleResult.setSampleCount(1); tracker.complete(sampleResult); } else { tracker.completeExceptionally(s.cause()); } }); // start sample sampleResult.sampleStart(); senderFuture.map(sender -> { final Message msg = ProtonHelper.message(); msg.setAddress(sender.getEndpoint() + "/" + tenant); MessageHelper.setPayload(msg, sampler.getContentType(), Buffer.buffer(sampler.getData())); MessageHelper.addDeviceId(msg, deviceId); if (sampler.isSetSenderTime()) { MessageHelper.addProperty(msg, TIME_STAMP_VARIABLE, System.currentTimeMillis()); } LOGGER.trace("sending message for device [{}]; credit: {}", deviceId, sender.getCredit()); final Handler<Void> sendHandler = s -> { if (waitForDeliveryResult) { sender.sendAndWaitForOutcome(msg).onComplete(deliveryTracker); } else { sender.send(msg).onComplete(ar -> { if (ar.succeeded()) { LOGGER.debug("{}: got delivery result for message sent for device [{}]: remoteState={}, localState={}", sampler.getThreadName(), deviceId, ar.result().getRemoteState(), ar.result().getLocalState()); } else { LOGGER.warn("{}: error getting delivery result for message sent for device [{}]", sampler.getThreadName(), deviceId, ar.cause()); } }); deliveryTracker.complete(); } }; ctx.runOnContext(send -> { if (sender.getCredit() > 0) { sendHandler.handle(null); } else { sender.sendQueueDrainHandler(sendHandler); } }); return null; }).otherwise(t -> { tracker.completeExceptionally(t); return null; }); try { tracker.get(sampler.getSendTimeoutOrDefaultAsInt(), TimeUnit.MILLISECONDS); LOGGER.debug("{}: sent message for device [{}]", sampler.getThreadName(), deviceId); } catch (InterruptedException | CancellationException | ExecutionException | TimeoutException e) { sampleResult.setSuccessful(false); if (e.getCause() instanceof ServiceInvocationException) { final ServiceInvocationException sie = (ServiceInvocationException) e.getCause(); sampleResult.setResponseMessage(sie.getMessage()); sampleResult.setResponseCode(String.valueOf(sie.getErrorCode())); } else { String uncompletedFutureHint = ""; if (e instanceof TimeoutException) { uncompletedFutureHint = !senderFuture.isComplete() ? " - timeout waiting for sender link" : !deliveryTracker.future().isComplete() ? " - timeout waiting for message delivery" : ""; } sampleResult.setResponseMessage((e.getCause() != null ? e.getCause().getMessage() : e.getClass().getSimpleName()) + uncompletedFutureHint); sampleResult.setResponseCode(String.valueOf(HttpURLConnection.HTTP_INTERNAL_ERROR)); } LOGGER.debug("{}: error sending message for device [{}]: {}", sampler.getThreadName(), deviceId, sampleResult.getResponseMessage()); if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } } sampleResult.sampleEnd(); }
Example 15
Source File: DubboSample.java From jmeter-plugins-for-apache-dubbo with Apache License 2.0 | 4 votes |
public void setResponseError(SampleResult res, String code, String message) { res.setSuccessful(false); res.setResponseCode(code); res.setResponseMessage(message); }
Example 16
Source File: SingleTopicHCSClient.java From hedera-mirror-node with Apache License 2.0 | 4 votes |
/** * Runs test by calling sampler subscribeTopic. Reports success based on call response from sampler */ @Override public SampleResult runTest(JavaSamplerContext context) { SampleResult result = new SampleResult(); HCSSamplerResult response = null; result.sampleStart(); try { MessageListener listener = MessageListener.builder() .historicMessagesCount(propHandler.getIntClientTestParam("HistoricMessagesCount", 0, "0")) .futureMessagesCount(propHandler.getIntClientTestParam("IncomingMessageCount", 0, "0")) .messagesLatchWaitSeconds(propHandler.getIntClientTestParam("SubscribeTimeoutSeconds", 0, "60")) .build(); response = hcsTopicSampler.subscribeTopic(listener); result.sampleEnd(); result.setResponseData(response.toString().getBytes()); result.setSuccessful(response.isSuccess()); if (!response.isSuccess()) { result.setResponseMessage("Failure in subscribe topic test"); result.setResponseCode("500"); } else { result.setResponseMessage("Successfully performed subscribe topic test"); result.setResponseCodeOK(); } } catch (Exception ex) { log.error("Error subscribing to topic", ex); StringWriter stringWriter = new StringWriter(); ex.printStackTrace(new PrintWriter(stringWriter)); result.sampleEnd(); result.setResponseMessage("Exception: " + ex); result.setResponseData(stringWriter.toString().getBytes()); result.setDataType(SampleResult.TEXT); result.setResponseCode("500"); } return result; }
Example 17
Source File: LicenseCheck.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
@Override public SampleResult runTest(JavaSamplerContext context) { SampleResult results = new SampleResult(); results.sampleStart(); String licenseID = context.getParameter("LicenseID"); String hardwareCode = context.getParameter("HardwareCode"); String installCode = context.getParameter("InstallCode"); int intervalTime = Integer.valueOf(context .getParameter("IntervalSeconds")) * 1000; String strResult = licenseID + ":\n"; long startTime = System.currentTimeMillis(); // 验证许可证的激活状态 try { String result = ServiceUtilTest.check(licenseID, hardwareCode, installCode); if (result.equals("Check Success")) { results.setSuccessful(true); results.setResponseCodeOK(); strResult += "验证通过!\n"; } else { results.setSuccessful(true); results.setResponseCodeOK(); strResult += "验证未通过,返回结果为:" + result + "\n"; } } catch (Exception e) { results.setSuccessful(false); strResult += "验证失败,异常信息:\n" + e.getMessage() + "\n"; } // 等待两次测试之间的间隔 if (intervalTime != 0) { try { Thread.sleep(intervalTime); } catch (InterruptedException e1) { e1.printStackTrace(); } } long pastTime = System.currentTimeMillis() - startTime - intervalTime; results.setResponseMessage(strResult + "\n实际耗时(毫秒):" + pastTime); results.sampleEnd(); return results; }
Example 18
Source File: CheckAccess.java From directory-fortress-core with Apache License 2.0 | 4 votes |
/**224 * Description of the Method * * @param samplerContext Description of the Parameter * @return Description of the Return Value */ public SampleResult runTest( JavaSamplerContext samplerContext ) { SampleResult sampleResult = new SampleResult(); try { int opCount = ++ctr % 10; if( opCount == 0 ) opCount = 10; int objCount = (ctr / 10) + 1; if(objCount > 10) { objCount = objCount % 10; } if(objCount == 0) { objCount = 1; } //int objCount = ((ctr / 10) + 1) % 10; String opName = "oper" + opCount; String objName = "loadtestobject" + objCount; sampleResult.sampleStart(); String message; if(isFortress) { message = "FT "; } else { message = "AC "; } message += "CheckAccess isFortress: " + isFortress + ", userId: " + userId + ", objName:" + objName + ", opName: " + opName; /* LOG.info( message ); System.out.println( message ); */ assertNotNull( session ); assertTrue( session.isAuthenticated() ); Permission perm = new Permission(); perm.setObjName( objName ); perm.setOpName( opName ); boolean result; if(isFortress) { assertNotNull( accessMgr ); result = accessMgr.checkAccess( session, perm ); } else { assertNotNull( accelMgr ); result = accelMgr.checkAccess( session, perm ); } // positive test case: assertTrue( message, result ); sampleResult.sampleEnd(); sampleResult.setBytes(1); sampleResult.setResponseMessage("test checkAccess completed"); sampleResult.setSuccessful(true); } catch ( org.apache.directory.fortress.core.SecurityException se ) { String error = "ThreadId:" + getThreadId() + "Error running test: " + se; LOG.error( error ); System.out.println( error ); se.printStackTrace(); fail( error ); sampleResult.setSuccessful( false ); } return sampleResult; }
Example 19
Source File: MultiTopicHCSClient.java From hedera-mirror-node with Apache License 2.0 | 4 votes |
private SampleResult sequentialRun() { SampleResult result = new SampleResult(); int successSamplesCount = 0; result.sampleStart(); try { HCSSamplerResult response = null; for (TopicSubscription subscription : consensusServiceReactiveSamplers.keySet()) { if (subscription.getMilliSecWaitBefore() > 0) { log.debug("Waiting {} ms before subscribing", subscription.getMilliSecWaitBefore()); Thread.sleep(subscription.getMilliSecWaitBefore(), 0); } MessageListener listener = MessageListener.builder() .historicMessagesCount(subscription.getHistoricMessagesCount()) .futureMessagesCount(subscription.getIncomingMessageCount()) .messagesLatchWaitSeconds(subscription.getSubscribeTimeoutSeconds()) .build(); response = consensusServiceReactiveSamplers.get(subscription).subscribeTopic(listener); if (!response.isSuccess()) { log.debug("Failure in subscribe topic test : " + subscription); } else { successSamplesCount++; log.debug("Successfully performed subscription : " + subscription); } } result.setResponseMessage("Successfully performed subscriptions"); result.setResponseCodeOK(); result.sampleEnd(); result.setResponseData(response.toString().getBytes()); result.setSuccessful(response.isSuccess()); } catch (Exception ex) { log.error("Error subscribing to topic", ex); StringWriter stringWriter = new StringWriter(); ex.printStackTrace(new PrintWriter(stringWriter)); result.setResponseMessage("Failure in subscribes"); result.setResponseCode("500"); result.sampleEnd(); result.setResponseMessage("Exception: " + ex); result.setResponseData(stringWriter.toString().getBytes()); result.setDataType(SampleResult.TEXT); result.setResponseCode("500"); } log.info("{} out of {} samples passed", successSamplesCount, clientCount); return result; }
Example 20
Source File: KafkaProducerSampler.java From kafkameter with Apache License 2.0 | 2 votes |
/** * Mark the sample result as @{code end}ed and not {@code successful}, set the * {@code responseCode} to {@code reason}, and set {@code responseData} to the stack trace. * * @param result the sample result to change * @param exception the failure exception */ private void sampleResultFailed(SampleResult result, String reason, Exception exception) { sampleResultFailed(result, reason); result.setResponseMessage("Exception: " + exception); result.setResponseData(getStackTrace(exception), ENCODING); }