db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r741227 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi: LDAPAuthenticationTest.java XAJNDITest.java
Date Thu, 05 Feb 2009 18:42:28 GMT
Author: myrnavl
Date: Thu Feb  5 18:42:27 2009
New Revision: 741227

URL: http://svn.apache.org/viewvc?rev=741227&view=rev
Log:
DERBY-3972; patch 3 modifies 2 tests to optionally take a property for 
  a different initial context factory than sun's

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java?rev=741227&r1=741226&r2=741227&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java
Thu Feb  5 18:42:27 2009
@@ -57,6 +57,8 @@
     private static String dnString;
     private static String ldapUser; // existing valid user on ldap server
     private static String ldapPassword; // password for existing valid user on ldap server
+    private static String ldapContextFactory; // optional initial context factory
+        // if not passed in with -DderbyTesting.ldapContextFactory, uses sun's
 
     // create own policy file, so we can connect to the ldap server
     private static String POLICY_FILE_NAME = 
@@ -104,6 +106,7 @@
             return new TestSuite("LDAPAuthenticationTest requires property " +
                 "derbyTesting.dnString for setting o=, eg: " +
                 "-DderbyTesting.dnString=myJNDIstring");
+        ldapContextFactory=getSystemProperty("derbyTesting.ldapContextFactory");
 
         TestSuite suite = new TestSuite("LDAPAuthenticationTest");
         suite.addTest(baseSuite("LDAPAuthenticationTest:embedded",
@@ -212,6 +215,12 @@
         setDatabaseProperty("derby.authentication.server", ldapServer, conn);
         setDatabaseProperty("derby.authentication.ldap.searchBase", "o=" + dnString, conn);
         setDatabaseProperty("derby.authentication.ldap.searchFilter","(&(objectClass=inetOrgPerson)(uid=%USERNAME%))",
conn);
+        // java.naming.factory.initial is Context.INITIAL_CONTEXT_FACTORY
+        // but using literal string here to avoid unnecessary import.
+        // If the initial context factory is not provided it'll default to 
+        // com.sun.jndi.ldap.LdapCtxFactory in LDAPAuthenticationSchemeImpl.
+        if ((ldapContextFactory != null) && (ldapContextFactory.length() > 0))
+            setDatabaseProperty("java.naming.factory.initial", ldapContextFactory, conn);
         commit();
         // shutdown the database as system, so the properties take effect
         TestConfiguration.getCurrent().shutdownDatabase();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java?rev=741227&r1=741226&r2=741227&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
Thu Feb  5 18:42:27 2009
@@ -79,8 +79,12 @@
     {
         try {
             Hashtable env = new Hashtable();
-            env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
-            // using a property - these will have to be passed in somehow.
+            // using properties - these will have been passed in.
+            String ldapContextFactory=getSystemProperty("derbyTesting.ldapContextFactory");
+            if (ldapContextFactory == null || ldapContextFactory.length() < 1)
+                env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+            else
+                env.put(Context.INITIAL_CONTEXT_FACTORY, ldapContextFactory);
             env.put(Context.PROVIDER_URL, "ldap://" + ldapServer + ":" + ldapPort);
             env.put(Context.SECURITY_AUTHENTICATION, "simple");
             return new InitialDirContext(env);



Mime
View raw message