本文整理匯總了Java中org.apache.jmeter.samplers.SampleResult.setSamplerData方法的典型用法代碼示例。如果您正苦於以下問題:Java SampleResult.setSamplerData方法的具體用法?Java SampleResult.setSamplerData怎麽用?Java SampleResult.setSamplerData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jmeter.samplers.SampleResult
的用法示例。
在下文中一共展示了SampleResult.setSamplerData方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: perform
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
Action action = Action.valueOf(sampler.getPropertyAsString(ACTION, Action.get_roster.toString()));
Roster roster = sampler.getXMPPConnection().getRoster();
String entry = sampler.getPropertyAsString(ENTRY);
res.setSamplerData(action.toString() + ": " + entry);
if (action == Action.get_roster) {
res.setResponseData(rosterToString(roster).getBytes());
} else if (action == Action.add_item) {
roster.createEntry(entry, entry, new String[0]);
} else if (action == Action.delete_item) {
RosterEntry rosterEntry = roster.getEntry(entry);
if (rosterEntry != null) {
roster.removeEntry(rosterEntry);
}
}
return res;
}
示例2: perform
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
// sending message
String recipient = sampler.getPropertyAsString(RECIPIENT);
String body = sampler.getPropertyAsString(BODY);
boolean wait_response = sampler.getPropertyAsBoolean(WAIT_RESPONSE);
if (wait_response) {
body += "\r\n" + System.currentTimeMillis() + "@" + NEED_RESPONSE_MARKER;
}
Message msg = new Message(recipient);
msg.setType(Message.Type.fromString(sampler.getPropertyAsString(TYPE, Message.Type.normal.toString())));
msg.addBody("", body);
res.setSamplerData(msg.toXML().toString());
sampler.getXMPPConnection().sendPacket(msg);
res.setSamplerData(msg.toXML().toString()); // second time to reflect the changes made to packet by conn
if (wait_response) {
return waitResponse(res, recipient);
}
return res;
}
示例3: perform
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
Presence.Type typeVal = Presence.Type.valueOf(sampler.getPropertyAsString(TYPE, Presence.Type.available.toString()));
Presence.Mode modeVal = Presence.Mode.valueOf(sampler.getPropertyAsString(MODE, Presence.Mode.available.toString()));
Presence presence = new Presence(typeVal);
presence.setMode(modeVal);
String to = sampler.getPropertyAsString(RECIPIENT);
if (!to.isEmpty()) {
presence.setTo(to);
}
String text = sampler.getPropertyAsString(STATUS_TEXT);
if (!text.isEmpty()) {
presence.setStatus(text);
}
sampler.getXMPPConnection().sendPacket(presence);
res.setSamplerData(presence.toXML().toString());
return res;
}
示例4: perform
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
String recipient = sampler.getPropertyAsString(FILE_RECIPIENT);
String filePath = sampler.getPropertyAsString(FILE_PATH);
res.setSamplerData("Recipient: " + recipient + "\r\nFile: " + filePath + "\r\n");
OutgoingFileTransfer transfer = mgr.createOutgoingFileTransfer(recipient);
transfer.sendFile(new File(filePath), filePath);
waitForTransfer(transfer, sampler.getXMPPConnection().getPacketReplyTimeout());
res.setResponseData(("Bytes sent: " + transfer.getBytesSent()).getBytes());
return res;
}
示例5: perform
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public SampleResult perform(final JMeterXMPPSampler sampler, SampleResult res) throws Exception {
final String xml = sampler.getPropertyAsString(XML);
res.setSamplerData(xml);
sampler.getXMPPConnection().sendPacket(new Packet() {
@Override
public CharSequence toXML() {
return xml;
}
});
return res;
}
示例6: perform
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
String entID = sampler.getPropertyAsString(ENTITY_ID);
res.setSamplerData("Entity ID: " + entID);
ServiceDiscoveryManager discoMgr = ServiceDiscoveryManager.getInstanceFor(sampler.getXMPPConnection());
IQ info;
if (Type.valueOf(sampler.getPropertyAsString(TYPE)) == Type.info) {
info = discoMgr.discoverInfo(entID);
} else {
info = discoMgr.discoverItems(entID);
}
res.setResponseData(info.toXML().toString().getBytes());
return res;
}
示例7: perform
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
String room = sampler.getPropertyAsString(ROOM);
String nick = sampler.getPropertyAsString(NICKNAME);
res.setSamplerData("Join Room: " + room + "/" + nick);
MultiUserChat muc = new MultiUserChat(sampler.getXMPPConnection(), room);
muc.join(nick);
return res;
}
示例8: perform
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
XMPPConnection conn = sampler.getXMPPConnection();
String loginStr = sampler.getPropertyAsString(LOGIN);
String pwdStr = sampler.getPropertyAsString(PASSWORD);
String resStr = sampler.getPropertyAsString(RESOURCE);
res.setSamplerData("Username: " + loginStr + "\nPassword: " + pwdStr + "\nResource: " + resStr);
AbstractXMPPConnection absConn = (AbstractXMPPConnection) conn;
if (loginStr.isEmpty()) {
absConn.loginAnonymously();
} else {
absConn.login(loginStr, pwdStr, resStr);
}
return res;
}