本文整理汇总了Java中org.apache.jmeter.util.JMeterUtils.setLocale方法的典型用法代码示例。如果您正苦于以下问题:Java JMeterUtils.setLocale方法的具体用法?Java JMeterUtils.setLocale怎么用?Java JMeterUtils.setLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jmeter.util.JMeterUtils
的用法示例。
在下文中一共展示了JMeterUtils.setLocale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doAction
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
/**
* @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent)
*/
@Override
public void doAction(ActionEvent e) {
String locale = ((Component) e.getSource()).getName();
Locale loc;
int sep = locale.indexOf('_');
if (sep > 0) {
loc = new Locale(locale.substring(0, sep), locale.substring(sep + 1));
} else {
loc = new Locale(locale, "");
}
log.debug("Changing locale to " + loc.toString());
try {
JMeterUtils.setLocale(loc);
} catch (JMeterError err) {
JMeterUtils.reportErrorToUser(err.toString());
}
}
示例2: setUp
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
@Override
public void setUp() {
if (testLocale == null) {
return;// errorDetected()
}
JMeterUtils.setLocale(testLocale);
Introspector.flushFromCaches(testBeanClass);
try {
beanInfo = Introspector.getBeanInfo(testBeanClass);
bundle = (ResourceBundle) beanInfo.getBeanDescriptor().getValue(GenericTestBeanCustomizer.RESOURCE_BUNDLE);
} catch (IntrospectionException e) {
log.error("Can't get beanInfo for " + testBeanClass.getName(), e);
throw new Error(e.toString(), e); // Programming error. Don't continue.
}
if (bundle == null) {
throw new Error("This can't happen!");
}
}
示例3: main
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
public static void main(String[] args) {
//JMeter Engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();
//JMeter initialization (properties, log levels, locale, etc)
JMeterUtils.loadJMeterProperties("/path/to/your/jmeter/bin/jmeter.properties");
JMeterUtils.setLocale(Locale.ENGLISH);
// ??? 啥用
JMeterUtils.setJMeterHome("");
JMeterUtils.initLocale();
// JMeter Test Plan, basic all u JOrphan HashTree
HashTree testPlanTree = new HashTree();
// Java Sampler
JavaSampler javaSampler = new JavaSampler();
javaSampler.setClassname("这里设置要运行的case主类");
javaSampler.setName("");
javaSampler.setComment("这个采集器的描述信息");
// Loop Controller
LoopController loopController = new LoopController();
// 循环次数
loopController.setLoops(1);
loopController.addTestElement(javaSampler);
loopController.setFirst(true);
loopController.initialize();
// Thread Group
org.apache.jmeter.threads.ThreadGroup threadGroup = new org.apache.jmeter.threads.ThreadGroup();
// 设置线程数
threadGroup.setNumThreads(1);
//
threadGroup.setRampUp(1);
threadGroup.setSamplerController(loopController);
// Test Plan
TestPlan testPlan = new TestPlan("Create JMeter Script From Java Code");
// Construct Test Plan from previously initialized elements
testPlanTree.add("testPlan", testPlan);
testPlanTree.add("loopController", loopController);
testPlanTree.add("threadGroup", threadGroup);
testPlanTree.add("javaSampler", javaSampler);
// Run Test Plan
jmeter.configure(testPlanTree);
jmeter.run();
}
示例4: initializeJMeter
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
private static void initializeJMeter()
{
JMeterUtils.setJMeterHome(new File("").getAbsolutePath());
JMeterUtils.loadJMeterProperties(new File("jmeter.properties").getAbsolutePath());
JMeterUtils.setProperty("saveservice_properties", File.separator + "saveservice.properties");
JMeterUtils.setProperty("user_properties", File.separator + "user.properties");
JMeterUtils.setProperty("upgrade_properties", File.separator + "upgrade.properties");
JMeterUtils.setProperty("system_properties", File.separator + "system.properties");
JMeterUtils.setLocale(Locale.ENGLISH);
JMeterUtils.setProperty("proxy.cert.directory", new File("").getAbsolutePath());
}
示例5: main
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
JMeterUtils.setJMeterHome("src/test/resources/");
JMeterUtils.loadJMeterProperties("src/test/resources/jmeter.properties");
JMeterUtils.setProperty("saveservice_properties", "saveservice.properties");
JMeterUtils.setProperty("search_paths", "ApacheJMeter_functions-2.9.jar");
JMeterUtils.setLocale(Locale.JAPAN);
JMeterEngine engine = new StandardJMeterEngine();
HashTree config = new ListedHashTree();
TestPlan testPlan = new TestPlan("websocket test");
testPlan.setFunctionalMode(false);
testPlan.setSerialized(false);
testPlan.setProperty(new BooleanProperty(TestElement.ENABLED, true));
testPlan.setUserDefinedVariables(new Arguments());
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(300);
threadGroup.setRampUp(20);
threadGroup.setDelay(0);
threadGroup.setDuration(0);
threadGroup.setProperty(new StringProperty(ThreadGroup.ON_SAMPLE_ERROR, "continue"));
threadGroup.setScheduler(false);
threadGroup.setName("Group1");
threadGroup.setProperty(new BooleanProperty(TestElement.ENABLED, true));
LoopController controller = new LoopController();
controller.setLoops(10);
controller.setContinueForever(false);
controller.setProperty(new BooleanProperty(TestElement.ENABLED, true));
threadGroup.setProperty(new TestElementProperty(ThreadGroup.MAIN_CONTROLLER, controller));
CSVDataSet csvDataSet = new CSVDataSet();
csvDataSet.setProperty(new StringProperty("filename", "src/test/resources/users.csv"));
csvDataSet.setProperty(new StringProperty("variableNames", "USER_NAME"));
csvDataSet.setProperty(new StringProperty("delimiter", ","));
csvDataSet.setProperty(new StringProperty("shareMode", "shareMode.all"));
csvDataSet.setProperty("quoted", false);
csvDataSet.setProperty("recycle", true);
csvDataSet.setProperty("stopThread", false);
WebSocketSampler sampler = new WebSocketSampler();
sampler.setName("WebSocket Test");
sampler.setProperty(new BooleanProperty(TestElement.ENABLED, true));
sampler.addNonEncodedArgument("name", "${USER_NAME}", "=");
sampler.setContentEncoding("UTF-8");
sampler.setProtocol("ws");
sampler.setDomain("localhost");
sampler.setPort(9090);
sampler.setPath("/", "UTF-8");
sampler.setSendMessage("${__RandomString(50,ABCDEFGHIJKLMNOPQRSTUVWXYZ)}");
sampler.setRecvMessage("\"name\":\"${USER_NAME}\"");
OnceOnlyController onceOnlyController = new OnceOnlyController();
Summariser summariser = new Summariser();
HashTree tpConfig = config.add(testPlan);
HashTree tgConfig = tpConfig.add(threadGroup);
HashTree oocConfig = tgConfig.add(onceOnlyController);
oocConfig.add(csvDataSet);
UniformRandomTimer randomTimer = new UniformRandomTimer();
randomTimer.setRange(3000);
HashTree samplerConfig = tgConfig.add(sampler);
samplerConfig.add(summariser);
tgConfig.add(randomTimer);
engine.configure(config);
engine.runTest();
}
示例6: resetLocale
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
public void resetLocale(){
JMeterUtils.setLocale(DEFAULT_LOCALE);
Locale.setDefault(DEFAULT_LOCALE);
}
示例7: tearDown
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
@Override
public void tearDown() {
JMeterUtils.setLocale(Locale.getDefault());
}