Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#22 NULL in Numeric field causes exception during result check

closed-fixed
Sujit Pal
None
5
2015-02-15
2005-04-12
Che---
No

Hi folks,

run into some problems during our testcases:

I have a table with some nullable numeric fields and i
expect that some of them should be null:

--- snip ---
<result>
<resultset id="1">
<row id="1">
--- snip ---
<col id="9"
name="VAT_CD_REF" type="NUMERIC">NULL</col>
<col id="10"
name="SURTAX_AMOUNT"
type="NUMERIC">NULL</col>
</row>
<row id="2">
--- snip ---
<col id="9"
name="VAT_CD_REF" type="NUMERIC">NULL</col>
<col id="10"
name="SURTAX_AMOUNT"
type="NUMERIC">NULL</col>
</row>
</resultset>
</result>
--- snip ---

I got this error:

[sqlunitdef] *** Running SQLUnit file: sqlunit-compare-
0005-01.xml
[sqlunitdef] Getting connection(1)
[sqlunitdef] Setting up test...
[sqlunitdef] Running test[1]: H.\compare-0005-01-vatrate
(0ms)
[sqlunitdef] For input string: "NULL"
[sqlunitdef] Tearing down test...
[sqlunitdef] sqlunit-ant: SQLUnit Tests Failed: In file:
H:\sqlunit-compare-0005-01.xml, tests: 1, failures: 1,
errors = 0

The stacktrace with debug enabled:

[sqlunitdef] at
net.sourceforge.sqlunit.SQLUnit.testWrapper
(SQLUnit.java:231)
[sqlunitdef] at net.sourceforge.sqlunit.SQLUnit.runTest
(SQLUnit.java:205)
[sqlunitdef] at
net.sourceforge.sqlunit.ant.SqlunitTask.execute
(SqlunitTask.java:111)
[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.taskdefs.Ant.execute(Ant.java:386)
[sqlunitdef] at
org.apache.tools.ant.taskdefs.CallTarget.execute
(CallTarget.java:106)
[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:
net.sourceforge.sqlunit.SQLUnitException: For input
string: "NULL"
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.invokeAssertion
(Assertions.java:754)
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.assertIsTrue
(Assertions.java:118)
[sqlunitdef] at
net.sourceforge.sqlunit.handlers.TestHandler.process
(TestHandler.java:216)
[sqlunitdef] at
net.sourceforge.sqlunit.SQLUnit.processDoc
(SQLUnit.java:308)
[sqlunitdef] at
net.sourceforge.sqlunit.SQLUnit.testWrapper
(SQLUnit.java:228)
[sqlunitdef] ... 19 more
[sqlunitdef] Caused by:
net.sourceforge.sqlunit.SQLUnitException: For input
string: "NULL"
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.invokeAssertion
(Assertions.java:754)
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.assertIsTrue
(Assertions.java:118)
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.assertEqual
(Assertions.java:172)
[sqlunitdef] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[sqlunitdef] at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
[sqlunitdef] at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
[sqlunitdef] at java.lang.reflect.Method.invoke
(Method.java:324)
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.invokeAssertion
(Assertions.java:751)
[sqlunitdef] ... 23 more
[sqlunitdef] Caused by:
java.lang.NumberFormatException: For input
string: "NULL"
[sqlunitdef] at
java.lang.NumberFormatException.forInputString
(NumberFormatException.java:48)
[sqlunitdef] at java.lang.Integer.parseInt
(Integer.java:426)
[sqlunitdef] at java.math.BigInteger.<init>
(BigInteger.java:314)
[sqlunitdef] at java.math.BigInteger.<init>
(BigInteger.java:447)
[sqlunitdef] at java.math.BigDecimal.<init>
(BigDecimal.java:216)
[sqlunitdef] at
net.sourceforge.sqlunit.beans.Col.equals(Col.java:171)
[sqlunitdef] at junit.framework.Assert.assertEquals
(Assert.java:66)
[sqlunitdef] at junit.framework.Assert.assertEquals
(Assert.java:75)
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.subAssertColumnsEq
ual(Assertions.java:968)
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.subAssertResultSets
Equal(Assertions.java:847)
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.assertResultSetsEqu
al(Assertions.java:406)
[sqlunitdef] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[sqlunitdef] at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
[sqlunitdef] at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
[sqlunitdef] at java.lang.reflect.Method.invoke
(Method.java:324)
[sqlunitdef] at
net.sourceforge.sqlunit.Assertions.invokeAssertion
(Assertions.java:751)
[sqlunitdef] ... 30 more
[sqlunitdef] sqlunit-ant: SQLUnit Tests Failed: In file:
H:\Eigene
Dateien\IBM\WBIMBToolkit\workspace\mai.mcc.ru.Test-
InvoiceUpload/$build/sqlunit/sqlunit-compa
re-0005-01.xml, tests: 1, failures: 1, errors = 0
[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:128)
[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.taskdefs.Ant.execute(Ant.java:386)
[sqlunitdef] at
org.apache.tools.ant.taskdefs.CallTarget.execute
(CallTarget.java:106)
[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

I have tested this with 4.4 and 4.5, both the same.
If you need any further debug output, i can send them
with mail (cant paste them due to some possible semi-
confidental parts).

We workaround this problem with a to_char(xxx) in the
select and changing the result part to (e.g.)

<col id="9" name="VAT_CD_REF"
type="VARCHAR">NULL</col>

Any other suggestions???

Discussion

  • Sujit Pal
    Sujit Pal
    2005-04-13

    • assigned_to: nobody --> spal
    • status: open --> pending-fixed
     
  • Sujit Pal
    Sujit Pal
    2005-04-13

    Logged In: YES
    user_id=184803

    Hi Che,

    This bug has been recently (couple of days ago) fixed. It
    was reported by James Henderson in the Open DIscussion Forum
    thread: Problems with NUMERIC, DECIMAL in SQLUnit. The files
    modified are:
    Checking in src/net/sourceforge/sqlunit/beans/Col.java;
    /cvsroot/sqlunit/sqlunit/src/net/sourceforge/sqlunit/beans/Col.java,v
    <-- Col.java
    new revision: 1.10; previous revision: 1.9
    done
    Checking in src/net/sourceforge/sqlunit/beans/OutParam.java;
    /cvsroot/sqlunit/sqlunit/src/net/sourceforge/sqlunit/beans/OutParam.java,v
    <-- OutParam.java
    new revision: 1.7; previous revision: 1.6
    done
    Checking in
    src/net/sourceforge/sqlunit/types/BigDecimalType.java;
    /cvsroot/sqlunit/sqlunit/src/net/sourceforge/sqlunit/types/BigDecimalType.java,v
    <-- BigDecimalType.java
    new revision: 1.14; previous revision: 1.13
    done
    Checking in src/net/sourceforge/sqlunit/utils/TypeUtils.java;
    /cvsroot/sqlunit/sqlunit/src/net/sourceforge/sqlunit/utils/TypeUtils.java,v
    <-- TypeUtils.java
    new revision: 1.5; previous revision: 1.4
    done

    Although there have been other changes since the 4.5 release
    as well, so I am not sure if these are the only ones you
    will need to get the fix. I would advise downloading the
    whole tree from CVS and rebuilding.

    Marking this resolved.

     
  • Che---
    Che---
    2005-04-13

    • status: pending-fixed --> open-fixed
     
  • Che---
    Che---
    2005-04-13

    Logged In: YES
    user_id=455149

    Hi,

    thanks for the info.
    Unfortunately , i'm unable to access the CVS repository
    (corporate firewall...).
    Is there an other way to get the latest sources (maybe a
    nightly tarball) ?

    If not, can you tell me when the next version (4.6) will be
    released, which includes these fixes?

    Thanks
    Che---

     
  • Che---
    Che---
    2005-04-14

    • status: open-fixed --> closed-fixed
     
  • Che---
    Che---
    2005-04-14

    Logged In: YES
    user_id=455149

    Hi,

    thanks for the fast release of 4.6.
    I have run my tests and all, as i can see yet, run now fine.

    Because i have accidentally changed the status in my last
    comment from pending to open, i rechange this again. But
    IMHO this Bug is fixed and could be closed.

    Che---