db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r533889 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
Date Mon, 30 Apr 2007 23:57:17 GMT
Author: myrnavl
Date: Mon Apr 30 16:57:17 2007
New Revision: 533889

URL: http://svn.apache.org/viewvc?view=rev&rev=533889
Log:
DERBY-1496 - speeding up NSSecurityMechanismTest by shutting down database before bouncing
server, so sleeping is not necessary. Also made methods private where possible.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java?view=diff&rev=533889&r1=533888&r2=533889
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
Mon Apr 30 16:57:17 2007
@@ -43,6 +43,7 @@
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.J2EEDataSource;
 import org.apache.derbyTesting.junit.JDBCDataSource;
+import org.apache.derbyTesting.junit.NetworkServerTestSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
 import junit.framework.Test;
@@ -349,13 +350,29 @@
             {
                 assertUSRSSBPWD_with_BUILTIN(testDERBY528ExpectedValues);
             }
+            else
+            {
+                // shutdown the database - this will prevent slow startup 
+                // when bouncing the server with next security mechanism.
+                // for ENCRYPTED_USER_AND_PASSWORD_SECURITY:
+                short secmeccode=SECMEC_EUSRIDPWD;
+                if (derby_drda_securityMechanism.equals("USER_ONLY_SECURITY"))
+                    secmeccode=SECMEC_USRIDONL;
+                else if (derby_drda_securityMechanism.equals(
+                    "CLEAR_TEXT_PASSWORD_SECURITY"))
+                    secmeccode=SECMEC_USRIDPWD;
+                assertConnectionUsingDriverManager(getJDBCUrl(
+                    "user=APP;password=APP;shutdown=true;securityMechanism=" +
+                    secmeccode)," BUILTIN (T5):",
+                    "08006");
+            }
         }
     }
     
     // returns a boolean true if the security mechanism is not supported
     // so the loop in which this is called can be continued without
     // causing unnecessary/impossible tests to be run
