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 "Manjula Kutty (JIRA)" <ji...@apache.org> on 2007/11/16 20:37:43 UTC

[jira] Created: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

Convert derbynet/NSinSameJVM.java to junit
------------------------------------------

                 Key: DERBY-3211
                 URL: https://issues.apache.org/jira/browse/DERBY-3211
             Project: Derby
          Issue Type: Test
            Reporter: Manjula Kutty
            Assignee: Manjula Kutty
            Priority: Minor




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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

Posted by "Myrna van Lunteren (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12545924 ] 

Myrna van Lunteren commented on DERBY-3211:
-------------------------------------------

I see your point, the method is very specific to something I don't see how to accomplish with decorators/setups in converting testProperties.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty updated DERBY-3211:
---------------------------------

    Attachment: DERBY-3211_diff_11_19.txt
                DERBY-3211_stat_11_19.txt

Submitting new patch which takes care of Dan's comments. Please review and if looks good please commit

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

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

Manjula> I created a different policy file since the network server is started on a different port other than 1527.

Is it required, I don't see anything in the policy file that refers to port 1527?

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Rick Hillegas updated DERBY-3211:
---------------------------------

    Fix Version/s:     (was: 10.3.2.1)

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12552392 ] 

Knut Anders Hatlen commented on DERBY-3211:
-------------------------------------------

Hi Manjula, I think your approach basically looks good. Please see my comments below.

1) I think this code

+        NetworkServerControl serverControl = null;
+        int port = TestConfiguration.getCurrent().getPort();
+        String hostName = TestConfiguration.getCurrent().getHostName();
+        serverControl = new NetworkServerControl(InetAddress
+                .getByName(hostName), port);// initialized for the shutdown.

could be replaced by a call to NetworkServerTestSetup.getNetworkServerControl()

2)
+        try {
+            serverControl.shutdown();
+        } catch (Exception e) {
+            fail("Unexpected exception" + e.getMessage());
+            e.printStackTrace();
+        }

e.printStackTrace() won't ever be called, since it's placed right after a call to fail(). Anyway, I think it is better just to remove the try/catch/fail and let JUnit handle the exception itself.

3) I can't see that getNewPort() is used, so it's probably best to remove it.

4) It looks like most of the changes in TestConfiguration.java are reformatting/white-space changes. If you could post a new patch which only contained what's actually changed, it would be easier to review those changes.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>          Components: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt, DERBY_3211_diff_12_14.txt, DERBY_3211_stat_12_14.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty updated DERBY-3211:
---------------------------------

    Derby Info: [Patch Available]

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>          Components: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt, DERBY_3211_diff_12_14.txt, DERBY_3211_stat_12_14.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12545775 ] 

Knut Anders Hatlen commented on DERBY-3211:
-------------------------------------------

Hi Myrna,

I think this getAlternativePort() method attempts to do too much. I would expect it just to return a port number, and that two subsequent calls would return the same number. Starting the server in a getter method also feels a little strange. I liked Manjula's approach with using NetworkServerTestSetup to start and stop the server better, if only the port number was defined in TestConfiguration instead of in the test itself.

If the alternative port is not available, I think it is OK that the test fails, since that would be a problem with the environment, the same way as if the default port was not available or the hard disk was full.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Kathey Marsden updated DERBY-3211:
----------------------------------

    Component/s: Test

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>          Components: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


Re: [jira] Reopened: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

Posted by "Dag H. Wanvik" <Da...@Sun.COM>.
"Knut Anders Hatlen (JIRA)" <ji...@apache.org> writes:

