I'm using jndi to perform a database lookup :
<jee:jndi-lookup id="myDataSource" jndi-name="jdbc/mydb"
resource-ref="true" expected-type="javax.sql.DataSource" />
In a spring context file I invoke the constructor using :
<bean id="myController " class="com.MyController">
<constructor-arg index="0" ref="myDataSource" />
</bean>
I no longer want to expose "myDataSource" via a jndi lookup, so a I create a mock object which is of same type as "javax.sql.DataSource" and use it instead as a constructor parameter :
<bean id="myMockDataSource" class="com.mock.MyMockDataSourceConnection">
</bean>
<bean id="myController" class="com.MyController">
<constructor-arg index="0" ref="myMockDataSource" />
</bean>
The mock object just returns a dummy connection.
Is this the correct way so as to longer use jndi lookup when want to use a mock object instead ?