@Test @Ignore public void testCompileJs2() throws Exception { final String templateName1 = "templates/template1.soy"; final String templateName2 = "templates/template2.soy"; final String jsData1 = "jsData1"; final String jsData2 = "jsData2"; final HttpServletRequest request = mock(HttpServletRequest.class); when(localeProvider.resolveLocale(request)).thenReturn(Optional.<Locale>absent()); when(soyMsgBundleResolver.resolve(any(Optional.class))).thenReturn(Optional.<SoyMsgBundle>absent()); final URL url1 = getClass().getClassLoader().getResource(templateName1); final URL url2 = getClass().getClassLoader().getResource(templateName2); when(templateFilesResolver.resolve(templateName1)).thenReturn(Optional.of(url1)); when(templateFilesResolver.resolve(templateName2)).thenReturn(Optional.of(url2)); when(tofuCompiler.compileToJsSrc(url1, null)).thenReturn(Optional.of(jsData1)); when(tofuCompiler.compileToJsSrc(url2, null)).thenReturn(Optional.of(jsData2)); final ResponseEntity<String> responseEntity = soyAjaxController.compile("", new String[]{templateName1, templateName2}, null, "true", request); Assert.assertEquals("data should be equal", jsData1 + jsData2, responseEntity.getBody()); Assert.assertTrue("http status should be equal", (responseEntity.getStatusCode() == HttpStatus.OK)); }
@RequestMapping(value="/soy/compileJs", method=GET) public ResponseEntity<String> compile(@RequestParam(required = false, value="hash", defaultValue = "") final String hash, @RequestParam(required = true, value = "file") final String[] templateFileNames, @RequestParam(required = false, value = "locale") String locale, @RequestParam(required = false, value = "disableProcessors", defaultValue = "false") String disableProcessors, final HttpServletRequest request) throws IOException { return compileJs(templateFileNames, hash, new Boolean(disableProcessors).booleanValue(), request, locale); }
SoyAjaxController { @RequestMapping(value="/soy/compileJs", method=GET) public ResponseEntity<String> compile(@RequestParam(required = false, value="hash", defaultValue = "") final String hash, @RequestParam(required = true, value = "file") final String[] templateFileNames, @RequestParam(required = false, value = "locale") String locale, @RequestParam(required = false, value = "disableProcessors", defaultValue = "false") String disableProcessors, final HttpServletRequest request) throws IOException { return compileJs(templateFileNames, hash, new Boolean(disableProcessors).booleanValue(), request, locale); } }
SoyAjaxController { @RequestMapping(value="/soy/compileJs", method=GET) public ResponseEntity<String> compile(@RequestParam(required = false, value="hash", defaultValue = "") final String hash, @RequestParam(required = true, value = "file") final String[] templateFileNames, @RequestParam(required = false, value = "locale") String locale, @RequestParam(required = false, value = "disableProcessors", defaultValue = "false") String disableProcessors, final HttpServletRequest request) throws IOException { return compileJs(templateFileNames, hash, new Boolean(disableProcessors).booleanValue(), request, locale); } SoyAjaxController(); }
SoyAjaxController { @RequestMapping(value="/soy/compileJs", method=GET) public ResponseEntity<String> compile(@RequestParam(required = false, value="hash", defaultValue = "") final String hash, @RequestParam(required = true, value = "file") final String[] templateFileNames, @RequestParam(required = false, value = "locale") String locale, @RequestParam(required = false, value = "disableProcessors", defaultValue = "false") String disableProcessors, final HttpServletRequest request) throws IOException { return compileJs(templateFileNames, hash, new Boolean(disableProcessors).booleanValue(), request, locale); } SoyAjaxController(); @PostConstruct void init(); @RequestMapping(value="/soy/compileJs", method=GET) ResponseEntity<String> compile(@RequestParam(required = false, value="hash", defaultValue = "") final String hash,
                                                            @RequestParam(required = true, value = "file") final String[] templateFileNames,
                                                            @RequestParam(required = false, value = "locale") String locale,
                                                            @RequestParam(required = false, value = "disableProcessors", defaultValue = "false") String disableProcessors,
                                                            final HttpServletRequest request); void setCacheControl(final String cacheControl); void setTemplateFilesResolver(final TemplateFilesResolver templateFilesResolver); void setTofuCompiler(final TofuCompiler tofuCompiler); void setSoyMsgBundleResolver(final SoyMsgBundleResolver soyMsgBundleResolver); void setLocaleProvider(final LocaleProvider localeProvider); void setHotReloadMode(final boolean hotReloadMode); void setEncoding(final String encoding); void setExpiresHeaders(final String expiresHeaders); void setOutputProcessors(List<OutputProcessor> outputProcessors); void setAuthManager(AuthManager authManager); void setCacheMaxSize(int cacheMaxSize); void setExpireAfterWrite(int expireAfterWrite); void setExpireAfterWriteUnit(String expireAfterWriteUnit); }
SoyAjaxController { @RequestMapping(value="/soy/compileJs", method=GET) public ResponseEntity<String> compile(@RequestParam(required = false, value="hash", defaultValue = "") final String hash, @RequestParam(required = true, value = "file") final String[] templateFileNames, @RequestParam(required = false, value = "locale") String locale, @RequestParam(required = false, value = "disableProcessors", defaultValue = "false") String disableProcessors, final HttpServletRequest request) throws IOException { return compileJs(templateFileNames, hash, new Boolean(disableProcessors).booleanValue(), request, locale); } SoyAjaxController(); @PostConstruct void init(); @RequestMapping(value="/soy/compileJs", method=GET) ResponseEntity<String> compile(@RequestParam(required = false, value="hash", defaultValue = "") final String hash,
                                                            @RequestParam(required = true, value = "file") final String[] templateFileNames,
                                                            @RequestParam(required = false, value = "locale") String locale,
                                                            @RequestParam(required = false, value = "disableProcessors", defaultValue = "false") String disableProcessors,
                                                            final HttpServletRequest request); void setCacheControl(final String cacheControl); void setTemplateFilesResolver(final TemplateFilesResolver templateFilesResolver); void setTofuCompiler(final TofuCompiler tofuCompiler); void setSoyMsgBundleResolver(final SoyMsgBundleResolver soyMsgBundleResolver); void setLocaleProvider(final LocaleProvider localeProvider); void setHotReloadMode(final boolean hotReloadMode); void setEncoding(final String encoding); void setExpiresHeaders(final String expiresHeaders); void setOutputProcessors(List<OutputProcessor> outputProcessors); void setAuthManager(AuthManager authManager); void setCacheMaxSize(int cacheMaxSize); void setExpireAfterWrite(int expireAfterWrite); void setExpireAfterWriteUnit(String expireAfterWriteUnit);  }