Index: src/test/java/org/jboss/ejb3/test/jndibinding/SimpleBean.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/jndibinding/SimpleBean.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/jndibinding/SimpleBean.java	(revision 0)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.jndibinding;
+
+/**
+ * SimpleBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface SimpleBean
+{
+   void doNothing();
+
+}
Index: src/test/java/org/jboss/ejb3/test/jndibinding/unit/JNDIBindingTestCase.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/jndibinding/unit/JNDIBindingTestCase.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/jndibinding/unit/JNDIBindingTestCase.java	(revision 0)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.jndibinding.unit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.jndibinding.SimpleBean;
+import org.jboss.ejb3.test.jndibinding.StatelessBeanOverridenJNDINameInXml;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * JNDIBindingTestCase
+ *
+ * Test case to ensure that the beans (deployed in any way - either through
+ * jar or ear) are binding to the correct jndi name (i.e. resolving the
+ * correct jndi name either from the xml or from the annotations or the default
+ * jndi name). 
+ * 
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class JNDIBindingTestCase extends JBossTestCase
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(JNDIBindingTestCase.class);
+
+   /**
+    * Constructor
+    */
+   public JNDIBindingTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Test that the {@link StatelessBeanOverridenJNDINameInXml} SLSB is bound to the jndi-name
+    * specified in the jboss.xml deployment descriptor. 
+    * 
+    * 
+    * @throws Throwable
+    */
+   public void testJNDILookupUsingJNDINameInXML() throws Throwable
+   {
+      Context ctx = new InitialContext();
+      // Lookup the bean based on the "jndi-name" specified in the jboss.xml
+      String jndiNameInXml = "SomeJNDINameInXml";
+      logger.debug("Looking up bean based on the jndi-name = " + jndiNameInXml + " in jboss.xml");
+      try
+      {
+         Object obj = ctx.lookup(jndiNameInXml);
+         assertNotNull("Lookup of " + StatelessBeanOverridenJNDINameInXml.class.getName() + " using jndi-name in jboss.xml = "
+               + jndiNameInXml + " returned NULL ", obj);
+         assertTrue("Object returned from jndi using jndi-name in jboss.xml = " + jndiNameInXml
+               + " is not an instance of " + SimpleBean.class, (obj instanceof SimpleBean));
+      }
+      catch (NameNotFoundException nnfe)
+      {
+         fail("Bean " + StatelessBeanOverridenJNDINameInXml.class.getName()
+               + " is not bound to the jndi-name name specified in jboss.xml = " + jndiNameInXml);
+      }
+
+   }
+
+   /**
+    * Add the test to the test suite
+    * @return
+    * @throws Exception
+    */
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(JNDIBindingTestCase.class, "jndibinding-test.jar");
+   }
+
+}
Index: src/test/java/org/jboss/ejb3/test/jndibinding/StatelessBeanOverridenJNDINameInXml.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/jndibinding/StatelessBeanOverridenJNDINameInXml.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/jndibinding/StatelessBeanOverridenJNDINameInXml.java	(revision 0)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.jndibinding;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+/**
+ * StatelessBeanOverridenJNDINameInXml
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+@Stateless
+@Remote (SimpleBean.class)
+public class StatelessBeanOverridenJNDINameInXml implements SimpleBean
+{
+
+   public void doNothing()
+   {
+      // nothing to do
+      
+   }
+   
+}
Index: src/test/resources/test/jndibinding/META-INF/jboss.xml
===================================================================
--- src/test/resources/test/jndibinding/META-INF/jboss.xml	(revision 0)
+++ src/test/resources/test/jndibinding/META-INF/jboss.xml	(revision 0)
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<jboss>
+       
+   <enterprise-beans>
+      <session>
+         <ejb-name>StatelessBeanOverridenJNDINameInXml</ejb-name>
+         <jndi-name>SomeJNDINameInXml</jndi-name>
+      </session>
+   </enterprise-beans>
+</jboss>

Property changes on: src/test/resources/test/jndibinding/META-INF/jboss.xml
___________________________________________________________________
Name: svn:executable
   + *

Index: src/test/resources/test/jndibinding/META-INF/ejb-jar.xml
===================================================================
--- src/test/resources/test/jndibinding/META-INF/ejb-jar.xml	(revision 0)
+++ src/test/resources/test/jndibinding/META-INF/ejb-jar.xml	(revision 0)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE ejb-jar PUBLIC 
+  "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" 
+  "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+<ejb-jar>
+   <enterprise-beans>
+      <session>
+         <ejb-name>StatelessBeanOverridenJNDINameInXml</ejb-name>
+	<remote>org.jboss.ejb3.test.jndibinding.SimpleBean</remote>
+         <ejb-class>org.jboss.ejb3.test.jndibinding.StatelessBeanOverridenJNDINameInXml</ejb-class>
+	<session-type>Stateless</session-type>
+			<transaction-type>Container</transaction-type>
+
+      </session>
+   </enterprise-beans>
+</ejb-jar>
Index: build-test.xml
===================================================================
--- build-test.xml	(revision 82362)
+++ build-test.xml	(working copy)
@@ -271,6 +271,11 @@
       <jvmarg value="-Djboss.messaging.ServerPeerID=1" />
    </server>
 
+    <!-- jndibinding -->
+    <server name="jndibinding" host="${node0}">
+      <jvmarg value="${ejb3.jboss.jvmargs}" />
+    </server>
+
   </server:config>
 
    <!-- =================== -->
@@ -4171,6 +4176,24 @@
          </fileset>
       </jar>
    </target>
+
+	<target name="jndibinding"
+	      description="Builds the jar file(s) required for testing the jndibinding testcase." >
+
+
+	      <mkdir dir="${build.lib}"/>
+
+	      <jar jarfile="${build.lib}/jndibinding-test.jar">
+	         <fileset dir="${build.classes}">
+	            <include name="org/jboss/ejb3/test/jndibinding/*.class"/>
+	         </fileset>
+	         <fileset dir="${resources}/test/jndibinding">
+	            <include name="META-INF/*.xml"/>
+	         </fileset>
+	      </jar>
+
+	
+	</target>
    
    <target name="jars" depends="statefulproxyfactoryoverride, removedislocal, statelesscreation, defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
       concurrent,
@@ -4199,7 +4222,7 @@
       timer, benchmark, entity, joininheritance, singletable, tableperclass, dependent, mdb, manytomany, regression,
       composite, composite2, entitycallback, relationships, ssl, ssladvanced, clusteredsession, strictpool, jacc,
       localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor,
-      statelesscreation, changexml, externalrefscoped, singleton"/>
+      statelesscreation, changexml, externalrefscoped, singleton, jndibinding"/>
 
    <target name="test" depends="init" if="test"
       description="Execute all tests in the given test directory.">
