Author: grobmeier
Date: Wed Dec 12 19:36:56 2012
New Revision: 1420928
URL: http://svn.apache.org/viewvc?rev=1420928&view=rev
Log:
example on how to wire session scoped spring beans prio spring-test 3.2 with
the junit plugin
Added:
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/MySessionBean.java
(with props)
Modified:
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/JUnitTestAction.java
struts/struts2/trunk/plugins/junit/src/test/resources/applicationContext.xml
Modified:
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/JUnitTestAction.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/JUnitTestAction.java?rev=1420928&r1=1420927&r2=1420928&view=diff
==============================================================================
---
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/JUnitTestAction.java
(original)
+++
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/JUnitTestAction.java
Wed Dec 12 19:36:56 2012
@@ -21,10 +21,14 @@
package org.apache.struts2;
import com.opensymphony.xwork2.ActionSupport;
+import org.springframework.beans.factory.annotation.Autowired;
public class JUnitTestAction extends ActionSupport {
private String name;
+ @Autowired
+ private MySessionBean mySessionBean;
+
public String getName() {
return name;
}
Added:
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/MySessionBean.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/MySessionBean.java?rev=1420928&view=auto
==============================================================================
---
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/MySessionBean.java
(added)
+++
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/MySessionBean.java
Wed Dec 12 19:36:56 2012
@@ -0,0 +1,28 @@
+/*
+ * $Id: $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2;
+
+public class MySessionBean {
+
+ public void doSomething() {
+ // do Something
+ }
+}
Propchange:
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/MySessionBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
struts/struts2/trunk/plugins/junit/src/test/resources/applicationContext.xml
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/resources/applicationContext.xml?rev=1420928&r1=1420927&r2=1420928&view=diff
==============================================================================
---
struts/struts2/trunk/plugins/junit/src/test/resources/applicationContext.xml
(original)
+++
struts/struts2/trunk/plugins/junit/src/test/resources/applicationContext.xml
Wed Dec 12 19:36:56 2012
@@ -2,5 +2,17 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean
class="org.springframework.beans.factory.config.CustomScopeConfigurer">
+ <property name="scopes">
+ <map>
+ <entry key="session">
+ <bean
class="org.springframework.context.support.SimpleThreadScope"/>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
<bean id="testAction" class="org.apache.struts2.JUnitTestAction"/>
+ <bean id="mySessionBean" class="org.apache.struts2.MySessionBean"
scope="session" />
</beans>
\ No newline at end of file