#23 4.6: Error during access to ant-properties

closed-fixed
Sujit Pal
None
5
2005-04-19
2005-04-14
Che---
No

(Crossposted to the corresponding RFE 1162977)

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.setupCurrent
Entit
y(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLEntityManager.startEntity
(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLEntityManager.startDTDEnti
ty
(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLDTDScannerImpl.setInputSo
urce
(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLDocumentScannerImpl$DTD
Disp
atcher.dispatch(Unknown Source)
[sqlunitdef] at
org.apache.xerces.impl.XMLDocumentFragmentScanner
Impl.
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

Discussion

  • Sujit Pal
    Sujit Pal
    2005-04-16

    Logged In: YES
    user_id=184803

    Hi Che,

    I will take a look at this over the weekend and let you know
    more as I find more.

    Thanks
    Sujit

     
  • Sujit Pal
    Sujit Pal
    2005-04-16

    • assigned_to: nobody --> spal
    • status: open --> open-accepted
     
  • Sujit Pal
    Sujit Pal
    2005-04-19

    • status: open-accepted --> closed-fixed
     
  • Sujit Pal
    Sujit Pal
    2005-04-19

    Logged In: YES
    user_id=184803

    Hi Che,

    I could not reproduce your exact stack trace, but what I did
    get was a NPE in ConnectionRegistry.safelyRollback() which
    was caused by an SQLUnit Exception because the connection-id
    was not declared in the sql tag.

    So basically, when you define a connection in the connection
    tag with a connection-id attribute, you need to reference
    the connection-id in the sql or call tags (iits an optional
    attribute there). This is for tests which connect to
    multiple databases or need multiple Connection objects for
    the tests (eg diff tags) or need to switch Connections
    midway through a test. If you do not specify a connection-id
    attribute in the connection or the sql or call tag, then it
    will use the pseudo id DEFAULT.

    I have built a test for this in test/mock/variabletests.xml
    where I pass in the mock driver and mock database url
    through ant properties defined in the build.xml. If I do not
    specify a connection-id attribute, then it goes through
    successfully. If I specify a connection-id attribute in both
    the connection and the sql call, it also succeeds. However,
    if I specify connection-id in the connection tag but not in
    the sql/call tag, then it gives me a NPE.

    The reason for the NPE was new code which attempts to close
    this null connection in the catch block for
    SQLUnitException. I have added in a check to make sure that
    it responds with a saner error message. The error message I
    see in my tests now looks like:
    [sqlunit] Running test[1]: Testing scalar substitution
    using set (221ms)
    [sqlunit] Running test[2]: Setting variable as lvalue (221ms)
    [sqlunit] Connection(__default) is NULL or incorrectly
    specified
    I achieved this by commenting out the default connection
    definition in the variabletests.xml file, so the first one
    works but none thereafter.

    I have checked in the code changes to make this happen, and
    here are the files changed.
    Checking in build.xml;
    /cvsroot/sqlunit/sqlunit/build.xml,v <-- build.xml
    new revision: 1.102; previous revision: 1.101
    done
    Checking in src/net/sourceforge/sqlunit/ConnectionFactory.java;
    /cvsroot/sqlunit/sqlunit/src/net/sourceforge/sqlunit/ConnectionFactory.java,v
    <-- ConnectionFactory.java
    new revision: 1.5; previous revision: 1.4
    done
    Checking in src/net/sourceforge/sqlunit/ConnectionRegistry.java;
    /cvsroot/sqlunit/sqlunit/src/net/sourceforge/sqlunit/ConnectionRegistry.java,v
    <-- ConnectionRegistry.java
    new revision: 1.20; previous revision: 1.19
    done
    Checking in
    src/net/sourceforge/sqlunit/handlers/SqlHandler.java;
    /cvsroot/sqlunit/sqlunit/src/net/sourceforge/sqlunit/handlers/SqlHandler.java,v
    <-- SqlHandler.java
    new revision: 1.21; previous revision: 1.20
    done

    This will be generally available in the next release. In the
    meantime, if you can download these fixes (wait for a day or
    so to allow these versions to be available on the public cvs
    server) and test to see if this fixed the problem, would
    greatly appreciate that.

    Thanks
    Sujit