Query on MicrocontainerTest
amit.bhayani Mar 12, 2009 10:23 AMHey Guys,
I am writing unit test for my application extending MicrocontainerTest.
public class EventFactoryTest extends MicrocontainerTest { public EventFactoryTest(String name) { super(name); } public void testAnnouncementPkgFactory(){ AnnouncementPkgFactory announcementPkgFactory = (AnnouncementPkgFactory) getBean("MMS.AnnouncementPkgFactory"); assertNotNull(announcementPkgFactory); assertEquals(Announcement.PACKAGE_NAME, announcementPkgFactory.getPackageName()); } public void testEventFactory(){ EventFactory eventFactory = (EventFactory) getBean("MMS.EventFactory"); assertNotNull(eventFactory); // RequestedEvent completedEvent = eventFactory.createRequestedEvent(Announcement.PACKAGE_NAME, Announcement.COMPLETED.getEventName()); // assertNotNull(completedEvent); // // assertEquals(Announcement.COMPLETED, completedEvent.getID()); } }
I have declared corresponding EventFactoryTest.xml
When I execute test only testAnnouncementPkgFactory passes and testEventFactory always fails with following message.
java.lang.IllegalStateException: Bean not found MMS.EventFactory at state ControllerState@827968{Installed} at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.handleNotFoundContext(MicrocontainerTestDelegate.java:235) at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.getControllerContext(MicrocontainerTestDelegate.java:205) at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.getBean(MicrocontainerTestDelegate.java:160) at org.jboss.test.kernel.junit.MicrocontainerTest.getBean(MicrocontainerTest.java:216) at org.jboss.test.kernel.junit.MicrocontainerTest.getBean(MicrocontainerTest.java:203) at org.mobicents.media.EventFactoryTest.testEventFactory(EventFactoryTest.java:24)
The debug shows that MC framework is looking for testAnnouncementPkgFactory.xml and testEventFactory.xml and since its not there I assume it will use EventFactoryTest.xml which is true for first test method and second test method always fail. That is, if I declare testEventFactory before testAnnouncementPkgFactory, than testEventFactory always passes and testAnnouncementPkgFactory always fails
here is debug
Found log4j.properties: file:/home/abhayani/workarea/mobicents/svn/trunk/servers/media/core/target/classes/log4j.properties Client DEBUG [12-03-2009 19:41:22] EventFactoryTest - ==== setUp org.mobicents.media.EventFactoryTest ==== Client DEBUG [12-03-2009 19:41:22] KernelFactory - Starting JBoss Kernel construction... Client DEBUG [12-03-2009 19:41:22] KernelFactory - Completed JBoss Kernel construction. Duration: 142 milliseconds Client DEBUG [12-03-2009 19:41:22] EventFactoryTest - Deploying file:/home/abhayani/workarea/mobicents/svn/trunk/servers/media/core/target/classes/org/mobicents/media/EventFactoryTest.xml Client DEBUG [12-03-2009 19:41:22] SaxJBossXBParser - Created parser: com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl@120bf2c, isNamespaceAware: true, isValidating: true, isXIncludeAware: true Client DEBUG [12-03-2009 19:41:22] SaxJBossXBParser - http://xml.org/sax/features/validation set to: true Client DEBUG [12-03-2009 19:41:22] SaxJBossXBParser - http://xml.org/sax/features/namespaces set to: true Client DEBUG [12-03-2009 19:41:22] SaxJBossXBParser - http://apache.org/xml/features/validation/dynamic set to: true Client DEBUG [12-03-2009 19:41:22] SaxJBossXBParser - Created parser: com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl@120bf2c, isNamespaceAware: true, isValidating: true, isXIncludeAware: true Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - ==== Starting testAnnouncementPkgFactory ==== Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - No method specific deployment /org/mobicents/media/EventFactoryTest#testAnnouncementPkgFactory.xml Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - testAnnouncementPkgFactory took 8ms Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - ==== Stopping testAnnouncementPkgFactory ==== Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - Undeploying [file:/home/abhayani/workarea/mobicents/svn/trunk/servers/media/core/target/classes/org/mobicents/media/EventFactoryTest.xml] Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - ==== tornDown org.mobicents.media.EventFactoryTest ==== Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - ==== Starting testEventFactory ==== Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - No method specific deployment /org/mobicents/media/EventFactoryTest#testEventFactory.xml Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - testEventFactory took 1ms Client DEBUG [12-03-2009 19:41:24] EventFactoryTest - ==== Stopping testEventFactory ====
Any help is highly appreciated. I don't want to declare two*-beans.xml having same content. Or I am missing something?
Thanks