0

Rational Functional Testerスクリプトは、どのバージョンのRFTで実行/構築されたかをどのように把握できますか?

私はドキュメントを掘り下げました、そして私が見つけた最も近いものは

com.rational.test.ft.script.ScriptUtilities.getOperatingSystemVersion() 

これはOSのバージョン情報を返します。これは近いかもしれませんが、それでもDaddyが探しているものではありません; O

4

2 に答える 2

1

APIまたはWindowsレジストリに何も見つかりませんでした。

私が考えることができる唯一の方法は、カスタムメソッドを作成し、それをヘルパークラスに含めることです。あなたはファイルでバージョンを見つけることができます、C:\IBM\SDP\FunctionalTester\properties\version\IBM_Rational_Functional_Tester.*.*.swtagあなたのインストールに一致するようにパスを変更してください。

import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

private final static String RFTVersionFolder = "C:\\IBM\\SDP\\FunctionalTester\\properties\\version";

public static String getRFTVersionWithXML() {
        File versionFolder = new File(RFTVersionFolder);
        File[] versionFile = versionFolder.listFiles( new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return (name.endsWith(".swtag"));
                } } );

        Document versionDocument = null;
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

        try {
            DocumentBuilder builder = factory.newDocumentBuilder();
            versionDocument = builder.parse(new FileInputStream(versionFile[0]));
        } catch (SAXParseException spe) {
            spe.printStackTrace();
        } catch (SAXException sxe) {
            sxe.printStackTrace();
        } catch (ParserConfigurationException pce) {
            pce.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }

        Node versionNode = versionDocument.getElementsByTagName("ProductVersion").item(0);

        return versionNode.getTextContent();
    }

これは、XML解析用のDocumentBuilderを実証するため、非常にコストのかかる方法です。別の方法として、ファイルの内容を文字列としてロードし、RegExpで解析し、次の一致パターンを使用します:[0-9]\。[0-9]\。[0-9]

public static String getRFTVersionWithRegexp() {
    File versionFolder = new File(RFTVersionFolder);
    File[] versionFile = versionFolder.listFiles( new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return (name.endsWith(".swtag"));
        } } );

    byte[] buffer = null;
    FileInputStream fin;
    try {
        fin = new FileInputStream(versionFile[0]);
        buffer = new byte[(int) versionFile[0].length()];
        new DataInputStream(fin).readFully(buffer);
        fin.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    } 
    String versionFileContent = new String(buffer);
    String version = null;
    Regex r = new Regex("[0-9]\\.[0-9]\\.[0-9]", Regex.MATCH_NORMAL);
    if (r.matches(versionFileContent))
        version = r.getMatch();

    return version;
}
于 2012-09-03T10:22:41.093 に答える
1

1) [ヘルプ] > [ RFTについて]に移動すると、バージョンが表示されます。

于 2014-02-20T21:48:50.767 に答える