A Oracle Test Manager API

This appendix provides a basic reference for the methods in the Oracle Test Manager Application Programming Interface (API).

A.1 Introduction

The Oracle Test Manager Application Programming Interface provides two methods for accessing Oracle Test Manager programmatically:

  • through a Java API that is built on top of the web service

  • directly through a web service

The Java API resides in the otm_external_api.jar and exposes the necessary classes for interacting with Oracle Test Manager through the oracle.oats.otm.external.api package.

The otm_external_api.jar is installed to the <installDir>\openScript\otm folder.

This guide provides basic instructions for using the Java API and the web service. See also the Oracle Test Manager API Javadoc reference pages installed in

<installDir>/openScript/otm/docs/api/index.html

for additional information and examples.

A.2 Sample Oracle Test Manager API Usage

This section provides basic examples of using the Oracle Test Manager API to work with Oracle Test Manager Assets.

A.2.1 Using the Oracle Test Manager API with OpenScript

The otm_external_api.jar can be used with any Java development environment. The examples in this Appendix show how to use otm_external_api.jar in the OpenScript application of the Oracle Application Testing Suite.

  1. Copy the otm_external_api.jar file from the <installDir>\openScript\otm folder to your OpenScript repository directory (the default is C:\OracleATS\OFT).

  2. Start OpenScript.

  3. Select New from the File menu.

  4. Expand the General folder and select Java Code Script.

  5. Click Next.

  6. Specify a name for the script and click Finish.

  7. Click the Assets tab in the Script view.

  8. Select JAR Files and click Add.

  9. Navigate the repository and select the otm_external_api.jar file and click OK.

  10. Select the Java Code tab in the Script View.

  11. Expand the import section at the top of the script and add:

    import oracle.oats.otm.external.api.*;
    
  12. Add your OTM API code to the Run section of the script in the Java Code view.

A.2.2 Connecting to Oracle Test Manager and Getting the Project

To connect to Oracle Test Manager using the API, create an instance of TestManager and call the authenticate(username, password, project, dataSource) method. For example:

import oracle.oats.otm.external.api.*;
//[...]
String url="http://localhost:8088";

String dataSource="OATS_otm_DS";
String projectName="Empty Project";
String username="administrator";
String password="password"; //OTM login password

TestManager otm = new TestManager(url);
otm.authenticate(username, password, projectName, dataSource);

After user authentication, get the project, as follows:

Project proj = otm.getProject();
String prjName = proj.getName();

A.2.3 Getting Asset Managers

Use the Asset Managers to obtain an asset in order to do any actions. Use the get[AssetName]Manager() methods to get the managers:

IssueManager issueMgr = proj.getIssueManager();
RequirementManager reqMgr = proj.getRequirementManager();
TestCaseManager tcMgr = proj.getTestCaseManager();
TestManager tstMgr = proj.getTestManager();
TestPlanManager tpMgr = proj.getTestPlanManager();
TestRunManager trMgr = proj.getTestRunManager();
TestSetManager tsMgr = proj.getTestSetManager();

A.2.4 Setting the Asset Path

The Oracle Test Manager API refers to Test Plans, Requirements, Test Cases, Test Sets, and Issues as "Assets". The Asset path specifies the type of Asset to work with and the path in the Asset tree. The Asset type and path is set using the resolve method of the Test Manager. The following examples show how to use the resolve method to set asset paths.

TestManager otm = new TestManager(url);

Test Plans (levels root through n):

TestPlan tpRoot = (TestPlan)otm.resolve("Test Plans/" );
TestPlan tpL2 = (TestPlan)otm.resolve("Test Plans/" + tpRoot);
TestPlan tpL3 = (TestPlan)otm.resolve("Test Plans/" + tpRoot + "/" + tpL2);

Requirements (levels root through n):

Requirement reqRoot = (Requirement)otm.resolve("Requirements/");
Requirement rqL2 = (Requirement)otm.resolve("Requirements/" + reqRoot);
Requirement rqL3 = (Requirement)otm.resolve("Requirements/" + reqRoot + "/" + rqL2);

Test Cases (levels root through n):

TestCase tcRoot = (TestCase)otm.resolve("Test Cases/");
TestCase tsL2 = (TestCase)otm.resolve("Test Cases/" + tcRoot);
TestCase tsL3 = (TestCase)otm.resolve("Test Cases/" + tcRoot + "/" + tsL2);

Test Sets (levels root through n):

TestSet tsRoot = (TestSet)otm.resolve("Test Sets/");
TestSet tsL2 = (TestSet)otm.resolve("Test Sets/" + tsRoot);
TestSet tsL3 = (TestSet)otm.resolve("Test Sets/" + tsRoot+ "/" + tsL2);

Issues (only 1 level):

Issue isRoot = (Issue)otm.resolve("Issues/")

A.2.5 Working with Assets

Assets are a core concept of the OTM API. All manipulation of data happens through assets. Every asset derives from the Asset class. Each asset has some common methods:

