Now working with both hibernate and eclipselink
[utils] / test / enterprise / src / main / java / org / wamblee / support / jndi / StubInitialContext.java
index 4db8a1126f4a3358e3d3aacf20af7f59740d9d94..5300a8b6a5f230ca84ea375b28dcedd03723b50a 100644 (file)
@@ -12,7 +12,7 @@
  * 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;
@@ -20,6 +20,7 @@ import java.util.Map;
 
 import javax.naming.InitialContext;
 import javax.naming.Name;
+import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 
 public class StubInitialContext extends InitialContext {
@@ -36,11 +37,19 @@ 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;
     }
 }