org.apache.jmeter.samplers.Entry Java Examples
The following examples show how to use
org.apache.jmeter.samplers.Entry.
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: HttpTestBean.java From BotServiceStressToolkit with MIT License | 6 votes |
@Override public SampleResult sample(Entry entry) { SampleResult res = new SampleResult(); res.setSampleLabel(getName()); res.sampleStart(); res.setDataType(SampleResult.TEXT); try { JMeterContext context = getThreadContext(); JMeterVariables vars = context.getVariables(); String body = Unirest.get("http://www.uol.com.br").asString().getBody(); res.setResponseData(body, null); res.sampleEnd(); res.setSuccessful(true); } catch (UnirestException e) { res.setResponseData(e.toString(), null); res.sampleEnd(); res.setSuccessful(false); } return res; }
Example #2
Source File: SetVariablesAction.java From jmeter-plugins with Apache License 2.0 | 6 votes |
private void processVariables() { final Arguments args1 = (Arguments) this.getUserDefinedVariablesAsProperty().getObjectValue(); Arguments args = (Arguments) args1.clone(); final JMeterVariables vars = JMeterContextService.getContext().getVariables(); Iterator<Map.Entry<String, String>> it = args.getArgumentsAsMap().entrySet().iterator(); Map.Entry<String, String> var; while (it.hasNext()) { var = it.next(); if (log.isDebugEnabled()) { log.debug("Setting " + var.getKey() + "=" + var.getValue()); } vars.put(var.getKey(), var.getValue()); } }
Example #3
Source File: JSONToXMLConverter.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public SampleResult sample(Entry e) { SampleResult result = new SampleResult(); result.setSampleLabel(getName()); result.setSamplerData(this.getJsonInput()); result.setDataType(SampleResult.TEXT); result.sampleStart(); if (!getJsonInput().equalsIgnoreCase("")) { try { this.convertToXML(); result.setResponseData(this.getXmlOutput().getBytes()); result.setSuccessful(true); } catch (Exception e1) { result.setResponseData(e1.getMessage().getBytes()); result.setSuccessful(false); } } result.sampleEnd(); return result; }
Example #4
Source File: AbstractIPSampler.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public SampleResult sample(Entry entry) { SampleResult res = new SampleResult(); res.setSampleLabel(getName()); res.setSamplerData(getRequestData()); res.sampleStart(); res.setDataType(SampleResult.TEXT); res.setSuccessful(true); res.setResponseCode(RC200); try { res.setResponseData(processIO(res)); } catch (Exception ex) { if (!(ex instanceof SocketTimeoutException)) { log.error(getHostName(), ex); } res.sampleEnd(); res.setSuccessful(false); res.setResponseCode(RC500); res.setResponseMessage(ex.toString()); res.setResponseData((ex.toString() + CRLF + ExceptionUtils.getStackTrace(ex)).getBytes()); } return res; }
Example #5
Source File: TupleTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testInsertPreparedTuple() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.PREPARED); cs.setProperty("queryArguments", "\"" + EXPECTED + "\""); cs.setProperty("query", "INSERT INTO " + TABLE + " (key,tup) VALUES (2, ?)"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); // See if the value matches String val = session.execute("select tup from " + KEYSPACE + "." + TABLE + " where key = 2").one().getTupleValue(0).toString(); assertEquals(EXPECTED, val); }
Example #6
Source File: TupleTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testSelectTuple() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.SIMPLE); cs.setProperty("query", "SELECT * FROM " + TABLE + " WHERE key = 1"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.info(rowdata); assertEquals(rowdata, "key\ttup\n" + "1" + "\t" + EXPECTED + "\n"); }
Example #7
Source File: ListTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testInsertPreparedthelist() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.PREPARED); cs.setProperty("queryArguments", "\"" + EXPECTED + "\""); cs.setProperty("query", "INSERT INTO " + TABLE + " (key,thelist) VALUES (2, ?)"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); // See if the value matches Row row = session.execute("select thelist from " + KEYSPACE + "." + TABLE + " where key = 2").one(); List<String> thelist = row.getList(0, String.class); assertTrue(thelist.contains("one")); assertTrue(thelist.contains("two")); assertTrue(thelist.contains("three")); assertEquals(3, thelist.size()); }
Example #8
Source File: ListTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testSelectthelist() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.SIMPLE); cs.setProperty("query", "SELECT * FROM " + TABLE + " WHERE key = 1"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.info(rowdata); assertEquals(rowdata, "key\tthelist\n" + "1" + "\t" + "[one,two,three]" + "\n"); }
Example #9
Source File: UDTTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testInsertPreparedUDT() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.PREPARED); cs.setProperty("queryArguments", "\"" + EXPECTED + "\""); cs.setProperty("query", "INSERT INTO " + TABLE + " (key,udt) VALUES (2, ?)"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); // See if the value matches String val = session.execute("select udt from " + KEYSPACE + "." + TABLE + " where key = 2").one().getUDTValue(0).toString(); assertEquals(val, EXPECTED); }
Example #10
Source File: UDTTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testSelectUDT() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.SIMPLE); cs.setProperty("query", "SELECT * FROM " + TABLE + " WHERE key = 1"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.info(rowdata); assertEquals(rowdata, "key\tudt\n" + "1" + "\t" + EXPECTED + "\n"); }
Example #11
Source File: MapTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testInsertPreparedthemap() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.PREPARED); cs.setProperty("queryArguments", "\"" + EXPECTED + "\""); cs.setProperty("query", "INSERT INTO " + TABLE + " (key,themap) VALUES (2, ?)"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); // See if the value matches Row row = session.execute("select themap from " + KEYSPACE + "." + TABLE + " where key = 2").one(); Map<Integer, String> themap = row.getMap(0, Integer.class, String.class); assertTrue(themap.get(1).contentEquals("one")); assertTrue(themap.get(2).contentEquals("two")); assertTrue(themap.get(3).contentEquals("three")); assertEquals(3, themap.size()); }
Example #12
Source File: MapTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testSelectthemap() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.SIMPLE); cs.setProperty("query", "SELECT * FROM " + TABLE + " WHERE key = 1"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.info(rowdata); assertEquals(rowdata, "key\tthemap\n" + "1" + "\t" + "{1:one,2:two,3:three}" + "\n"); }
Example #13
Source File: SimpleQueryTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test(dataProvider = "provideQueries") public void testPreparedMapQuery(String table, String expected, Object nothing) { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.PREPARED); cs.setProperty("queryArguments", expected ); cs.setProperty("query", "SELECT * FROM map_" + table + " WHERE K = ?"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.debug(rowdata); assertEquals(rowdata, "k\tv\n"+ expected +"\t{"+ expected + ":" + expected +"}\n"); }
Example #14
Source File: SimpleQueryTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test(dataProvider = "provideQueries") public void testPreparedListQuery(String table, String expected, Object nothing) { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.PREPARED); cs.setProperty("queryArguments", expected ); cs.setProperty("query", "SELECT * FROM list_" + table + " WHERE K = ?"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.debug(rowdata); assertEquals(rowdata, "k\tv\n"+ expected +"\t["+ expected +"]\n"); }
Example #15
Source File: SimpleQueryTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test(dataProvider = "provideQueries") public void testPreparedSetQuery(String table, String expected, Object nothing) { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.PREPARED); cs.setProperty("queryArguments", expected ); cs.setProperty("query", "SELECT * FROM set_" + table + " WHERE K = ?"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.debug(rowdata); assertEquals(rowdata, "k\tv\n"+ expected +"\t{"+ expected +"}\n"); }
Example #16
Source File: SimpleQueryTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test(dataProvider = "provideQueries") public void testSimpleQuery(String table, String expected, Object nothing) { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.SIMPLE); cs.setProperty("query", "SELECT * FROM " + table); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.info(rowdata); assertEquals(rowdata, "k\tv\n"+ expected +"\t"+ expected +"\n"); }
Example #17
Source File: SetTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testInsertPreparedthesetle() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.PREPARED); cs.setProperty("queryArguments", "\"" + EXPECTED + "\""); cs.setProperty("query", "INSERT INTO " + TABLE + " (key,theset) VALUES (2, ?)"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); // See if the value matches Row row = session.execute("select theset from " + KEYSPACE + "." + TABLE + " where key = 2").one(); Set<String> theSet = row.getSet(0, String.class); assertTrue(theSet.contains("one")); assertTrue(theSet.contains("two")); assertTrue(theSet.contains("three")); assertEquals(3, theSet.size()); }
Example #18
Source File: SetTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testSelectthesetle() { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.SIMPLE); cs.setProperty("query", "SELECT * FROM " + TABLE + " WHERE key = 1"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.info(rowdata); assertEquals(rowdata, "key\ttheset\n" + "1" + "\t" + "{one,three,two}" + "\n"); }
Example #19
Source File: HonoSenderSampler.java From hono with Eclipse Public License 2.0 | 6 votes |
@Override public SampleResult sample(final Entry entry) { final SampleResult res = new SampleResult(); res.setDataType(SampleResult.TEXT); res.setResponseOK(); res.setResponseCodeOK(); res.setSampleLabel(getName()); if (getMessageCountPerSamplerRunAsInt() == 1) { honoSender.send(res, getDeviceId(), isWaitForDeliveryResult()); } else { honoSender.send(res, getMessageCountPerSamplerRunAsInt(), getDeviceId(), isWaitForDeliveryResult()); } return res; }
Example #20
Source File: SimpleQueryTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test(dataProvider = "provideQueries") public void testPreparedQuery(String table, String expected, Object nothing) { CassandraSampler cs = new CassandraSampler(); cs.setProperty("sessionName",TESTSESSION); cs.setProperty("consistencyLevel", AbstractCassandaTestElement.ONE); cs.setProperty("resultVariable","rv"); cs.setProperty("queryType", AbstractCassandaTestElement.PREPARED); cs.setProperty("queryArguments", expected ); cs.setProperty("query", "SELECT * FROM " + table + " WHERE K = ?"); TestBeanHelper.prepare(cs); SampleResult res = cs.sample(new Entry()); assertTrue(res.isSuccessful(), res.getResponseMessage()); String rowdata = new String(res.getResponseData()); logger.debug(rowdata); assertEquals(rowdata, "k\tv\n"+ expected +"\t"+ expected +"\n"); }
Example #21
Source File: HonoReceiverSampler.java From hono with Eclipse Public License 2.0 | 5 votes |
@Override public SampleResult sample(final Entry entry) { final SampleResult res = new SampleResult(); res.setResponseOK(); res.setDataType(SampleResult.TEXT); res.setSampleLabel(getName()); honoReceiver.sample(res); return res; }
Example #22
Source File: ConcurrencyThreadGroupTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public SampleResult sample(Entry e) { System.out.println(this.getName()); SampleResult result = super.sample(e); try { Thread.sleep(300); } catch (InterruptedException ex) { throw new AssertionError(ex); } return result; }
Example #23
Source File: HTTPRawSampler.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public SampleResult sample(Entry entry) { SampleResult res = super.sample(entry); if (isParseResult()) { parseResponse(res); } return res; }
Example #24
Source File: DubboSample.java From jmeter-plugins-for-apache-dubbo with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public SampleResult sample(Entry entry) { SampleResult res = new SampleResult(); res.setSampleLabel(getName()); //构造请求数据 res.setSamplerData(getSampleData()); //调用dubbo res.setResponseData(JsonUtils.toJson(callDubbo(res)), StandardCharsets.UTF_8.name()); //构造响应数据 res.setDataType(SampleResult.TEXT); return res; }
Example #25
Source File: JSONToXMLConverterTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
/** * Test of sample method, of class JSONToXMLConverter. */ @Test public void testSample() { System.out.println("sample"); Entry e = null; JSONToXMLConverter instance = new JSONToXMLConverter(); SampleResult expResult = null; SampleResult result = instance.sample(e); }
Example #26
Source File: ParallelSamplerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
@Override public SampleResult sample(Entry e) { count.addAndGet(1); log.debug("Sample #" + count.get()); ThreadLocalRandom.current().nextInt(10); return super.sample(e); }
Example #27
Source File: AbstractIPSamplerTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
/** * Test of sample method, of class AbstractIPSampler. */ @Test public void testSample() { System.out.println("sample"); Entry entry = null; AbstractIPSampler instance = new AbstractIPSamplerImpl(); SampleResult result = instance.sample(entry); assertNotNull(result); }
Example #28
Source File: HonoCommanderSampler.java From hono with Eclipse Public License 2.0 | 5 votes |
@Override public SampleResult sample(final Entry entry) { final HonoCommanderSampleResult sampleResult = new HonoCommanderSampleResult(); sampleResult.setDataType(SampleResult.TEXT); sampleResult.setSampleLabel(getName()); honoCommander.sample(sampleResult); return sampleResult; }
Example #29
Source File: HTTP2Sampler.java From jmeter-http2-plugin with Apache License 2.0 | 5 votes |
@Override public SampleResult sample(Entry e) { log.debug("sample()"); // Load test elements HeaderManager headerManager = (HeaderManager)getProperty(HTTPSamplerBase.HEADER_MANAGER).getObjectValue(); // Send H2 request NettyHttp2Client client = new NettyHttp2Client(getMethod(), getDomain(), getPort(), getPath(), headerManager); SampleResult res = client.request(); res.setSampleLabel(getName()); return res; }
Example #30
Source File: JMeterXMPPSampler.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
@Override public SampleResult sample(Entry entry) { SampleResult res = new SampleResult(); res.setSampleLabel(getName()); res.setDataType(SampleResult.TEXT); res.setSuccessful(true); res.setResponseCode("200"); res.setResponseMessage("OK"); res.sampleStart(); try { if (connConfig == null) { throw new RuntimeException("Cannot sample XMPP without XMPP Connection component"); } XMPPConnection conn = getXMPPConnection(); if (conn == null) { throw new RuntimeException("No XMPP Connection available"); } String headers = "Connection ID: " + conn.getConnectionID() + "\r\n"; String action = getAction(); if (!conn.isConnected() && !action.equals(Connect.class.getCanonicalName())) { log.error("Please call Connect before calling other actions"); throw new SmackException.NotConnectedException(); } headers += "User: " + conn.getUser() + "\r\n"; res.setRequestHeaders(headers); AbstractXMPPAction actObject = connConfig.getActions().get(action); if (actObject.perform(this, res) == null) { return null; } } catch (Exception e) { log.error("Error in XMPP Sampler: ", e); res.setSuccessful(false); res.setResponseCode("500"); res.setResponseMessage((e.getMessage() == null || e.getMessage().isEmpty()) ? e.toString() : e.getMessage()); res.setResponseData(ExceptionUtils.getStackTrace(e).getBytes()); } res.sampleEnd(); return res; }