Method Description
associate(asset) Associates this asset with another asset (for example associating an issue with a requirement).
attach(file) Attaches a file to this asset.
delete() Deletes this asset.
getAttachments() Returns a list of attachments associated with this asset.
getChildNodes() If the asset supports child assets, returns the children of the asset.
getChildNodes(queryFilter, sortFilter) If the asset supports child assets, returns the children of the asset that match the queryFilter and then sorts the results according to sortFilter. See FilterCriteria for description of queryFilter and sortFilter format).
getField(field) Gets the specified data field.
getFields() Gets all fields associated with the asset.
getId() Gets the unique OTM ID associated with the asset.
getLabel() Gets the name of the asset.
getProject() Gets the project that the asset is in.
save() Persists any modifications to this asset in OTM (usually called after modifying fields).

In order to limit the amount of data being transferred, most of the methods that return collections of objects will return iterators that you will need to use to visit the collections. For example:

AssetIterator<Issue> issues = issueMgr.getIssues();
while (issues.hasNext()) {
    Issue issue = issues.next();
    info("issue name: " + issue.getId() + " " + issue.getLabel());
}

For multi-level assets (Test Plans, Requirements, Test Cases, and Test Sets, you can use the getChildNodes() method to retrieve the children of the specified level then iterate through the child nodes. For example:

//Get All Test Plan Names as Assets
//Set the Root level
TestPlan testPlanFolder = (TestPlan)otm.resolve("Test Plans/" );

//Iterate Through Test Plan Tree and Get Test Plan Names
AssetIterator<Asset> L1iterator = testPlanFolder.getChildNodes();
while (L1iterator.hasNext()) {
  //Get Root Level Test Plan Names/Labels
  Asset L1asset = L1iterator.next();
  info("L1 TP Asset: " + L1asset.getId() + " " + L1asset.getLabel());

    //Get Second Level Test Plan Names/Labels
    AssetIterator<Asset> L2iterator = L1asset.getChildNodes();
    while (L2iterator.hasNext()) {
      Asset L2asset = L2iterator.next();
      info("L2 TP Asset Child: " + L2asset.getId() + " " + L2asset.getLabel());

       //Get Third Level Test Plan Names/Labels
       AssetIterator<Asset> L3iterator = L2asset.getChildNodes();
       while (L3iterator.hasNext()) {
         Asset L3asset = L3iterator.next();
         info("L3 TP Asset Grandchild: " + L3asset.getId() + " " + 
            L3asset.getLabel());
       }
    }
}

A.2.6 Working with Fields

Fields correspond to OTM DataField object metadata that can be associated with an asset. Usually these are things like Priority, Severity, Description, and Platform fields that are visible through the UI. You can get the value of a field by calling getValue() or set its value by calling setValue(value). You must persist the field through a call to save(). When creating or working with Asset fields, you specify the data to include in the fields using the List<DataFieldObject> object. See the example below of changing the platform field on a newly created issue:

String name = "Issue " + System.currentTimeMillis();
List<DataFieldObject> fields = new ArrayList<DataFieldObject>();
fields.add(new DataFieldObject("Priority", "Low"));
fields.add(new DataFieldObject("Summary", name));
fields.add(new DataFieldObject("Component", "Application"));
fields.add(new DataFieldObject("AssignedTo", "Administrator User"));
fields.add(new DataFieldObject("Status", "1 - Created"));
fields.add(new DataFieldObject("Severity", "Low"));
Issue issue1 = issueMgr.newIssue(name, fields);

You can use a ListIterator<Field> to get the field names for each asset type. The following example shows how to get the field names for issues:

List<Field> issuefields = issue1.getFields();
ListIterator<Field> issuefielditerator1 = issuefields.listIterator();
while (issuefielditerator1.hasNext()){
  Field fieldname = issuefielditerator1.next();
  info("Issue Field Name "  + fieldname.getName());
}

A.2.6.1 Test Plan Fields

The Test Plan fields and valid values are as follows:

Table A-1 Test Plan Field Names and Valid Values

Field Name Valid Values

Owner

Administrator User

Default User

Any valid user name as defined in the Oracle Test Manager Administrator.

Priority

N/A

Low

Medium

High

Any valid priority as defined in the Priority option list of the Oracle Test Manager Add Test Plan dialog box. (Priority options are defined in the Priority field Option List in the Oracle Test Manager Administrator Fields tab).

Description

Any text string.


The following sample Java code provides an example:

//Add New Test Plan to the Root of the Test Plan Tree
//Specify the Asset Path of the Test Plan as the Root Level
TestPlan L1testPlanFolder = (TestPlan)otm.resolve("Test Plans/" );

//Define the Test Plan Name
String L1name = "L1 New Test Plan";

//Create the List<DataFieldObject> and add Fields
List<DataFieldObject> L1fields = new ArrayList<DataFieldObject>();
 L1fields.add(new DataFieldObject("Owner", "Administrator User"));
 L1fields.add(new DataFieldObject("Priority", "Low"));
 L1fields.add(new DataFieldObject("Description", "Level 1 Test Plan Desc"));

//Use the Test Plan Manager to create the New Test Plan 
tpMgr.newTestPlan(L1testPlanFolder, L1name, L1fields);

//--or- create the New Test Plan with a URL attachment
tpMgr.newTestPlan(L1testPlanFolder, L1name, L1fields)
 .attachUrl("L1 Test URL", "http://example.com/");

//--or-- create the New Test Plan with a file attachment
File L1file = new File("C:\\files\\example.txt");
tpMgr.newTestPlan(L1testPlanFolder, L1name, L1fields)
 .attach(L1file);

A.2.6.2 Requirements Fields

The Requirements fields and valid values are as follows:

Table A-2 Requirements Field Names and Valid Values

Field Name Valid Values

Owner

Administrator User

Default User

Any valid user name as defined in the Oracle Test Manager Administrator.

Priority

N/A

Low

Medium

High

Any valid priority as defined in the Priority option list of the Oracle Test Manager Add Requirement dialog box. (Priority options are defined in the Priority field Option List in the Oracle Test Manager Administrator Fields tab).

Type

Business Requirement

Functional Requirement

Performance Requirement

Test Requirement

Any valid type as defined in the Type option list of the Oracle Test Manager Add Requirement dialog box. (Type options are defined in the Type field Option List in the Oracle Test Manager Administrator Fields tab).

Status

1 - Proposed

2 - Approved

3 - Rejected

4 - Implemented

5 - Verified

Any valid status as defined in the Status option list of the Oracle Test Manager Add Requirement dialog box. (Status options are defined in the Status field Option List in the Oracle Test Manager Administrator Fields tab).

Description

Any text string.


The following sample Java code provides an example:

//Define New Requirement
//Specify the Asset Path of the Requirement as the Root Level
Requirement reqRoot = (Requirement)otm.resolve("Requirements/");

//Define the Requirement Name
String reqName = "L1 Requirement Name";

//Create the List<DataFieldObject> and add Fields
List<DataFieldObject> reqL1fields = new ArrayList<DataFieldObject>();
 reqL1fields.add(new DataFieldObject("Owner", "Administrator User"));
 reqL1fields.add(new DataFieldObject("Priority", "Low"));
 reqL1fields.add(new DataFieldObject("Type", "Performance Requirement"));
 reqL1fields.add(new DataFieldObject("Status", "2 - Approved"));
 reqL1fields.add(new DataFieldObject("Description", "Requirement Description"));

//Use the Requirement Manager to create the Requirement 
reqMgr.newRequirement(reqRoot, reqName, reqL1fields);

//--or- create the new Requirement as a variable that can be associated with
// another Asset, such as a Test Plan
Requirement req = reqMgr.newRequirement(reqRoot, reqName, reqL1fields);
TestPlan p1 = tpMgr.newTestPlan(L1testPlanFolder, L1name, L1fields);
p1.associate(req);

A.2.6.3 Test Case Fields

The Test Case fields and valid values are as follows:

Table A-3 Test Case Field Names and Valid Values

Field Name Valid Values

Owner

Administrator User

Default User

Any valid user name as defined in the Oracle Test Manager Administrator.

FunctionalityTested

Any text string.

Priority

Low

Medium

High

Any valid priority as defined in the Priority option list of the Oracle Test Manager Add Test dialog box. (Priority options are defined in the Priority field Option List in the Oracle Test Manager Administrator Fields tab).

Description

Any text string.


The following sample Java code provides an example:

//Define New Test Case
//Specify the Asset Path of the Test Case as the Root Level
TestCase tcRoot = (TestCase)otm.resolve("Test Cases/");

//Define the Test Case Name
String tcName = "Test Case Name";

//Create the List<DataFieldObject> and add Fields
List<DataFieldObject> tcL1fields = new ArrayList<DataFieldObject>();
tcL1fields.add(new DataFieldObject("Owner", "Administrator User"));
tcL1fields.add(new DataFieldObject("FunctionalityTested", "Demo Test Case"));
tcL1fields.add(new DataFieldObject("Priority", "Low"));
tcL1fields.add(new DataFieldObject("Description", "Test Case Description"));

//Use the Test Case Manager to create a Manual Test Case
tcMgr.newManualTestCase(tcRoot, tcName, tcL1fields);

//--or- create the new Test Case as a variable that can be associated with
// another Asset, such as a Requirement
TestCase testCase = tcMgr.newManualTestCase(tcRoot, tcName, tcL1fields);
Requirement req = reqMgr.newRequirement(reqRoot, reqName, reqL1fields);
req.associate(testCase);

//Add Test Steps to the New Manual Test Case
TestStep ts1 = testCase.newTestStep();
ts1.setAction("Test Step1 Action");
ts1.setComment("Test Step1 Comment");
ts1.setExpected("Test Step1 Expected Result");
ts1.save();

TestStep ts2 = testCase.newTestStep();
ts2.setAction("Test Step2 Action");
ts2.setComment("Test Step2 Comment");
ts2.setExpected("Test Step2 Expected Result");
ts2.save();

//Use TestStepIterator to get Test Steps from a Manual Test Case
TestStepIterator testSteps = testCase.getTestSteps();
while (testSteps.hasNext()){
  TestStep stepname = testSteps.next();
  info("Test Step ID "  + stepname.getId());
  info("Test Step Action "  + stepname.getAction());
  info("Test Step Comment "  + stepname.getComment());
  info("Test Step Expected "  + stepname.getExpected());
}

//For OpenScript Test Cases, specify the repository, workspace (if used)
//Script Name, Run settings, and script password (if used)
String osName = "OpenScript Test";
String osRepository = "Default";
String osWorkspace = ""; //or the name of the OpenScript folder if used
String scriptName = "osWebTest";
String cmdLine = "-propertiesPath C:/PlaybackSettings.properties";
String password1 = ""; //or the password used for encrpted scripts

TestCase ostestCase = tcMgr.newOpenScriptTestCase(tcRoot, osName, tcL1fields, 
  osRepository, osWorkspace, scriptName, cmdLine, password);

A.2.6.4 Test Set Fields

The Test Set fields and valid values are as follows:

Table A-4 Test Set Field Names and Valid Values

Field Name Valid Values

Type

Test Set

Test Folder

Owner

Administrator User

Default User

Any valid user name as defined in the Oracle Test Manager Administrator.

FunctionalityTested

Any text string.

Priority

Low

Medium

High

Any valid priority as defined in the Priority option list of the Oracle Test Manager Add Test Set dialog box. (Priority options are defined in the Priority field Option List in the Oracle Test Manager Administrator Fields tab).

Description

Any text string.


The following sample Java code provides an example:

//Define New TestSet
//Specify the Asset Path of the Test Set as the Root Level
TestSet tsRoot = (TestSet)otm.resolve("Test Sets/");

 //Define the Test Set Name 
String tsName = "TestSet Name";

//Create the List<DataFieldObject> and add Fields
List<DataFieldObject> tsL1fields = new ArrayList<DataFieldObject>();
tsL1fields.add(new DataFieldObject("Type", "Test Set"));
tsL1fields.add(new DataFieldObject("Owner", "Administrator User"));
tsL1fields.add(new DataFieldObject("FunctionalityTested", "Demo TestSet"));
tsL1fields.add(new DataFieldObject("Priority", "Low"));

//Use the Test Set Manager to create the Test Set
tsMgr.newTestSet(tsRoot, tsName, tsL1fields);

//--or- create the new Test Set as a variable that can be associated with
// another Asset, such as a Test Case
TestSet tSet = tsMgr.newTestSet(tsRoot, tsName, tsL1fields);

TestCase testCase = tcMgr.newManualTestCase(tcRoot, tcName, tcL1fields);
testCase.associate(tSet);

A.2.6.5 Issue Fields

The Issue fields and valid values are as follows:

Table A-5 Issue Field Name and Valid Values

Filed Name Valid Values

Summary

Any text string.

Component

Application

Application server

Database server

Web server

Any valid component as defined in the Component option list of the Oracle Test Manager Add Issue dialog box. (Component options are defined in the Component field Option List in the Oracle Test Manager Administrator).

(note: case sensitive)

Version

Any valid version as defined in the Version option list of the Oracle Test Manager Add Issue dialog box. (Versions options are defined in the Version field Option List in the Oracle Test Manager Administrator Fields tab).

AssignedTo

Administrator User

Default User

Any valid user name as defined in the Oracle Test Manager Administrator.

Status

1 - Created

2 - Open

3 - Reproduced

4 - Rejected

5 - Fixed

6 - Closed

Any valid status as defined in the Status option list of the Oracle Test Manager Add Issue dialog box. (Status options are defined in the Status field Option List in the Oracle Test Manager Administrator Fields tab).

Priority

Low

Medium

High

Any valid priority as defined in the Priority option list of the Oracle Test Manager Add Issue dialog box. (Priority options are defined in the Priority field Option List in the Oracle Test Manager Administrator Fields tab).

Severity

Low

Medium

High

Any valid severity as defined in the Severity option list of the Oracle Test Manager Add Issue dialog box. (Priority options are defined in the Severity field Option List in the Oracle Test Manager Administrator Fields tab).

Description

Any text string.

Platform

Other

Windows

Unix

Linux

Any valid version as defined in the Platform option list of the Oracle Test Manager Issue dialog box. (Platform options are defined in the Platform field Option List in the Oracle Test Manager Administrator)

Solution

Any text string.


The following sample Java code provides an example:

//Define New Issue
//Specify the Asset Path of the Issue as the Root Level
Issue issueRoot = (Issue)otm.resolve("Issues/");

//Define the Issue Name
String issueName = "Issue Name";

//Create the List<DataFieldObject> and add Fields
List<DataFieldObject> issueL1fields = new ArrayList<DataFieldObject>();
issueL1fields.add(new DataFieldObject("Summary", "New Issue Summary"));
issueL1fields.add(new DataFieldObject("Component", "Application server"));
issueL1fields.add(new DataFieldObject("Version", "1.0"));
issueL1fields.add(new DataFieldObject("AssignedTo", "Administrator User"));
issueL1fields.add(new DataFieldObject("Status", "1 - Created"));
issueL1fields.add(new DataFieldObject("Priority", "Medium"));
issueL1fields.add(new DataFieldObject("Severity", "Medium"));
issueL1fields.add(new DataFieldObject("Platform", "Windows"));
issueL1fields.add(new DataFieldObject("Description", "Issue Description"));
issueL1fields.add(new DataFieldObject("Solution", "Solution Text"));

//Use the Issue Manager to create the Issue
issueMgr.newIssue(issueName, issueL1fields);

//--or- create the new Test Set as a variable that can be associated with
// another Asset, such as a Test Case
Issue issue1 = issueMgr.newIssue(issueName, issueL1fields);

TestCase testCase = tcMgr.newManualTestCase(tcRoot, tcName, tcL1fields);
testCase.associate(issue1);

A.2.6.6 Test Run Fields

The Test Run fields and valid values are as follows:

Table A-6 Test Run Field Names and Valid Values

Field Name Valid Values

RunName

Any text string.

Version

Any text string or any valid version as defined in the Version option list of the Oracle Test Manager Test Run Info dialog box. (Version options are defined in the Version field Option List in the Oracle Test Manager Administrator Fields tab).

Manual Test Run Results Parameter

Passed

Warning

Failed

Any valid status as defined in the Status option list of the Oracle Test Manager Run Manual Test dialog box.

Manual Test Run Summary Parameter

Any text string.


The following sample Java code provides an example:

//Create the List<DataFieldObject> and add Fields
List<DataFieldObject> trfields = new ArrayList<DataFieldObject>();
trfields.add(new DataFieldObject("RunName", "Run Name"));
trfields.add(new DataFieldObject("Version", "1.0", true));

//Use the Test Run Manager to a crete a Manual Test Test Run with Result
//'testCase.getId()' is from a previously defined manual Test Case
trMgr.createManualTestRun(testCase.getId(), trfields, "Passed", "Summary text");

//--or- create the new Test Set as a variable that can be used for
// other actions for the Test Run
TestRun tr1 = trMgr.createManualTestRun(testCase.getId(), trfields, "Passed");

//For OpenScript Test Runs, provide any run settings and the server name
String server = "OTM Server";
String runSetting = "-propertiesPath C:/PlaybackSettings.properties";
trMgr.executeAutomatedTestCase(ostestCase.getId(), trfields, runSetting, server);

A.2.7 Working with Attachments

Attachments can be created using the attach(file) method of any asset that supports attachments. Attachments can be retrieved by calling getAttachments() on any asset that supports attachments. An attachment can be deleted by calling the delete() method on the attachment itself.

Assets can also be associated with other Assets using the associate(asset) method.

Table A-7 Types of Attachments and Associated Assets

Asset Type Attachments/Associated Assets

Test Plan

Attach file

Attach URL

Associate Requirement

Associate Test Sets

Requirement

Attach file

Attach URL

Associate Test Plan

Associate Test Cases

Test Folder/Test Case

Attach file

Attach URL

Associate Requirement

Associate Test Sets

Associate Issues

Test Folder/Test Set

Attach file

Attach URL

Associate Requirement

Associate Test Plans

Associate Issues

Issue

Attach file

Attach URL

Associate Test Cases

Associate Issues


The following example shows how to add attachments and associate other assets with a new issue:

//Define New Issue 
String issueName = "Issue Name";
List<DataFieldObject> issueFields = new ArrayList<DataFieldObject>();
issueFields.add(new DataFieldObject("Summary", "New Issue Summary"));
issueFields.add(new DataFieldObject("Component", "Application server"));
issueFields.add(new DataFieldObject("Version", "1.0"));
issueFields.add(new DataFieldObject("AssignedTo", "Administrator User"));
issueFields.add(new DataFieldObject("Status", "1 - Created"));
issueFields.add(new DataFieldObject("Priority", "Medium"));
issueFields.add(new DataFieldObject("Severity", "Medium"));
issueFields.add(new DataFieldObject("Platform", "Windows"));
issueFields.add(new DataFieldObject("Description", "Issue Description"));
issueFields.add(new DataFieldObject("Solution", "Solution Text"));

Issue issueRoot = (Issue)otm.resolve("Issues/");
//Create the issue as 'issue1'
Issue issue1 = issueMgr.newIssue(issueName, issueFields);

//Add Attachments and Associated Assets
File issueFile = new File("C:\\files\\example.txt");
issue1.associate(testCase); //Associate Test Case object 'testCase'
issue1.attach(issueFile);  //Attach File
issue1.attachUrl("Issue URL", "http://example.com"); //Attach URL

//Associate an Existing Issue with the ID value=1
//with the Issue object 'issue1'AssetIterator<Asset> issueIterator1 = issueRoot.getChildNodes();
while (issueIterator1.hasNext()) {  Asset issueAsset = issueIterator1.next();
  Long issueId = issueAsset.getId();
  if (issueId.equals(Long.valueOf(1))) {
    issue1.associate(issueAsset);
  }
}

The following example creates a few files with random data then does various attachment related operations:

File[] files = new File[10];
StringBuilder[] fileContents = new StringBuilder[files.length];

for (int i = 0; i < files.length; i++) {
   files[i] = File.createTempFile("otm_" + i, ".txt");

   / generate file contents
   fileContents[i] = new StringBuilder();
   for (int j = 0; j < Math.random() * 1000; j++) {
      fileContents[i].append(UUID.randomUUID().toString());
   }
   FileWriter writer = new FileWriter(files[i]);
   writer.write(fileContents[i].toString());
   writer.close();
}

TestCase t = project.getTestCaseManager().newTestCase(testFolder, "Attach Test");

for (int i = 0; i < files.length; i++) {

   t.attach(files[i]);
}

assertEquals(t.getAttachments().size(), files.length);

List<Attachment> attachments = t.getAttachments();
for (int i = 0; i < attachments.size(); i++) {
   Attachment attachment = attachments.get(i);
   logger.debug(attachment.getName());
   File f = attachment.getFile();
   FileReader reader = new FileReader(f);
   char[] contents = new char[(int)f.length()];
   reader.read(contents, 0, contents.length);
   reader.close();
   assertEquals(fileContents[i].toString(), new String(contents));
}

for (int i = 0; i < attachments.size(); i++) {
   Attachment attachment = attachments.get(i);
   attachment.delete();
   assertEquals(t.getAttachments().size(), attachments.size() - (i + 1));
}

A.2.8 Working with Filters

Filters are used to specifically query for data and/or sort the data. Filters operate on a field, take an operator (equal, not equal, contains, greater than, less than or null) and a value and can be chained together with an AND or an OR. Filters can also be case sensitive. Please see the FilterCriteria class for more details. An example of using a filter is provided below:

TestCase tc = tcMgr.getRoot();
//Define filters to get test cases from ID 0 to ID 50
//Define low range value
FilterCriteria tcFilterCr = new FilterCriteria();
tcFilterCr.setField("TestCaseId");
tcFilterCr.setOperator(Operator.greaterThan);
tcFilterCr.setValue("0");

//Define high range value and set AND
FilterCriteria tcFilterCr2 = new FilterCriteria();
tcFilterCr2.setField("TestCaseId");
tcFilterCr2.setOperator(Operator.lessThan);
tcFilterCr2.setValue("50");
tcFilterCr2.setAnd(true);

//Add filters
List<FilterCriteria> tcFilter = new ArrayList<FilterCriteria>();
tcFilter.add(tcFilterCr);
tcFilter.add(tcFilterCr2);

//Get Filtered Test Cases
TestCase testCaseFolder = (TestCase)otm.resolve("Test Cases/" );
AssetIterator<Asset> L1iterator = testCaseFolder.getChildNodes(tcFilter);

//Iterate Through The Assets in the Test Case Tree
while (L1iterator.hasNext()) {
  Asset L1asset = L1iterator.next();
  info("L1 Asset: " + L1asset.getLabel());

     //Get Second Level in the Test Case Tree
     AssetIterator<Asset> L2iterator = L1asset.getChildNodes();
     while (L2iterator.hasNext()) {
       Asset L2asset = L2iterator.next();
       info("L2 Asset Child: " + L2asset.getLabel());

        //Get Third Level in the Test Case Tree
        AssetIterator<Asset> L3iterator = L2asset.getChildNodes();
        while (L3iterator.hasNext()) {
          Asset L3asset = L3iterator.next();
          info("L3 Asset Grandchild: " + L3asset.getLabel());
        }
      }
}

The following table lists the Field names and types used with the setField() filter criteria.

Table A-8 Filter Criteria Field Values and Types

Asset Field Name Field Label Field Type/Description

TestCase

TestType

Test Type

Enumeration Type

Requirement

RequirementId

Requirement Id

ID Type

TestCase

TestCaseId

TestCase Id

ID Type

Issue

IssueId

Issue Id

ID Type

Requirement

Requirement

Requirement Name

String Type

TestCase

TestName

Test Name

String Type

Issue

IssueName

Issue Name

String Type

All subclass of Asset

CreatedBy

Created By

String Type, must be one of the registered users.

All subclass of Asset

ModifiedBy

Modified By

String Type, must be one of the registered users.

TestStep

ActionOrPage

Action Or Page(for OSE scripts test)

String Type

TestStep

ExpectedResult

Expected Result

String Type

TestStep

TestStepComment

Step Comment

String Type

TestStep

StepResult

Step Result

String Type

TestStep

Summary

Summary

String Type

Requirement

RequirementCreationDate

Requirement Creation Date

Date Type

TestCase

TestCreationDate

TestCase Creation Date

Date Type

Issue

IssueCreationDate

Issue Creation Date

Date Type

TestRun

RunByUser

Last Run By

String Type, must be one of the registered users.

TestRun

Duration

Duration

String Type

TestRun

RunDate

TestRun Last Run Date

Date Type

TestSet

TestSet

TestSet Name

String Type

TestSet

TestSetId

TestSet Id

String Type

All subclass of Asset

ModifiedDate

Last Modified Date

Date Type


A.2.9 Accessing Web Services Directly

Pre-generated raw web service Java classes are available in the oracle.oats.otm.webservices package. These will allow you to make raw web service calls. You will need to refer to the WSDL definitions for each of the various asset manager services for the exact message formats. The web services that are exposed are:

/AttachmentManager (generic attachment service)

/IssueManager

/Manager (generic manager service – can handle any asset type)

/RequirementManager

/TestCaseManager

/TestPlanManager

/TestSetManager

/TestExecutor

Note that when you connect to a manager and authenticate, you can maintain that session when connecting to other managers using the SESSION_MAINTAIN_PROPERTY property of the binding provider as follows:

TestCaseManager_Service service = new TestCaseManager_Service();
TestCaseManager manager = service.getTestCaseManagerPort();
((BindingProvider)manager).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);

