Menu

Version 2.1 solves some problems in 2.0

Anonymous
2003-09-30
2013-04-25
  • Anonymous

    Anonymous - 2003-09-30

    so far so good.
    All the Bugs that cropped up in 2.0 have been routed.
    set works and variable access across tests also seems to be doing great.

     
    • Sujit Pal

      Sujit Pal - 2003-10-04

      Thats really good to know :-).
      Let me know if you come across something.

      Thanks
      -sujit

       
    • Anonymous

      Anonymous - 2003-10-06

      oops! found one teeny weeny bug....

      Sybase 11.x

      lest say my stored procedure has an output parameter @e .This is not set to anything in the procedure .This means that the variable has a null on the receiving end.

      sqlunit cannot handle this.

      is there a way to work this out other than chaning my procedure (ie setting value of @e to something when nothing will be assigned to it)

      pls look into this....

       
    • Sujit Pal

      Sujit Pal - 2003-10-07

      Does SQLUnit complain about this? If so, if you can send me the stack trace, that will be very helpful. I see that there is code in CallHandler to check if the object returned by CallableStatement.getObject(int) is null, and if so, to print the String "NULL" in the output.
      I am going to build a test case to test this scenario out too, and will update when I am done.

       
    • Anonymous

      Anonymous - 2003-10-08

      SYBASE 11.x---sqlunit 2.1
      #################################
      my stored procedure will be

      use Test
      go
      if exists(select 1
          from sysobjects
          where name = 'sp_test'
          and type = 'P')
      drop procedure sp_test
      go

      CREATE PROCEDURE sp_test
          @Out_intval        int OUTPUT,
          @Out_varcharval        varchar(100) OUTPUT

      AS
      BEGIN
          select count(*) from SSTbl
                     
      END
      go

      grant execute on sp_test to User
      go
      ###########################################
      my test case will be

          <test name="sp_test">
              <call>
            <stmt>{?=call Test..sp_test(?,?)}</stmt>
              <param id="1" type="INTEGER" inout="out">${rc}</param>
              <param id="2" type="INTEGER" inout="out">${errcode}</param>
              <param id="3" type="VARCHAR" inout="out">${errdesc}</param>
           </call>
             <result>
                   <outparam id="1" type="INTEGER">0</outparam>
               </result>
          </test>
      #########################################
      the stack trace :

      Running test[1]: sp_test (116ms)
        [sqlunit] Tearing down test...
        [sqlunit] net.sourceforge.sqlunit.SQLUnitException: SQLUnit Tests Failed: In file: ../../test/sybase/SuperSeva/su/test.xml, tests: 1, failures: 1, errors = 0
        [sqlunit]     at net.sourceforge.sqlunit.SQLUnit.testWrapper(SQLUnit.java:96)
        [sqlunit]     at net.sourceforge.sqlunit.SQLUnit.runTest(SQLUnit.java:82)
        [sqlunit]     at junit.framework.TestCase.runBare(TestCase.java:140)
        [sqlunit]     at net.sourceforge.antsqlunittask.SqlunitTask.execute(SqlunitTask.java:76)
        [sqlunit]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:193)
        [sqlunit]     at org.apache.tools.ant.Task.perform(Task.java:341)
        [sqlunit]     at org.apache.tools.ant.Target.execute(Target.java:309)
        [sqlunit]     at org.apache.tools.ant.Target.performTasks(Target.java:336)
        [sqlunit]     at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
        [sqlunit]     at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
        [sqlunit]     at org.apache.tools.ant.Main.runBuild(Main.java:609)
        [sqlunit]     at org.apache.tools.ant.Main.start(Main.java:196)
        [sqlunit]     at org.apache.tools.ant.Main.main(Main.java:235)
        [sqlunit] Caused by: net.sourceforge.sqlunit.SQLUnitException: null
        [sqlunit]     at net.sourceforge.sqlunit.CallHandler.process(CallHandler.java:208)
        [sqlunit]     at net.sourceforge.sqlunit.TestHandler.process(TestHandler.java:77)
        [sqlunit]     at net.sourceforge.sqlunit.SQLUnit.processDoc(SQLUnit.java:149)
        [sqlunit]     at net.sourceforge.sqlunit.SQLUnit.testWrapper(SQLUnit.java:93)
        [sqlunit]     ... 12 more
        [sqlunit] Caused by: java.lang.NullPointerException
        [sqlunit]     at net.sourceforge.sqlunit.SqlTypeUtils.convertToString(SqlTypeUtils.java:343)
        [sqlunit]     at net.sourceforge.sqlunit.CallHandler.process(CallHandler.java:196)
        [sqlunit]     ... 15 more
      ###########################################
      if i modify my procedure to be this evting is fine.....

      CREATE PROCEDURE sp_test
          @Out_intval        int OUTPUT,
          @Out_varcharval        varchar(100) OUTPUT

      AS
      BEGIN
          select count(*) from SSRequestTbl
          select     @Out_intval=1
          select  @Out_varcharval    ="out"
                 
      END
      go
      ##################################
      if u grep the stack trace the culprit is defn in CallHandler

      cheers
      lakshmi

       
    • Sujit Pal

      Sujit Pal - 2003-10-09

      I am not able to reproduce the problem with my current version (pre 2.2). Also it looks like your test case specification is not correct. I am going to check in the stored procedure I used:
      test/sybase/TestNullOutParam.sql
      and the test specification in the test named: sp_TestNullOutParam in test/sybase/test.xml. Here is the result I get from running the test:
        [sqlunit] Running test[7]: running sp_TestNullOutParam (26ms)
        [sqlunit] No match on #-variables,
        [sqlunit] *** expected:
        [sqlunit] <result>
        [sqlunit]   <outparam id="1" type="INTEGER">0</outparam>
        [sqlunit] </result>
        [sqlunit] *** but got:
        [sqlunit] <result>
        [sqlunit]   <outparam id="2" type="INTEGER">NULL</outparam>
        [sqlunit]   <outparam id="1" type="INTEGER">0</outparam>
        [sqlunit]   <outparam id="3" type="VARCHAR">NULL</outparam>
        [sqlunit]   <resultset id="1">
        [sqlunit]     <row id="1">
        [sqlunit]       <col id="1" type="INTEGER">1</col>
        [sqlunit]     </row>
        [sqlunit]   </resultset>
        [sqlunit] </result>
        [sqlunit]
        [sqlunit] Tearing down test...
        [sqlunit] SQLUnit Tests Failed: In file: test/sybase/test.xml, tests: 7, failures: 1, errors = 0
      As you will notice, SQLUnit correctly insists that your <result> tag must contain a single resultset (from your select count(*) from SSTbl) and also sets the outparam ids 2 and 3 to NULL. It also reports a test failure rather than throwing a stack trace, another desirable behavior IMO :-).
      As far as I know, I only changed the logging behavior for 2.2 as well as fixed some bugs for Sowmya, not sure if the fix slipped in somehow :-). In any case, can you give it a try with 2.2 due to go out tonight?

      Thanks
      Sujit

       
      • Arun

        Arun - 2004-09-27

        Sujit,
        I think this problem of null values in the return out-params of stored procedures has re-appeared in release 4.0. The code segment to convert null parameter in result object in CallHandler is missing. I think it would look like:
                        // get the value from the CallableStatement
                        Object value = tcs.getObject(i + 1);
                        // if returned value is null then force it to string "NULL"
                       //  Changes Start ...
                        if (value == null){
                           value = "NULL";
                        }
                       //  ... Changes Finish

        When I made this correction it took care of the problem. Note: I tested it only in Oracle.

        Thanks. Arun.

         
        • Sujit Pal

          Sujit Pal - 2004-09-27

          Hi Arun,

          BTW, you may want to open new threads, since people tend not to look at version specific messages...

          Are you working with the release 4.0 version or the latest one in CVS? If the former, then you are right, I missed that, but I put it in when Chris pointed out the problem with nulls in the resultset. It should be formally available in 4.1, but is already there in CVS. The fix is actually a litle further down. Each Type object knows to return a "NULL" string in its toString() method if the value of the wrapped object is null.

          Your fix will also work, of course. My initial reaction to Chris's report was to do something similar on the ResultSetBean, but then I decided that I could do this just as well in the Type objects (once in UnsupportedType and use inheritance to propagate this behavior), since the conversion knowledge should legitimately belong to the Type object and not with the caller.

          -sujit

           

Log in to post a comment.