[ http://jira.codehaus.org/browse/MPJCOVERAGE-22?page=comments#action_40399 ] Nico De Groote commented on MPJCOVERAGE-22: -------------------------------------------
Sorry, for earlier comments. I do think the source of my problem is slightly different. It is probably situated in the fact I'm using the JDK 5.0 and its generics. If the other fix helps you guys, than its ok, but I still have a problem. Regards, Nico > jcoverage fails while junit passes? > ----------------------------------- > > Key: MPJCOVERAGE-22 > URL: http://jira.codehaus.org/browse/MPJCOVERAGE-22 > Project: maven-jcoverage-plugin > Type: Bug > Versions: 1.0.9 > Environment: Windows XP SP2, JDK 1.4.2_05, Maven 1.0.1, Spring Framework > 1.1.3 > Reporter: Brian Guan > Assignee: Emmanuel Venisse > > > I have written a unit test to test my webapp, which runs fine using maven, > but when I try to run maven jcoverage the same unit test case fails with a > file not found error. > The webapp is developed using Spring MVC framework 1.1.3, and the junit test > case is written using Spring Mock 1.1.3. > The following is the console output with a successful maven (default goal) > run and a failed maven jcoverage run: > =================== > D:\yorzdev\trunk\pubweb-sprmvc>maven > __ __ > | \/ |__ _Apache__ ___ > | |\/| / _` \ V / -_) ' \ ~ intelligent projects ~ > |_| |_\__,_|\_/\___|_||_| v. 1.0.1 > build:start: > yorz-build: > war:init: > war:war-resources: > [copy] Copying 1 file to C:\tomcat-5.0\webapps\pubweb\WEB-INF > java:prepare-filesystem: > java:compile: > [echo] Compiling to D:\yorzdev\trunk\pubweb-sprmvc/target/classes > java:jar-resources: > test:prepare-filesystem: > test:test-resources: > test:compile: > [javac] Compiling 1 source file to > D:\yorzdev\trunk\pubweb-sprmvc\target\test-classes > test:test: > [junit] Running com.yorz.pubweb.PubWebControllerTest > (xml.XmlBeanDefinitionReader 119 ) Loading XML bean definitions from > ServletContext resource [/mockContext.xml] > (xml.XmlBeanDefinitionReader 119 ) Loading XML bean definitions from > ServletContext resource [/WEB-INF/pubweb-servlet.xml] > (support.XmlWebApplicationContext 90 ) Bean factory for application > context [org.springframework.web.context.support.XmlWebApplicationCo > ntext;hashCode=18061339]: > org.springframework.beans.factory.support.DefaultListableBeanFactory defining > beans [txnLogicSvc,messageSource,vie > wResolver,exceptionResolver,urlMapping,tilesConfigurer,pubwebController,pubwebControllerResolver,loginForm,loginValidator,selfRegisterForm,s > elfRegisterValidator,addListingForm,addReferralForm,addListingValidator,addReferralValidator]; > root of BeanFactory hierarchy > (support.XmlWebApplicationContext 294 ) 16 beans defined in application > context [org.springframework.web.context.support.XmlWebApplicatio > nContext;hashCode=18061339] > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'messageSource' > (support.XmlWebApplicationContext 395 ) Using MessageSource > [org.springframework.context.support.ResourceBundleMessageSource: basenames=[ > messages]] > (support.XmlWebApplicationContext 426 ) Unable to locate > ApplicationEventMulticaster with name 'applicationEventMulticaster': using > defau > lt [EMAIL PROTECTED] > (support.UiApplicationContextUtils 67 ) No ThemeSource found for > [org.springframework.web.context.support.XmlWebApplicationContext;hashCo > de=18061339]: using ResourceBundleThemeSource > (support.XmlWebApplicationContext 448 ) Refreshing listeners > (support.DefaultListableBeanFactory 246 ) Pre-instantiating singletons in > factory [org.springframework.beans.factory.support.DefaultListabl > eBeanFactory defining beans > [txnLogicSvc,messageSource,viewResolver,exceptionResolver,urlMapping,tilesConfigurer,pubwebController,pubwebCont > rollerResolver,loginForm,loginValidator,selfRegisterForm,selfRegisterValidator,addListingForm,addReferralForm,addListingValidator,addReferra > lValidator]; root of BeanFactory hierarchy] > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'txnLogicSvc' > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'viewResolver' > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'exceptionResolver' > (handler.SimpleMappingExceptionResolver 102 ) Default error view is > 'generalException' > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'urlMapping' > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'pubwebController' > (pubweb.PubWebController 213 ) Found action method [public > org.springframework.web.servlet.ModelAndView com.yorz.pubweb.PubWebCo > ntroller.homeHandler(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) > throws javax.servlet.ServletException] > (pubweb.PubWebController 213 ) Found action method [public > org.springframework.web.servlet.ModelAndView com.yorz.pubweb.PubWebCo > ntroller.listingsHandler(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) > throws javax.servlet.ServletException > ] > (pubweb.PubWebController 213 ) Found action method [public > org.springframework.web.servlet.ModelAndView com.yorz.pubweb.PubWebCo > ntroller.listingHandler(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) > throws javax.servlet.ServletException] > (pubweb.PubWebController 213 ) Found action method [public > org.springframework.web.servlet.ModelAndView com.yorz.pubweb.PubWebCo > ntroller.myListingsHandler(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) > throws java.lang.Exception] > (pubweb.PubWebController 213 ) Found action method [public > org.springframework.web.servlet.ModelAndView com.yorz.pubweb.PubWebCo > ntroller.myReferralsHandler(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) > throws javax.servlet.ServletExcept > ion] > (pubweb.PubWebController 213 ) Found action method [public > org.springframework.web.servlet.ModelAndView com.yorz.pubweb.PubWebCo > ntroller.viewReferralsHandler(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) > throws java.lang.Exception] > (pubweb.PubWebController 213 ) Found action method [public > org.springframework.web.servlet.ModelAndView com.yorz.pubweb.PubWebCo > ntroller.referralHandler(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) > throws javax.servlet.ServletException > ] > (pubweb.PubWebController 213 ) Found action method [public final > org.springframework.web.servlet.ModelAndView org.springframewor > k.web.servlet.mvc.AbstractController.handleRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) > throws java > .lang.Exception] > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'pubwebControllerResolver' > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path [/myListings.htm] > onto handler [EMAIL PROTECTED] > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'loginForm' > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path [/login.htm] onto > handler [EMAIL PROTECTED] > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'addReferralForm' > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'addReferralValidator' > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path [/addReferral.htm] > onto handler [EMAIL PROTECTED] > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path [/home.htm] onto > handler [EMAIL PROTECTED] > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path [/myReferrals.htm] > onto handler [EMAIL PROTECTED] > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path [/referral/*.htm] > onto handler [EMAIL PROTECTED] > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path [/listing/*.htm] > onto handler [EMAIL PROTECTED] > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'selfRegisterForm' > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'selfRegisterValidator' > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path > [/selfRegister.htm] onto handler [EMAIL PROTECTED] > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'addListingForm' > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'addListingValidator' > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path > [/listings/**/addListing.htm] onto handler [EMAIL PROTECTED] > b2d7df] > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path > [/listings/**/index.htm] onto handler [EMAIL PROTECTED] > (handler.SimpleUrlHandlerMapping 172 ) Mapped URL path > [/viewReferrals.htm] onto handler [EMAIL PROTECTED] > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'tilesConfigurer' > (tiles.TilesConfigurer 113 ) TilesConfigurer: adding > definitions [/WEB-INF/tiles-defs.xml] > (util.PropertyMessageResources 127 ) Initializing, > config='org.apache.struts.util.LocalStrings', returnNull=true > (support.DefaultListableBeanFactory 232 ) Creating shared instance of > singleton bean 'loginValidator' > [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.219 sec > war:webapp: > [echo] Assembling webapp pubweb-sprmvc > BUILD SUCCESSFUL > Total time: 4 seconds > Finished at: Tue Dec 28 21:45:22 PST 2004 > D:\yorzdev\trunk\pubweb-sprmvc>maven jcoverage:html-report > __ __ > | \/ |__ _Apache__ ___ > | |\/| / _` \ V / -_) ' \ ~ intelligent projects ~ > |_| |_\__,_|\_/\___|_||_| v. 1.0.1 > build:start: > java:prepare-filesystem: > java:compile: > [echo] Compiling to D:\yorzdev\trunk\pubweb-sprmvc/target/classes > instrumenting the class-files... > jcoverage:on: > java:jar-resources: > test:prepare-filesystem: > test:test-resources: > test:compile: > test:test: > [junit] Running com.yorz.pubweb.PubWebControllerTest > [junit] (xml.XmlBeanDefinitionReader 119 ) Loading XML bean > definitions from ServletContext resource [/mockContext.xml] > [junit] (web.MockServletContext 169 ) Couldn't open > InputStream for class path resource [/mockContext.xml] > [junit] java.io.FileNotFoundException: Could not open class path resource > [/mockContext.xml] > [junit] at > org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:109) > [junit] at > org.springframework.mock.web.MockServletContext.getResourceAsStream(MockServletContext.java:166) > [junit] at > org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:87) > [junit] at > org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:129) > [junit] at > org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.j > ava:83) > [junit] at > org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:114) > [junit] at > org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:82) > [junit] at > org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicati > onContext.java:87) > [junit] at > org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:262) > [junit] at > org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicatio > nContext.java:131) > [junit] at > com.yorz.pubweb.PubWebControllerTest.setUp(PubWebControllerTest.java:27) > [junit] at junit.framework.TestCase.runBare(TestCase.java:125) > [junit] at junit.framework.TestResult$1.protect(TestResult.java:106) > [junit] at > junit.framework.TestResult.runProtected(TestResult.java:124) > [junit] at junit.framework.TestResult.run(TestResult.java:109) > [junit] at junit.framework.TestCase.run(TestCase.java:118) > [junit] at junit.framework.TestSuite.runTest(TestSuite.java:208) > [junit] at junit.framework.TestSuite.run(TestSuite.java:203) > [junit] at > org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325) > [junit] at > org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:536) > [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.234 sec > [junit] [ERROR] TEST com.yorz.pubweb.PubWebControllerTest FAILED > BUILD FAILED > File...... C:\Documents and > Settings\bguan\.maven\cache\maven-test-plugin-1.6.2\plugin.jelly > Element... fail > Line...... 181 > Column.... 54 > There were test failures. > Total time: 2 seconds > Finished at: Tue Dec 28 21:50:50 PST 2004 > =================== > It seems the class loader behavioral difference is causing my test case to > fail to load the file /mockContext.xml. > My junit code is very simple. Attached below for your information: > =============================== > package com.yorz.pubweb; > import java.util.Map; > import junit.framework.TestCase; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > import org.springframework.mock.web.MockHttpServletRequest; > import org.springframework.mock.web.MockHttpServletResponse; > import org.springframework.mock.web.MockServletContext; > import org.springframework.web.context.support.XmlWebApplicationContext; > import org.springframework.web.servlet.ModelAndView; > public class PubWebControllerTest extends TestCase { > > private static Log log = LogFactory.getLog(PubWebControllerTest.class); > > private XmlWebApplicationContext ctx; > public void setUp() { > > String[] paths = {"/mockContext.xml", "/WEB-INF/pubweb-servlet.xml"}; > ctx = new XmlWebApplicationContext(); > ctx.setConfigLocations(paths); > ctx.setServletContext(new MockServletContext("/")); > ctx.refresh(); > } > public void testHomeHandler() throws Exception { > PubWebController c = (PubWebController) ctx.getBean("pubwebController"); > > MockServletContext mockCtx = new MockServletContext(); > MockHttpServletRequest mockReq = new MockHttpServletRequest(mockCtx, > "GET", "/home.htm"); > MockHttpServletResponse mockResp = new MockHttpServletResponse(); > > ModelAndView mav = c.handleRequest(mockReq, mockResp); > > Map m = (Map) mav.getModel(); > > assertNotNull(m.get(PubWebConstants.MDL_GEO)); > assertNotNull(m.get(PubWebConstants.MDL_TOPCATS)); > assertNotNull(m.get(PubWebConstants.MDL_SUBCAT_MAP)); > assertNotNull(m.get(PubWebConstants.MDL_CATCNT_MAP)); > assertEquals(mav.getViewName(), PubWebConstants.VW_HOME); > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
