Hi,
I use Canoo Webtest (R_1766).
I want to use the SQL script for testing. The SQL script has to be
called from macro, because I need to do block of commands before I start
SQL script and a next block of commands after SQL script. And I use the
macro (macrodef) like a method with parameters. These parameters are
very good benefits. At least for me.;)
But I see that there are some problems. I attached example (sorry if the
are more bugs in examples). But I think it may help.
The idea of code (very simpleexample) is :
1. create property (e.g user name)
2. start macro with parameter of property; the macro should:
2a. display parameter using echo
2b. call the SQL script (oracle PLSQL) where I use parameter from macro
2c. display the result of sql script.
But I see that the step 2a. - echo displays the parameter
@{myInformation}, but the ANT SQL has problem with it.
It seems to me that I can use ${variable}, but not the variable
@{variable} in SQL script called using SCR.
I got the exception:
Caused by: C:\Program
Files\Eclipse\workspaceExpersoft\pm1-jTests\modules\!EXAMPLE\load_sql_script.xml:21:
java.sql.SQLException: Unsupported token SQL92 on position: 209:
myInformation
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:454)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
com.canoo.webtest.steps.AbstractStepContainer.executeContainedStep(AbstractStepContainer.java:72)
at
com.canoo.webtest.steps.AbstractStepContainer.executeContainedSteps(AbstractStepContainer.java:80)
at
com.canoo.webtest.steps.control.GroupStep.doExecute(GroupStep.java:14)
at com.canoo.webtest.steps.Step.execute(Step.java:103)
... 83 more
The added files should be in folders:
\cases\!EXAMPLE\sql_example.xml
\modules\!EXAMPLE\load_sql_script.xml
\modules\!EXAMPLE\select_simle.sql
\modules\!EXAMPLE\set_data_sql.xml
Regards,
Martin
<?xml version="1.0"?>
<!DOCTYPE project [
<!ENTITY config SYSTEM "../../config/config.xml">
<!ENTITY set_data_sql SYSTEM "../../modules/!EXAMPLE/set_data_sql.xml">
<!ENTITY load_sql_script SYSTEM "../../modules/!EXAMPLE/load_sql_script.xml">
]>
<project name="SQL" default="case" basedir="..">
<import file="${webtest.home}/lib/taskdef.xml"/>
<target name="case">
<echo>SQL EXAMPLE</echo>
<webtest name="SQL EXAMPLE">
&config;
<steps>
&set_data_sql;
&load_sql_script;
<call_sql myInformation="${data1}"/>
<call_sql myInformation="${data2}"/>
</steps>
</webtest>
</target>
</project>
<!-- Go to Portfolio-Masterdata -->
<macrodef name="call_sql"
description="This just call an SQL">
<attribute name="myInformation" default="MY_DATA_INFO" />
<sequential>
<echo message="Into the macro was sent: @{myInformation}" />
<antWrapper>
<sql
driver="${driver}"
url="${url}"
userid="${login.superuser.account}"
password="${login.superuser.password}"
onerror="stop"
delimitertype = "row"
delimiter="/"
output="modules/!EXAMPLE/output.txt"
print="true"
>
<transaction src="modules/!EXAMPLE/select_simle.sql" />
</sql>
</antWrapper>
<invoke
description="Go to Portfolio-Masterdata"
url="modules/!EXAMPLE/output.txt"/>
</sequential>
</macrodef>
DECLARE
tmpDATA1 VARCHAR2(10);
tmpDATA2 VARCHAR2(10);
tmpMyInformation VARCHAR2(10);
BEGIN
SELECT ${data1} INTO tmpDATA1 from dual;
SELECT ${data2} INTO tmpDATA2 from dual;
SELECT @{myInformation} INTO tmpMyInformation from dual;
create table example (
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
name VARCHAR2(10)
);
insert into examle (name) value (tmpDATA1);
insert into examle (name) value (tmpDATA2);
insert into examle (name) value (tmpMyInformation);
END;
select * from example;
drop table exaple;
<condition property="data1" value="DATA_0001">
<not>
<isset property="data1"/>
</not>
</condition>
<condition property="data2" value="DATA_0002">
<not>
<isset property="data2"/>
</not>
</condition>
Caused by: C:\Program
Files\Eclipse\workspaceExpersoft\pm1-jTests\modules\!EXAMPLE\load_sql_script.xml:21:
java.sql.SQLException: Unsupported token SQL92 on position: 209: myInformation
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:454)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
com.canoo.webtest.steps.AbstractStepContainer.executeContainedStep(AbstractStepContainer.java:72)
at
com.canoo.webtest.steps.AbstractStepContainer.executeContainedSteps(AbstractStepContainer.java:80)
at
com.canoo.webtest.steps.control.GroupStep.doExecute(GroupStep.java:14)
at com.canoo.webtest.steps.Step.execute(Step.java:103)
... 83 more
Caused by: java.sql.SQLException: Unsupported token SQL92 on position: 209:
myInformation
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.OracleSql.handleToken(OracleSql.java:1165)
at oracle.jdbc.driver.OracleSql.handleODBC(OracleSql.java:1064)
at oracle.jdbc.driver.OracleSql.parse(OracleSql.java:984)
at oracle.jdbc.driver.OracleSql.getSql(OracleSql.java:312)
at oracle.jdbc.driver.OracleSql.getSqlBytes(OracleSql.java:557)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:946)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
at
oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1688)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1654)
at org.apache.tools.ant.taskdefs.SQLExec.execSQL(SQLExec.java:564)
at org.apache.tools.ant.taskdefs.SQLExec.runStatements(SQLExec.java:539)
at
org.apache.tools.ant.taskdefs.SQLExec$Transaction.runTransaction(SQLExec.java:781)
at
org.apache.tools.ant.taskdefs.SQLExec$Transaction.access$000(SQLExec.java:707)
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:438)
... 93 more