本文整理汇总了Java中org.robotframework.javalib.annotation.RobotKeyword类的典型用法代码示例。如果您正苦于以下问题:Java RobotKeyword类的具体用法?Java RobotKeyword怎么用?Java RobotKeyword使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RobotKeyword类属于org.robotframework.javalib.annotation包,在下文中一共展示了RobotKeyword类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: patchRequest
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword(" Send a PATCH request on the session object found using the\n\n"
+ "given `alias`\n\n"
+ "``alias`` that will be used to identify the Session object in the cache\n\n"
+ "``uri`` to send the PATCH request to\n\n"
+ "``data`` a dictionary of key-value pairs that will be urlencoded and sent as PATCH data or binary data that is sent as the raw body content\n\n"
+ "``headers`` a dictionary of headers to use with the request\n\n"
+ "``files`` a dictionary of file names containing file data to PATCH to the server\n\n"
+ "\n\n"
+ "``allow_redirects`` Boolean. Set to True if redirect following is allowed.\n\n"
+ "``timeout`` connection timeout")
@ArgumentNames({ "alias", "uri", "data={}", "headers={}", "files={}", "allow_redirects=False", "timeout=0" })
public ResponseData patchRequest(String alias, String uri, String... params) {
RestClient rc = new RestClient();
Object dataList = (String) Robot.getParamsValue(params, 0, "");
if (Robot.isDictionary(dataList.toString())) {
dataList = (Map<String, String>) Robot.getParamsValue(params, 0,
(Map<String, String>) new HashMap<String, String>());
}
Map<String, String> headers = Robot.getParamsValue(params, 1,
(Map<String, String>) new HashMap<String, String>());
Map<String, String> files = Robot.getParamsValue(params, 2,
(Map<String, String>) new HashMap<String, String>());
Boolean allowRedirects = Boolean.parseBoolean(Robot.getParamsValue(params, 3, "false"));
rc.makePatchRequest(alias, uri, dataList, headers, files, allowRedirects);
return rc.getSession(alias).getResponseData();
}
示例2: deleteRequest
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword(" Send a DELETE request on the session object found using the\n\n"
+ "given `alias`\n\n"
+ "``alias`` that will be used to identify the Session object in the cache\n\n"
+ "``uri`` to send the DELETE request to\n\n"
+ "``data`` a dictionary of key-value pairs that will be urlencoded and sent as DELETE data or binary data that is sent as the raw body content\n\n"
+ "``params`` url parameters to append to the uri\n\n"
+ "``headers`` a dictionary of headers to use with the request\n\n"
+ "\n\n"
+ "``allow_redirects`` Boolean. Set to True if redirect following is allowed.\n\n"
+ "``timeout`` connection timeout")
@ArgumentNames({ "alias", "uri", "data={}", "params={}", "headers={}", "allow_redirects=False", "timeout=0" })
public ResponseData deleteRequest(String alias, String uri, String... params) {
RestClient rc = new RestClient();
Object dataList = (String) Robot.getParamsValue(params, 0, "");
if (Robot.isDictionary(dataList.toString())) {
dataList = (Map<String, String>) Robot.getParamsValue(params, 0,
(Map<String, String>) new HashMap<String, String>());
}
Map<String, String> paramList = Robot.getParamsValue(params, 1,
(Map<String, String>) new HashMap<String, String>());
Map<String, String> headers = Robot.getParamsValue(params, 2,
(Map<String, String>) new HashMap<String, String>());
Boolean allowRedirects = Boolean.parseBoolean(Robot.getParamsValue(params, 3, "true"));
rc.makeDeleteRequest(alias, uri, dataList, paramList, headers, allowRedirects);
return rc.getSession(alias).getResponseData();
}
示例3: createSession
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("Create a HTTP session to a server\n\n"
+ "``url`` Base url of the server\n\n"
+ "``alias`` Robot Framework alias to identify the session\n\n"
+ "``headers`` Dictionary of default headers\n\n"
+ "``auth`` List of username & password for HTTP Basic Auth\n\n"
+ "``timeout`` Connection timeout\n\n"
+ "\n\n"
+ "``proxy`` Dictionary that contains proxy information. Only one proxy supported per session. Dictionary should contain at least following keys: *protocol*, *host* and *port* of proxy. It can also contain *username* and *password*\n\n"
+ "``verify`` Whether the SSL cert will be verified. A CA_BUNDLE path can also be provided.\n\n"
+ "``debug`` Enable http verbosity option more information\n\n")
@ArgumentNames({ "alias", "url", "headers={}", "cookies=None", "auth=None", "timeout=None", "proxy=None",
"verify=False", "debug=False" })
public void createSession(String alias, String url, String... params) {
RestClient rc = new RestClient();
Map<String, String> headers = Robot.getParamsValue(params, 0, new HashMap<String, String>());
Proxy proxy = new Proxy(Robot.getParamsValue(params, 4, new HashMap<String, String>()));
String verify = Robot.getParamsValue(params, 5, "False");
Boolean debug = Boolean.parseBoolean(Robot.getParamsValue(params, 6, "False"));
RobotLogger.setDebugToAll(debug);
Authentication auth = Authentication
.getAuthentication(Robot.getParamsValue(params, 2, (List<String>) new ArrayList<String>()));
rc.createSession(alias, url, headers, auth, verify, debug, proxy);
}
示例4: createDigestSession
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("Create a HTTP session to a server\n\n"
+ "``url`` Base url of the server\n\n"
+ "``alias`` Robot Framework alias to identify the session\n\n"
+ "``headers`` Dictionary of default headers\n\n"
+ "``auth`` List of username & password for HTTP Digest Auth\n\n"
+ "``timeout`` Connection timeout\n\n"
+ "\n\n"
+ "``proxy`` Dictionary that contains proxy information. Only one proxy supported per session. Dictionary should contain at least following keys: *protocol*, *host* and *port* of proxy. It can also contain *username* and *password*\n\n"
+ "``verify`` Whether the SSL cert will be verified. A CA_BUNDLE path can also be provided.\n\n"
+ "``debug`` Enable http verbosity option more information\n\n")
@ArgumentNames({ "alias", "url", "headers={}", "cookies=None", "auth=None", "timeout=None", "proxy=None",
"verify=False", "debug=False" })
public void createDigestSession(String alias, String url, String... params) {
RestClient rc = new RestClient();
Map<String, String> headers = Robot.getParamsValue(params, 0, new HashMap<String, String>());
Proxy proxy = new Proxy(Robot.getParamsValue(params, 4, new HashMap<String, String>()));
String verify = Robot.getParamsValue(params, 5, "False");
Boolean debug = Boolean.parseBoolean(Robot.getParamsValue(params, 6, "False"));
RobotLogger.setDebugToAll(debug);
Authentication auth = Authentication.getAuthentication(
Robot.getParamsValue(params, 2, (List<String>) new ArrayList<String>()), Authentication.Type.DIGEST);
rc.createSession(alias, url, headers, auth, verify, debug, proxy);
}
示例5: getRequest
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword(" Send a GET request on the session object found using the\n\n"
+ "given `alias`\n\n"
+ "``alias`` that will be used to identify the Session object in the cache\n\n"
+ "``uri`` to send the GET request to\n\n"
+ "``params`` url parameters to append to the uri\n\n"
+ "``headers`` a dictionary of headers to use with the request\n\n"
+ "\n\n"
+ "``allow_redirects`` Boolean. Set to True if redirect following is allowed.\n\n"
+ "``timeout`` connection timeout")
@ArgumentNames({ "alias", "uri", "headers={}", "params={}", "allow_redirects=true", "timeout=0" })
public ResponseData getRequest(String alias, String uri, String... params) {
RestClient rc = new RestClient();
Boolean allowRedirects = Boolean.parseBoolean(Robot.getParamsValue(params, 2, "true"));
Map<String, String> paramList = Robot.getParamsValue(params, 1,
(Map<String, String>) new HashMap<String, String>());
Map<String, String> headers = Robot.getParamsValue(params, 0,
(Map<String, String>) new HashMap<String, String>());
rc.makeGetRequest(alias, uri, headers, paramList, allowRedirects);
return rc.getSession(alias).getResponseData();
}
示例6: headRequest
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword(" Send a HEAD request on the session object found using the\n\n"
+ "given `alias`\n\n"
+ "``alias`` that will be used to identify the Session object in the cache\n\n"
+ "``uri`` to send the HEAD request to\n\n"
+ "``headers`` a dictionary of headers to use with the request\n\n"
+ "\n\n"
+ "``allow_redirects`` Boolean. Set to True if redirect following is allowed.\n\n"
+ "``timeout`` connection timeout")
@ArgumentNames({ "alias", "uri", "headers={}", "allow_redirects=False", "timeout=0" })
public ResponseData headRequest(String alias, String uri, String... params) {
RestClient rc = new RestClient();
Map<String, String> headers = Robot.getParamsValue(params, 0,
(Map<String, String>) new HashMap<String, String>());
Boolean allowRedirects = Boolean.parseBoolean(Robot.getParamsValue(params, 1, "false"));
rc.makeHeadRequest(alias, uri, headers, allowRedirects);
return rc.getSession(alias).getResponseData();
}
示例7: optionsRequest
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword(" Send a OPTIONS request on the session object found using the\n\n"
+ "given `alias`\n\n"
+ "``alias`` that will be used to identify the Session object in the cache\n\n"
+ "``uri`` to send the OPTIONS request to\n\n"
+ "``headers`` a dictionary of headers to use with the request\n\n"
+ "\n\n"
+ "``allow_redirects`` Boolean. Set to True if redirect following is allowed.\n\n"
+ "``timeout`` connection timeout")
@ArgumentNames({ "alias", "uri", "headers={}", "allow_redirects=False", "timeout=0" })
public ResponseData optionsRequest(String alias, String uri, String... params) {
RestClient rc = new RestClient();
Map<String, String> headers = Robot.getParamsValue(params, 0,
(Map<String, String>) new HashMap<String, String>());
Boolean allowRedirects = Boolean.parseBoolean(Robot.getParamsValue(params, 1, "true"));
rc.makeOptionsRequest(alias, uri, headers, allowRedirects);
return rc.getSession(alias).getResponseData();
}
示例8: exportDataFromTable
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("Exports the data from the given table into a file that is stored at the "
+ "given location. The where-clause can (and should) be used to narrow the "
+ "amount of rows that is exported this way. The file is stored in some "
+ "simple XML-format and can be imported again to the database using the "
+ "\"Import Data From File\" keyword. This way it is possible to store a set "
+ "of testdata permanently retrieving it for example from some Live- or "
+ "Demosystem. This keyword will probably have some issues if millions of "
+ "rows are exported/imported using it. " + "\n\n"
+ "*NOTE*: If using keyword remotely, file need to be trasfered to server some "
+ "other way; this library is not doing the transfer.\n\n"
+ "The keyword returns the amount of rows written to the XML-file. " + "\n\n"
+ "Example: | ${ROWSEXPORTED}= | MySampleTable | /tmp/mysampletable.xml | Timestamp > sysdate-50 |")
@ArgumentNames({ "Table name", "Export file path (including name)", "Where clause=''" })
public int exportDataFromTable(String tableName, String filePath, String... whereClause)
throws SQLException, DatabaseLibraryException, ParserConfigurationException,
TransformerFactoryConfigurationError, TransformerException {
new Assert().tableMustExist(tableName);
String query = "Select * from " + tableName;
if (whereClause.length > 0) {
query += " where " + whereClause[0];
}
List<HashMap<String, Object>> data = queryRunner.executeSql(query);
return writeQueryResultsToFile(tableName, filePath, data);
}
示例9: deleteAllRowsFromTable
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("Deletes the entire content of the given database table. This keyword is"
+ "useful to start tests in a clean state. Use this keyword with care as"
+ "accidently execution of this keyword in a productive system will cause"
+ "heavy loss of data. There will be no rollback possible.\n\n" + "Example: \n"
+ "| Delete All Rows From Table | MySampleTable |")
@ArgumentNames({ "Table name" })
public void deleteAllRowsFromTable(String tableName) throws SQLException {
String sql = "delete from " + tableName;
Statement stmt = DatabaseConnection.getConnection().createStatement();
try {
stmt.execute(sql);
} finally {
stmt.close();
}
}
示例10: rowShouldNotExistInTable
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("This keyword can be used to check the inexistence of content inside a "
+ "specific row in a database table defined by a where-clause. This can be "
+ "used to validate an exclusion of specific data from a table. " + "\n\n" + "Example: \n"
+ "| Row Should Not Exist In Table | MySampleTable | Name='John Doe' | " + "\n\n"
+ "This keyword was introduced in version 1.1. ")
@ArgumentNames({ "Table to check", "Where clause" })
public void rowShouldNotExistInTable(String tableName, String whereClause)
throws SQLException, DatabaseLibraryException {
String sql = "select * from " + tableName + " where " + whereClause;
Statement stmt = DatabaseConnection.getConnection().createStatement();
try {
stmt.executeQuery(sql);
ResultSet rs = (ResultSet) stmt.getResultSet();
if (rs.next() == true) {
throw new DatabaseLibraryException(
"Row exists (but should not) for where-clause: " + whereClause + " in table: " + tableName);
}
} finally {
stmt.close();
}
}
示例11: transactionIsolationLevelMustBe
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("Can be used to check that the database connection used for executing "
+ "tests has the proper transaction isolation level. The string parameter "
+ "accepts the following values in a case-insensitive manner: "
+ "TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, "
+ "TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE or " + "TRANSACTION_NONE. " + "\n\n"
+ "Example: \n" + "| Transaction Isolation Level Must Be | TRANSACTION_READ_COMMITTED | ")
@ArgumentNames({ "Isolation level" })
public void transactionIsolationLevelMustBe(String levelName) throws SQLException, DatabaseLibraryException {
String transactionName = new Information().getTransactionIsolationLevel();
if (!transactionName.equals(levelName)) {
throw new DatabaseLibraryException(
"Expected Transaction Isolation Level: " + levelName + " Level found: " + transactionName);
}
}
示例12: verifyNumberOfRowsMatchingWhere
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("This keyword checks that a given table contains a given amount of rows "
+ "matching a given WHERE clause. " + "\n\n"
+ "For the example this means that the table \"MySampleTable\" must contain "
+ "exactly 2 rows matching the given WHERE, otherwise the teststep will " + "fail. " + "\n\n"
+ "Example: \n" + "| Verify Number Of Rows Matching Where | MySampleTable | [email protected] | 2 | ")
@ArgumentNames({ "Table to check", "Where clause", "Expected number of rows" })
public void verifyNumberOfRowsMatchingWhere(String tableName, String where, String rowNumValue)
throws SQLException, DatabaseLibraryException {
long rowNum = Long.valueOf(rowNumValue);
long num = getNumberOfRows(tableName, where, (rowNum + 1));
if (num != rowNum) {
throw new DatabaseLibraryException("Expecting " + rowNum + " rows, fetched: " + num);
}
}
示例13: disconnectFromDatabase
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("Releases the existing connection to the database. In addition this"
+ "keyword will log any SQLWarnings that might have been occurred on the connection.\n"
+ "If current connection is closed and there's still some open, you have to activate that manually.\n"
+ "Example:\n" + "| Disconnect from Database | default |")
@ArgumentNames({ "Database alias=default" })
public void disconnectFromDatabase(String... aliasParam) throws SQLException {
String alias = aliasParam.length > 0 ? aliasParam[0] : defaultAlias;
Connection disconnectingConnection = getConnection(alias);
System.out.println(String.format("SQL Warnings on this connection (%s): %s", alias,
disconnectingConnection.getWarnings()));
disconnectingConnection.close();
DatabaseConnection.connectionMap.remove(alias);
if (alias.equals(DatabaseConnection.currentConnectionAlias)) {
DatabaseConnection.currentConnectionAlias = "";
}
}
示例14: executeQuery
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("Execute SQL Query. Returns a list of values. When the query selects a single column, a simple list of values is returned.\n"
+ "When the query selects multiple columns a list of lists is returned.\n" +
"Example usage:\n"
+ " | @{singleColResult}= | Execute Query | select 1 from dual union select 2 from dual | \n"
+ " | Log Many | @{singleColResult} | | \n"
+ " | @{multiColResult}= | Execute Query | select 1,2 from dual union select 3,4 from dual | \n"
+ " | Log Many | ${singleColResult[2]} | | \n")
// @formatter:on
@ArgumentNames({ "sql" })
public List<Object> executeQuery(String sql) {
List<String> sqls = new ArrayList<>();
if (FileUtil.isSqlFileName(sql)) {
sqls = FileUtil.parseSQLStatements(sql);
} else {
sqls.add(sql);
}
if (sqls.size() != 1) {
throw new FileLibraryException("Only a single SQL Query is allowed in the .sql file for this keyword.");
}
StatementParser parser = new StatementParser(sqls.get(0));
return service.getQueryResultsAsList(parser.getStatement(), TemplateContext.getInstance().resolveAttributes(parser.getParameters()), 0);
}
示例15: statement
import org.robotframework.javalib.annotation.RobotKeyword; //导入依赖的package包/类
@RobotKeyword("Execute SQL INSERT or UPDATE statement(s). Specify either an SQL directly or the path to a .sql file.")
@ArgumentNames({ "sql" })
public void executeSQL(String sql) {
List<String> sqls = new ArrayList<>();
if (FileUtil.isSqlFileName(sql)) {
sqls = FileUtil.parseSQLStatements(sql);
} else {
sqls.add(sql);
}
for (String rawSql : sqls) {
StatementParser parser = new StatementParser(rawSql);
service.executeStatement(parser.getStatement(), TemplateContext.getInstance().resolveAttributes(parser.getParameters()));
}
}