>      [ https://issues.apache.org/jira/browse/DERBY-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>
> Knut Anders Hatlen reopened DERBY-3211:
> ---------------------------------------
>
>
> Reopening the issue since there are some remaining problems:
>
> 1) Dan's comment about try/catch/println is not addressed. As the test is written now, JUnit won't ever notice if the test fails, since all exceptions are swallowed.
>
> 2) I don't think the port number and host name should be hard coded
> in the test. Instead of "localhost", TestConfiguration.getHostName()
> should be used. Also, I think we need to add a method to
> TestConfiguration called getAlternativePort() or something, instead
> of hard coding the port number 20000 in the test. The point of
> centralizing the allocation of port numbers in TestConfiguration, is
> to enable people to run multiple JUnit tests in parallel on the same
> machine without conflicting with each other (there was an effort
> some time ago to achieve this, I don't remember how far they

I did some work on this, and at that point in time, no tests used any
port except the one found in TestConfiguration. I verified this by
tracing the server code opening the port. This state of things may
have deteriorated since, though.

Thanks,
Dag


[jira] Reopened: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Knut Anders Hatlen reopened DERBY-3211:
---------------------------------------


Reopening the issue since there are some remaining problems:

1) Dan's comment about try/catch/println is not addressed. As the test is written now, JUnit won't ever notice if the test fails, since all exceptions are swallowed.

2) I don't think the port number and host name should be hard coded in the test. Instead of "localhost", TestConfiguration.getHostName() should be used. Also, I think we need to add a method to TestConfiguration called getAlternativePort() or something, instead of hard coding the port number 20000 in the test. The point of centralizing the allocation of port numbers in TestConfiguration, is to enable people to run multiple JUnit tests in parallel on the same machine without conflicting with each other (there was an effort some time ago to achieve this, I don't remember how far they got). If we start hard-coding port numbers in the tests, this becomes much more difficult.

I also think the new decorator methods in TestConfiguration should not take port number as an argument, as that will encourage more tests to use arbitrary port numbers. Instead we should name them differently (e.g., defaultServerDecoratorWithAlternativePort), remove the port parameter, and let them use getAlternativePort() internally.

3) Class header for NSinSameJVMTest header says DRDAProtocolTest.

4) testShutdown() has a comment which says "Just connect, do something and close the connection", but there is no code to close the connection (or the statement) as far as I can see.

5) NSinSameJVMTest.java contains a mixture of tabs/spaces, which I think should be avoided in new files.

6) The new method TestConfiguration.defaultServerDecorator(Test,int) has a comment which says "This looks bogus to me." That doesn't sound very comforting... ;)

7) Why does the test need to sleep for five seconds before it finishes? It would be good to document this in a comment.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty updated DERBY-3211:
---------------------------------

    Attachment: DERBY_3211_diff_12_19.txt
                DERBY_3211_stat_12_19.txt

Thanks Knut for your input. Please find the attached patch with the recommended changes. If it looks good, please commit

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>          Components: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt, DERBY_3211_diff_12_14.txt, DERBY_3211_diff_12_19.txt, DERBY_3211_stat_12_14.txt, DERBY_3211_stat_12_19.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty updated DERBY-3211:
---------------------------------

    Derby Info: [Patch Available]

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_stat_11_16.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty commented on DERBY-3211:
--------------------------------------

If I don't give a seperate policy file for the port 20000 (which I used in this test) the test fails with the following exception.

$ java junit.textui.TestRunner org.apache.derbyTesting.functionTests.tests.derby
net.NSinSameJVMTest
.java.security.AccessControlException: access denied (java.net.SocketPermission
0.0.0.0:20000 connect,resolve)
        at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:264)
        at java.security.AccessController.checkPermission(AccessController.java:
427)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034)
        at java.net.Socket.connect(Socket.java:513)
        at java.net.Socket.connect(Socket.java:469)
        at java.net.Socket.<init>(Socket.java:366)
        at java.net.Socket.<init>(Socket.java:208)
        at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:202)
        at org.apache.derby.impl.drda.NetworkServerControlImpl$6.run(NetworkServ
erControlImpl.java:2358)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.setUpSocket(Netwo
rkServerControlImpl.java:2329)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.shutdown(NetworkS
erverControlImpl.java:927)
        at org.apache.derby.drda.NetworkServerControl.shutdown(NetworkServerCont
rol.java:348)
        at org.apache.derbyTesting.functionTests.tests.derbynet.NSinSameJVMTest.
