directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert r. Sanders" <robert.sand...@ipov.net>
Subject Re: Configure (Eve) server from properties file.
Date Wed, 02 Mar 2005 21:52:12 GMT
I know this is more of a user's list question, but there doesn't seem to 
be one yet.

After looking back over my code, I think that what I was doing was not 
what I was trying to do.  What I want is to have several alternative 
configurations (schemas + data) as text files; and load those (not all 
at once) into the server so I can then test some JNDI calls to see if 
they are returning the expected results (given the data that was 
loaded).  I think something like LDIF files are what I am aiming for 
(although a clean xml syntax might be cool) - are there any examples or 
docs that would be useful to me in figuring this out?  Thanks for your time.

Alex Karasulu wrote:

> Robert r. Sanders wrote:
>
>> I'd like to use the JNDI server so that I can create and run JUnit 
>> tests of JNDI/LDAP functionality.  To that end I'm trying to figure 
>> out the easiest way to configure a server instance; it looked like 
>> properties files would be a decent way (at least better than 
>> programmatically creating a bunch of JNDI Attribute objects); but I 
>> don' t know how to get the server to load a properties file - this is 
>> what I have so far (using properties file contents from documentation 
>> example):
>>
> When running it via command line it can have prop file arg but you 
> don't need that.  Looks like you're doing it right below.
>
>> Properties env = new Properties();
>> FileInputStream in = new 
>> FileInputStream("sandbox/src/test/jndi01.properties");
>> env.load(in);
>> env.put( Context.PROVIDER_URL, "ou=system" );
>> env.put( Context.INITIAL_CONTEXT_FACTORY, 
>> "org.apache.ldap.server.jndi.ServerContextFactory" );
>> env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
>> env.put( Context.SECURITY_CREDENTIALS, "secret" );
>>
> Looks good to me.  Is this not working?
>
>> DirContext ctx = new InitialDirContext( env );
>>
>> Once I have the DirContext I have just been using code from the JNDI 
>> tutorial to see what's there:
>>
>> NamingEnumeration list = ctx.list("");
>> while (list.hasMore()) {
>>    NameClassPair nc = (NameClassPair)list.next();
>>    System.out.println( nc );
>> }
>
>
> You should see the listing of some entries.  Let me know if you have a 
> problem.  You approach looks good.
>
> Alex
>

-- 
    Robert r. Sanders
    Chief Technologist
    iPOV
    (334) 821-5412
    www.ipov.net


Mime
View raw message