Java Code Examples for org.apache.jmeter.util.JMeterUtils#setProperty()
The following examples show how to use
org.apache.jmeter.util.JMeterUtils#setProperty() .
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: LoadosophiaClientTest.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
@Test public void testHandleSamples() throws Exception { JMeterUtils.setProperty("sense.delay", "10000"); LoadosophiaClient client = new LoadosophiaClient(); client.setOnlineInitiated(true); client.setResultCollector(new ResultCollector()); client.setFileName(""); StatusNotifierCallbackTest.StatusNotifierCallbackImpl notifierCallback = new StatusNotifierCallbackTest.StatusNotifierCallbackImpl(); client.setInformer(notifierCallback); client.setApiClient(new LoadosophiaAPIClientEmul(notifierCallback)); List<SampleResult> list = new LinkedList<>(); list.add(new SampleResult(System.currentTimeMillis(), 1)); list.add(new SampleResult(System.currentTimeMillis() + 1000, 1)); list.add(new SampleResult(System.currentTimeMillis() + 2000, 1)); long start = System.currentTimeMillis(); client.handleSampleResults(list, null); long end = System.currentTimeMillis(); assertTrue((end - start) > 9999); }
Example 2
Source File: BlazemeterUploaderTest.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
@Test public void testFlow() throws Exception { JMeterUtils.setProperty("blazemeter.client", BLCEmul.class.getName()); BlazeMeterUploader uploader = new BlazeMeterUploader(); uploader.setGui(new BlazeMeterUploaderGui()); uploader.setShareTest(true); uploader.setProject("project"); uploader.setTitle("title"); uploader.testStarted(); uploader.testEnded(); assertEquals(true, uploader.isShareTest()); assertEquals("project", uploader.getProject()); assertEquals("title", uploader.getTitle()); assertEquals("", uploader.getUploadToken()); }
Example 3
Source File: LoadosophiaUploaderTest.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
@Test public void testTestEndedWithNoStoreDir() throws IOException { System.out.println("testEnded"); JMeterUtils.setProperty("loadosophia.address", "http://localhost/"); LoadosophiaUploader instance = new LoadosophiaUploaderEmul(); instance.setStoreDir(""); instance.setTitle("UnitTest"); instance.setColorFlag("gray"); instance.setProject("DEFAULT"); instance.setUploadToken("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); instance.testStarted(); SampleResult res = new SampleResult(); res.sampleStart(); res.sampleEnd(); SampleEvent event = new SampleEvent(res, "test"); instance.sampleOccurred(event); instance.testEnded(); }
Example 4
Source File: HTTPRawSamplerTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Test public void testProcessIO_long_Limited() throws Exception { JMeterUtils.setProperty(AbstractIPSampler.RECV_BUFFER_LEN_PROPERTY, Integer.toString(1024)); JMeterUtils.setProperty(AbstractIPSampler.RESULT_DATA_LIMIT, Integer.toString(1024)); instance = new HTTPRawSamplerEmul(); instance.setHostName("169.254.250.25"); instance.setPort("80"); instance.setTimeout("0"); System.out.println("processIOlim"); SampleResult res = new SampleResult(); res.sampleStart(); String resp = TestJMeterUtils.getTestData(12048); instance.sockEmul.setBytesToRead(ByteBuffer.wrap(resp.getBytes())); byte[] result = instance.processIO(res); System.out.println(result.length); assertEquals(4096, result.length); }
Example 5
Source File: DummySamplerGuiTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Test public void displayGUI() throws InterruptedException { if (!GraphicsEnvironment.isHeadless()) { JMeterUtils.setProperty("search_paths", System.getProperty("user.home") + "/.m2/repository/org/apache/jmeter/ApacheJMeter_core/2.13"); DummySamplerGui obj = new DummySamplerGui(); DummySampler te = (DummySampler) obj.createTestElement(); obj.configure(te); obj.clearGui(); obj.modifyTestElement(te); JFrame frame = new JFrame(obj.getStaticLabel()); frame.setPreferredSize(new Dimension(1024, 768)); frame.getContentPane().add(obj, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); while (frame.isVisible()) { Thread.sleep(1000); } } }
Example 6
Source File: JMeterPluginsUtilsTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Test public void testGetShortHostnameCustomPattern1() throws IOException { System.out.println("testGetShortHostnameCustomPattern1"); TestJMeterUtils.createJmeterEnv(); JMeterUtils.setProperty("jmeterPlugin.perfmon.label.useHostname.pattern", "([\\w\\-]+\\.us-(east|west)-[0-9]).*"); String host; host = JMeterPluginsUtils.getShortHostname("host1.us-west-2.ec2.internal"); assertEquals("host1.us-west-2", host); host = JMeterPluginsUtils.getShortHostname("host.us-west-2.ec2.internal"); assertEquals("host.us-west-2", host); host = JMeterPluginsUtils.getShortHostname("1host.us-east-1.ec2.internal"); assertEquals("1host.us-east-1", host); host = JMeterPluginsUtils.getShortHostname("search-head.us-west-1.ec2.internal"); assertEquals("search-head.us-west-1", host); host = JMeterPluginsUtils.getShortHostname("search-index.us-west-2.ec2.internal"); assertEquals("search-index.us-west-2", host); }
Example 7
Source File: JMeterRecorder.java From jsflight with Apache License 2.0 | 5 votes |
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()); }
Example 8
Source File: AbstractSimpleThreadGroupTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Test public void testFlow() { JMeterUtils.setProperty(AbstractSimpleThreadGroup.THREAD_GROUP_DISTRIBUTED_PREFIX_PROPERTY_NAME, "distprefix"); final AbstractSimpleThreadGroupImpl tg = new AbstractSimpleThreadGroupImpl(); tg.setName("TGName"); LoopController looper = new LoopController(); looper.setLoops(-1); tg.setSamplerController(looper); tg.setNumThreads(1); ListedHashTree listedHashTree = ArrivalsThreadGroupTest.getListedHashTree(tg, false); tg.start(0, null, listedHashTree, null); for (Map.Entry<JMeterThread, Thread> entry : tg.getAllThreads().entrySet()) { assertEquals("distprefix-TGName 0-1", entry.getValue().getName()); } new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); tg.tellThreadsToStop(); tg.waitThreadsStopped(); } catch (InterruptedException e) { e.printStackTrace(); } } }).start(); tg.verifyThreadsStopped(); }
Example 9
Source File: UltimateThreadGroupTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Test public void testSchedule_Prop() { System.out.println("schedule from property"); String threadsSchedule = "spawn(1,1s,1s,1s,1m) spawn(2,1s,3s,1s,2h)"; JMeterUtils.setProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY, threadsSchedule); UltimateThreadGroup instance = new UltimateThreadGroup(); JMeterProperty result = instance.getData(); JMeterUtils.setProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY, ""); // clear! assertEquals("[[1, 1, 1, 1, 60], [2, 1, 3, 1, 7200]]", result.toString()); }
Example 10
Source File: DistributedTestControl.java From jmeter-plugins with Apache License 2.0 | 5 votes |
public CollectionProperty getData() { CollectionProperty data = (CollectionProperty) getProperty(DATA_PROP); LinkedList<String> arr=new LinkedList<String>(); for (int n = 0; n < data.size(); n++) { arr.add(data.get(n).getStringValue()); } String val = StringUtils.join(arr, ","); log.debug("Setting hosts 1: " + val); JMeterUtils.setProperty(PROP_HOSTS, val); return data; }
Example 11
Source File: VariableThroughputTimerTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Test public void testDelay_Prop() { System.out.println("delay from property"); String load = "const(10,10s) line(10,100,1m) step(5,25,5,1h)"; JMeterUtils.setProperty(VariableThroughputTimer.DATA_PROPERTY, load); VariableThroughputTimer instance = new VariableThroughputTimer(); JMeterUtils.setProperty(VariableThroughputTimer.DATA_PROPERTY, ""); // clear! JMeterProperty result = instance.getData(); assertEquals("[[10, 10, 10], [10, 100, 60], [5, 5, 3600], [10, 10, 3600], [15, 15, 3600], [20, 20, 3600], [25, 25, 3600]]", result.toString()); }
Example 12
Source File: TestJMeterUtils.java From jmeter-plugins with Apache License 2.0 | 5 votes |
public static void createJmeterEnv() { JMeterUtils.setJMeterHome(getTempDir()); File dst = new File(JMeterUtils.getJMeterHome() + "/ss.props"); InputStream src = DirectoryAnchor.class.getResourceAsStream("/kg/apc/jmeter/bin/saveservice.properties"); try { Files.copy(src, dst.toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { throw new RuntimeException("Failed to copy file " + src + " to " + dst, e); } JMeterUtils.loadJMeterProperties(dst.getAbsolutePath()); JMeterUtils.setLocale(new Locale("ignoreResources")); JMeterTreeModel jMeterTreeModel = new JMeterTreeModel(); JMeterTreeListener jMeterTreeListener = new JMeterTreeListener(); jMeterTreeListener.setModel(jMeterTreeModel); JMeterContextService.getContext().setVariables(new JMeterVariables()); StandardJMeterEngine engine = new EmulatorJmeterEngine(); JMeterThreadMonitor monitor = new EmulatorThreadMonitor(); JMeterContextService.getContext().setEngine(engine); HashTree hashtree = new HashTree(); hashtree.add(new LoopController()); JMeterThread thread = new JMeterThread(hashtree, monitor, null); thread.setThreadName("test thread"); JMeterContextService.getContext().setThread(thread); ThreadGroup threadGroup = new org.apache.jmeter.threads.ThreadGroup(); threadGroup.setName("test thread group"); JMeterContextService.getContext().setThreadGroup(threadGroup); JMeterUtils.setProperty("sample_variables", "TEST1,TEST2,TEST3"); // for Flexible File Writer Test JMeterUtils.setProperty("saveservice_properties", "/ss.props"); JMeterUtils.setProperty("upgrade_properties", "/ss.props"); JMeterUtils.setProperty("sampleresult.default.encoding", "UTF-8"); // enable multibyte }
Example 13
Source File: ParallelHTTPSamplerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { TestJMeterUtils.createJmeterEnv(); JMeterUtils.setProperty("HTTPResponse.parsers", "htmlParser"); JMeterUtils.setProperty("htmlParser.types", "text/html"); JMeterUtils.setProperty("htmlParser.className", "org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser"); }
Example 14
Source File: DebuggerDialogTest.java From jmeter-debugger with Apache License 2.0 | 5 votes |
@Test public void testGui() throws Exception { if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) { return; } String actions = ActionRouter.class.getProtectionDomain().getCodeSource().getLocation().getFile(); String renderers = RenderAsHTML.class.getProtectionDomain().getCodeSource().getLocation().getFile(); JMeterUtils.setProperty("search_paths", actions + ";" + renderers); TestProvider prov = new TestProvider(); JMeterTreeModel mdl = prov.getTreeModel(); JMeterTreeListener a = new JMeterTreeListener(); a.setActionHandler(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { log.debug("Action " + actionEvent); } }); a.setModel(mdl); GuiPackage.getInstance(a, mdl); DebuggerDialog obj = new DebuggerDialogMock(prov.getTreeModel()); obj.componentShown(null); obj.started(); obj.statusRefresh(JMeterContextService.getContext()); obj.frozenAt(new SamplerDebug()); obj.continuing(); obj.stopped(); obj.componentHidden(null); }
Example 15
Source File: HonoSampler.java From hono with Eclipse Public License 2.0 | 5 votes |
void addSemaphore() { synchronized (semaphoreLock) { final String receivers = (getSemaphores() + 1) + ""; JMeterUtils.setProperty(HONO_PREFIX + getAddress(), receivers); LOGGER.info("addSemaphore - receivers: {}", receivers); } }
Example 16
Source File: JMeterXMPPConnectionGuiTest.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
private void setSearchPaths() { ClassLoader cl = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader) cl).getURLs(); String classes = "."; for (URL url : urls) { if (url.getFile().contains("bouncy") || !url.getFile().contains("jmeter")) { continue; } classes += ";" + url.getFile(); } JMeterUtils.setProperty("search_paths", classes); }
Example 17
Source File: WebSocketSendSamplerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpClass() throws Exception { TestJMeterUtils.createJmeterEnv(); factoryMock = Mockito.mock(Factory.class); handlerMqttMock = Mockito.mock(MqttCallBackImpl.class); mqttAsyncClientMock = Mockito.mock(IMqttAsyncClient.class); JMeterUtils.setProperty("WebSocketConnectionConfig.Server", "server"); }
Example 18
Source File: DebuggerDialogTest.java From jmeter-debugger with Apache License 2.0 | 4 votes |
@Test public void displayGUI() throws InterruptedException, IOException, IllegalUserActionException { if (!GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) { TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/vars.jmx", "vars.jmx"); JMeterTreeModel mdl = prov.getTreeModel(); JMeterTreeListener a = new JMeterTreeListener(); a.setActionHandler(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { log.debug("Action " + actionEvent); } }); a.setModel(mdl); GuiPackage.getInstance(a, mdl); String actions = ActionRouter.class.getProtectionDomain().getCodeSource().getLocation().getFile(); String renderers = RenderAsHTML.class.getProtectionDomain().getCodeSource().getLocation().getFile(); JMeterUtils.setProperty("search_paths", actions + ";" + renderers); MainFrame mf = new MainFrame(mdl, a); // does important stuff inside ComponentFinder<JMeterToolBar> finder = new ComponentFinder<>(JMeterToolBar.class); JMeterToolBar tb = finder.findComponentIn(mf); tb.add(new JButton("test")); new TimeFunction(); long now = System.currentTimeMillis(); JMeterUtils.setProperty("START.MS", Long.toString(now)); Date today = new Date(now); JMeterUtils.setProperty("START.YMD", new SimpleDateFormat("yyyyMMdd").format(today)); JMeterUtils.setProperty("START.HMS", new SimpleDateFormat("HHmmss").format(today)); DebuggerDialogMock frame = new DebuggerDialogMock(mdl); frame.setPreferredSize(new Dimension(800, 600)); frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); frame.pack(); frame.setVisible(true); while (frame.isVisible()) { Thread.sleep(1000); } } }
Example 19
Source File: WebSocketSamplerTest.java From jmeter-websocket with Apache License 2.0 | 4 votes |
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(); }
Example 20
Source File: HonoSampler.java From hono with Eclipse Public License 2.0 | 4 votes |
void removeSemaphores() { synchronized (semaphoreLock) { JMeterUtils.setProperty(HONO_PREFIX + getAddress(), "0"); } }