Package javango.polls.tests

Source Code of javango.polls.tests.Tests

package javango.polls.tests;

import java.io.CharArrayWriter;
import java.io.Writer;

import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

import com.google.inject.Injector;

import javango.contrib.freemarker.FreemarkerResponse;
import javango.contrib.hibernate.HibernateUtil;
import javango.http.HttpResponse;
import javango.test.Client;
import junit.framework.TestCase;

public class Tests extends TestCase {

  Client c;
  Injector injector;
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    injector = new javango.polls.Settings().createInjector(null);   
    Configuration cfg = injector.getInstance(HibernateUtil.class).getConfiguration();
    new SchemaExport(cfg).drop(false, true);
    new SchemaExport(cfg).create(false, true);
    c = new Client(injector);
  }

  @Override
  protected void tearDown() throws Exception {
    super.tearDown();
    injector.getInstance(HibernateUtil.class).closeSession();
  }


  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"));
  }

}
TOP

Related Classes of javango.polls.tests.Tests

TOP
Copyright © 2018 www.massapi.com. 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.