org.apache.jmeter.testbeans.TestBeanHelper Java Examples
The following examples show how to use
org.apache.jmeter.testbeans.TestBeanHelper.
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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
Source File: CassandraConnection.java From jmeter-cassandra with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") // call to TestBeanHelper.prepare() is intentional public void testStarted() { this.setRunningVersion(true); TestBeanHelper.prepare(this); JMeterVariables variables = getThreadContext().getVariables(); LoadBalancingPolicy loadBalancingPolicy = null; if (loadBalancer.contentEquals(DC_AWARE_ROUND_ROBIN)) { // in driver v2.0.2+, we can use the default constructor on // dcawareroundrobinpolicy if (localDataCenter.isEmpty()) { loadBalancingPolicy = new DCAwareRoundRobinPolicy(); } else { loadBalancingPolicy = new DCAwareRoundRobinPolicy(localDataCenter); } } else if (loadBalancer.contentEquals(WHITELIST)) { loadBalancingPolicy = new WhiteListPolicy(new RoundRobinPolicy(), contactPointsIS); } else if (loadBalancer.contentEquals(ROUND_ROBIN)) { loadBalancingPolicy = new RoundRobinPolicy(); } else if (loadBalancer.contentEquals(DC_TOKEN_AWARE)) { loadBalancingPolicy = new TokenAwarePolicy(new DCAwareRoundRobinPolicy()); } else if (loadBalancer.contentEquals(DEFAULTLOADBALANCER)) { loadBalancingPolicy = null; } Session session = CassandraSessionFactory.createSession(sessionName, contactPointsI, keyspace, username, password, loadBalancingPolicy); variables.putObject(sessionName, session); }
Example #17
Source File: AbstractDebugElement.java From jmeter-debugger with Apache License 2.0 | 4 votes |
protected void prepareBean() { if (wrapped instanceof TestBean) { //noinspection deprecation TestBeanHelper.prepare((TestElement) wrapped); // the deprecation reason is not sufficient } }