manager.authenticate("administrator", "Password01", "Empty Project", "OATS_otm_DS");

TestExecutor_Service tes = new TestExecutor_Service();
TestExecutor te = tes.getTestExecutorPort();

// don't have to authenticate, can just immediately call any method
List<TestRunObject> runs = te.listTestRuns(6, "testCase", 0, 0);

A.3 Oracle Test Manager API Reference

The following section provides an alphabetical listing of the classes in the Oracle Test Manager API.

A.3.1 Alphabetical OTM API Class Listing

The following table lists the Oracle Test Manager API classes in alphabetical order.

Table A-9 List of Oracle Test Manager External API Classes

Method Description

AbstractManager.java

The abstract class for all Manager classes.

Asset.java

Provides the basic object that OTM uses to work with Issues, Requirements, TestCases, TestPlans, and TestSets.

AssetIterator.java

An Iterator implementation that retrieves the asset by its queryFilter and sorted by sortFilter in the page size as the "fetch_size" property in the Configuration. defined.

AssociationList.java

A list that encapsulated Asset associations with get/size methods and internal cache mechanism.

Attachment.java

Provides methods to get Assets. An Attachment is either a binary file that an asset has or an URL/Link that an Asset contains.

config.properties

Stores the Property setting(s).

Configuration.java

