// Path: j2w-webtest/src/main/java/java2word/actions/Testing.java
// public class Testing extends ActionSupport implements ServletResponseAware, ServletRequestAware {
// 
//     @Override
//     public String execute() throws Exception {
// //		System.out.println("### About to generate Word doc...");
// 
// //		System.out.println("XML is: \n" + this.xml + "\n");
// //###LEO
// 
//         request.setAttribute("res", "@@@ " + new Date());
//         request.getSession().setAttribute("xml", xml);
// 
//         //'UTF-8', 'ISO-8859-1' or nothing? up to you...
//         if (!StringUtils.isEmpty(xml)) {
//             response.setContentType("application/msword; charset=UTF-8");
//             response.setHeader("Content-disposition",
//                     "inline;filename=wordDoc.doc");
// 
//             PrintWriter writer = response.getWriter();
//             writer.println(xml);
//             writer.flush();
// //		System.out.println("### Doc generated...");
//             return null;
//         }else{
//             System.out.println("Error: Empty XML field porra!!!" );
//         }
// 
// 
//         return SUCCESS;
//     }
// 
//     // ### Getters and setters
//     private String xml;
//     private HttpServletResponse response;
//     private HttpServletRequest request;
// 
//     public String getXml() {
//         return xml;
//     }
// 
//     public void setXml(String xml) {
//         this.xml = xml;
//     }
// 
//     //@Override
//     public void setServletResponse(HttpServletResponse servletResponse) {
//         response = servletResponse;
//     }
// 
//     public void setServletRequest(HttpServletRequest servletRequest) {
//         request = servletRequest;
//     }
// 
// 
// 
// }


import java2word.actions.Testing;
import org.apache.struts2.StrutsTestCase;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;
import org.junit.Test;
import com.opensymphony.xwork2.ActionProxy;
import static com.opensymphony.xwork2.ActionSupport.*;
package java2word;





public class TestingTest extends StrutsTestCase{

    @Test
    public void testSanity() throws Exception{
        //pre requirements
        request.setParameter("xml", "this is the xml");

        //kinda of replay()
        ActionProxy proxy = getActionProxy("/testing");
// Path: j2w-webtest/src/main/java/java2word/actions/Testing.java
// public class Testing extends ActionSupport implements ServletResponseAware, ServletRequestAware {
// 
//     @Override
//     public String execute() throws Exception {
// //		System.out.println("### About to generate Word doc...");
// 
// //		System.out.println("XML is: \n" + this.xml + "\n");
// //###LEO
// 
//         request.setAttribute("res", "@@@ " + new Date());
//         request.getSession().setAttribute("xml", xml);
// 
//         //'UTF-8', 'ISO-8859-1' or nothing? up to you...
//         if (!StringUtils.isEmpty(xml)) {
//             response.setContentType("application/msword; charset=UTF-8");
//             response.setHeader("Content-disposition",
//                     "inline;filename=wordDoc.doc");
// 
//             PrintWriter writer = response.getWriter();
//             writer.println(xml);
//             writer.flush();
// //		System.out.println("### Doc generated...");
//             return null;
//         }else{
//             System.out.println("Error: Empty XML field porra!!!" );
//         }
// 
// 
//         return SUCCESS;
//     }
// 
//     // ### Getters and setters
//     private String xml;
//     private HttpServletResponse response;
//     private HttpServletRequest request;
// 
//     public String getXml() {
//         return xml;
//     }
// 
//     public void setXml(String xml) {
//         this.xml = xml;
//     }
// 
//     //@Override
//     public void setServletResponse(HttpServletResponse servletResponse) {
//         response = servletResponse;
//     }
// 
//     public void setServletRequest(HttpServletRequest servletRequest) {
//         request = servletRequest;
//     }
// 
// 
// 
// }


// Path: j2w-webtest/src/test/java/java2word/TestingTest.java
import java2word.actions.Testing;
import org.apache.struts2.StrutsTestCase;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;
import org.junit.Test;
import com.opensymphony.xwork2.ActionProxy;
import static com.opensymphony.xwork2.ActionSupport.*;

package java2word;





public class TestingTest extends StrutsTestCase{

    @Test
    public void testSanity() throws Exception{
        //pre requirements
        request.setParameter("xml", "this is the xml");

        //kinda of replay()
        ActionProxy proxy = getActionProxy("/testing");
        Testing testingAction = (Testing) proxy.getAction();