Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How can a user set values for an attribute of type "Normal" using web services?

How can a user set values for an attribute of type "Normal" using web services?

Problem:

How can a user set values for an attribute of type "Normal" using web services?

Resolution:

Using the SilkCentral Test Manager GUI, setting a value for attributes would be done in Test Manager | Settings | Attributes tab (see below):

Using Web Services you can also set values for an attribute of type "Normal". Please see example below that logs in as admin | admin and sets a Value ("IE 6") to the attribute "Browser"

Note: Attributes and their options must be defined by using the GUI before they can be used via web services

............................................

package com.borland.testmanager.democlient.samples;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import com.borland.testmanager.stubs.sccsystem.SystemService;
import com.borland.testmanager.stubs.sccsystem.SystemServiceServiceLocator;
import com.borland.testmanager.stubs.tmplanning.PlanningService;
import com.borland.testmanager.stubs.tmplanning.PlanningServiceServiceLocator;
import com.borland.testmanager.stubs.tmplanning.tm.PropertyValue;
import com.borland.testmanager.stubs.tmplanning.tm.TestPlanningNode;

public class SetBrowserAttributeNormalOption {

String host = "localhost";
int port = 19120;
String user = "admin";
String pwd = "admin";
int nodeId = 3; // see demo project: test definition "Correct Login data" (ID=3)
String browserOption = "IE 6";

/**
* @param args
*/
public static void main(String[] args) {

SetBrowserAttributeNormalOption optionsSetter = new SetBrowserAttributeNormalOption();

optionsSetter.processArguments(args);

try {
long sessionId = optionsSetter.login();


optionsSetter.setBrowserAttributeOption(sessionId);

TestPlanningNode node = optionsSetter.retrieveNode(sessionId);

boolean noAttributesFound = ReadAttributeOptions.printAttributes(node);

if (noAttributesFound) {
System.out.printf("no attributes found for node "%s" (ID=%d)%n", node.getName(), node.getId());
}

} catch (Exception e) {
e.printStackTrace();
}
}

private void setBrowserAttributeOption(long sessionId) throws MalformedURLException, ServiceException, RemoteException {
PlanningService planningService = new PlanningServiceServiceLocator().gettmplanning(new URL("http", host, port, "/services/tmplanning"));
planningService.updateProperties(sessionId, makeBrowserOption());
}

private PropertyValue[] makeBrowserOption() {
return new PropertyValue[] {
new PropertyValue() {
{
setPropertyTypeID("_attribute_");
setPropertyID ("_attribute_Browser");
setName ("Browser");
setValue (browserOption);
setNodeID (Integer.toString(nodeId));
setType (11); // attribute type NORMAL (see javadoc of PropertyMetaInfo)
}
}
};
}

private TestPlanningNode retrieveNode(long sessionId) throws ServiceException, MalformedURLException, RemoteException {
PlanningService planningService = new PlanningServiceServiceLocator().gettmplanning(new URL("http", host, port, "/services/tmplanning"));
TestPlanningNode node = planningService.getNode(sessionId, Integer.toString(nodeId));
return node;
}

private long login() throws ServiceException, MalformedURLException, RemoteException {
SystemService sccService = new SystemServiceServiceLocator().getsccsystem(new URL("http", host, port, "/services/sccsystem"));
long sessionId = sccService.logonUser(user, pwd);
return sessionId;
}

private void processArguments(String[] args) {
for (int i = 0; i
switch (i) {
case 0:
if ("help".equals(args)) {
System.out.println("valid arguments: host port user password nodeID browserOption");
System.exit(0);
} else {
host = args;
}
break;
case 1:
port = Integer.parseInt(args);
break;
case 2:
user = args;
break;
case 3:
pwd = args;
case 4:
nodeId = Integer.parseInt(args);
break;
case 5:
browserOption = args;
}
}
}

}

SetBrowserAttributeNormalOption.java
Old KB# 30288

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 20:45
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.