An encapsulated Properties class that loads properties from "config.properties" file.

ExternalAPIUtil.java

Used for sharing session across the WS-API calls.

Field.java

Provides methods for getting Field properties. Field is used as a meta data for an Asset.

fields.properties

Stores the Field setting(s).

FilterCriteria.java

The Filter Criteria is an abstraction of querying the Asset by A Field.

Folder.java

A Folder is a type of Asset and Test Case that usually presents a Test Case parent when creating the children TestCases.

IManagedObject.java

ManagedObject Interface is an interface that describes the object that can be managed with Create, Read, Update, Delete operations.

Issue.java

Provides methods for saving, deleting, and getting associated test cases and issues. An Issue is a type of Asset that can be used to track the problems during development.

IssueManager.java

The manager that does the Create, Read, Update, Delete operations for Issue asset.

package-info.java

Provides the JAX-WS API for Oracle Test Manager.

Project.java

A project is a collection of its Assets and reference of initialized TestManager. Users can centralize the usage of {AbstractManager then use those Managers to retrieve the Asset.

Requirement.java

Provides methods saving, deleting, and getting associated test cases for Requirements. Requirement is a type of Asset that can be used to track the specifications of software development.

RequirementManager.java

The manager that does the Create, Read, Update, Delete operations for Requirement assets.

TestCase.java

TestCase is a type of Asset that Oracle Test Manager maintains. Test cases can include multiple TestSteps and can execute TestRuns..

TestCaseManager.java

The manager that does the Create, Read, Update, Delete operations for TestCase assets.

TestManager.java

TestManager is used when initializing the testing session. It provides for authentication, field manipulation, and general Asset resolution.

TestPlan.java

The TestPlan is a type of Asset that can be used to track TestCase usage and TestSet execution.

TestPlanManager.java

The AbstractManager of that presents the Create, Read, Update, Delete operations for TestPlans.

TestRun.java

TestRun} represents an action to execute TestCases.

