Eclipse的TPTP工具使用方法

发表于:2007-11-19来源:作者:点击数: 标签:eclipsetptp
Eclipse的TPTP工具使用方法: 1.TPTP是什么: TPTP是Eclipse的一个顶级工程(Top-Level Project),TPTP项目封装了一大堆公共的操作接口与数据,甚至一个远程执行环境,以供其它的TPTP工具使用。另外,它还提供了扩展点以方便进行定制编码。实际上就是一个依托于
Eclipse的TPTP工具使用方法:
1.        TPTP是什么:
TPTP是Eclipse的一个顶级工程(Top-Level Project),TPTP项目封装了一大堆公共的操作接口与数据,甚至一个远程执行环境,以供其它的TPTP工具使用。另外,它还提供了扩展点以方便进行定制编码。实际上就是一个依托于Eclipse的JAVA的Profile与分析工具,还提供了整合SWT GUI的Record与Replay功能(另外的文章中进行介绍)。

2.下载要安装的各种plugin。

以TPTP4.1为例
   a.解决安装信赖条件:
     Eclipse SDK 3.1.0
     JDK 1.4
     EMF SDK 2.1.0
     XSD 2.1.0

    b.Agent Controller安装
      下载
       将下载完的安装包解压到想安装的目录。
       将<unzip directory>\bin加到系统PATH环境变量中,不能有双引号。
      执行<unzip directory>\bin下的SetConfig.bat生成基本配置环境。
      执行RAServer.exe,运行守护进程。

  c.安装TPTP,此处选择手动安装。
     下载TPTP4.1
      解压到eclipse\plugins下。

完成安装。


测试。
新建一个工程(Java Project)
将下列类导入到工程中:

package com.yadong.testtptp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class CarModel {

    /* Required car parts: 1 Engine, 4 wheels, and 2 doors */
    public Engine engine = new Engine();
    public Wheel[] wheel = new Wheel[4];          
    public Door left = new Door(), right = new Door();



    public CarModel()
    {
      for(int i = 0; i  < 4; i++)
        wheel[i] = new Wheel();
    }
        
        
        
    /* Launcher */
    public static void main(String[] args) throws IOException
    {
        final String LINE_SEPARATOR =
        System.getProperty("line.separator");
        final int BORDER_CHAR_LENGTH = 40;
        final int UNREF_OBJ_CREATED = 10;
        StringBuffer menu = new StringBuffer();
        CarModel car = new CarModel();
                
        /* Create the menu */
        for (int i = 0;i < BORDER_CHAR_LENGTH; i++)
          menu.append('-');
        menu.append (LINE_SEPARATOR).append("   (1) Simulate car usage");
        menu.append (LINE_SEPARATOR).append("   (2) Create unreferenced objects");
        menu.append (LINE_SEPARATOR).append("   (q) Quit");
        menu.append (LINE_SEPARATOR);
        for (int i = 0;i < BORDER_CHAR_LENGTH; i++)
          menu.append('-');
                
        /* Display the menu */
        System.out.println ("CarModel started" + LINE_SEPARATOR + "Menu:");
        System.out.println (menu.toString());
        System.out.println ("Choose an option:");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String input = in.readLine().trim();

                
        /* Aclearcase/" target="_blank" >ccept input for the desired option */
        while (!input.equalsIgnoreCase("q"))
        {                        
          /* Check for invalid entry */
          if (input == null || input.length() != 1 || !Character.isDigit(input.charAt(0)))
          {
            System.err.println ("Wrong option");
            input = in.readLine().trim();
            continue;
          }
                                                
          switch(Integer.valueOf(input).intValue())
          {
            case 1:
              simulateCarUsage(car);
              break;
            case 2:
              for (int i = 0; i < UNREF_OBJ_CREATED; i++)
                new CarModel();
              System.out.println (UNREF_OBJ_CREATED + " unreferenced objects of CarModel has been created");
              break;
            default:
              System.err.println ("Wrong option");                                
          }
        input = in.readLine().trim();
      }
                                
    }

        
    /* Simulates car usage */
    public static void simulateCarUsage(CarModel car)
    {
      car.left.window.rollup();
      car.engine.start();
      car.engine.rev();
      car.wheel[0].align();
      car.engine.stop();
    }
}


/* Inner classes used to model car parts */
class Engine
{        
    public void start()
      { System.out.println("Start the car.");}
    public void rev()  
      {System.out.println("Rev the engine.");}
    public void stop()  
      {System.out.println("Car stopped.");}
}

class Wheel
{        
    public void align()
      {System.out.println("Tires aligned.");}
}

class Window
{        
    public void rollup()
      {System.out.println("Rollup the window.");}
    public void rolldown()
      {System.out.println("Rolldown the window.");}
}

class Door
{
    public Window window = new Window();
    public void open()
          {System.out.println("Open()");}
    public void close()
      {System.out.println("Close()");}
}


右键点击CarModel.java,这时会在弹出菜单中显示出Profile As ->Java Application
运行.
同时切换视图到”Profiling and logging”,这样就可以得到正在运行中程序的Profile
在这个视图中如果设置得当的话可以查看到如下结果:

1.        Coverage
2.        Execution flow
3.        Memory
4.        Object Reference
5.        UML2 object/class/Thread Interaction


下载地址:
  Eclipse SDK 3.1.0(Win32):   www.eclipse.com/downloads/index.php
JDK 1.4(Win32):    java.sun.com
EMF SDK 2.1.0(Win32): www.eclipse.com/downloads/index.php
XSD 2.1.0(Win32):http://download.eclipse.org/tools/emf/downloads/drops/2.1.0/R200507070200/xsd-SDK-2.1.0.zip:TPTP(Win32)
http://download.eclipse.org/tptp/4.1.0/TPTP-4.1.0-200511150100/tptp.runtime-TPTP-4.1.0-200511150100.zip
Agent Controller(Win32):http://download.eclipse.org/tptp/4.1.0/TPTP-4.1.0-200511150100/tptpdc.win_ia32-TPTP-4.1.0-200511150100.zip
 

原文转自:http://www.ltesting.net