testShutdown(NSinSameJVMTest.java:70)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:
95)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        at junit.textui.TestRunner.doRun(TestRunner.java:116)
        at junit.textui.TestRunner.start(TestRunner.java:172)
        at junit.textui.TestRunner.main(TestRunner.java:138)

So I thought the default hostname and ipaddress defaults to the default port of 1527. Should the policy file accept all the ports, without explicitly giving them in the policy file? If so then this will be a bug, else I need a seperate policy file just for the different port.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty updated DERBY-3211:
---------------------------------

    Attachment: DERBY-3211_diff_11_16.txt
                DERBY-3211_stat_11_16.txt

Please review this patch and if looks good please commit. I didn't delete the NSinSameJVM.java from derbyall. Will do that once this patch gets commited.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_stat_11_16.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

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

This is because your test *and* policy file is using a different *host* (0.0.0.0), not because it's using a different port number.

The policy file already handles a settable host file using derbyTesting.serverhost, I wonder though if this test should just use the default host (a different port number is fine) and not specifically 0.0.0.0. In special testing of 0.0.0.0 is needed then it probably should be set at a test configuration level and not hard-coded within a test.



> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

Posted by "Myrna van Lunteren (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12544855 ] 

Myrna van Lunteren commented on DERBY-3211:
-------------------------------------------

I thought the latest patch looked good, and as there were no further comments, I committed it to trunk with revision 597456, and removed the old test and masters etc. with revision 597466.

I intend to backport this to 10.3 - tomorrow.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Closed: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty closed DERBY-3211.
--------------------------------


Thanks Knut for committing this one

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>          Components: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt, DERBY_3211_diff_12_14.txt, DERBY_3211_diff_12_19.txt, DERBY_3211_stat_12_14.txt, DERBY_3211_stat_12_19.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

Posted by "Myrna van Lunteren (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12545642 ] 

Myrna van Lunteren commented on DERBY-3211:
-------------------------------------------

Coincidentally, I wrote a silly getAlternatePort() method for the TestConfiguration class.

Maybe some review of the method will be useful here - it'll take a bit longer before I have the test I'm working on (testProperties.java) converted. This is what I have so far:

    public int getAlternativePort() throws SQLException {

        Exception failException = null;
        // start with the default port + 1
        // there may be a smarter way to get the starting point...
        int possiblePort = getPort();
        if (!(possiblePort > 0))
            possiblePort = 1528;
        else
            possiblePort = getPort() + 1;
        try {
            boolean portOK = false;
            while (!portOK) {
                // check for first one in use
                NetworkServerControl networkServer =
                    new NetworkServerControl(InetAddress.getByName("localhost"), possiblePort);
                // Ping and wait for the network server to reply
                boolean started = false;

                    try {
                        networkServer.ping();
                        // If ping throws no exception the server is running
                        started = true;
                    } catch(Exception e) {         
                        failException = e;
                    }
                // Check if we got a reply on ping
                if (!started) {
                    // we'll assume we can use this port. 
                    // If there was some other problem with the pinging, it'll
                    // become clear when someone attempts to use the port
                    portOK = true;
                }
                else { // this port's in use.
                    possiblePort = possiblePort + 1;
                }
            }
        } catch (Exception e) {
            SQLException se = new SQLException("Error pinging network server");
            se.initCause(failException);
            throw se;
        }        
        return possiblePort;
    }

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

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

- Are there comments as to why a different security policy file is needed? It didn't jump out at me what was different about these policy files.

- Instead of code like this you can use the utility method: JDBC.assertDrainResults()
+			while (rs.next()) {
+				rs.getString(1);
+			}
+			rs.close();

- In a test fixture (e.g. testStartAndShutdown) there's no need to catch Exception like this:
+		} catch (Exception e) {
+			System.out.print("FAIL: Unexpected exception" + e.getMessage());
+			e.printStackTrace();
+		}