TestRunIterator.java

Iterator for TestRuns.

TestRunManager.java

The manager that does the Create, Read, Update, Delete operations for TestRun assets..

TestSet.java

A TestSet Asset is a type of asset that may contains multiple TestCases.

TestSetManager.java

The manager that does the Create, Read, Update, Delete operations for TestSteps.

TestStep.java

The TestStep represents the steps when executing the TestCase.

TestStepIterator.java

Iterator for TestSteps.


The following table lists the Oracle Test Manager WebServices API classes in alphabetical order.

Table A-10 List of Oracle Test Manager WebServices API Classes

Method Description

AssetDescriptor.java

Java class for assetDescriptor complex type.

AssetObject.java

Java class for assetObject complex type.

Associate.java

Java class for associate complex type.

AssociateResponse.java

Java class for associateResponse complex type.

AttachFile.java

Java class for attachFile complex type.

AttachFileResponse.java

Java class for attachFileResponse complex type.

AttachmentManager.java

Java class for AttachmentManager.

AttachmentManager_Service.java

Java class for AttachmentManager_Service.

AttachmentObject.java

Java class for attachmentObject complex type.

AttachUrl.java

Java class for attachUrl complex type.

AttachUrlResponse.java

Java class for attachUrlResponse complex type.

Authenticate.java

