tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Gary Geiglein <>
Subject Junit unit test setup for testing an authentication realm
Date Tue, 29 Jul 2014 17:45:54 GMT
Currently working on Tomcat 7.0.53 on 32 bit Windows Server, Testing on same Tomcat on windows

Java JDK 1.7.0_60 in both environments.

We have been using a custom realm, and had a need to update it.

All of the old unit tests fail when trying to lookup the realm configuration from the JNDI

I would like to know if there is something that could be done in the setup for the tests to
make this work.

We currently load the JNDI context form copies of the server.xml and context.xml and this
works fine for testing applications.

But the realm uses a combination of org.apache.naming.ContextBindings and org.apache.naming.SelectorContext
that are not picking up the environment.

I have gone so far adding the following code after the environment is built:

ContextBindings.bindContext("Acentia-Jndi-UnitTests", ctx);
ContextBindings.bindClassLoader("Acentia-Jndi-UnitTests", null, Thread.currentThread().getContextClassLoader());

This seems to make it available as far as the call to ContextBindings.getClassLoader(), this
returns a context containing the environment that was setup.

But when I try context.lookup(jndiName) It ends up returning a new SelectorContext with the
environment instead of returning the object.

The code works correctly inside tomcat so I am assuming that there needs to be something else
setup prior to trying to instanciate the realm from the JNDI environment.

The information in this electronic mail message is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this electronic mail message by anyone
else is unauthorized. If you are not the intended recipient, please notify the sender and
delete this message immediately. Any disclosure, copying, distribution or any action taken
or omitted to be taken in reliance on information in this message by unauthorized recipients
is prohibited and may be unlawful.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message