updateTestPlan インターフェイスは、XML ファイルから既存のルート ノードに対してテストを更新します。すべての呼び出しの HTTP の応答には、変更されたテストの XML 構造が含まれます。新しいコードの識別子は、更新された XML テストの構造から取得できます。
次の表は、updateTestPlan インターフェイスのパラメータを表しています。
| インターフェイス URL | パラメータ | 説明 |
|---|---|---|
|
http://<front-end URL>/servicesExchange?hid=updateTestPlan |
sid | ユーザー認証用の Web サービス トークンまたはセッション識別子。Web サービス トークンは、Silk Central UI の 設定ページ から生成できます。このページにアクセスするには、Silk Central メニューに表示されているユーザー名にマウス カーソルを移動し、ユーザー設定 を選択します。セッション識別子は、利用可能な Web サービス のうちの logonUser メソッドを呼び出すことで取得できます。 |
例:http://<front-end URL>/servicesExchange?hid=updateTestPlan&sid=<webServiceToken>
テスト計画を検証するために使用される XML スキーマ定義ファイルは、フロントエンド サーバー URL http://<フロントエンド URL>/silkroot/xsl/testplan.xsd を使用してダウンロードするか、フロントエンド サーバーのインストール フォルダ <Silk Central インストール フォルダ>/wwwroot/silkroot/xsl/testplan.xsd からコピーできます。
以下のコードでは、Apache HttpClient を使用して、テストが更新されます。
import org.apache.commons.httpclient.*; // Apache HttpClient
String webServiceToken = "e39a0b5b-45db-42db-84b2-b85028d954d5";
String xml = loadTestPlanUtf8(DEMO_TEST_PLAN_XML);
HttpClient client = new HttpClient();
URL webServiceUrl = new URL("http", mWebServiceHelper.getHost(),
mWebServiceHelper.getPort(),
String.format("/servicesExchange?hid=%s&sid=%s",
"updateTestPlan",
webServiceToken));
StringPart testPlanXml = new StringPart(DEMO_TEST_PLAN_XML, xml,
"UTF-8");
testPlanXml.setContentType("text/xml");
Part[] parts = {testPlanXml};
PostMethod filePost = new PostMethod(webServiceUrl.toExternalForm());
filePost.setRequestEntity(new MultipartRequestEntity(parts,
filePost.getParams()));
client.getHttpConnectionManager().getParams().setConnectionTimeout(60000);
int status = client.executeMethod(filePost);
System.out.println(filePost.getStatusLine());
String responseXml = filePost.getResponseBodyAsString();
リクエスト毎に 1 つの添付ファイルのみアップロードすることができます。Apache HttpComponents をダウンロードするには、http://hc.apache.org/downloads.cgi を参照してください。必要なライブラリについては、コンポーネントのドキュメントを参照してください。
次のコードは、createTestPlan サービス、および updateTestPlan サービスを使用して Silk Central へアップロードすることができるテストの例を示しています。
<?xml version="1.0" encoding="UTF-8"?>
<TestPlan xmlns="http://www.borland.com/TestPlanSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://<front-end URL>/silkroot/xsl/testplan.xsd">
<Folder name="Folder1" id="5438">
<Description>Description of the folder</Description>
<Property name="property1">
<propertyValue>value1</propertyValue>
</Property>
<Test name="TestDef1" type="plugin.SilkTest">
<Description>Description of the test</Description>
<Property name="property2">
<propertyValue>value2</propertyValue>
</Property>
<Property name="property3">
<propertyValue>value3</propertyValue>
<propertyValue>value4</propertyValue>
</Property>
<Parameter name="param1" type="string">string1</Parameter>
<Parameter name="param2" type="boolean">true</Parameter>
<Parameter name="paramDate" type="date">01.01.2001</Parameter>
<Parameter name="paramInherited" type="string"
inherited="true">
inheritedValue1
</Parameter>
<Step id="1" name="StepA">
<ActionDescription>do it</ActionDescription>
<ExpectedResult>everything</ExpectedResult>
</Step>
<Step id="2" name="StepB">
<ActionDescription>and</ActionDescription>
<ExpectedResult>everything should come</ExpectedResult>
</Step>
</Test>
<Test name="ManualTest1" id="5441" type="_ManualTestType"
plannedTime="03:45">
<Description>Description of the manual test</Description>
<Step id="1" name="StepA">
<ActionDescription>do it</ActionDescription>
<ExpectedResult>everything</ExpectedResult>
</Step>
<Step id="2" name="StepB">
<ActionDescription>and</ActionDescription>
<ExpectedResult>everything should come</ExpectedResult>
</Step>
<Step id="3" name="StepC">
<ActionDescription>do it now"</ActionDescription>
<ExpectedResult>
everything should come as you wish
</ExpectedResult>
</Step>
</Test>
<Folder name="Folder2" id="5439">
<Description>Description of the folder</Description>
<Property name="property4">
<propertyValue>value5</propertyValue>
</Property>
<Parameter name="param3" type="number">123</Parameter>
<Folder name="Folder2_1" id="5442">
<Description>Description of the folder</Description>
<Test name="TestDef2" type="plugin.SilkPerformer">
<Description>Description of the test</Description>
<Property name="_sp_Project File">
<propertyValue>ApplicationAccess.ltp</propertyValue>
</Property>
<Property name="_sp_Workload">
<propertyValue>Workload1</propertyValue>
</Property>
</Test>
<Test name="TestDef3" type="JUnitTestType"
externalId="com.borland.MyTest">
<Description>Description of the test</Description>
<Property name="_junit_ClassFile">
<propertyValue>com.borland.MyTest</propertyValue>
</Property>
<Property name="_junit_TestMethod">
<propertyValue>testMethod</propertyValue>
</Property>
<Step id="1" name="StepA">
<ActionDescription>do it</ActionDescription>
<ExpectedResult>everything</ExpectedResult>
</Step>
<Step id="2" name="StepB">
<ActionDescription>and</ActionDescription>
<ExpectedResult>everything should come</ExpectedResult>
</Step>
</Test>
</Folder>
</Folder>
</Folder>
</TestPlan>