Junit will report a failure if an exception is thrown from a fixture.

- In testStartAndShutdown() any idea what this comment means? Since the fixture finishes there is no test code making sure of anything so
I wonder what it's trying to sat?

+			// Leave the connection open before shutdown to make 
+			// sure the thread closes down.

testStartAndShutdown() doesn't actually start the network server, that's handled by the decorator, right? If so the description and name of the fixture is misleading.






 


> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_stat_11_16.txt
>
>


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


[jira] Resolved: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Myrna van Lunteren resolved DERBY-3211.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 10.4.0.0
                   10.3.1.5

backported to 10.3 with revision 597751.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

Posted by "Myrna van Lunteren (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12545929 ] 

Myrna van Lunteren commented on DERBY-3211:
-------------------------------------------

On that note...
This test originally did something unique in the old test harness, which always kicked off a separate process for networkserver.
Now, in the junit framework, we're *always* starting networkserver within the same jvm, so what is the use of this test?

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty updated DERBY-3211:
---------------------------------

    Attachment: DERBY_3211_diff_12_14.txt
                DERBY_3211_stat_12_14.txt

Attaching my latest patch. Please review and if looks good please commit

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>          Components: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt, DERBY_3211_diff_12_14.txt, DERBY_3211_stat_12_14.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

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

The end of the fixture (testShutdown) has this line:

    Thread.sleep(5000)

Any idea why? It would be good to comment why this test is sleeping for 5 seconds at the end, if it's not required it should be removed.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty updated DERBY-3211:
---------------------------------

    Attachment: DERBY-3211_diff_11_19_ver2.txt
                DERBY-3211_stat_11_19_ver2.txt

Yes, I agree with you Dan. And I think it is OK to use the localhost instead of 0.0.0.0. So I made the changes accordingly and now there is no seperate policy file for this test. Please review this latest patch.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Updated: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Myrna van Lunteren updated DERBY-3211:
--------------------------------------

    Derby Info:   (was: [Patch Available])

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty commented on DERBY-3211:
--------------------------------------

I had the same question and found out that, now the test is used to test starting the server and shutdown with a different port and also shutting down with one open connection, and also felt it is good to have such a test. 

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt
>
>


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


[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Manjula Kutty commented on DERBY-3211:
--------------------------------------

Thank you for your comments Dan. Here are my thoughts regrding your questions. If I'm wrong in any context please correct me.

I created a different policy file since the network server is started on a different port other than 1527.

I will look in to the JDBC.assertDrainResults()  and will change my code accordingly. Will submit a patch soon with this change

Actually the test is not doing any explicit connecction.close(). Instead, it just shuts down the server and make sure no exceptions are thrown.

Yes. I agree that the server is started using the decorator. Will change the function name. 
 

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_stat_11_16.txt
>
>


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


[jira] Resolved: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit

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

Knut Anders Hatlen resolved DERBY-3211.
---------------------------------------

    Resolution: Fixed
    Derby Info:   (was: [Patch Available])

Thanks, Manjula! Committed revision 605719.

> Convert derbynet/NSinSameJVM.java to junit
> ------------------------------------------
>
>                 Key: DERBY-3211
>                 URL: https://issues.apache.org/jira/browse/DERBY-3211
>             Project: Derby
>          Issue Type: Test
>          Components: Test
>            Reporter: Manjula Kutty
>            Assignee: Manjula Kutty
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3211_diff_11_16.txt, DERBY-3211_diff_11_19.txt, DERBY-3211_diff_11_19_ver2.txt, DERBY-3211_stat_11_16.txt, DERBY-3211_stat_11_19.txt, DERBY-3211_stat_11_19_ver2.txt, DERBY_3211_diff_12_14.txt, DERBY_3211_diff_12_19.txt, DERBY_3211_stat_12_14.txt, DERBY_3211_stat_12_19.txt
>
>


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