本文整理汇总了Java中play.mvc.Content类的典型用法代码示例。如果您正苦于以下问题:Java Content类的具体用法?Java Content怎么用?Java Content使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Content类属于play.mvc包,在下文中一共展示了Content类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResult
import play.mvc.Content; //导入依赖的package包/类
/**
* getResult
* @return response's body as a play framework Result
* @throws Exception
*/
@JsonIgnore
public Result getResult () throws Exception {
if (this.getType() == ResponseType.JSON) {
return Results.ok((String)this.getContent() );
} else if (this.getType() == ResponseType.FILE) {
return Results.ok(new FileInputStream((String)this.getContent() ) );
} else if (this.getType() == ResponseType.HTML) {
return Results.ok((Content)this.getContent() );
}
throw new CodeException(
151,
12,
"Unhandled ResponseBody Type ["
+ this.getType().toString()
+ "]",
ExceptionClass.TYPE);
}
示例2: renderTemplate
import play.mvc.Content; //导入依赖的package包/类
/**
* Illustrates how to render a template for testing.
*/
@Test
public void renderTemplate() {
Content html = views.html.index.render("Welcome to the home page.");
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("home page");
}
示例3: renderTemplate
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderTemplate() {
Content html = views.html.index.render(Collections.<Resource>emptyList(),
Form.form(Resource.class));
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains(Messages.get("header"));
}
示例4: renderTemplate
import play.mvc.Content; //导入依赖的package包/类
/**
* Illustrates how to render a template for testing.
*/
@Test
public void renderTemplate() {
Content html = views.html.Index.render("Welcome to the home page.");
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("home page");
}
示例5: renderTemplate
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderTemplate() {
Content html = views.html.index.render("Your new application is ready.");
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("Your new application is ready.");
}
示例6: renderIndex
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderIndex() {
Content html = views.html.index.render(Observation.all(),Country.all(),Indicator.all());
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("ObservaTerra");
}
示例7: renderIndex
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderIndex() {
Content html = views.html.index2.render();
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("ObservaTerra");
}
示例8: renderLogin
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderLogin() {
Content html = views.html.index2.render();
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("ObservaTerra");
}
示例9: renderObservationsList
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderObservationsList() {
Content html = views.html.login.loginform.render(loginForm);
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("ObservaTerra");
}
示例10: renderProfile
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderProfile() {
Content html = views.html.profile.render("admin");//Just a test, you should be logged in...
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("div");
}
示例11: renderSignUp
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderSignUp() {
Content html = views.html.signup.form.render(signupForm);
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("Sign");
}
示例12: renderSummary
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderSummary(){
Content html = views.html.signup.summary.render(new User());//empty user => empty summary, but it renders...
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("ObservaTerra");
}
示例13: renderTemplate
import play.mvc.Content; //导入依赖的package包/类
@Test
public void renderTemplate() {
Content html = views.html.index.render(Messages.get("application.name"));
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains(Messages.get("application.name"));
}
示例14: setHtmlContent
import play.mvc.Content; //导入依赖的package包/类
/**
* setHtmlContent
* alternative to overriding the method below
* setHtmlContent (Object... args)
* this method can be directly called instead
* @param htmlContent
* @throws Exception
*/
@JsonIgnore
final public void setHtmlContent (Content htmlContent) throws Exception {
this.content = htmlContent;
}