Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4111

Restful2ActionMapper add test to documentation

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.3.15
    • Fix Version/s: 2.3.16
    • Component/s: Documentation
    • Labels:

      Description

      public class MovieActionTest extends StrutsJUnit4TestCase<MovieActionTest>{
          
          @Before
          public void setUp() throws Exception {
      
              //assumes Basic authentication
              super.setUp();
              String credentials = "username:password";
              request.addHeader("authorization", "BASIC " + Base64.encodeBase64String(credentials.getBytes()));
          }
      
              
          @Test
          public void testIndex() throws Exception {
              
               
              request.setMethod("get"); //Http method should be set
              
              ActionProxy proxy = getActionProxy("/rest/movie/");                        
            
              proxy.setExecuteResult(false);
              String result = proxy.execute();
              
             //assertions ...
              
          }
          
          @Test
          public void testView() throws Exception {
              
            
              request.setMethod("get"); //Http method should be set
                    
              ActionProxy proxy = getActionProxy("/rest/movie/1");                        
              MovieAction movieAction = MovieAction.class.cast(proxy.getAction());
                 
              proxy.setExecuteResult(false);
              
              String result = proxy.execute();
              //assertions ...
               assertEquals("1", movieAction.getId()); 
              
          }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              gkogkaka@tcd.ie Antonios Gkogkakis
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: