Java 类play.mvc.Content 实例源码

项目:vos_backend    文件:ResponseBody.java   
/**
 * 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);
}
项目:PlayResponsiveKamanu-1    文件:ApplicationTest.java   
/**
 * 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");
}
项目:javabin-play-public    文件:ApplicationTest.java   
@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"));
}
项目:PlayResponsiveKamanu    文件:ApplicationTest.java   
/**
 * 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");
}
项目:play1    文件:ApplicationTest.java   
/**
 * 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");
}
项目:surferpedia    文件:ApplicationTest.java   
/**
 * 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");
}
项目:PlayTraining    文件:ApplicationTest.java   
@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.");
}
项目:ObservaTerra42    文件:ApplicationTest.java   
@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"); 
}
项目:observaTerraPlay    文件:ApplicationTest.java   
@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"); 
}
项目:ObservaTerra51    文件:ApplicationTest.java   
@Test
public void renderIndex() {
    Content html = views.html.index2.render();
    assertThat(contentType(html)).isEqualTo("text/html");
    assertThat(contentAsString(html)).contains("ObservaTerra"); 
}
项目:ObservaTerra51    文件:ApplicationTest.java   
@Test
public void renderLogin() {
    Content html = views.html.index2.render();
    assertThat(contentType(html)).isEqualTo("text/html");
    assertThat(contentAsString(html)).contains("ObservaTerra");
}
项目:ObservaTerra51    文件:ApplicationTest.java   
@Test
public void renderObservationsList() {
    Content html = views.html.login.loginform.render(loginForm);
    assertThat(contentType(html)).isEqualTo("text/html");
    assertThat(contentAsString(html)).contains("ObservaTerra");
}
项目:ObservaTerra51    文件:ApplicationTest.java   
@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");
}
项目:ObservaTerra51    文件:ApplicationTest.java   
@Test
public void renderSignUp() {
    Content html = views.html.signup.form.render(signupForm);
    assertThat(contentType(html)).isEqualTo("text/html");
    assertThat(contentAsString(html)).contains("Sign");
}
项目:ObservaTerra51    文件:ApplicationTest.java   
@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");
}
项目:tracker    文件:ApplicationTest.java   
@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"));
}
项目:shopnplay    文件:RoutesTest.java   
@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.");
}
项目:vos_backend    文件:ResponseBodyHtml.java   
/**
 * 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;
}