???????Struts2Spring?????Action??Service
???????????? ???????[ 2013/11/13 14:55:31 ] ????????
????4.???Service??
package action;
import org.springframework.stereotype.Service;
@Service
public class UserService {
/**
* ????????????
*/
public String getName(String name) {
// ?????????????????Dao??ò????????????
// ?????????????Struts2Spring?????У?Struts??Action??Spring????Service??
// Struts2Spring+Hibernate/Mybatis???????????н????
return name;
}
}
????5.???????Action??
package unittest;
import org.apache.struts2.StrutsSpringTestCase;
import org.junit.Test;
import action.UserAction;
import com.opensymphony.xwork2.ActionProxy;
/**
* ????StrutsSpring??????????????StrutsSpringTestCase?????
* ??????????Struts????????StrutsTestCase??
*
* @author http://blog.csdn.net/fansunion/
*
*/
public class ActionUnitTest extends StrutsSpringTestCase {
// ??д????????????????????????
protected String[] getContextLocations() {
return new String[] { "struts.xml"?? "applicationContext-spring.xml" };
}
@Test
public void testExecute() throws Exception {
ActionProxy proxy = getActionProxy("/unitTest");
UserAction test = (UserAction) proxy.getAction();
assertNotNull(test);
String result = proxy.execute();
assertEquals("success"?? result);
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11