Hello ApacheDS,

I'm trying to use ApacheDS as an LDAP testing server for one the application I'm working on. ApacheDS "integ" seems to have some really really nice features on that subject, but I'm encountering a little problem : I'm using Scala for my application (yes Emmanuel ;) and Scala doesn't have such a thing as "public static field".

I didn't see any other way to interact with the integration installation than with this LdapServer field, do I miss it ?

On the other hand, Scala can have "public static method", so it would be great if in place of the field, you could use getter/setter for accessing LdapServer.

I attached patches on core-integ and server-integ to show what would make Scala (and me) happy. They are just here to give you an idea, in that state they break something like all of your testcases (because of course the use the convention with a service/ldapServer field, not a setService/setLdapServer method).

What do you think about that ? Whould it be possible to switch to getter/setter injection ?

Have a nice day

--
Francois Armand
Index: src/main/java/org/apache/directory/server/core/integ/state/TestServiceContext.java
===================================================================
--- src/main/java/org/apache/directory/server/core/integ/state/TestServiceContext.java	(révision 835420)
+++ src/main/java/org/apache/directory/server/core/integ/state/TestServiceContext.java	(copie de travail)
@@ -20,8 +20,9 @@
 
 
 import java.io.IOException;
-import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.server.core.DirectoryService;
@@ -204,8 +205,8 @@
     {
         try
         {
-            Field field = testClass.getJavaClass().getDeclaredField( "service" );
-            field.set( testClass.getJavaClass(), get().getService() );
+            Method setService = testClass.getJavaClass().getMethod("setService", DirectoryService.class);
+            setService.invoke(testClass.getJavaClass(), get().getService());
             
             notifier.fireTestStarted( description );
             statement.evaluate();
Index: src/main/java/org/apache/directory/server/integ/state/TestServerContext.java
===================================================================
--- src/main/java/org/apache/directory/server/integ/state/TestServerContext.java	(révision 835424)
+++ src/main/java/org/apache/directory/server/integ/state/TestServerContext.java	(copie de travail)
@@ -20,8 +20,8 @@
 
 
 import java.io.IOException;
-import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 import javax.naming.NamingException;
 
@@ -212,8 +212,8 @@
     {
         try
         {
-            Field field = testClass.getJavaClass().getDeclaredField( "ldapServer" );
-            field.set( testClass.getJavaClass(), getServerContext().getLdapServer() );
+            Method setLdapServer = testClass.getJavaClass().getMethod("setLdapServer", LdapServer.class);
+            setLdapServer.invoke(testClass.getJavaClass(), getServerContext().getLdapServer());
 
             notifier.fireTestStarted( description );
             statement.evaluate();

Reply via email to