淘宝商城(天猫)高级技术专家.3年研发+3年性能测试调优/系统测试+4年团队管理与测试架构、研发系统实践. 新舞台新气象, 深化测试基础架构及研发架构,希望能在某个技术领域成为真正的技术大牛。欢迎荐才http://bbs.51testing.com/viewthread.php?tid=120496&extra=&page=1 .邮件: jianzhao.liangjz@alibaba-inc.com,MSN:liangjianzhao@163.com.微博:http://t.sina.com.cn/1674816524

Jmeter图形化框架

上一篇 / 下一篇  2008-08-10 14:54:48 / 个人分类:loadrunner性能测试经验

最近在看Jmeter源代码,顺便温习JAVA SwingAPI

 

为了看得更清楚Jmeter图形化处理,偶尽量剥离Jmeter相关的API,使用SUN JAVA API

 

更多请参考经典的JAVA书籍:《Java 2核心技术》。偶的JAVA知识从这2本书开始J

 

最核心的技术点:

Ø        JframeJPanel等容器

Ø        ActionListener事件处理

Ø        ImageIcon图片展现

Ø        反射,如commandClass.newInstance

 

 

packageorg.apache.jmeter;

importjava.awt.BorderLayout;

importjava.awt.Color;

importjava.awt.Component;

importjava.awt.Container;

importjava.awt.Dimension;

importjava.awt.GridLayout;

importjava.awt.HeadlessException;

importjava.awt.Point;

importjava.awt.event.ActionEvent;

importjava.awt.event.ActionListener;

importjava.awt.event.KeyEvent;

importjava.awt.event.MouseAdapter;

importjava.awt.event.MouseEvent;

importjava.lang.reflect.Modifier;

importjava.util.HashMap;

importjava.util.HashSet;

importjava.util.Iterator;

importjava.util.List;

importjava.util.Map;

importjava.util.Set;

 

importjavax.swing.BorderFactory;

importjavax.swing.Box;

importjavax.swing.BoxLayout;

importjavax.swing.ImageIcon;

importjavax.swing.JButton;

importjavax.swing.JComponent;

importjavax.swing.JDialog;

importjavax.swing.JFrame;

importjavax.swing.JLabel;

importjavax.swing.JMenu;

importjavax.swing.JMenuBar;

importjavax.swing.JMenuItem;

importjavax.swing.JOptionPane;

importjavax.swing.JPanel;

importjavax.swing.JScrollPane;

importjavax.swing.JSplitPane;

importjavax.swing.JMenu;

importjavax.swing.JMenuBar;

importjavax.swing.KeyStroke;

importjavax.swing.SwingUtilities;

importjavax.swing.border.EmptyBorder;

 

importorg.apache.jmeter.gui.action.Command;

 

//为了事件处理,实现ActionListener

publicclassJFrameTestextendsJFrame implementsActionListener {

   privateMapcommands=newHashMap();

   privateMappreActionListeners=newHashMap();

   privateMappostActionListeners=newHashMap();

   JDialogabout=null;

   

   //actionPerformed事件处理入口

   publicvoidactionPerformed(finalActionEvent e) {

      SwingUtilities.invokeLater(newRunnable() {

          publicvoidrun() {

             performAction(e);

          }

 

      });

   }  

   //加入命令映射器

   //核心代码就是反射技术

   privatevoidpopulateCommandMap() {

      List listClasses;

      Command command;

      Iterator iterClasses;

      Class commandClass;

      try

      {

      commands=newHashMap(1);

      commandClass = Class.forName("org.apache.jmeter.gui.action.AboutCommand");

       if(!Modifier.isAbstract(commandClass.getModifiers())) {

           command = (Command) commandClass.newInstance();

           Iterator iter = command.getActionNames().iterator();

           while(iter.hasNext()) {

               String commandName = (String) iter.next();

               Set commandObjects = (Set)commands.get(commandName);

               if(commandObjects ==null) {

                   commandObjects =newHashSet();

                   commands.put(commandName, commandObjects);

               }

               commandObjects.add(command);

           }

       }

      }catch(Exception e)

      {

          e.printStackTrace();

      }

      

   }

   /**

    *AllowsanActionListenertoreceivenotificationofacommandbeing

    *executedpriortotheactualexecutionofthecommand.

    *

   

TAG: jmeter swing awt 反射 图片

liming_oicq的个人空间 引用 删除 liming_oicq   /   2008-08-15 10:34:34
多谢!!
阿里巴巴一个测试架构师 引用 删除 liangjz   /   2008-08-14 18:01:09
http://jakarta.apache.org/jmeter 可以下载
liming_oicq的个人空间 引用 删除 liming_oicq   /   2008-08-14 09:10:48
如何获得Jmeter源代码呢?
 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar