You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kathey Marsden (JIRA)" <ji...@apache.org> on 2007/02/07 01:25:05 UTC

[jira] Created: (DERBY-2299) convert cursor.java to junit

convert cursor.java to junit
----------------------------

                 Key: DERBY-2299
                 URL: https://issues.apache.org/jira/browse/DERBY-2299
             Project: Derby
          Issue Type: Task
          Components: Test
    Affects Versions: 10.3.0.0
            Reporter: Kathey Marsden
            Priority: Minor
             Fix For: 10.3.0.0


Convert cursor.java to junit

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


Re: [jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by Myrna van Lunteren <m....@gmail.com>.
On 2/12/07, Daniel John Debrunner (JIRA) <ji...@apache.org> wrote:
>
>    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472525 ]
>
> The use of assertEquals in the converted test has the arguments the wrong way around.
>
>                assertEquals(1956, cursor.getInt(1));
>                assertEquals("hello world", cursor.getString(2).trim());
>
> http://www.junit.org/junit/javadoc/3.8.1/junit/framework/Assert.html
>
> static void     assertEquals(int expected, int actual)
>

This comment confused me. It seems to me that in the above examples
the expected int *is* the first parameter, and the actual *is* the
second, so those are correct....Or am I missing something there?

I did see one instance of assertEquals in the test where the expected
and actual appeared reversed:
    assertEquals(cursor.getCursorName(),"ForCoverageSake");


Then, To reply to Kathey's question:
>>I wonder whether we should test the different states in the test or
change the >>client SQLState to match embedded.

