Regarding the testParameterMetadataWithXXXParameters () fixtures that
do test the parameterMetaData, I am proposing to modify
testParameterMetadataWithXXXParameters () to include parameterMetaData
tests as follows. Feedback is appreciated.

      /**
        *  test ParameterMetaData for Java procedures with INTEGER parameters
        */
       public void testParameterMetadataWithINTParameters () throws
SQLException {

               if(!usingDerbyNetClient())
               {
                       Statement stmt = createStatement();
                       stmt.execute("CREATE PROCEDURE PMDI(IN pmdI_1
INTEGER, IN pmdI_2 INTEGER, INOUT pmdI_3 INTEGER, OUT pmdI_4 INTEGER)
language java parameter style java external name
'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummyint'");
                       CallableStatement cs = prepareCall("CALL
PMDI(?, ?, ?, ?)");

                       // parameters 1 and 2 are input only
                       cs.setInt(1,1);
                       cs.setInt(2,1);
                       // parameter 3 is input and output
                       Object x = new Integer(1);
                       cs.setObject(3,x, Types.INTEGER);
                       cs.registerOutParameter(3,Types.INTEGER);
                       //parameter 4 is output only
                       cs.registerOutParameter(4,Types.INTEGER);

                       //verify the meta data for the parameters
                       ParameterMetaData paramMetaData =
cs.getParameterMetaData();
                       assertEquals("Unexpected parameter count", 4,
paramMetaData.getParameterCount());

                       cs.close();
                       stmt.execute("DROP PROCEDURE PMDI");
               }
       }
      /**
        *  test ParameterMetaData for Java procedures with CHAR parameters
        */
        public void testParameterMetadataWithCHARParameters () throws
SQLException {
               if(!usingDerbyNetClient())
               {
                       Statement stmt = createStatement();
                       stmt.execute("CREATE PROCEDURE PMDC(IN pmdI_1
CHAR(10), IN pmdI_2 VARCHAR(25), INOUT pmdI_3 CHAR(19), OUT pmdI_4
VARCHAR(32)) language java parameter style java external name
'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummyString'");
                       CallableStatement cs = prepareCall("CALL
PMDC(?, ?, ?, ?)");
                       // parameters 1 and 2 are input only
                       cs.setString(1, "TEST0");
                       cs.setString(2, "TEST1");
                       // parameter 3 is input and output
                       Object x = new String("TEST");
                       cs.setObject(3,x, Types.CHAR);
                       cs.registerOutParameter(3,Types.CHAR);
                       //parameter 4 is output only
                       cs.registerOutParameter(4,Types.CHAR);
                       //verify the meta data for the parameters
                       ParameterMetaData paramMetaData =
cs.getParameterMetaData();
                       assertEquals("Unexpected parameter count", 4,
paramMetaData.getParameterCount());

                       cs.close();
                       stmt.execute("DROP PROCEDURE PMDC");
               }
       }
       /**
        *  test ParameterMetaData for Java procedures with DECIMAL parameters
        */
       public void testParameterMetadataWithDECIMALParameters ()
throws SQLException {

               if(!usingDerbyNetClient())
               {
                       Statement stmt = createStatement();
                       stmt.execute("CREATE PROCEDURE PMDD(IN pmdI_1
DECIMAL(5,3), IN pmdI_2 DECIMAL(4,2), INOUT pmdI_3 DECIMAL(9,0), OUT
pmdI_4 DECIMAL(10,2)) language java parameter style java external name
'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummyDecimal'");
                       CallableStatement cs = prepareCall("CALL
PMDD(?, ?, ?, ?)");

                       // parameters 1 and 2 are input only
                       cs.setBigDecimal(1,new BigDecimal("1"));;
                       cs.setBigDecimal(2,new BigDecimal("1"));;
                       // parameter 3 is input and output
                       Object x = new BigDecimal(1.1);
                       cs.setObject(3,x, Types.DECIMAL);
                       cs.registerOutParameter(3,Types.DECIMAL);
                       //parameter 4 is output only
                       cs.registerOutParameter(4,Types.DECIMAL);
                       //verify the meta data for the parameters
                       ParameterMetaData paramMetaData =
cs.getParameterMetaData();
                       assertEquals("Unexpected parameter count", 4,
paramMetaData.getParameterCount());


                       cs.close();
               }
       }
       /**
        *  test ParameterMetaData for Java procedures with some
literal parameters
        */
       public void testParameterMetadataWithLITERALParameters ()
throws SQLException {

               if(!usingDerbyNetClient())
               {
                       Statement stmt = createStatement();
                       CallableStatement cs = prepareCall("CALL
PMDD(32.4, ?, ?, ?)");
                       // parameters 2 is input only
                       cs.setBigDecimal(1,new BigDecimal("1"));;
                       // parameter 3 is input and output
                       Object x = new BigDecimal(1.1);
                       cs.setObject(2,x, Types.DECIMAL);
                       cs.registerOutParameter(2,Types.DECIMAL);
                       //parameter 4 is output only
                       cs.registerOutParameter(3,Types.DECIMAL);

                       //verify the meta data for the parameters
                       ParameterMetaData paramMetaData =
cs.getParameterMetaData();
                       assertEquals("Unexpected parameter count", 3,
paramMetaData.getParameterCount());
                       cs.close();

                       cs = prepareCall("CALL PMDD(32.4, 47.9, ?, ?)");
                       // parameter 3 is input and output
                       Object y = new BigDecimal(1.1);
                       cs.setObject(1,y, Types.DECIMAL);
                       cs.registerOutParameter(1,Types.DECIMAL);
                       //parameter 4 is output only
                       cs.registerOutParameter(2,Types.DECIMAL);
                       paramMetaData = cs.getParameterMetaData();
                       assertEquals("Unexpected parameter count", 2,
paramMetaData.getParameterCount());
                       cs.close();

                       cs = prepareCall("CALL PMDD(?, 38.2, ?, ?)");
                       // parameters 1 is input only
                       cs.setBigDecimal(1,new BigDecimal("1"));;
                       // parameter 3 is input and output
                       Object z = new BigDecimal(1.1);
                       cs.setObject(2,z, Types.DECIMAL);
                       cs.registerOutParameter(2,Types.DECIMAL);
                       //parameter 4 is output only
                       cs.registerOutParameter(3,Types.DECIMAL);

                       //verify the meta data for the parameters
                       paramMetaData = cs.getParameterMetaData();
                       assertEquals("Unexpected parameter count", 3,
paramMetaData.getParameterCount());

                       cs.close();
                       stmt.execute("DROP PROCEDURE PMDD");
               }
       }


On 5/30/07, Kathey Marsden (JIRA) <[EMAIL PROTECTED]> wrote:

    [ 
https://issues.apache.org/jira/browse/DERBY-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500234
 ]

Kathey Marsden commented on DERBY-2658:
---------------------------------------

Thanks Ramin for looking at this test conversion.  The main thing I think is 
that we really need to make sure that we are testing everything the old test 
tested.  Below are some specific comments, but it would be good to do a close 
review comparing the old and new test to make sure that we have assertions for 
all of the cases that were tested by canon comparison before.  Anyway, here are 
some comments ....

Typically the test class name for the junit tests starts with a capital letter. 
e.g. ParameterMetaDataJdbc30Test

parameterMetaDataJdbc30_app.properties and master/parameterMetaDataJdbc30.out  
should be deleted.

Attach the output of svn stat to your next patch.


When I run the test all the tests fail with
parameterMetaDataJdbc30Test)java.sql.SQLException: Schema 'SAMPLE' does not 
exist
This is I think because setUp attempts to drop the table that is not there.
I think you would be better off using  CleanDatabaseSetup and the decorateSQL 
method to create your table and function, rather than creating it with each 
fixture.  There are lots of examples of CleanDatabaseSetup usage in other tests.

The dumpExpectedSQLExceptions method only checks an SQLException's sqlstate 
against itself, so would always pass.  Instead of calls to 
dumpExpectedSQLExceptions
you should have assertSQLState("XXXXX",e) where XXXX is the hardcoded expected 
SQLState. You can see the expected states by looking at the canon in 
functionTests/master/parameterMetaDataJdbc30.out or just temporarily printing  SQLState 
to see what it is.


Calls like      assertTrue ("Jira 44 failed.", "22019".equals(e.getSQLState()) 
can be replaced by assertSQLState

The System.out's in the old test need to be translated into assertions. e.g.
//System.out.println("parameters count for callable statement is: " + 
paramMetaData.getParameterCount());
should be replaced with an assertEquals call.

dumpParameterMetaDataNegative doesn't look quite right to me. It seems like it 
would always fail. Instead of

try {
                        fail("parameter isNullable " + 
paramMetaData.isNullable(-1));
                } catch (SQLException e) {
                        dumpExpectedSQLExceptions(e);
                }

I would expect something like.
try {
        parameterMetaData.isNullable(-1);
        fail("parameterMetaData.isNullable(-1) should have failed);
    } catch (SQLException se)
        {
        assertSQLState("XCL13",se.getSQLState());
        }

For the code where we have if(!usingDerbyNetClient()) there should be an 
explanation of why we don't run with client with a Jira reference.  If there is 
a bug and it is not filed, file one.

The fixtures testParameterMetadataWithXXXParameters () doesn't actually seem to 
test the parameterMetaData.  I don't know if that is an artifact of the old 
test but we should add in some testing.




> Convert jdbcapi/parameterMetaDataJdbc30.java to JUnit
> -----------------------------------------------------
>
>                 Key: DERBY-2658
>                 URL: https://issues.apache.org/jira/browse/DERBY-2658
>             Project: Derby
>          Issue Type: Test
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Ramin Moazeni
>            Assignee: Ramin Moazeni
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY-2658.diff
>
>
> Convert jdbcapi/parameterMetaDataJdbc30.java to JUnit.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Reply via email to