当前位置: 首页>>代码示例>>Java>>正文


Java JMeterUtils类代码示例

本文整理汇总了Java中org.apache.jmeter.util.JMeterUtils的典型用法代码示例。如果您正苦于以下问题:Java JMeterUtils类的具体用法?Java JMeterUtils怎么用?Java JMeterUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JMeterUtils类属于org.apache.jmeter.util包,在下文中一共展示了JMeterUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupTest

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
@Override
public void setupTest(BackendListenerContext context) throws Exception {
    try {
        this.index        = context.getParameter(ES_INDEX);
        this.bulkSize     = Integer.parseInt(context.getParameter(ES_BULK_SIZE));
        this.timeoutMs = JMeterUtils.getPropDefault(ES_TIMEOUT_MS, DEFAULT_TIMEOUT_MS);
        this.buildNumber  = (JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER) != null 
                && JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER).trim() != "") 
                ? Integer.parseInt(JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER)) : 0;
        String host         = context.getParameter(ES_HOST);
        int port         = Integer.parseInt(context.getParameter(ES_PORT));
        this.client       = new RestHighLevelClient(
                    RestClient.builder(
                        new HttpHost(host, port, context.getParameter(ES_SCHEME, "http")))
                    .setRequestConfigCallback(requestConfigBuilder -> 
                         requestConfigBuilder
                                    .setConnectTimeout(5000)
                                    .setSocketTimeout((int)timeoutMs))
                    .setMaxRetryTimeoutMillis(60000));
        this.bulkRequest = new BulkRequest().timeout(TimeValue.timeValueMillis(timeoutMs));
        super.setupTest(context);
    } catch (Exception e) {
        throw new IllegalStateException("Unable to setup connectivity to ES", e);
    }
}
 
开发者ID:delirius325,项目名称:jmeter-elasticsearch-backend-listener,代码行数:26,代码来源:ElasticsearchBackend.java

示例2: loadControl1

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
@Test
public void loadControl1() throws Exception {
   log.info("start loadControl1()");

   // Initialize Properties, logging, locale, etc.
   JMeterUtils.loadJMeterProperties(JMETER_HOME + "/bin/jmeter.properties");
   JMeterUtils.setJMeterHome(JMETER_HOME);
   JMeterUtils.initLocale();

   // Initialize JMeter SaveService
   SaveService.loadProperties();

   // Load existing .jmx Test Plan
   ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
   URL url = classLoader.getResource("tutorial/jmeter/Tutorial6.jmx");
   File file = new File(url.toURI());
   HashTree testPlanTree = SaveService.loadTree(file);

   // Run JMeter Test
   StandardJMeterEngine jmeter = new StandardJMeterEngine();
   jmeter.configure(testPlanTree);
   jmeter.run();
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:24,代码来源:Tutorial6.java

示例3: getResponseAsString

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
public static String getResponseAsString(SampleResult res) {
    String response = null;
    if (isTextDataType(res)) {
        // Showing large strings can be VERY costly, so we will avoid
        // doing so if the response
        // data is larger than 200K. TODO: instead, we could delay doing
        // the result.setText
        // call until the user chooses the "Response data" tab. Plus we
        // could warn the user
        // if this happens and revert the choice if he doesn't confirm
        // he's ready to wait.
        int len = res.getResponseDataAsString().length();
        if (MAX_DISPLAY_SIZE > 0 && len > MAX_DISPLAY_SIZE) {
            StringBuilder builder = new StringBuilder(MAX_DISPLAY_SIZE+100);
            builder.append(JMeterUtils.getResString("view_results_response_too_large_message")) //$NON-NLS-1$
                .append(len).append(" > Max: ").append(MAX_DISPLAY_SIZE)
                .append(", ").append(JMeterUtils.getResString("view_results_response_partial_message")) // $NON-NLS-1$
                .append("\n").append(res.getResponseDataAsString().substring(0, MAX_DISPLAY_SIZE)).append("\n...");
            response = builder.toString();
        } else {
            response = res.getResponseDataAsString();
        }
    }
    return response;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:26,代码来源:ViewResultsFullVisualizer.java

示例4: testHandleSamples

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
@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);
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:23,代码来源:LoadosophiaClientTest.java

示例5: createLeftPanel

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
private synchronized Component createLeftPanel() {
    SampleResult rootSampleResult = new SampleResult();
    rootSampleResult.setSampleLabel("Root");
    rootSampleResult.setSuccessful(true);
    root = new SearchableTreeNode(rootSampleResult, null);

    treeModel = new DefaultTreeModel(root);
    jTree = new JTree(treeModel);
    jTree.setCellRenderer(new ResultsNodeRenderer());
    jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree.addTreeSelectionListener(this);
    jTree.setRootVisible(false);
    jTree.setShowsRootHandles(true);
    JScrollPane treePane = new JScrollPane(jTree);
    treePane.setPreferredSize(new Dimension(200, 300));

    VerticalPanel leftPane = new VerticalPanel();
    leftPane.add(treePane, BorderLayout.CENTER);
    leftPane.add(createComboRender(), BorderLayout.NORTH);
    autoScrollCB = new JCheckBox(JMeterUtils.getResString("view_results_autoscroll")); // $NON-NLS-1$
    autoScrollCB.setSelected(false);
    autoScrollCB.addItemListener(this);
    leftPane.add(autoScrollCB, BorderLayout.SOUTH);
    return leftPane;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:26,代码来源:ViewResultsFullVisualizer.java

示例6: init

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());

    // URL CONFIG
    http2RequestPanel = new HTTP2RequestPanel(false, true, false);

    // AdvancedPanel (embedded resources, source address and optional tasks)
    JPanel advancedPanel = new VerticalPanel();
    advancedPanel.add(createEmbeddedRsrcPanel());
    advancedPanel.add(createSourceAddrPanel());
    advancedPanel.add(createOptionalTasksPanel());

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.add(JMeterUtils
            .getResString("web_testing_basic"), http2RequestPanel);
    tabbedPane.add(JMeterUtils
            .getResString("web_testing_advanced"), advancedPanel);

    JPanel emptyPanel = new JPanel();
    emptyPanel.setMaximumSize(new Dimension());

    add(makeTitlePanel(), BorderLayout.NORTH);
    add(tabbedPane, BorderLayout.CENTER);        
    add(emptyPanel, BorderLayout.SOUTH);
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:27,代码来源:Http2DefaultsGui.java

示例7: createEmbeddedRsrcPanel

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
protected JPanel createEmbeddedRsrcPanel() {
    // retrieve Embedded resources
    retrieveEmbeddedResources = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$

    final JPanel embeddedRsrcPanel = new HorizontalPanel();
    embeddedRsrcPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils
            .getResString("web_testing_retrieve_title"))); // $NON-NLS-1$
    embeddedRsrcPanel.add(retrieveEmbeddedResources);

    
    // Embedded URL match regex
    embeddedRE = new JLabeledTextField(JMeterUtils.getResString("web_testing_embedded_url_pattern"),20); // $NON-NLS-1$
    embeddedRsrcPanel.add(embeddedRE); 
    
    return embeddedRsrcPanel;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:17,代码来源:HTTP2RequestGui.java

