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


Java TestPlan类代码示例

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


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

示例1: startEngine

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
/**
 * Start JMeter engine
 * @param noTimer ignore timers 
 */
private void startEngine(boolean ignoreTimer) {
    GuiPackage gui = GuiPackage.getInstance();
    HashTree testTree = gui.getTreeModel().getTestPlan();
    JMeter.convertSubTree(testTree);
    testTree.add(testTree.getArray()[0], gui.getMainFrame());
    log.debug("test plan before cloning is running version: "
            + ((TestPlan) testTree.getArray()[0]).isRunningVersion());
    TreeCloner cloner = cloneTree(testTree, ignoreTimer);
    engine = new StandardJMeterEngine();
    engine.configure(cloner.getClonedTree());
    try {
        engine.runTest();
    } catch (JMeterEngineException e) {
        JOptionPane.showMessageDialog(gui.getMainFrame(), e.getMessage(), 
                JMeterUtils.getResString("error_occurred"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
    }
    log.debug("test plan after cloning and running test is running version: "
            + ((TestPlan) testTree.getArray()[0]).isRunningVersion());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:24,代码来源:Start.java

示例2: getProperBranch

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
/**
 * Extract from tree (included test plan) all Test Elements located in a Test Fragment
 * @param tree HashTree included Test Plan
 * @return HashTree Subset within Test Fragment or Empty HashTree
 */
private HashTree getProperBranch(HashTree tree) {
    for (Object o : new LinkedList<>(tree.list())) {
        TestElement item = (TestElement) o;

        //if we found a TestPlan, then we are on our way to the TestFragment
        if (item instanceof TestPlan)
        {
            return getProperBranch(tree.getTree(item));
        }

        if (item instanceof TestFragmentController)
        {
            return tree.getTree(item);
        }
    }
    log.warn("No Test Fragment was found in included Test Plan, returning empty HashTree");
    return new HashTree();
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:24,代码来源:IncludeController.java

示例3: marshal

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void marshal(Object arg0, HierarchicalStreamWriter writer, MarshallingContext context) {
    TestElement el = (TestElement) arg0;
    ConversionHelp.saveSpecialProperties(el,writer);
    PropertyIterator iter = el.propertyIterator();
    while (iter.hasNext()) {
        JMeterProperty jmp=iter.next();
        // Skip special properties if required
        if (!ConversionHelp.isSpecialProperty(jmp.getName())) {
            // Don't save empty comments - except for the TestPlan (to maintain compatibility)
               if (!(
                       TestElement.COMMENTS.equals(jmp.getName())
                       && jmp.getStringValue().length()==0
                       && !el.getClass().equals(TestPlan.class)
                   ))
               {
                writeItem(jmp, context, writer);
               }
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:23,代码来源:TestElementConverter.java

示例4: getTestPlan

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
public TestPlan getTestPlan() {
    TestPlan testPlan = new TestPlan();

    testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
    testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());
    testPlan.setProperty(TestElement.ENABLED, true);
    testPlan.setFunctionalMode(false);
    testPlan.setSerialized(true);
    Arguments arguments = new Arguments();
    arguments.setProperty(TestElement.GUI_CLASS, "org.apache.jmeter.protocol.http.gui.HTTPArgumentsPanel");
    arguments.setProperty(TestElement.TEST_CLASS, "org.apache.jmeter.config.Arguments");
    arguments.setName("User Defined Variables");
    arguments.setProperty(TestElement.ENABLED, true);
    testPlan.setUserDefinedVariables(arguments);
    testPlan.setTestPlanClasspath("");
    return testPlan;
}
 
开发者ID:lithiumtech,项目名称:mineraloil-jmeter,代码行数:18,代码来源:JMeterRunner.java

示例5: canAddTo

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
/**
 * Determine whether or not dragged nodes can be added to this parent. Also
 * used by Paste TODO tighten rules TODO move to MenuFactory?
 *
 * @param parentNode
 * @return whether it is OK to add the dragged nodes to this parent
 */
static boolean canAddTo(ReportTreeNode parentNode) {
    if (null == parentNode) {
        return false;
    }
    TestElement te = parentNode.getTestElement();
    // System.out.println("Add to: "+te.getClass().getName());
    if (te instanceof Controller) {
        return true;
    }
    if (te instanceof Sampler) {
        return true;
    }
    if (te instanceof WorkBench) {
        return true;
    }
    if (te instanceof TestPlan) {
        return true;
    }
    return false;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:28,代码来源:ReportDragNDrop.java

示例6: configure

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
/**
 * A newly created component can be initialized with the contents of a Test
 * Element object by calling this method. The component is responsible for
 * querying the Test Element object for the relevant information to display
 * in its GUI.
 *
 * @param el
 *            the TestElement to configure
 */
@Override
public void configure(TestElement el) {
    super.configure(el);
    if (el instanceof TestPlan) {
        TestPlan tp = (TestPlan) el;
    functionalMode.setSelected(tp.isFunctionalMode());
    serializedMode.setSelected(tp.isSerialized());
    tearDownOnShutdown.setSelected(tp.isTearDownOnShutdown());
    final JMeterProperty udv = tp.getUserDefinedVariablesAsProperty();
    if (udv != null) {
        argsPanel.configure((Arguments) udv.getObjectValue());
    }
    browseJar.setFiles(tp.getTestPlanClasspathArray());
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:25,代码来源:TestPlanGui.java

示例7: marshal

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void marshal(Object arg0, HierarchicalStreamWriter writer, MarshallingContext context) {
    TestElement el = (TestElement) arg0;
    if (SaveService.IS_TESTPLAN_FORMAT_22){
        ConversionHelp.saveSpecialProperties(el,writer);
    }
    PropertyIterator iter = el.propertyIterator();
    while (iter.hasNext()) {
        JMeterProperty jmp=iter.next();
        // Skip special properties if required
        if (!SaveService.IS_TESTPLAN_FORMAT_22 || !ConversionHelp.isSpecialProperty(jmp.getName())) {
            // Don't save empty comments - except for the TestPlan (to maintain compatibility)
               if (!(
                       TestElement.COMMENTS.equals(jmp.getName())
                       && jmp.getStringValue().length()==0
                       && !el.getClass().equals(TestPlan.class)
                   ))
               {
                writeItem(jmp, context, writer);
               }
        }
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:25,代码来源:TestElementConverter.java

示例8: addSubTree

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
/**
 * Adds the sub tree at the given node. Returns a boolean indicating whether
 * the added sub tree was a full test plan.
 */
public HashTree addSubTree(HashTree subTree, JMeterTreeNode current) throws IllegalUserActionException {
    Iterator<Object> iter = subTree.list().iterator();
    while (iter.hasNext()) {
        TestElement item = (TestElement) iter.next();
        if (item instanceof TestPlan) {
            TestPlan tp = (TestPlan) item;
            current = (JMeterTreeNode) ((JMeterTreeNode) getRoot()).getChildAt(0);
            final TestPlan userObject = (TestPlan) current.getUserObject();
            userObject.addTestElement(item);
            userObject.setName(item.getName());
            userObject.setFunctionalMode(tp.isFunctionalMode());
            userObject.setSerialized(tp.isSerialized());
            addSubTree(subTree.getTree(item), current);
        } else if (item instanceof WorkBench) {
            current = (JMeterTreeNode) ((JMeterTreeNode) getRoot()).getChildAt(1);
            final TestElement testElement = ((TestElement) current.getUserObject());
            testElement.addTestElement(item);
            testElement.setName(item.getName());
            addSubTree(subTree.getTree(item), current);
        } else {
            addSubTree(subTree.getTree(item), addComponent(item, current));
        }
    }
    return getCurrentSubTree(current);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:30,代码来源:JMeterTreeModel.java

示例9: getProperBranch

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
/**
 * Extract from tree (included test plan) all Test Elements located in a Test Fragment
 * @param tree HashTree included Test Plan
 * @return HashTree Subset within Test Fragment or Empty HashTree
 */
private HashTree getProperBranch(HashTree tree) {
    Iterator<Object> iter = new LinkedList<Object>(tree.list()).iterator();
    while (iter.hasNext()) {
        TestElement item = (TestElement) iter.next();

        //if we found a TestPlan, then we are on our way to the TestFragment
        if (item instanceof TestPlan)
        {
            return getProperBranch(tree.getTree(item));
        }

        if (item instanceof TestFragmentController)
        {
            return tree.getTree(item);
        }
    }
    log.warn("No Test Fragment was found in included Test Plan, returning empty HashTree");
    return new HashTree();
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:25,代码来源:IncludeController.java

示例10: testReverseReplacement

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
public void testReverseReplacement() throws Exception {
    ValueReplacer replacer = new ValueReplacer(variables);
    assertTrue(variables.getUserDefinedVariables().containsKey("server"));
    assertTrue(replacer.containsKey("server"));
    TestElement element = new TestPlan();
    element.setProperty(new StringProperty("domain", "jakarta.apache.org"));
    List<Object> argsin = new ArrayList<Object>();
    argsin.add("username is jack");
    argsin.add("his_password");
    element.setProperty(new CollectionProperty("args", argsin));
    replacer.reverseReplace(element);
    assertEquals("${server}", element.getPropertyAsString("domain"));
    @SuppressWarnings("unchecked")
    List<JMeterProperty> args = (List<JMeterProperty>) element.getProperty("args").getObjectValue();
    assertEquals("username is ${username}", args.get(0).getStringValue());
    assertEquals("${password}", args.get(1).getStringValue());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:18,代码来源:TestValueReplacer.java

示例11: executePlan

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
private Map<String, String> executePlan(int numLoops, int numThreads, int rampUp) throws IOException {
	HashTree testPlanTree = new HashTree();
	HTTPSamplerProxy httpSampler = makeSampler();

	LoopController loopController = new LoopController();
	loopController.setLoops(numLoops);
	loopController.addTestElement(httpSampler);
	loopController.setFirst(true);
	loopController.initialize();

	ThreadGroup threadGroup = new ThreadGroup();
	threadGroup.setNumThreads(numThreads);
	threadGroup.setRampUp(rampUp);
	threadGroup.setSamplerController(loopController);

	TestPlan testPlan = new TestPlan("JMeter regression test");
	HashTree tpConfig = testPlanTree.add(testPlan);
	HashTree tgConfig = tpConfig.add(threadGroup);
	tgConfig.add(httpSampler);

	Summariser summer = new Summariser("summary");
	ResultCollector logger = new ResultCollector(summer);
	tgConfig.add(logger);

	jmeter.configure(testPlanTree);
	jmeter.run();

	return extractTotals(summer);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:30,代码来源:ConverterLoadTest.java

示例12: main

import org.apache.jmeter.testelement.TestPlan; //导入依赖的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();
    }
 
开发者ID:cbooy,项目名称:cakes,代码行数:51,代码来源:Demo1.java

示例13: mousePressed

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
    int selRow = tree.getRowForLocation(e.getX(), e.getY());

    if (tree.getPathForLocation(e.getX(), e.getY()) != null) {
        final TreePath currentPath = tree.getPathForLocation(e.getX(), e.getY());

        if (selRow != -1 && currentPath != null) {
            if (isRightClick(e)) {
                if (tree.getSelectionCount() < 2) {
                    tree.setSelectionPath(currentPath);
                }
                final JMeterTreeNode node = (JMeterTreeNode) currentPath.getLastPathComponent();
                TestElement te = (TestElement) node.getUserObject();
                if (te instanceof ConfigElement || te instanceof TestPlan || te instanceof ThreadGroup || te instanceof WorkBench) {
                    log.debug("No breakpoint possible for " + te);
                    return;
                }
                JPopupMenu popup = getPopup(te);
                popup.pack();
                popup.show(tree, e.getX(), e.getY());
                popup.setVisible(true);
                popup.requestFocusInWindow();
            }
        }
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:28,代码来源:DebuggerDialogBase.java

示例14: configure

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
@Override
public void configure(HashTree testTree) {
    // Is testplan serialised?
    SearchByClass<TestPlan> testPlan = new SearchByClass<>(TestPlan.class);
    testTree.traverse(testPlan);
    Object[] plan = testPlan.getSearchResults().toArray();
    if (plan.length == 0) {
        throw new RuntimeException("Could not find the TestPlan class!");
    }
    TestPlan tp = (TestPlan) plan[0];
    serialized = tp.isSerialized();
    tearDownOnShutdown = tp.isTearDownOnShutdown();
    active = true;
    test = testTree;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:16,代码来源:StandardJMeterEngine.java

示例15: addNode

import org.apache.jmeter.testelement.TestPlan; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void addNode(Object node, HashTree subTree) {
    if (node instanceof TestElement && !(node instanceof TestPlan)) {
        ((TestElement) node).setRunningVersion(true);
    }

}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:11,代码来源:TurnElementsOn.java


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