本文整理汇总了Java中org.apache.jmeter.samplers.Entry类的典型用法代码示例。如果您正苦于以下问题:Java Entry类的具体用法?Java Entry怎么用?Java Entry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Entry类属于org.apache.jmeter.samplers包,在下文中一共展示了Entry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sample
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
public SampleResult sample(Entry arg0) {
SampleResult res = new SampleResult();
res.setSampleLabel("函数助手小工具");
res.sampleStart();
// 输出GUI界面所输入的函数方法返回结果
JMeterProperty properties = this.getProperty(FUNCTION);
System.out.println(properties);
//
if (properties != null) {
res.setResponseData("Function结果是:" + properties.getStringValue(), null);
res.setDataType(SampleResult.TEXT);
}
res.sampleEnd();
res.setSuccessful(true);
return res;
}
示例2: sample
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@Override
public SampleResult sample(Entry entry) {
SampleResult result = new SampleResult();
result.setSampleLabel(getName());
try {
result.sampleStart();
Producer<String, String> producer = getProducer();
KeyedMessage<String, String> msg = new KeyedMessage<String, String>(getTopic(), getMessage());
producer.send(msg);
result.sampleEnd();
result.setSuccessful(true);
result.setResponseCodeOK();
} catch (Exception e) {
result.sampleEnd(); // stop stopwatch
result.setSuccessful(false);
result.setResponseMessage("Exception: " + e);
// get stack trace as a String to return as document data
java.io.StringWriter stringWriter = new java.io.StringWriter();
e.printStackTrace(new java.io.PrintWriter(stringWriter));
result.setResponseData(stringWriter.toString(), null);
result.setDataType(org.apache.jmeter.samplers.SampleResult.TEXT);
result.setResponseCode("FAILED");
}
return result;
}
示例3: formatSet
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
private void formatSet(StringBuilder sb, @SuppressWarnings("rawtypes") Set s) {
@SuppressWarnings("unchecked")
List<Map.Entry<Object, Object>> al = new ArrayList<>(s);
Collections.sort(al, new Comparator<Map.Entry<Object, Object>>(){
@Override
public int compare(Map.Entry<Object, Object> o1, Map.Entry<Object, Object> o2) {
String m1,m2;
m1=(String)o1.getKey();
m2=(String)o2.getKey();
return m1.compareTo(m2);
}
});
for(Map.Entry<Object, Object> me : al){
sb.append(me.getKey());
sb.append("=");
sb.append(me.getValue());
sb.append("\n");
}
}
示例4: sample
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
/**
* Performs a test sample.
*
* The <code>sample()</code> method retrieves the reference to the Java
* client and calls its <code>runTest()</code> method.
*
* @see JavaSamplerClient#runTest(JavaSamplerContext)
*
* @param entry
* the Entry for this sample
* @return test SampleResult
*/
@Override
public SampleResult sample(Entry entry) {
Arguments args = getArguments();
args.addArgument(TestElement.NAME, getName()); // Allow Sampler access
// to test element name
context = new JavaSamplerContext(args);
if (javaClient == null) {
log.debug(whoAmI() + "\tCreating Java Client");
javaClient = createJavaClient();
javaClient.setupTest(context);
}
SampleResult result = javaClient.runTest(context);
// Only set the default label if it has not been set
if (result != null && result.getSampleLabel().length() == 0) {
result.setSampleLabel(getName());
}
return result;
}
示例5: printEnvironment
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
private void printEnvironment(Context context) throws NamingException {
try {
Hashtable<?,?> env = context.getEnvironment();
if(env != null) {
log.debug("Initial Context Properties");
for (Map.Entry<?, ?> entry : env.entrySet()) {
log.debug(entry.getKey() + "=" + entry.getValue());
}
} else {
log.warn("context.getEnvironment() returned null (should not happen according to javadoc but non compliant implementation can return this)");
}
} catch (javax.naming.OperationNotSupportedException ex) {
// Some JNDI implementation can return this
log.warn("context.getEnvironment() not supported by implementation ");
}
}
示例6: testSelectthesetle
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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");
}
示例7: testInsertPreparedthesetle
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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());
}
示例8: testSimpleQuery
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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");
}
示例9: testPreparedQuery
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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");
}
示例10: testPreparedSetQuery
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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");
}
示例11: testPreparedListQuery
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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");
}
示例12: testPreparedMapQuery
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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");
}
示例13: testSelectthemap
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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");
}
示例14: testInsertPreparedthemap
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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());
}
示例15: testSelectUDT
import org.apache.jmeter.samplers.Entry; //导入依赖的package包/类
@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");
}