Hello, I am trying to setup a test environment (in Jetty) to run my application. I do not expect everything to work in my test environment (like my JMS lookups), since I am just using it mainly for visuals and some small workflows. Anyways, I deploy my application to Websphere Application Server 6.1, and I use spring to do the JMS-JNDI lookups like so (this is in my src/main/resources/applicationContext-jms.xml):
Now, for my test environment, I do not need JMS functioning, but I would like to leave my configuration the same. Thus, I thought I could use mock objects in my test-resources spring config like so (src/test/resources/applicationContext.xml):Code:<jee:jndi-lookup id="simpleTopic" jndi-name="jms/RepositoryTopic" /> <jee:jndi-lookup id="simpleTopicConnectionFactory" jndi-name="jms/RepositoryTopicConnectionFactory" /> <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory"> <ref bean="simpleTopicConnectionFactory" /> </property> <property name="defaultDestination"> <ref bean="simpleTopic" /> </property> <property name="receiveTimeout"> <value>30000</value> </property> </bean> <bean id="dispatcher" class="com.cerner.healthe.provisioning.impl.CHREventDispatcher"> <property name="jmsTemplate" ref="jmsTemplate" /> </bean>
Now, I was hoping that adding the primary="true" attribute would mean that spring would not try to build the <jee:jndi-lookup ...> beans, but alas, it still tries to do so, and thus my application fails to start in my test environment. Is there a better way to do this? I want to keep the same spring config, but do not require the same functionality in my test environment. My test environment is a Jetty instance with a Pluto portlet container running in it ... I am not familiar with setting up JNDI/JMS in jetty, and since I do not require it, I was trying to avoid the whole thing. Any suggestions?Code:<bean id="jmsMockObjectFactory" class="com.mockrunner.mock.jms.JMSMockObjectFactory" /> <bean id="destManager" factory-bean="jmsMockObjectFactory" factory-method="getDestinationManager" /> <bean id="topicConnectionFactory" factory-bean="jmsMockObjectFactory" factory-method="getMockTopicConnectionFactory" /> <bean id="simpleTopicConnectionFactoryTemplate" class="org.springframework.mock.jndi.ExpectedLookupTemplate"> <constructor-arg value="java:comp/env/jms/RepositoryTopicConnectionFactory" /> <constructor-arg ref="topicConnectionFactory" /> <property name="environment"> <props> <prop key="java.naming.factory.initial"> org.sprinframework.mock.jndi.SimpleNamingContextBuilder </prop> </props> </property> </bean> <bean id="simpleTopicConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" primary="true"> <property name="jndiTemplate" ref="simpleTopicConnectionFactoryTemplate" /> <property name="jndiName" value="java:comp/env/jms/RepositoryTopicConnectionFactory" /> </bean> <bean id="topic" factory-bean="destManager" factory-method="createTopic"> <constructor-arg value="repositoryTopic" /> </bean> <bean id="simpleTopicTemplate" class="org.springframework.mock.jndi.ExpectedLookupTemplate"> <constructor-arg value="java:comp/env/jms/RepositoryTopic" /> <constructor-arg ref="topic" /> <property name="environment"> <props> <prop key="java.naming.factory.initial"> org.sprinframework.mock.jndi.SimpleNamingContextBuilder </prop> </props> </property> </bean> <bean id="simpleTopic" class="org.springframework.jndi.JndiObjectFactoryBean" primary="true"> <property name="jndiTemplate" ref="simpleTopicTemplate" /> <property name="jndiName" value="java:comp/env/jms/RepositoryTopic" /> </bean>
Thanks,
Brian


Reply With Quote