* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.support.jndi;
import java.util.HashMap;
import javax.naming.InitialContext;
import javax.naming.Name;
+import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
public class StubInitialContext extends InitialContext {
@Override
public Object lookup(String aName) throws NamingException {
- return bindings.get(aName);
+ Object value = bindings.get(aName);
+ if (value == null) {
+ throw new NameNotFoundException(aName);
+ }
+ return value;
}
@Override
public Object lookup(Name aName) throws NamingException {
- return super.lookup(aName.toString());
+ Object value = super.lookup(aName.toString());
+ if (value == null) {
+ throw new NameNotFoundException(aName.toString());
+ }
+ return value;
}
}