Review Board 1.7.22


Closure compile all feature JavaScript as part of JUnit execution to ensure no JavaScript errors at build time

Review Request #5107 - Created May 14, 2012 and submitted

Stanton Sievers
SHINDIG-1771
Reviewers
shindig
shindig
See the JIRA for the high-level description.

My approach to doing this was to introduce a new test case in the end-to-end tests.  This way I can test with a real FeatureRegistry against the real web app.  I make a request to the JsServlet for all of the features, which will run through the compiler processors.  Because of the changes that went in for https://issues.apache.org/jira/browse/SHINDIG-1770, we will return the compile error and this will get printed as part of the JUnit assert failure, pin-pointing the exact compile problem.

Note that this does increase the time it takes to execute the EndToEndTest on the scale of tens of seconds.
Introduced some JS errors and verified that the unit test failed.  Additionally verified the reason for the failure was readily available.
http://svn.apache.org/repos/asf/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/AllJsFilter.java
Diff Revision 3 Diff Revision 4
[20] 59 lines
[+20] [+] public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
60

    
   
60

   
61
    HttpServletRequest req = (HttpServletRequest) request;
61
    HttpServletRequest req = (HttpServletRequest) request;
62
    HttpServletResponse resp = (HttpServletResponse) response;
62
    HttpServletResponse resp = (HttpServletResponse) response;
63

    
   
63

   
64
    String requestURI = req.getRequestURI();
64
    String requestURI = req.getRequestURI();
65
    if (!requestURI.contains("all.js")) {
65
    if (!requestURI.contains("all-features-please.js")) {
66
      chain.doFilter(request, response);
66
      chain.doFilter(request, response);
67
    } else {
67
    } else {
68
      String newURI = requestURI.replace("all.js", allFeatures + ".js") + "?" + req.getQueryString();
68
      String newURI = requestURI.replace("all-features-please.js", allFeatures + ".js") + "?" + req.getQueryString();
69
      resp.sendRedirect(newURI);
69
      resp.sendRedirect(newURI);
70
    }
70
    }
71
  }
71
  }
72

    
   
72

   
73
  public void destroy() {
73
  public void destroy() {
74
  }
74
  }
75
}
75
}
76

    
   
76

   
http://svn.apache.org/repos/asf/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
Diff Revision 3 Diff Revision 4
 
  1. http://svn.apache.org/repos/asf/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/AllJsFilter.java: Loading...
  2. http://svn.apache.org/repos/asf/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java: Loading...