import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
-public class StubInitialContext extends InitialContext {
+/**
+ * Initial context implementation.
+ *
+ * @author Erik Brakkee
+ */
+class StubInitialContext extends InitialContext {
private Map<String, Object> bindings = new HashMap<String, Object>();
public StubInitialContext() throws NamingException {
public void bind(String aName, Object aObj) throws NamingException {
bindings.put(aName, aObj);
}
+
+ @Override
+ public void unbind(String aName) throws NamingException {
+ bindings.remove(aName);
+ }
@Override
public Object lookup(String aName) throws NamingException {
}
return value;
}
+
+ @Override
+ public void bind(Name aName, Object aObj) throws NamingException {
+ bind(aName.toString(), aObj);
+ }
+
+ @Override
+ public void unbind(Name aName) throws NamingException {
+ unbind(aName.toString());
+ }
@Override
public Object lookup(Name aName) throws NamingException {
- Object value = super.lookup(aName.toString());
- if (value == null) {
- throw new NameNotFoundException(aName.toString());
- }
- return value;
+ return lookup(aName.toString());
}
}