[SPRING] Struts2.3.12 junit4 테스트 케이스 요청 및 세션이 null입니다.
SPRINGStruts2.3.12 junit4 테스트 케이스 요청 및 세션이 null입니다.
나는 이미이 해결책을 경험했다 : Struts 2 JUnit Plugin v2.2.3 : 테스트 클래스 확장 StrutsTestCase; '요청'이 null입니다.
그러나 나는 이미 struts2-spring 플러그인을 가지고 있지 않으며, 둘 다 Spring에서도 사용하고 있지 않습니다.
나는 3 개의 테스트 케이스를 가지고 있고, 2 개는 요청이 null 일 때 실패하고 하나는 세션이 null 일 때 실패한다.
첫 번째 스택 트레이스
java.lang.NullPointerException
at org.apache.struts2.interceptor.MessageStoreInterceptor.before(MessageStoreInterceptor.java:228)
at org.apache.struts2.interceptor.MessageStoreInterceptor.intercept(MessageStoreInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at actions.TestIoOptimizationAction.login(TestIoOptimizationAction.java:29)
에 해당
Collection actionErrors = (Collection) session.get(actionErrorsSessionKey);
두 번째 및 세 번째 테스트 스택 트레이스
java.lang.NullPointerException
at org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.StrutsJUnit4TestCase.getActionProxy(StrutsJUnit4TestCase.java:149)
에 해당
String contextPath = ServletActionContext.getRequest().getContextPath();
일부 종속성 문제가 있다고 생각합니다. 몇 가지 종속성을 하나씩 제거하려고 시도했지만 어느 것도 작동하지 않습니다.
POM의 모양은 다음과 같습니다.
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.paypal.sdk</groupId>
<artifactId>rest-api-sdk</artifactId>
<version>0.7.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils-core</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.0.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.7.3</version>
</dependency>
<!-- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>-->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>2.1.11</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>3.7.5</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
</dependencies>
<properties>
<struts.version>2.3.12</struts.version>
<hibernate.version>3.6.10.Final</hibernate.version>
<struts.jquery.version>3.5.1</struts.jquery.version>
<netbeans.compile.on.save>all</netbeans.compile.on.save>
<netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server>
</properties>
업데이트 - 테스트 결과는 다음과 같습니다.
@Test
public void login() throws Exception {
request.setParameter("email", "nitin.cool4urchat@gmail.com");
request.setParameter("password", "22");
ActionProxy proxy = getActionProxy("login");
String result = proxy.execute();
assertEquals("success", result);
System.out.println(response.getContentAsString());
}
@Test
public void testView() throws Exception {
ActionProxy proxy = getActionProxy("/optimize/view");
String result = proxy.execute();
assertEquals("success", result);
System.out.println(response.getContentAsString());
proxy = getActionProxy("/optimize/view/23");
result = proxy.execute();
assertEquals("success", result);
System.out.println(response.getContentAsString());
proxy = getActionProxy("/optimize/view/110");
result = proxy.execute();
assertEquals("success", result);
System.out.println(response.getContentAsString());
}
@Test
public void testSave() throws Exception {
request.setContent("{\"id\":\"1\",\"name\":\"nitin\"}".getBytes());
request.addHeader("Content-Type", "application/json");
request.setMethod("POST");
ActionProxy proxy = getActionProxy("/save");
actions.IoOptimizationAction myAct = (actions.IoOptimizationAction) proxy.getAction();
String result = proxy.execute();
assertEquals("success", result);
System.out.println(response.getContentAsString());
}
업데이트 제안 된 executeAction으로 테스트를 변경 했으므로 2 차 테스트는 다음과 같이 보입니다.
@Test
public void testView() throws Exception {
System.out.println(ActionContext.getContext());
System.out.println(executeAction("optimize/view"));
}
오류 스택 추적은 다음과 같습니다.
[2013-10-29 14:50:38.766] [ WARN] MockServletContext.getRealPath:298 - Couldn't determine real path of resource class path resource [org/apache/struts2/dispatcher/error_en_US.ftl]
java.io.FileNotFoundException: class path resource [org/apache/struts2/dispatcher/error_en_US.ftl] cannot be resolved to URL because it does not exist
at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:179)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:48)
at org.springframework.mock.web.MockServletContext.getRealPath(MockServletContext.java:295)
at freemarker.cache.WebappTemplateLoader.findTemplateSource(WebappTemplateLoader.java:129)
at freemarker.cache.MultiTemplateLoader.findTemplateSource(MultiTemplateLoader.java:111)
at freemarker.cache.TemplateCache.acquireTemplateSource(TemplateCache.java:646)
at freemarker.cache.TemplateCache.findTemplateSource(TemplateCache.java:622)
at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:346)
at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:235)
at freemarker.template.Configuration.getTemplate(Configuration.java:578)
at freemarker.template.Configuration.getTemplate(Configuration.java:543)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:841)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:569)
at org.apache.struts2.StrutsJUnit4TestCase.executeAction(StrutsJUnit4TestCase.java:128)
at actions.TestIoOptimizationAction.testView(TestIoOptimizationAction.java:44)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:520)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1060)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:911)
[2013-10-29 14:50:38.810] [ WARN] MockServletContext.getRealPath:298 - Couldn't determine real path of resource class path resource [org/apache/struts2/dispatcher/error_en.ftl]
java.io.FileNotFoundException: class path resource [org/apache/struts2/dispatcher/error_en.ftl] cannot be resolved to URL because it does not exist
at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:179)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:48)
at org.springframework.mock.web.MockServletContext.getRealPath(MockServletContext.java:295)
at freemarker.cache.WebappTemplateLoader.findTemplateSource(WebappTemplateLoader.java:129)
at freemarker.cache.MultiTemplateLoader.findTemplateSource(MultiTemplateLoader.java:111)
at freemarker.cache.TemplateCache.acquireTemplateSource(TemplateCache.java:646)
at freemarker.cache.TemplateCache.findTemplateSource(TemplateCache.java:622)
at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:346)
at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:235)
at freemarker.template.Configuration.getTemplate(Configuration.java:578)
at freemarker.template.Configuration.getTemplate(Configuration.java:543)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:841)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:569)
at org.apache.struts2.StrutsJUnit4TestCase.executeAction(StrutsJUnit4TestCase.java:128)
at actions.TestIoOptimizationAction.testView(TestIoOptimizationAction.java:44)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:520)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1060)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:911)
[2013-10-29 14:50:39.127] [ WARN] MockServletContext.getRealPath:298 - Couldn't determine real path of resource class path resource [org/apache/struts2/dispatcher/error.ftl]
java.io.FileNotFoundException: class path resource [org/apache/struts2/dispatcher/error.ftl] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/C:/Users/hp/.m2/repository/org/apache/struts/struts2-core/2.3.12/struts2-core-2.3.12.jar!/org/apache/struts2/dispatcher/error.ftl
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:204)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
at org.springframework.mock.web.MockServletContext.getRealPath(MockServletContext.java:295)
at freemarker.cache.WebappTemplateLoader.findTemplateSource(WebappTemplateLoader.java:129)
at freemarker.cache.MultiTemplateLoader.findTemplateSource(MultiTemplateLoader.java:111)
at freemarker.cache.TemplateCache.acquireTemplateSource(TemplateCache.java:646)
at freemarker.cache.TemplateCache.findTemplateSource(TemplateCache.java:622)
at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:346)
at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:235)
at freemarker.template.Configuration.getTemplate(Configuration.java:578)
at freemarker.template.Configuration.getTemplate(Configuration.java:543)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:841)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:569)
at org.apache.struts2.StrutsJUnit4TestCase.executeAction(StrutsJUnit4TestCase.java:128)
at actions.TestIoOptimizationAction.testView(TestIoOptimizationAction.java:44)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:520)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1060)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:911)
<html>
<head>
<title>Struts Problem Report</title>
<style>
pre {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<h2>Struts Problem Report</h2>
<p>
Struts has detected an unhandled exception:
</p>
<div id="exception-info">
<table>
<tr>
<td><strong>Messages</strong>:</td>
<td>
</td>
</tr>
<tr>
<td><strong>File</strong>:</td>
<td>org/apache/struts2/impl/StrutsActionProxy.java</td>
</tr>
<tr>
<td><strong>Line number</strong>:</td>
<td>69</td>
</tr>
</table>
</div>
<div id="stacktraces">
<hr />
<h3>Stacktraces</h3>
<div class="stacktrace" style="padding-left: 0em">
<strong>java.lang.NullPointerException</strong>
<div>
<pre>
org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:536)
org.apache.struts2.StrutsJUnit4TestCase.executeAction(StrutsJUnit4TestCase.java:128)
actions.TestIoOptimizationAction.testView(TestIoOptimizationAction.java:44)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
org.junit.runners.ParentRunner.run(ParentRunner.java:236)
junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:520)
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1060)
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:911)
</pre>
</div>
</div>
</div>
<div class="footer">
<hr />
<p>
You are seeing this page because development mode is enabled. Development mode, or devMode, enables extra
debugging behaviors and reports to assist developers. To disable this mode, set:
<pre>
struts.devMode=false
</pre>
in your <code>WEB-INF/classes/struts.properties</code> file.
</p>
</div>
</body>
</html>
해결법
-
==============================
1.getActionProxy 메소드를 사용하여 작업을 실행하는 경우 새 세션 맵을 호출 컨텍스트로 설정해야합니다.
getActionProxy 메소드를 사용하여 작업을 실행하는 경우 새 세션 맵을 호출 컨텍스트로 설정해야합니다.
ActionProxy actionProxy = getActionProxy("/action"); Map<String, Object> sessionMap = new HashMap<String, Object>(); actionProxy.getInvocation().getInvocationContext().setSession(sessionMap); actionProxy.execute();
액션 프록시에 대한 참조가 필요 없다면 executeAction 메소드를 사용할 수 있습니다. executeAction은 execute 메소드에서 반환 된 결과가 아니라 결과의 실제 결과를 반환합니다.
-
==============================
2.제 경우에는 super.setUp을 테스트에서 호출해야했습니다.
제 경우에는 super.setUp을 테스트에서 호출해야했습니다.
-
==============================
3.요청이 null이되지 않도록하려면 다음을 수행하십시오.
요청이 null이되지 않도록하려면 다음을 수행하십시오.
request = new MockHttpServletRequest();
세션 :
Map<String, Object> sessionMap = new HashMap<String, Object>(); actionProxy.getInvocation().getInvocationContext().setSession(sessionMap);
from https://stackoverflow.com/questions/19649952/struts2-3-12-junit4-testcase-request-session-are-null by cc-by-sa and MIT license
'SPRING' 카테고리의 다른 글
[SPRING] 봄 일괄 처리에서 끝나지 않은 큰 따옴표 (0) | 2019.02.21 |
---|---|
[SPRING] Spring 구성 파일에서 <util : list>를 다시 사용할 수 있습니까? (0) | 2019.02.21 |
[SPRING] JBoss 6 + Spring 3.0.5 + JAX-WS / CXF (0) | 2019.02.21 |
[SPRING] 응용 프로그램을 전개하는 java.lang.AbstractMethodError (Spring 4 MVC + Hibernate 4/5) (0) | 2019.02.21 |
[SPRING] PropertyPlaceholderConfigurer : 외부 속성 파일 사용 (0) | 2019.02.21 |