Java class for authenticate complex type.

AuthenticateResponse.java

Java class for authenticateResponse complex type.

DataFieldObject.java

Java class for dataFieldObject complex type.

DeleteAttachment.java

Java class for deleteAttachment complex type.

DeleteAttachmentResponse.java

Java class for deleteAttachmentResponse complex type.

DeleteIssue.java

Java class for deleteIssue complex type.

DeleteIssueResponse.java

Java class for deleteIssueResponse complex type.

DeleteRequirement.java

Java class for deleteRequirement complex type.

DeleteRequirementResponse.java

Java class for deleteRequirementResponse complex type.

DeleteTestCase.java

Java class for deleteTestCase complex type.

DeleteTestCaseResponse.java

Java class for deleteTestCaseResponse complex type.

DeleteTestPlan.java

Java class for deleteTestPlan complex type.

DeleteTestPlanResponse.java

Java class for deleteTestPlanResponse complex type.

DeleteTestRun.java

Java class for deleteTestRun complex type.

DeleteTestRunResponse.java

Java class for deleteTestRunResponse complex type.

DeleteTestSet.java

Java class for deleteTestSet complex type.

DeleteTestSetResponse.java

Java class for deleteTestSetResponse complex type.

DeleteTestStep.java

Java class for deleteTestStep complex type.

