Created
October 5, 2010 09:58
-
-
Save MoriTanosuke/611307 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-Dcactus.contextURL=http://localhost:8080/test | |
-Dcactus.jetty.resourceDir=./WebContent | |
-Dcactus.jetty.config=./test/jetty.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import org.apache.struts.action.Action; | |
import org.apache.struts.action.ActionForm; | |
import org.apache.struts.action.ActionForward; | |
import org.apache.struts.action.ActionMapping; | |
public class StringReverseAction extends Action { | |
@Override | |
public ActionForward execute(ActionMapping mapping, ActionForm form, | |
HttpServletRequest request, HttpServletResponse response) | |
throws Exception { | |
// reverse parameter 'value' | |
final String value = new StringBuilder(request.getParameter("value")).reverse().toString(); | |
request.setAttribute("result", value.toString()); | |
return mapping.findForward("success"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import junit.framework.Test; | |
import junit.framework.TestSuite; | |
import org.apache.cactus.ServletTestCase; | |
import org.apache.cactus.extension.jetty.Jetty6xTestSetup; | |
import org.apache.struts.action.Action; | |
import org.apache.struts.action.ActionForward; | |
public class StringReverseActionTest extends ServletTestCase { | |
public static Test suite() { | |
TestSuite suite = new TestSuite(); | |
suite.addTestSuite(StringReverseActionTest.class); | |
return new Jetty6xTestSetup(suite); | |
} | |
public void testExecute() throws Exception { | |
Action action = new StringReverseAction(); | |
ActionForward forward = action.execute(null, null, request, response); | |
assertNotNull(forward); | |
assertEquals("/success.jsp", forward.getPath()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment