Package javango.contrib.freemarker

Examples of javango.contrib.freemarker.FreemarkerResponse


import javango.http.HttpResponse;

public class Views {

  public static HttpResponse index(HttpRequest request) {
    return new FreemarkerResponse("javango/tests/ftl/index.ftl", new HashMap<String, Object>());
  }
View Full Code Here


  public void testIndex() throws Exception {
    HttpResponse resp = c.get("");

    assertTrue(resp instanceof FreemarkerResponse);
    FreemarkerResponse freeResp = (FreemarkerResponse)resp;
//    assertEquals(freeResp.getTemplate(), "src/main/webapp/templates/index.html");
   
    assertEquals(freeResp.getTemplate(), "javango/polls/templates/index.ftl");
    Writer w = new CharArrayWriter();
    freeResp.renderToWriter(w);
    assertFalse(w.toString().contains("TODO"));
  }
View Full Code Here

  }

  public void testAdminHomePage() throws Exception {
    HttpResponse r = c.get("admin/");
    assertTrue(r instanceof FreemarkerResponse);
    FreemarkerResponse fr = (FreemarkerResponse)r;
    Writer writer = new CharArrayWriter();
    fr.renderToWriter(writer);
    //System.out.println(writer.toString());
    assertTrue(writer.toString().contains("<a href=\"./javango.contrib.admin.tests.Poll/\">Poll</a>"));
    assertTrue(writer.toString().contains("<a href=\"./javango.contrib.admin.tests.Choice/\">Your Choice</a>"));

  }
View Full Code Here

  }
 
  public void testPollList() throws Exception {
    HttpResponse r = c.get("admin/javango.contrib.admin.tests.Poll/");
    assertTrue(r instanceof FreemarkerResponse);
    FreemarkerResponse fr = (FreemarkerResponse)r;
    Writer writer = new CharArrayWriter();
    fr.renderToWriter(writer);
    //System.out.println(writer.toString());
    assertTrue(writer.toString().contains("No Results"));
   
    fixture(1);
    r = c.get("admin/javango.contrib.admin.tests.Poll/");
    assertTrue(r instanceof FreemarkerResponse);
    fr = (FreemarkerResponse)r;
    writer = new CharArrayWriter();
    fr.renderToWriter(writer);
    assertTrue(writer.toString().contains("AdminTestQuestion : 0"));
  }
View Full Code Here

  }
 
  public void testAddPoll() throws Exception {
    HttpResponse r = c.get("admin/javango.contrib.admin.tests.Poll/add/");
    assertTrue(r instanceof FreemarkerResponse);
    FreemarkerResponse fr = (FreemarkerResponse)r;
   
    Writer writer = new CharArrayWriter();
    fr.renderToWriter(writer);
    System.out.println(writer.toString());
    String expected =
        "<tr><th><label for='id_pubDate'>Pub Date</label></th><td><input id=\"id_pubDate\" type=\"text\" name=\"pubDate\" /></td></tr>\n" +
        "<tr><th><label for='id_question'>Question</label></th><td><input maxlength=\"255\" id=\"id_question\" type=\"text\" name=\"question\" /></td></tr>\n";
   
    // TODO This is not 100% correct as the form could possibly be in this order even without the fieldset
    assertTrue(writer.toString().contains(expected));
   
    Map<String, String[]> params = new HashMap<String, String[]>();
    params.put("question", new String[] {"Do you like cheese?"});
    params.put("pubDate", new String[] {"01/02/2008"});
    r = c.post("admin/javango.contrib.admin.tests.Poll/add/", params);
    assertEquals(HttpResponseRedirect.class, r.getClass());
   
    r = c.get("admin/javango.contrib.admin.tests.Poll/");
    assertTrue(r instanceof FreemarkerResponse);
    fr = (FreemarkerResponse)r;
    writer = new CharArrayWriter();
    fr.renderToWriter(writer);
    assertTrue(writer.toString().contains("Do you like cheese?"));
  }
View Full Code Here

  public void testIndex() throws Exception {
    HttpResponse resp = c.get("");

    assertTrue(resp instanceof FreemarkerResponse);
    FreemarkerResponse freeResp = (FreemarkerResponse)resp;
//    assertEquals(freeResp.getTemplate(), "src/main/webapp/templates/index.html");
   
    assertEquals(freeResp.getTemplate(), "javango/polls/templates/index.ftl");
    Writer w = new CharArrayWriter();
    freeResp.renderToWriter(w);
    assertFalse(w.toString().contains("TODO"));
  }
View Full Code Here

TOP

Related Classes of javango.contrib.freemarker.FreemarkerResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.