[jira] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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
[ 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
[ 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] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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 2 (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:2 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] Commented: (DERBY-3211) Convert derbynet/NSinSameJVM.java to junit
[ 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.