Hi,
i would be nice if we could set properties in the Ant
script and use them in the SQLUnit test file, like this:
Ant script:
<!-- Database URL, schema and user
definitions -->
<property name="db.local.url"
value="jdbc:oracle:thin:@127.0.0.1:1556:TEST" />
<property name="db.local.user1"
value="che />
<property name="db.local.pass1"
value="che" />
SQLUnit test file:
<sqlunit>
<connection connection-id="1" transaction-
support="on">
<driver>oracle.jdbc.driver.OracleDriver</driver
>
<url>${db.local.url}</url>
<user>${db.local.user1}</user>
<password>${db.local.pass2}
</password>
</connection>
Bye
Che
Logged In: YES
user_id=184803
Hi Che,
Sorry about the delay in getting back, I have been pretty
busy lately, and does not look like this is going to change
anytime soon.
It would be nice, agreed. And it is not too hard to do
either, by using the Task.project Properties object that is
accessible to any subclass of the Task object.
I found some information here if you are interested:
http://builder.com.com/5100-6374_14-1027617-2.html#Listing%20F
Probably the only thing we need to do is to mark them
somehow, so frex, in your example, ${db.local.url} would be
${ant.db.local.url} when called inside SQLUnit.
Based on the cursory reading of the article, it looks like
something fairly simple to do, but I will confirm in a few
days how easy it will be to do.
-sujit
Logged In: YES
user_id=184803
Hi Che,
This is now done. There are changes in the following files:
src/net/sourceforge/sqlunit/ant/SqlunitAntTask.java
src/net/sourceforge/sqlunit/SymbolTable.java
src/net/sourceforge/sqlunit/SQLUnit.java
test/mock/functest.xml
To access ant variables in your SQLUnit test file, you would
need to prefix "ant." to your variable reference. So for
example:
If your build.xml contains a user property called:
programmer.name
you can refer to the value of this ant variable in your
SQLUnit file as ${ant.programmer.name}.
Similarly, you can refer to the Ant predefined variable
ant.project.name in SQLUnit as ${ant.ant.project.name}. A
mock test is available under test/mock/functest.xml for this
testcase.
I will be making it generally available in the next release,
due sometime in April. In the meantime if you can test it
out, please download the files I have listed above and let
me know how it went. Also I generally make a reference to
people whose requests or bug fixes are in this release in my
release notes, so if you would let me know your full name, I
will include it, or alternatively, I can use your
sourceforge alias.
-sujit
Logged In: YES
user_id=455149
Hi Sujit,
i will try to download the chaged files and test it, if i
find the time (i'm under some time pressure because the
milestones coming up very fast...).
Meanwhile i work with the copy/filter pattern to override
tokens like @db.testserver.url@ in the sqlunit-testfiles.
Bye
Che
Logged In: YES
user_id=455149
Hi,
i have tested this with 4.6.
I have, for example, a connection description like this in my
test file:
<connection connection-id="1" transaction-support="on">
<driver>${ant.db.default.driver}</driver>
<url>${ant.db.cfm.url}</url>
<user>${ant.db.cfm.user1}</user>
<password>${ant.db.cfm.pass1}>/password>
</connection>
Then i start my test, i see in the debug output, that all
needed properties are set in the right way, like:
[sqlunitdef] DEBUG [main] (SymbolTable.java:136) - >>
setValue(${ant.db.mms-
st.url},jdbc:oracle:thin:@xx.xxx.xx.xx:xxxx:xxxxx)
After all, i got this error output:
[sqlunitdef] DEBUG [main] (SQLUnitResult.java:126) - >>
setTestFile(xxxxx.xml)
[sqlunitdef] *** Running SQLUnit file: xxxxx.xml
[sqlunitdef] Error (java.lang.IllegalArgumentException)
encountered: null
[sqlunitdef] DEBUG [main] (ConnectionRegistry.java:209) -
>> releaseConnections()
[sqlunitdef] DEBUG [main] (SQLUnitResult.java:90) - >>
errorCount()
[sqlunitdef] DEBUG [main] (SQLUnitResult.java:81) - >>
failureCount()
[sqlunitdef] FATAL [main] (SQLUnit.java:223) - System error
(java.lang.IllegalArgumentException): null
[sqlunitdef] net.sourceforge.sqlunit.SQLUnitException:
System error (java.lang.IllegalArgumentException): null
[sqlunitdef] at net.sourceforge.sqlunit.SQLUnit.processDoc
(SQLUnit.java:404)
[sqlunitdef] at net.sourceforge.sqlunit.SQLUnit.testWrapper
(SQLUnit.java:243)
[sqlunitdef] at net.sourceforge.sqlunit.SQLUnit.runTest
(SQLUnit.java:220)
[sqlunitdef] at
net.sourceforge.sqlunit.ant.SqlunitTask.execute
(SqlunitTask.java:112)
[sqlunitdef] at
org.apache.tools.ant.UnknownElement.execute
(UnknownElement.java:275)
[sqlunitdef] at org.apache.tools.ant.Task.perform
(Task.java:364)
[sqlunitdef] at org.apache.tools.ant.Target.execute
(Target.java:341)
[sqlunitdef] at org.apache.tools.ant.Target.performTasks
(Target.java:369)
[sqlunitdef] at org.apache.tools.ant.Project.executeTarget
(Project.java:1214)
[sqlunitdef] at org.apache.tools.ant.Project.executeTargets
(Project.java:1062)
[sqlunitdef] at org.apache.tools.ant.Main.runBuild
(Main.java:673)
[sqlunitdef] at org.apache.tools.ant.Main.startAnt
(Main.java:188)
[sqlunitdef] at org.apache.tools.ant.launch.Launcher.run
(Launcher.java:196)
[sqlunitdef] at org.apache.tools.ant.launch.Launcher.main
(Launcher.java:55)
[sqlunitdef] Caused by: java.lang.IllegalArgumentException
[sqlunitdef] at sun.net.www.ParseUtil.decode
(ParseUtil.java:155)
[sqlunitdef] at
sun.net.www.protocol.file.Handler.openConnection
(Handler.java:56)
[sqlunitdef] at java.net.URL.openConnection(URL.java:943)
[sqlunitdef] at
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntit
y(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLEntityManager.startEntity
(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLEntityManager.startDTDEntity
(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource
(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDisp
atcher.dispatch(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.
scanDocument(Unknown Source)
[sqlunitdef] at
org.apache.xerces.parsers.XML11Configuration.parse
(Unknown Source)
[sqlunitdef] at
org.apache.xerces.parsers.XML11Configuration.parse
(Unknown Source)
[sqlunitdef] at org.apache.xerces.parsers.XMLParser.parse
(Unknown Source)
[sqlunitdef] at
org.apache.xerces.parsers.AbstractSAXParser.parse
(Unknown Source)
[sqlunitdef] at org.jdom.input.SAXBuilder.build
(SAXBuilder.java:370)
[sqlunitdef] at org.jdom.input.SAXBuilder.build
(SAXBuilder.java:684)
[sqlunitdef] at net.sourceforge.sqlunit.SQLUnit.processDoc
(SQLUnit.java:272)
[sqlunitdef] ... 13 more
[sqlunitdef] sqlunit-ant: System error
(java.lang.IllegalArgumentException): null
[sqlunitdef] net.sourceforge.sqlunit.SQLUnitException: One
or more SQLUnit Tests failed, see the console for details
[sqlunitdef] at
net.sourceforge.sqlunit.ant.SqlunitTask.execute
(SqlunitTask.java:129)
[sqlunitdef] at
org.apache.tools.ant.UnknownElement.execute
(UnknownElement.java:275)
[sqlunitdef] at org.apache.tools.ant.Task.perform
(Task.java:364)
[sqlunitdef] at org.apache.tools.ant.Target.execute
(Target.java:341)
[sqlunitdef] at org.apache.tools.ant.Target.performTasks
(Target.java:369)
[sqlunitdef] at org.apache.tools.ant.Project.executeTarget
(Project.java:1214)
[sqlunitdef] at org.apache.tools.ant.Project.executeTargets
(Project.java:1062)
[sqlunitdef] at org.apache.tools.ant.Main.runBuild
(Main.java:673)
[sqlunitdef] at org.apache.tools.ant.Main.startAnt
(Main.java:188)
[sqlunitdef] at org.apache.tools.ant.launch.Launcher.run
(Launcher.java:196)
[sqlunitdef] at org.apache.tools.ant.launch.Launcher.main
(Launcher.java:55)
[sqlunitdef] One or more SQLUnit Tests failed, see the
console for details