-    public boolean setSecurityMechanism(String derby_security_mechanism) 
+    private boolean setSecurityMechanism(String derby_security_mechanism) 
     throws Exception {
         try {
         // getting a networkservercontrol to shutdown the currently running 
@@ -367,7 +384,6 @@
 
         // shut down the server
         server.shutdown();
-        Thread.sleep(500);
         } catch (Exception e) {
             if (!(e.getMessage().substring(0,17).equals("DRDA_InvalidValue")))
             {
@@ -396,9 +412,7 @@
             //server2.start(new PrintWriter(System.out, true));
             // and comment out:
             server2.start(null);
-            // TODO: sleep ridiculously long, otherwise getting 08001 errors
-            //       even when the server is up.
-            Thread.sleep(120000);
+            NetworkServerTestSetup.waitForServerStart(server2);
             
             if (derby_drda_securityMechanism.equals("") ||
                 derby_drda_securityMechanism.equals("INVALID_VALUE"))
@@ -430,7 +444,7 @@
         return false;
     }
 
-    public void assertConnectionsUsingDriverManager(String[] expectedValues)
+    private void assertConnectionsUsingDriverManager(String[] expectedValues)
     {
         assertConnectionUsingDriverManager(
             getJDBCUrl(null),"T1:", expectedValues[1]);
@@ -466,7 +480,7 @@
     /**
      * Get connection from datasource and also set security mechanism
      */
-    public void assertConnectionUsingDataSource(String[] expectedValues)
+    private void assertConnectionUsingDataSource(String[] expectedValues)
     {
         // Note: bug in jcc, throws error with null password
         if (usingDerbyNetClient())
@@ -502,7 +516,7 @@
         }
     }
 
-    public void assertSecurityMechanismOK(String user, String password,
+    private void assertSecurityMechanismOK(String user, String password,
         Short secmec, String msg, String expectedValue)
     {
         Connection conn;
@@ -559,7 +573,7 @@
         }
     }
 
-    public void assertConnectionUsingDriverManager(
+    private void assertConnectionUsingDriverManager(
         String dbUrl, String msg, String expectedValue)
     {
         try
@@ -788,7 +802,7 @@
      |     |      |8       |N         | -       -       Err1         |
      ================================================================= 
      */
-    public void assertAllCombinationsOfUserPasswordSecMecInputOK(
+    private void assertAllCombinationsOfUserPasswordSecMecInputOK(
         String[] expectedValues) {
         // Try following combinations:
         // user { null, user attribute given}
@@ -895,7 +909,7 @@
      * @param password password
      * @param expectedValue expected sql state
      */
-    public void getDataSourceConnection(
+    private void getDataSourceConnection(
         String user, String password, String expectedValue)
     {
         Connection conn;
@@ -937,7 +951,7 @@
      * @param sqle SQLException whose complete chain of exceptions is
      * traversed and sqlstate and message is printed out
      */
-    public static void dumpSQLException(SQLException sqle)
+    private static void dumpSQLException(SQLException sqle)
     {
         while ( sqle != null)
         {
@@ -958,7 +972,7 @@
      * @param secmec security mechanism for datasource
      * @throws Exception
      */
-    public void assertSecMecWithConnPoolingOK(
+    private void assertSecMecWithConnPoolingOK(
         String user, String password, Short secmec) throws Exception
     {
         Connection conn;
@@ -982,6 +996,7 @@
         conn.close();
         conn = pc.getConnection();
         assertConnectionOK(conn);
+        pc.close();
         conn.close();
     }
 
@@ -990,7 +1005,7 @@
      * @param   conn    database connection
      * @throws Exception if there is any error
      */
-    public void assertConnectionOK(Connection conn)
+    private void assertConnectionOK(Connection conn)
     throws Exception
     {
         Statement stmt = conn.createStatement();
@@ -1059,7 +1074,7 @@
      * derby.drda.securityMechanism to restrict client connections based on
      * the security mechanism.
      */
-    public void assertDerby1080Fixed(String expectedValue)
+    private void assertDerby1080Fixed(String expectedValue)
     {
         try
         {
@@ -1100,7 +1115,7 @@
      * 
      * @throws Exception if there an unexpected error
      */
-    public void assertUSRSSBPWD_with_BUILTIN(String[] expectedValues)
+    private void assertUSRSSBPWD_with_BUILTIN(String[] expectedValues)
     {
         // Turn on Derby BUILTIN authentication and attempt connecting with
         // USRSSBPWD security mechanism.
@@ -1191,7 +1206,7 @@
         }
     }
     
-    public Connection getDataSourceConnectionWithSecMec(
+    private Connection getDataSourceConnectionWithSecMec(
         String user, String password, Short secMec)
     {
         Connection conn = null;
@@ -1221,7 +1236,7 @@
         return conn;
     }
 
-    public String getJDBCUrl(String attrs) {
+    private String getJDBCUrl(String attrs) {
         String dbName = 
             TestConfiguration.getCurrent().getDefaultDatabaseName();
         // s is protocol, subprotocol, + dbName
@@ -1235,12 +1250,12 @@
         return s;
     }
 
-    public javax.sql.DataSource getDS(String user, String password)
+    private javax.sql.DataSource getDS(String user, String password)
     {
         return getDS(user,password,null);
     }
 
-    public javax.sql.DataSource getDS(
+    private javax.sql.DataSource getDS(
         String user, String password, HashMap attrs)
     {
         if (attrs == null)
@@ -1290,7 +1305,7 @@
         return attrs;
     }
 
-    public javax.sql.ConnectionPoolDataSource getCPDS(
+    private javax.sql.ConnectionPoolDataSource getCPDS(
         String user, String password)
     {
         HashMap attrs = new HashMap();
@@ -1310,7 +1325,7 @@
         return cpds;
     }
 
-    public static String getSetterName(String attribute)
+    private static String getSetterName(String attribute)
     {
         return "set" + Character.toUpperCase(attribute.charAt(0)) +
             attribute.substring(1);
@@ -1323,5 +1338,4 @@
         if (expectedValue.equals("08001.C.8"))
             assertEquals("Password can not be null.", sqle.getMessage());
     }
-    
 }



Mime
View raw message