示例8: init

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
private void init() {
	setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());
    
    http2RequestPanel = new HTTP2RequestPanel(true,true,true);
    
    // AdvancedPanel (embedded resources, source address and optional tasks)
    JPanel advancedPanel = new VerticalPanel();
    advancedPanel.add(createEmbeddedRsrcPanel());
    advancedPanel.add(createSourceAddrPanel());
    advancedPanel.add(createOptionalTasksPanel());

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.add(JMeterUtils
            .getResString("web_testing_basic"), http2RequestPanel);
    tabbedPane.add(JMeterUtils
            .getResString("web_testing_advanced"), advancedPanel);

    JPanel emptyPanel = new JPanel();
    emptyPanel.setMaximumSize(new Dimension());

    add(makeTitlePanel(), BorderLayout.NORTH);
    add(tabbedPane, BorderLayout.CENTER);        
    add(emptyPanel, BorderLayout.SOUTH);
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:26,代码来源:HTTP2RequestGui.java

示例9: setup

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
@Before
public void setup() throws MalformedURLException {
	TestJMeterUtils.createJmeterEnv();
	JMeterUtils.setProperty("HTTPResponse.parsers", "htmlParser");
	JMeterUtils.setProperty("htmlParser.className","org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser");
	JMeterUtils.setProperty("htmlParser.types","text/html application/xhtml+xml application/xml text/xml");
	url = new URL("http://www.tenfieldigital.com.uy");
	http2Connection = Mockito.mock(HTTP2Connection.class);
	stream = Mockito.mock(Stream.class);
	pushPromisFrame = Mockito.mock(PushPromiseFrame.class);
	headersFrame = Mockito.mock(HeadersFrame.class);
	responseMetadata = Mockito.mock(MetaData.Response.class);
	callback = Mockito.mock(Callback.class);
	dataFrame = Mockito.mock(DataFrame.class);
	
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:17,代码来源:HTTP2StreamHandlerTest.java

示例10: createHTTPClient

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
private static AbstractHttpClient createHTTPClient() {
    AbstractHttpClient client = new DefaultHttpClient();
    String proxyHost = System.getProperty("https.proxyHost", "");
    if (!proxyHost.isEmpty()) {
        int proxyPort = Integer.parseInt(System.getProperty("https.proxyPort", "-1"));
        log.info("Using proxy " + proxyHost + ":" + proxyPort);
        HttpParams params = client.getParams();
        HttpHost proxy = new HttpHost(proxyHost, proxyPort);
        params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

        String proxyUser = System.getProperty(JMeter.HTTP_PROXY_USER, JMeterUtils.getProperty(JMeter.HTTP_PROXY_USER));
        if (proxyUser != null) {
            log.info("Using authenticated proxy with username: " + proxyUser);
            String proxyPass = System.getProperty(JMeter.HTTP_PROXY_PASS, JMeterUtils.getProperty(JMeter.HTTP_PROXY_PASS));

            String localHost;
            try {
                localHost = InetAddress.getLocalHost().getCanonicalHostName();
            } catch (Throwable e) {
                log.error("Failed to get local host name, defaulting to 'localhost'", e);
                localHost = "localhost";
            }

            AuthScope authscope = new AuthScope(proxyHost, proxyPort);
            String proxyDomain = JMeterUtils.getPropDefault("http.proxyDomain", "");
            NTCredentials credentials = new NTCredentials(proxyUser, proxyPass, localHost, proxyDomain);
            client.getCredentialsProvider().setCredentials(authscope, credentials);
        }
    }
    return client;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:32,代码来源:HttpUtils.java

示例11: testFlow

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
@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());
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:17,代码来源:BlazemeterUploaderTest.java

示例12: testTestEndedWithNoStoreDir

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
@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();
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:21,代码来源:LoadosophiaUploaderTest.java

示例13: initProxyConfiguration

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
static void initProxyConfiguration() {
    proxyHost = System.getProperty("http.proxyHost",null);
    proxyPort = Integer.parseInt(System.getProperty("http.proxyPort","0"));
    List<String> nonProxyHostList = Arrays.asList(System.getProperty("http.nonProxyHosts","").split("\\|"));
    nonProxyHosts = nonProxyHostList.stream().filter(h -> !h.startsWith("*")).collect(Collectors.toList());
    nonProxyWildcards = nonProxyHostList.stream().filter(h -> h.startsWith("*")).map(w -> w.substring(1)).collect(Collectors.toList());
    proxyUsername = JMeterUtils.getPropDefault(JMeter.HTTP_PROXY_USER,null);
    proxyPassword = JMeterUtils.getPropDefault(JMeter.HTTP_PROXY_PASS,null);
}
 
开发者ID:ptrd,项目名称:jmeter-websocket-samplers,代码行数:10,代码来源:WebsocketSampler.java

示例14: checkJMeterVersion

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
private static void checkJMeterVersion() {
    try {
        String jmeterVersion = JMeterUtils.getJMeterVersion();
        Matcher m = Pattern.compile("(\\d+)\\.(\\d+).*").matcher(jmeterVersion);
        if (m.matches()) {
            int major = Integer.parseInt(m.group(1));
            int minor = Integer.parseInt(m.group(2));
            if (major < 3 || (major == 3 && minor < 1))  {
                String errorMsg = "This version of the WebSocketSamplers plugin requires JMeter 3.1 or later.";
                if (GuiPackage.getInstance() != null) {
                    SwingUtilities.invokeLater(() -> {
                        GuiPackage.showErrorMessage(errorMsg, "Incompatible versions");
                    });
                } else {
                    LoggingManager.getLoggerForClass().error(errorMsg);
                }
            }
        }
    }
    catch (Exception e) {
        // Let this method never throw an exception
    }
}
 
开发者ID:ptrd,项目名称:jmeter-websocket-samplers,代码行数:24,代码来源:WebsocketSampler.java

示例15: getResult

import org.apache.jmeter.util.JMeterUtils; //导入依赖的package包/类
/**
 * Returns the result of the Assertion. Here it checks whether the Sample
 * took to long to be considered successful. If so an AssertionResult
 * containing a FailureMessage will be returned. Otherwise the returned
 * AssertionResult will reflect the success of the Sample.
 */
@Override
public AssertionResult getResult(SampleResult response) {
    AssertionResult result = new AssertionResult(getName());
    result.setFailure(false);
    long duration=getAllowedDuration();
    if (duration > 0) {
        long responseTime=response.getTime();
    // has the Sample lasted too long?
        if ( responseTime > duration) {
            result.setFailure(true);
            Object[] arguments = { Long.valueOf(responseTime), Long.valueOf(duration) };
            String message = MessageFormat.format(
                    JMeterUtils.getResString("duration_assertion_failure") // $NON-NLS-1$
                    , arguments);
            result.setFailureMessage(message);
        }
    }
    return result;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:26,代码来源:DurationAssertion.java


注:本文中的org.apache.jmeter.util.JMeterUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。