DeleteTestStepResponse.java

Java class for deleteTestStepResponse complex type.

Exception.java

Java class for Exception complex type.

Exception_Exception.java

Java class for Exception_Exception.

ExecuteTestCase.java

Java class for executeTestCase complex type.

ExecuteTestCaseResponse.java

Java class for executeTestCaseResponse complex type.

ExecuteTestSetRun.java

Java class for executeTestSetRun complex type.

ExecuteTestSetRunResponse.java

Java class for executeTestSetRunResponse complex type.

FilterCriteriaObject.java

Java class for filterCriteriaObject complex type.

FolderObject.java

Java class for folderObject complex type.

GetAssociations.java

Java class for getAssociations complex type.

GetAssociationsResponse.java

Java class for getAssociationsResponse complex type.

GetAttachments.java

Java class for getAttachments complex type.

GetAttachmentsResponse.java

Java class for getAttachmentsResponse complex type.

GetField.java

Java class for getField complex type.

GetFieldResponse.java

Java class for getFieldResponse complex type.

GetFields.java

Java class for getFields complex type.

GetFieldsResponse.java

Java class for getFieldsResponse complex type.

GetFile.java

Java class for getFile complex type.

GetFileResponse.java

Java class for getFileResponse complex type.

GetIssue.java

Java class for getIssue complex type.

