sqlunit not working

Anais
2008-06-13
2013-04-25
  • Anais
    Anais
    2008-06-13

    Hello,

    I run this sqlunit test and i have this incredible output that doesn't help at all.
    Did this happen to you?
    Suggestions are more than welcome.

    Many thanks in advance!

    --------------------------------------------
    --------------------------------------
    SQLunit test case
    --------------------------------------
    <!DOCTYPE sqlunit SYSTEM "sqlunit.dtd" [
    <!ENTITY connection SYSTEM "../canoo/includes/connection.xml">
    ]>
    <sqlunit>

    &connection
     
      <test name="Log request" assert="equal">
        <sql>
          <stmt>SELECT zone_id FROM data_raw_ad_request WHERE ad_id=4</stmt>
        </sql>
        <result echo="true">
          <resultset id="1">
            <row id="1">
              <col id="1" type="INTEGER" name="zone_id">3</col>
            </row>
          </resultset>
        </result>
      </test>
     
    </sqlunit>

    ---------------------------------------
    -------------------------------------- 
    OUTPUT
    --------------------------------------
    --------------------------------------
    [sqlunit] Getting connection(DEFAULT)
      [sqlunit] Setting up test...
      [sqlunit] Running test[1]: Log request (0ms)
      [sqlunit] At ${result[1,1,1]}, could not convert java.lang.Long returned from database to INTEGER(4)
      [sqlunit] Tearing down test...
      [sqlunit] sqlunit-ant: SQLUnit Tests Failed: In file: path/to/sqlunit/testcase/log_request.xml, tests: 1, failures: 1, errors = 0
      [sqlunit] SQLUnit Tests Failed: In file: path/to/sqlunit/testcase/log_request.xml, tests: 1, failures: 1, errors = 0

     
    • Sujit Pal
      Sujit Pal
      2008-06-13

      It is telling you that zone_id is being returned as a java.lang.Long, which your driver does not believe maps to a sql.types.Type.INTEGER.

      Check out types.properties to override the setting for your driver if you believe the default mapping is incorrect for your driver. If I remember correctly, there is documentation in the types.properties file (or in the user manual) what you need to do to find your driver name, etc.

      HTH
      -sujit

       
    • Anais
      Anais
      2008-06-19

      Thank you for answering to me.
      I am still a little confuse reading you response.

      I think i should mention something else about how i run sqlunit tests.
      I integrated it in webtest.
      But the fact it doesn't work means that maybe it is not really integrated.

      I understand ths first part that "zone_id is being returned as a java.lang.Long, which your driver does not believe maps to a sql.types.Type.INTEGER."

      The second part with "Check out types.properties to override the setting for your driver " is not clear to me.
      If you could be more precise.
      i am not an expert.

      What I know is that i have a user.remote.properties file where i define the driver
      ant.sql.driver= com.mysql.jdbc.Driver

      I think this is correct.
      Why shouldn't it be correct?

      What do you understand when you say that "the default mapping is incorrect for your driver"?
      Are you refering to the property ant.sql.driver= com.mysql.jdbc.Driver
      and it's value?

      Where is this types.properties file that you talk about?
      Is it a java file?

      Please can you give some more precisions?

      Thank u in advance.

       
    • Sujit Pal
      Sujit Pal
      2008-06-21

      There is a types.properties in the JAR file that defines the default mappings and special mappings of data types per driver. In your case you are using MySQL. You can either explode the JAR file and update the types.properties and JAR it back up, or you can (I think) use types.user.properties to augment/override the default types.properties.

      The manual should provide more info.

      -sujit

       
    • Ilya Kalujny
      Ilya Kalujny
      2008-08-01

      I have to add to this topic:

      Mysql now supports stored procedures and we are using SQLUnit to unit test our DB schema (SQLUnit is great, Thanks a lot Sujit)
      I have to say that i did what was proposed in types.properties and mentioned in documentation. The problem is that mysql connector driver works differently with int(n) mysql type: if its unsigned it returns INTEGER as java.lang.Long and if its unsigned it returns INTEGER as java.lang.Integer. Since types.properties only allows for having only one conversion per type.

      Luckily my DB schema allowed me to get rid of unsigned ints, since they were irrelevant, but hope this can be modified in the future.

      Thanks.