jUnit Testing Problem with Tiles
) at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230) at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230) at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:130) at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230) at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230) at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227) at com.opensymphony.xwork2.DefaultActionProxy.execute(DefaultActionProxy.java:130) at pack.HelloWorldTest.testHelloWorldAction(HelloWorldTest.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:228) at junit.framework.TestSuite.run(TestSuite.java:223) at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) If you look at the tutorial I refer, you can understand that I am not the only one who have this problem. I try to set the configuration file to tiles.defs.xml as suggested, but it gave an XML parse exception. What can be the solution;? Thanks jUnit newbie Ezgi :) -- View this message in context: http://www.nabble.com/jUnit-Testing-Problem-with-Tiles-tp18131822p18131822.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jUnit Testing Problem with Tiles
This is the tiles.defs.xml : ?xml version=1.0 encoding=ISO-8859-1 ? !DOCTYPE tiles-definitions PUBLIC -//Apache Software Foundation//DTD Tiles Configuration 2.0//EN http://tiles.apache.org/dtds/tiles-config_2_0.dtd; tiles-definitions definition name=tvq.template.default template=/layouts/default.jsp put-attribute name=title value=Tiles tutorial homepage / put-attribute name=header value=/tiles/header.jsp / put-attribute name=menu value=/tiles/menu.jsp / put-attribute name=content value=/tiles/content.jsp / put-attribute name=footer value=/tiles/footer.jsp / /definition definition name=tvq.ListTasks extends=tvq.template.default put-attribute name=title value=List Tasks / put-attribute name=content value=/jsp/task/ListTasks.jsp / /definition definition name=tvq.addTask extends=tvq.template.default put-attribute name=title value=Add a Task / put-attribute name=content value=/jsp/task/addTask.jsp / /definition /tiles-definitions and this is the web.xml : ?xml version=1.0 encoding=UTF-8? web-app id=WebApp_ID version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; display-nameTVQ/display-name filter filter-namestruts2/filter-name filter-class org.apache.struts2.dispatcher.FilterDispatcher /filter-class /filter !-- Add the filter mapping after all filters -- filter-mapping filter-namestruts2/filter-name url-pattern/*/url-pattern /filter-mapping listener listener-class org.springframework.web.context.ContextLoaderListener /listener-class /listener listener listener-class org.apache.struts2.tiles.StrutsTilesListener /listener-class /listener servlet servlet-nametiles/servlet-name servlet-class org.apache.tiles.web.startup.TilesServlet /servlet-class init-param param-name org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG /param-name param-value /WEB-INF/tiles-defs.xml /param-value /init-param load-on-startup2/load-on-startup /servlet filter filter-nameTiles_Filter/filter-name filter-class org.apache.tiles.web.startup.TilesFilter /filter-class init-param param-name org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG /param-name param-value /WEB-INF/tiles-defs.xml /param-value /init-param /filter filter-mapping filter-nameTiles_Filter/filter-name url-pattern/*/url-pattern dispatcherREQUEST/dispatcher /filter-mapping welcome-file-list welcome-fileindex.html/welcome-file welcome-fileindex.htm/welcome-file welcome-fileindex.jsp/welcome-file welcome-filedefault.html/welcome-file welcome-filedefault.htm/welcome-file welcome-filedefault.jsp/welcome-file /welcome-file-list /web-app Antonio Petrelli-3 wrote: 2008/6/26 ezgi [EMAIL PROTECTED]: If you look at the tutorial I refer, you can understand that I am not the only one who have this problem. I try to set the configuration file to tiles.defs.xml as suggested, but it gave an XML parse exception. Can we see the Tiles definition files that you are using? Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/jUnit-Testing-Problem-with-Tiles-tp18131822p18132170.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jUnit Testing Problem with Tiles
I tried three of them seperatley, but it did not work. Should I modify the configuration variable in the BaseStrutsTestCase? I did not add there web.xml and tiles-defs.xml. As you suggested, I add this code into web.xml. listener listener-class org.apache.tiles.web.startup.TilesListener /listener-class /listener context-param param-name org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG /param-name param-value /WEB-INF/tiles-defs.xml,/org/apache/tiles/classpath-defs.xml /param-value /context-param Antonio Petrelli-3 wrote: 2008/6/26 ezgi [EMAIL PROTECTED]: This is the tiles.defs.xml : listener listener-class org.apache.struts2.tiles.StrutsTilesListener /listener-class /listener servlet servlet-nametiles/servlet-name servlet-class org.apache.tiles.web.startup.TilesServlet /servlet-class init-param param-name org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG /param-name param-value /WEB-INF/tiles-defs.xml /param-value /init-param load-on-startup2/load-on-startup /servlet filter filter-nameTiles_Filter/filter-name filter-class org.apache.tiles.web.startup.TilesFilter /filter-class init-param param-name org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG /param-name param-value /WEB-INF/tiles-defs.xml /param-value /init-param /filter filter-mapping filter-nameTiles_Filter/filter-name url-pattern/*/url-pattern dispatcherREQUEST/dispatcher /filter-mapping The problem is that you are using StrutsTilesListener (that loads /WEB-INF/tiles.xml by default), TilesServlet and TilesFilter at the same time. Choose one and configure it. I suggest to use StrutsTilesListener only. Configuring it means putting a context parameter. See: http://tiles.apache.org/tutorial/configuration.html Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/jUnit-Testing-Problem-with-Tiles-tp18131822p18132646.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jUnit Testing Problem with Tiles
I have loaded the Tiles listener and run the jUnit test and it gave the same NullPointer Exception. Moreover, the trace is same as before. Then, I tried to load tiles servlet, and it gave the same error. Lastly, I loaded the tiles filter and it gave ther same NPE. I have already tried three of them so I can't figure out what the problem is. Did I load them wrongly? I have just replaced the code with the new one, isn't it the one you suggested? Modified web.xml: ?xml version=1.0 encoding=UTF-8? web-app id=WebApp_ID version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; display-nameTVQ/display-name filter filter-namestruts2/filter-name filter-class org.apache.struts2.dispatcher.FilterDispatcher /filter-class /filter !-- Add the filter mapping after all filters -- filter-mapping filter-namestruts2/filter-name url-pattern/*/url-pattern /filter-mapping listener listener-class org.springframework.web.context.ContextLoaderListener /listener-class /listener listener listener-class org.apache.tiles.web.startup.TilesListener /listener-class /listener context-param param-name org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG /param-name param-value /WEB-INF/tiles-defs.xml,/org/apache/tiles/classpath-defs.xml /param-value /context-param welcome-file-list welcome-fileindex.html/welcome-file welcome-fileindex.htm/welcome-file welcome-fileindex.jsp/welcome-file welcome-filedefault.html/welcome-file welcome-filedefault.htm/welcome-file welcome-filedefault.jsp/welcome-file /welcome-file-list /web-app Antonio Petrelli-3 wrote: 2008/6/26 ezgi [EMAIL PROTECTED]: I tried three of them seperatley, but it did not work. Please clarify, what do you mean with it did not work? Do you receive an exception at startup? Should I modify the configuration variable in the BaseStrutsTestCase? I did not add there web.xml and tiles-defs.xml. Sincerely I am not into BaseStrutsTestCase, so I cannot help in this case param-value /WEB-INF/tiles-defs.xml,/org/apache/tiles/classpath-defs.xml /param-value Have you got a classpath-defs.xml anywhere in your code? If not, remove it. Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/jUnit-Testing-Problem-with-Tiles-tp18131822p18132968.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jUnit Testing Problem with Tiles
If I add the location of web.xml or any other thing to here private static final String CONFIG_LOCATIONS = file:src/struts.xml ; I got a parsing error. I am not very experienced with tiles, I just test the code in a big project. The problem is , if I do not include tiles, my unit test works perfectly. If you did not look at the BaseStrutsTEstCase class, it is a helper class to create an artificial environment for requests and interceptors. May be my problem is related to the jUnit part, but why I can't test with tiles? Antonio Petrelli-3 wrote: 2008/6/26 ezgi [EMAIL PROTECTED]: I have just replaced the code with the new one, isn't it the one you suggested? Yes, but you had to adapt it to your needs. By the way, do you still receive a parsing error, at startup? Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/jUnit-Testing-Problem-with-Tiles-tp18131822p18133212.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jUnit Testing Problem with Tiles
In my action, I have a reference to Http request and it requires to access the HttpServletRequest object, so I can not easily test the action with just calling the execute method and comparing the result. So, I have found out a solution from the link that I refere before, I did not write the BaseStrutsTestCase, I modified the class. It creates mock objects and helps to test my action outside of the server environment. It takes the advantage of the ActionProxy. All I did was to simulate some user input, and remaining part is handled by this helper class. Antonio Petrelli-3 wrote: 2008/6/26 ezgi [EMAIL PROTECTED]: If I add the location of web.xml or any other thing to here private static final String CONFIG_LOCATIONS = file:src/struts.xml ; I got a parsing error. I am not very experienced with tiles, I just test the code in a big project. The problem is , if I do not include tiles, my unit test works perfectly. If you did not look at the BaseStrutsTEstCase class, it is a helper class to create an artificial environment for requests and interceptors. May be my problem is related to the jUnit part, but why I can't test with tiles? Just one question: how are you configuring the artificial environment? Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/jUnit-Testing-Problem-with-Tiles-tp18131822p18133546.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jUnit Testing Problem with Tiles
This is the action class: public class HelloWorldTest extends BaseStrutsTestCase { HelloWorld hello; Map testSession; @Before public void setUp() throws Exception { super.setUp(); hello = createAction( HelloWorld.class, /,HelloWorld ); testSession = new HashMap(); testSession.put(username, admin); testSession.put(password, sifre); proxy.getInvocation().getInvocationContext().setParameters(testSession); } @Test public void testHelloWorldAction() throws Exception { assertTrue(SUCCESS.equals(proxy.execute())); } If you look at the link, you can understand the problem. Whose initialization is the one that you can't understand? Antonio Petrelli-3 wrote: 2008/6/26 ezgi [EMAIL PROTECTED]: In my action, I have a reference to Http request and it requires to access the HttpServletRequest object, so I can not easily test the action with just calling the execute method and comparing the result. So, I have found out a solution from the link that I refere before, I did not write the BaseStrutsTestCase, I modified the class. It creates mock objects and helps to test my action outside of the server environment. It takes the advantage of the ActionProxy. All I did was to simulate some user input, and remaining part is handled by this helper class. And the initialization? I still cannot understand. Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/jUnit-Testing-Problem-with-Tiles-tp18131822p18133751.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jUnit Testing Problem with Tiles
How can I initialize tiles in this context? Antonio Petrelli-3 wrote: 2008/6/26 ezgi [EMAIL PROTECTED]: If you look at the link, you can understand the problem. Whose initialization is the one that you can't understand? I see, but I am sorry, without initialization Tiles won't work. Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/jUnit-Testing-Problem-with-Tiles-tp18131822p18133946.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jUnit Testing Problem with Tiles
Thank you very much, but they also seem not to find the solution. Antonio Petrelli-3 wrote: 2008/6/26 ezgi [EMAIL PROTECTED]: How can I initialize tiles in this context? In some ways, you have to manage to put StrutsTilesListener, or at least its code, but I don't really know how to do it. I suggest to ask the BaseStrutsTestCase developers. Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/jUnit-Testing-Problem-with-Tiles-tp18131822p18134225.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]