GetIssueResponse.java

Java class for getIssueResponse complex type.

GetRequirement.java

Java class for getRequirement complex type.

GetRequirementResponse.java

Java class for getRequirementResponse complex type.

GetRoot.java

Java class for getRoot complex type.

GetRootResponse.java

Java class for getRootResponse complex type.

GetTestCase.java

Java class for getTestCase complex type.

GetTestCaseResponse.java

Java class for getTestCaseResponse complex type.

GetTestPlan.java

Java class for getTestPlan complex type.

GetTestPlanResponse.java

Java class for getTestPlanResponse complex type.

GetTestRun.java

Java class for getTestRun complex type.

GetTestRunResponse.java

Java class for getTestRunResponse complex type.

GetTestSet.java

Java class for getTestSet complex type.

GetTestSetResponse.java

Java class for getTestSetResponse complex type.

GetTestSteps.java

Java class for getTestSteps complex type.

GetTestStepsResponse.java

Java class for getTestStepsResponse complex type.

HierarchicalAssetObject.java

Java class for hierarchicalAssetObject complex type.

IssueManager.java

Java class for issueManager.

IssueManager_Service.java

Java class for issueManager_Service.

IssueObject.java

Java class for issueObject complex type.

LabelValueObject.java

Java class for labelValueObject complex type.

List.java

Java class for list complex type.

ListResponse.java

Java class for listResponse complex type.

ListTestRuns.java

Java class for listTestRuns complex type.

ListTestRunsResponse.java

Java class for listTestRunsResponse complex type.

ListTestStepResults.java

Java class for listTestStepResults complex type.

ListTestStepResultsResponse.java

Java class for listTestStepResultsResponse complex type.

Manager.java

Java class for manger.

Manager_Service.java

Java class for manager_Service.

NewFolder.java

Java class for newFolder complex type.

NewFolderResponse.java

Java class for newFolderResponse complex type.

NewIssue.java

Java class for newIssue complex type.

NewIssueResponse.java

Java class for newIssueResponse complex type.

NewRequirement.java

Java class for newRequirement complex type.

NewRequirementResponse.java

Java class for newRequirementResponse complex type.

NewTestCase.java

Java class for newTestCase complex type.

NewTestCaseResponse.java

Java class for newTestCaseResponse complex type.

NewTestPlan.java

Java class for newTestPlan complex type.

NewTestPlanResponse.java

Java class for newTestPlanResponse complex type.

NewTestRun.java

Java class for newTestRun complex type.

NewTestRunResponse.java

Java class for newTestRunResponse complex type.

NewTestSet.java

Java class for newTestSet complex type.

NewTestSetResponse.java

Java class for newTestSetResponse complex type.

NewTestStep.java

Java class for newTestStep complex type.

NewTestStepResponse.java

Java class for newTestStepResponse complex type.

ObjectFactory.java

Contains factory methods for each Java content interface and Java element interface generated in the oracle.oats.otm.webservices package.

package-info.java

Contains package information.

RequirementManager.java

Java class for requirementManager.

RequirementManager_Service.java

Java class for requirementManager_Service.

RequirementObject.java

Java class for requirementObject complex type.

SetField.java

Java class for setField complex type.

SetFieldResponse.java

Java class for setFieldResponse complex type.

StoreTestCase.java

Java class for storeTestCase complex type.

StoreTestCaseResponse.java

Java class for storeTestCaseResponse complex type.

StoreTestStep.java

Java class for storeTestStep complex type.

StoreTestStepResponse.java

Java class for storeTestStepResponse complex type.

TestCaseManager.java

Java class for testCaseManager.

TestCaseManager_Service.java

Java class for testCaseManager_Service.

TestCaseObject.java

Java class for testCaseObject complex type.

TestExecutor.java

Java class for testExecutor.

TestExecutor_Service.java

Java class for testExecutor_Service.

TestPlanManager.java

Java class for testPlanManager.

TestPlanManager_Service.java

Java class for testPlanManager_Service.

TestPlanObject.java

Java class for testPlanObject complex type.

TestRunObject.java

Java class for testRunObject complex type.

TestSetManager.java

Java class for testSetManager.

TestSetManager_Service.java

Java class for testSetManager_Service.

TestSetObject.java

Java class for testSetObject complex type.

TestStepObject.java

Java class for testStepObject complex type.

TestStepResultObject.java

Java class for testStepResultObject complex type.

User.java

Java class for user complex type.