The documentation clearly states that differences in SQLState are
expected. (http://db.apache.org/derby/docs/10.2/adminguide/cadminappsclientdiffs.html).
Changing the SQLState to match embedded may be what we ought to do in
the bigger scheme of things, but I think it goes completely out of the
scope for this JIRA. You could log a separate bug for it. There may
already be a bug existing (I have not searched).

Finally, I have two nits:
- the file was committed(revision 506709) but no cross-reference was
done to the JIRA. I think it would be nice if that's done. I know not
everyone does this all the time, though.
- the new file has a mix of spaces and tabs. While I find that
acceptable in old code I think we should attempt a clean setup in new
code.

But - like I said, those are just nits.

Myrna

[jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by "Manjula Kutty (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472451 ] 

Manjula Kutty commented on DERBY-2299:
--------------------------------------

I think the test should run in both modes. There is a difference in the SQL state retuned in the n/w server mode. But the cursor behaviour is same in both. Please see the following discussion.

http://mail-archives.apache.org/mod_mbox/db-derby-dev/200702.mbox/%3cwjo8r6sz8zku.fsf@sun.com%3e 




> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt, DERBY_2299_2.txt
>
>
> Convert cursor.java to junit

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


[jira] Updated: (DERBY-2299) convert cursor.java to junit

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-2299:
----------------------------------

    Attachment: DERBY_2299_2.txt

Changes from first patch.
Manjula recommended I get rid of the try/catch blocks and use methods from BaseJDBCTestCase.  I didn't see what I needed so added assertNextError assertGetIntError to BaseJDBCTestCase and removed the try/catch blocks from CursorTest


> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt, DERBY_2299_2.txt
>
>
> Convert cursor.java to junit

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


[jira] Updated: (DERBY-2299) convert cursor.java to junit

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-2299:
----------------------------------

    Attachment: DERBY_2299.stat

> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt
>
>
> Convert cursor.java to junit

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


[jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by "Manjula Kutty (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472491 ] 

Manjula Kutty commented on DERBY-2299:
--------------------------------------

you can test the different SQL states with usingEmbedded/usingDerbyNet/usingDerbyNetClient methods from the BaseJdBCTestCase.

example:

if (usingEmbedded())
	assertStatementError("24000", delete);
else
	assertStatementError("XCL07", delete);

where delete is the prepared statement


> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt, DERBY_2299_2.txt
>
>
> Convert cursor.java to junit

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


[jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472487 ] 

Kathey Marsden commented on DERBY-2299:
---------------------------------------

MK>I think the test should run in both modes. There is a difference in the SQL state retuned in the n/w server mode. 

Thanks Manjula
I wonder whether we should test the different states in the test or change the client SQLState to match embedded.
If the answer is to change the test to check for different SQLStates for client,  how do I branch for a different test for client with a junit test?


> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt, DERBY_2299_2.txt
>
>
> Convert cursor.java to junit

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


[jira] Resolved: (DERBY-2299) convert cursor.java to junit

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden resolved DERBY-2299.
-----------------------------------

    Resolution: Fixed

> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt, DERBY_2299_2.txt
>
>
> Convert cursor.java to junit

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


[jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472395 ] 

Kathey Marsden commented on DERBY-2299:
---------------------------------------

I would appreciate if someone with some junit knowledge would review my conversion of cursor.java to a junit test CursorTest.java.  Please let me know of any improvements needed. This is my first attempt so I would appreciate a thorough review and any input,
 

> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt
>
>
> Convert cursor.java to junit

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


[jira] Updated: (DERBY-2299) convert cursor.java to junit

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-2299:
----------------------------------

    Attachment: DERBY_2299.txt

First pass at converting cursor.java to junit

> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.txt
>
>
> Convert cursor.java to junit

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


[jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472805 ] 

Kathey Marsden commented on DERBY-2299:
---------------------------------------

Thanks Dan for looking at this.  I do see one that I think is the wrong way around. 
assertEquals(cursor.getCursorName(),"ForCoverageSake");

but the ones you quoted seem right to me with the expected value first.

assertEquals(1956, cursor.getInt(1));
assertEquals("hello world", cursor.getString(2).trim()); 

I tested changing 1956 to a different value and got an error message "expected 19567 but was 1956"
I am sure I must be missing something quite obvious here, but could you clarify why these are wrong?


> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt, DERBY_2299_2.txt
>
>
> Convert cursor.java to junit

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


[jira] Closed: (DERBY-2299) convert cursor.java to junit

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden closed DERBY-2299.
---------------------------------


> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt, DERBY_2299_2.txt
>
>
> Convert cursor.java to junit

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


[jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by "Daniel John Debrunner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472818 ] 

Daniel John Debrunner commented on DERBY-2299:
----------------------------------------------

Sorry my fault.
The first version of the patch had a number of assertEquals() wrong and I made the mistake of thinking it was across the whole class.
Then I went and quoted the wrong ones, I even know I double checked it, but still messed up. :-(


> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt, DERBY_2299_2.txt
>
>
> Convert cursor.java to junit

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


[jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by "Rajesh Kartha (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472431 ] 

Rajesh Kartha commented on DERBY-2299:
--------------------------------------

I applied the patch and was able to run the test succesfully in Embedded. 

Comparing the orginal cursor.java the new test I did not find  the following in the new one:
testCursorName("select * from t for update of i", "myselect");


Also, the test seem to run only in embedded mode, are there plans to make it run under Network server?. 
I tried running it under both using 

return TestConfiguration.defaultSuite(CursorTest.class);

in the suite() method.

With the Network server I noticed the SQLStates returned are different for line 87:

assertEquals("Wrong SQLState thrown",se.getSQLState(),"24000");

I am getting  XJ121 (Invalid operation at current cursor position) instead of the 
expected 24000 (Invalid cursor state - no current row) so the tests failed for me with Network Server.



> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt
>
>
> Convert cursor.java to junit

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


[jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by "Manjula Kutty (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472412 ] 

Manjula Kutty commented on DERBY-2299:
--------------------------------------

I made a very quick review. And everything works fine. 

I'm also not an expert in the junit world. But here is what I think to make this test look better

most of the try catch block can be replaced by assertStatementError methods from the BaseJDBCTestCase.java. Please see Dan's comments for DERBY-2283



> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt
>
>
> Convert cursor.java to junit

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


Re: [jira] Assigned: (DERBY-2299) convert cursor.java to junit

Posted by "Dag H. Wanvik" <Da...@Sun.COM>.
Bryan Pendleton <bp...@amberpoint.com> writes:

>> Kathey Marsden reassigned DERBY-2299:
>> -------------------------------------
>>     Assignee: Kathey Marsden
>
> Hi Kathey, welcome back!
>
> It's nice to see you back in the Derby community.

In deed :) Welcome back!

Cheers,

Dag

Re: [jira] Assigned: (DERBY-2299) convert cursor.java to junit

Posted by Bryan Pendleton <bp...@amberpoint.com>.
> Kathey Marsden reassigned DERBY-2299:
> -------------------------------------
> 
>     Assignee: Kathey Marsden

Hi Kathey, welcome back!

It's nice to see you back in the Derby community.

thanks,

bryan


[jira] Assigned: (DERBY-2299) convert cursor.java to junit

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden reassigned DERBY-2299:
-------------------------------------

    Assignee: Kathey Marsden

> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>
> Convert cursor.java to junit

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


[jira] Commented: (DERBY-2299) convert cursor.java to junit

Posted by "Daniel John Debrunner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472525 ] 

Daniel John Debrunner commented on DERBY-2299:
----------------------------------------------

The use of assertEquals in the converted test has the arguments the wrong way around.

		assertEquals(1956, cursor.getInt(1));
		assertEquals("hello world", cursor.getString(2).trim());

http://www.junit.org/junit/javadoc/3.8.1/junit/framework/Assert.html

static void 	assertEquals(int expected, int actual) 

While it doesn't make a difference when the test passes, it does when it fails. The output provided by the method will give the wrong information to the person trying to resolve the failure, since the expected and actual will be switched in the message. This has the potential to waste tiem and confuse people.

> convert cursor.java to junit
> ----------------------------
>
>                 Key: DERBY-2299
>                 URL: https://issues.apache.org/jira/browse/DERBY-2299
>             Project: Derby
>          Issue Type: Task
>          Components: Test
>    Affects Versions: 10.3.0.0
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY_2299.stat, DERBY_2299.txt, DERBY_2299_2.txt
>
>
> Convert cursor.java to junit

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