本文整理汇总了Java中freemarker.template.TemplateException类的典型用法代码示例。如果您正苦于以下问题:Java TemplateException类的具体用法?Java TemplateException怎么用?Java TemplateException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TemplateException类属于freemarker.template包,在下文中一共展示了TemplateException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequestShouldThrowException
import freemarker.template.TemplateException; //导入依赖的package包/类
@Test
public void handleRequestShouldThrowException() throws TemplateException, KeyOperationException, IOException {
expectedException.expect(RuntimeException.class);
expectedException.expectMessage("Email");
LinkGeneratorLambdaHandler handler = mock(LinkGeneratorLambdaHandler.class);
doCallRealMethod().when(handler).handleRequest(any(), any());
Exception ex = new TemplateException("Message", null);
doThrow(ex).when(handler).getUploadPageUrlFromRequest(any(), any());
Context context = mock(Context.class);
LambdaLogger logger = mock(LambdaLogger.class);
doNothing().when(logger).log(anyString());
doReturn(logger).when(context).getLogger();
handler.handleRequest(mock(LinkGeneratorRequest.class), context);
}
示例2: templateConfiguration
import freemarker.template.TemplateException; //导入依赖的package包/类
private static Configuration templateConfiguration() {
Configuration configuration = new Configuration(Configuration.VERSION_2_3_26);
configuration.setDefaultEncoding("UTF-8");
configuration.setLogTemplateExceptions(false);
try {
configuration.setSetting("object_wrapper",
"DefaultObjectWrapper(2.3.26, forceLegacyNonListCollections=false, "
+ "iterableSupport=true, exposeFields=true)");
} catch (TemplateException e) {
e.printStackTrace();
}
configuration.setAPIBuiltinEnabled(true);
configuration.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(),
"templates/ccda");
return configuration;
}
示例3: allSignatures
import freemarker.template.TemplateException; //导入依赖的package包/类
public void allSignatures(String inputFile) throws IOException, TemplateException {
Configuration cfg = new Configuration();
Template template = cfg.getTemplate(inputFile);
Map<String, Object> data = new HashMap<String, Object>();
template.process(data, new OutputStreamWriter(System.out)); //TP
template.process(data, new OutputStreamWriter(System.out), null); //TP
template.process(data, new OutputStreamWriter(System.out), null, null); //TP
}
示例4: createDroolRule
import freemarker.template.TemplateException; //导入依赖的package包/类
public String createDroolRule(Rule rule) throws TemplateException, IOException {
try {
Template temp = cfg.getTemplate(templateName);
Writer out = new StringWriter();
temp.process(createMap(rule), out);
return out.toString();
} catch (IOException iE) {
logger.error("Problem getting rule template file." + iE.getMessage());
throw iE;
} catch (TemplateException tE) {
logger.error("Problem writing Drool rule." + tE.getMessage());
throw tE;
} catch (Exception e) {
logger.error("Problem creating rule: " + e.getMessage());
throw e;
}
}
示例5: generateUserDockerrunFileTest
import freemarker.template.TemplateException; //导入依赖的package包/类
@Test
public void generateUserDockerrunFileTest() throws IOException, TemplateException {
Map<String, Object> parameters = new HashMap<>();
parameters.put("awsEBDockerrunVersion", "2");
parameters.put("hostPort", "80");
parameters.put("configFile", "config.yml");
parameters.put("containerPort", "80");
parameters.put("memory", "2");
parameters.put("awsEBDockerrunVersion", "6144");
FileGenerator.generateUserDockerrunFile(
"src/test/resources/DockerrunTemplate.ftlh",
"src/test/resources/testUserDockerrunFile.aws.json",
parameters
);
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> generatedTestData = mapper.readValue(new File("src/test/resources/testUserDockerrunFile.aws.json"), Map.class);
Map<String, Object> expectedTestData = mapper.readValue(new File("src/test/resources/expectedDockerrunFile.aws.json"), Map.class);
for (String k : generatedTestData.keySet()) {
Assert.assertTrue(generatedTestData.get(k).equals(expectedTestData.get(k)));
}
File generatedTestFile = new File("src/test/resources/testUserDockerrunFile.aws.json");
generatedTestFile.delete();
}
示例6: generateDefaultDockerrunFileTest
import freemarker.template.TemplateException; //导入依赖的package包/类
@Test
public void generateDefaultDockerrunFileTest() throws IOException, TemplateException {
Map<String, Object> parameters = new HashMap<>();
parameters.put("awsEBDockerrunVersion", "2");
parameters.put("hostPort", "80");
parameters.put("configFile", "config.yml");
parameters.put("containerPort", "80");
parameters.put("memory", "2");
parameters.put("awsEBDockerrunVersion", "6144");
FileGenerator.generateDefaultDockerrunFile(
"src/test/resources/defaultGeneratedDockerrun.aws.json",
parameters
);
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> generatedTestData = mapper.readValue(new File("src/test/resources/defaultGeneratedDockerrun.aws.json"), Map.class);
Map<String, Object> expectedTestData = mapper.readValue(new File("src/test/resources/expectedDockerrunFile.aws.json"), Map.class);
for (String k : generatedTestData.keySet()) {
Assert.assertTrue(generatedTestData.get(k).equals(expectedTestData.get(k)));
}
File generatedTestFile = new File("src/test/resources/defaultGeneratedDockerrun.aws.json");
generatedTestFile.delete();
}
示例7: LinkGeneratorLambdaHandler
import freemarker.template.TemplateException; //导入依赖的package包/类
LinkGeneratorLambdaHandler(String region, String jwtEncryptKeyArn, String pageStorageBucket, String authVerifyEndpointURL,
AWSCredentialsProvider awsCredential, String introPageTemplateName) throws IOException, TemplateException {
AWSKMS kmsClient = AWSKMSClientBuilder.standard()
.withCredentials(awsCredential)
.withRegion(region)
.build();
AmazonS3 s3client = AmazonS3ClientBuilder
.standard()
.withCredentials(awsCredential)
.withRegion(region)
.build();
kmsEncrypt = new KMSEncrypt(kmsClient, jwtEncryptKeyArn);
this.pageStorageBucket = pageStorageBucket;
this.authVerifyEndpointURL = authVerifyEndpointURL;
this.pageUploader = new PageUploader(s3client, pageStorageBucket);
this.introPageTemplate = new IntroPageTemplate(introPageTemplateName);
}
示例8: displayTestTemplate
import freemarker.template.TemplateException; //导入依赖的package包/类
@Override
public String displayTestTemplate(User user) {
String applicationPropertyUrl = environment.getProperty("spring.application.url");
String siteName = mailUI.getMessage("mail.site.name");
String greeting = "YOUSA!";
Map<String, Object> model = new Hashtable<>();
model.put("siteName", siteName);
model.put("greeting", greeting);
model.put("user", user);
model.put("applicationPropertyUrl", applicationPropertyUrl);
String result = null;
try {
Template template = fm.getTemplate("tests/test.ftl");
result = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
} catch (IOException | TemplateException e) {
logger.error("Problem merging test template : " + e.getMessage());
}
return result;
}
示例9: createRssPostContent
import freemarker.template.TemplateException; //导入依赖的package包/类
@Override
public String createRssPostContent(Post post) {
String html = null;
Map<String, Object> model = new Hashtable<>();
model.put("post", post);
model.put("baseurl", applicationSettings.getBaseUrl());
try {
Template template = fm.getTemplate("posts/rss_post.ftl");
html = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
} catch (IOException | TemplateException e) {
logger.error("Problem merging post template : " + e.getMessage());
}
return html;
}
示例10: createPostHtml
import freemarker.template.TemplateException; //导入依赖的package包/类
@Override
public String createPostHtml(Post post, String templateName) {
String html = null;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM dd, yyyy");
String postCreated = post.getPostDate().format(formatter);
Map<String, Object> model = new Hashtable<>();
model.put("post", post);
model.put("postCreated", postCreated);
model.put("shareSiteName",
StringUtils.deleteWhitespace(applicationSettings.getSiteName()));
model.put("shareUrl",
String.format("%s/post/%s", applicationSettings.getBaseUrl(), post.getPostName()));
String displayType = templateName == null ? post.getDisplayType().name().toLowerCase() : templateName;
String ftl = String.format("posts/%s.ftl", displayType);
try {
Template template = fm.getTemplate(ftl);
html = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
} catch (IOException | TemplateException e) {
logger.error("Problem merging post template : " + e.getMessage());
}
return html;
}
示例11: createPostAtoZs
import freemarker.template.TemplateException; //导入依赖的package包/类
@Override
public String createPostAtoZs() {
String html = null;
String backToTop = mailUI.getMessage("posts.az.page.backtotop");
String azFileName = environment.getProperty("posts.az.file.name");
String azFilePath = applicationSettings.getPostAtoZFilePath();
Map<String, Object> model = new Hashtable<>();
model.put("alphaLinks", postService.getAlphaLInks());
model.put("alphaPosts", postService.getAlphaPosts());
model.put("backToTop", backToTop);
try {
Template template = fm.getTemplate("posts/az.ftl");
html = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
InputStream in = IOUtils.toInputStream(html, "UTF-8");
FileUtils.copyInputStreamToFile(in, new File(azFilePath + azFileName));
} catch (IOException | TemplateException e) {
logger.error("Problem creating A-to-Z template or HTML file: " + e.getMessage());
}
return html;
}
示例12: generateMessage
import freemarker.template.TemplateException; //导入依赖的package包/类
private String generateMessage(String trigger, Map executionData, Map config) {
HashMap<String, Object> model = new HashMap<String, Object>();
model.put("trigger", trigger);
model.put("executionData", executionData);
model.put("config", config);
StringWriter sw = new StringWriter();
try {
Template template = FREEMARKER_CFG.getTemplate(DINGTALK_MESSAGE_TEMPLATE);
template.process(model, sw);
} catch (IOException ioEx) {
throw new DingtalkNotificationPluginException("Error loading Dingtalk notification message template: [" + ioEx.getMessage() + "].", ioEx);
} catch (TemplateException templateEx) {
throw new DingtalkNotificationPluginException("Error merging Dingtalk notification message template: [" + templateEx.getMessage() + "].", templateEx);
}
return sw.toString();
}
示例13: writeMiddle
import freemarker.template.TemplateException; //导入依赖的package包/类
@SuppressWarnings({"nls"})
@Override
protected void writeMiddle(SectionWriter writer) throws IOException
{
List<Option<?>> options = listState.getOptions();
for( Option<?> option : options )
{
writer.writeTag("li");
writer.writeTag("input", "type", "hidden", "name", listState.getName(), "value", option.getValue());
loopVars[0] = new BeanModel(option, wrapper);
try
{
body.render(writer);
}
catch( TemplateException e )
{
SectionUtils.throwRuntime(e);
}
writer.endTag("li");
}
}
示例14: writeMiddle
import freemarker.template.TemplateException; //导入依赖的package包/类
@Override
protected void writeMiddle(SectionWriter writer) throws IOException
{
List<ListOption<Object>> optionList = renderer.renderOptionList(writer);
for( ListOption<Object> listOption : optionList )
{
Option<Object> option = listOption.getOption();
HtmlBooleanState state = listOption.getBooleanState();
state.setLabel(new TextLabel(option.getName(), true));
loopVars[0] = new BeanModel(option, wrapper);
loopVars[1] = new BeanModel(state, wrapper);
try
{
body.render(writer);
}
catch( TemplateException e )
{
throw Throwables.propagate(e);
}
}
}
示例15: generateContent
import freemarker.template.TemplateException; //导入依赖的package包/类
public String generateContent(String mainChallengeTitle,
String sponsorName,
String codingSessionDurationLabel, String username,
String token,
String authVerifyEndpointUrl,
Date expirationDate,
String journeyId)
throws IOException, TemplateException {
StringWriter stringWriter = new StringWriter();
Map<String, String> contentParams = new HashMap<>();
contentParams.put("MAIN_CHALLENGE_TITLE", mainChallengeTitle);
contentParams.put("SPONSOR", sponsorName);
contentParams.put("EXPIRATION_DATE", dateFormatter.format(expirationDate));
contentParams.put("CODING_SESSION_DURATION", codingSessionDurationLabel);
contentParams.put("API_VERIFY_ENDPOINT", authVerifyEndpointUrl);
contentParams.put("USERNAME", username);
contentParams.put("TOKEN", token);
contentParams.put("JOURNEY_ID", journeyId);
template.process(contentParams, stringWriter);
return stringWriter.toString();
}