Newman, John W wrote: > > Where ever you're creating a new MockRoundTrip(), there's an additional > constructor to attach an existing http session. Looks like you're > prebuilding a session w/ your spring beans injected, but are you passing > that session into any trips? Maybe post the code for one of the unit > tests. > > Just curious, what are you using spring http session beans for? >
I created a mockSession and instantiated it in my setup method. In my test I pass it when creating a new MockRoundTrip and I get the stack trace below. You are right there are a couple of Spring beans that are being created at start up that are scoped to "session." Like I said previously we were able to work around this issue in our main application by adding the RequestContextListener in the web.xml file to give Stripes access to session scoped beans for injection into our Stripes app. Long story short as to the reasons why we are using session scoped Spring beans is for our login bean. Basically, when this Spring app was written, about 3 years ago, they had to keep a session of the login bean so that it can be passed to a service that would check credentials before accessing any data in our service layer. This service layer is a Spring bean that is injected with the login bean so it (the service layer Spring bean) is session scoped as well. However, this service layer Spring bean is also a proxied bean. The challenge for us is that our Stripes application has to use the session scoped login Spring bean. But since it is being injected upon startup for our unit tests we are not sure how to either do a work around, which might include creating a applicationContext-test.xml where there are no session scoped Spring beans. This is not desirable because we would have to maintain two aplicationContext*.xml files. We are not sure what other options we have if we can't get the session scoped login bean to work with our current unit testing framework. Thanks for any help! Jay INFO: Root WebApplicationContext: initialization completed in 266 ms Dec 18, 2009 3:12:44 PM net.sourceforge.stripes.util.Log error SEVERE: net.sourceforge.stripes.exception.StripesRuntimeException: Something is trying to access the current Stripes configuration but the current request was never routed through the StripesFilter! As a result the appropriate Configuration object cannot be located. Please take a look at the exact URL in your browser's address bar and ensure that any requests to that URL will be filtered through the StripesFilter according to the filter mappings in your web.xml. at net.sourceforge.stripes.controller.StripesFilter.getConfiguration(StripesFilter.java:161) at net.sourceforge.stripes.util.CryptoUtil.encrypt(CryptoUtil.java:123) at net.sourceforge.stripes.mock.MockRoundtrip.setSourcePage(MockRoundtrip.java:234) at net.sourceforge.stripes.mock.MockRoundtrip.<init>(MockRoundtrip.java:160) at com.initiatesystems.accessibility.actions.TaskSearhActionBeanTest.testFailBeginEndDates(TaskSearhActionBeanTest.java:135) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Dec 18, 2009 3:12:44 PM net.sourceforge.stripes.util.Log warn WARNING: Found unique SpringBean with type [com.initiatesystems.web.inspector.controller.InspectorInitController]. Matching on type is a little risky so watch out! Dec 18, 2009 3:12:44 PM net.sourceforge.stripes.util.Log warn WARNING: Unhandled exception caught by the Stripes default exception handler. net.sourceforge.stripes.exception.StripesRuntimeException: Exception while trying to lookup and inject a Spring bean into a bean of type TaskSearchActionBean using field access on field protected com.initiatesystems.web.common.spring.LoginBean com.initiatesystems.accessibility.actions.BaseActionBean.loginBean at net.sourceforge.stripes.integration.spring.SpringHelper.injectBeans(SpringHelper.java:132) at net.sourceforge.stripes.integration.spring.SpringHelper.injectBeans(SpringHelper.java:93) at net.sourceforge.stripes.integration.spring.SpringHelper.injectBeans(SpringHelper.java:81) at net.sourceforge.stripes.integration.spring.SpringInterceptor.intercept(SpringInterceptor.java:67) at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113) at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) at net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74) at net.sourceforge.stripes.controller.DispatcherHelper.resolveActionBean(DispatcherHelper.java:102) at net.sourceforge.stripes.controller.DispatcherServlet.resolveActionBean(DispatcherServlet.java:238) at net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:141) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at net.sourceforge.stripes.mock.MockFilterChain.doFilter(MockFilterChain.java:66) at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247) at net.sourceforge.stripes.mock.MockFilterChain.doFilter(MockFilterChain.java:63) at net.sourceforge.stripes.mock.MockServletContext.acceptRequest(MockServletContext.java:255) at net.sourceforge.stripes.mock.MockRoundtrip.execute(MockRoundtrip.java:245) at net.sourceforge.stripes.mock.MockRoundtrip.execute(MockRoundtrip.java:257) at com.initiatesystems.accessibility.actions.TaskSearhActionBeanTest.testFailBeginEndDates(TaskSearhActionBeanTest.java:140) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.IllegalArgumentException: Session must not be null at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.web.util.WebUtils.getSessionMutex(WebUtils.java:327) at org.springframework.web.context.request.ServletRequestAttributes.getSessionMutex(ServletRequestAttributes.java:191) at org.springframework.web.context.request.SessionScope.get(SessionScope.java:88) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:285) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:737) at net.sourceforge.stripes.integration.spring.SpringHelper.findSpringBean(SpringHelper.java:258) at net.sourceforge.stripes.integration.spring.SpringHelper.injectBeans(SpringHelper.java:128) ... 38 more -- View this message in context: http://old.nabble.com/Unit-Testing-Mock-Object---Spring-Beans-tp26845824p26849934.html Sent from the stripes-users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users