Search in sources :

Example 1 with Team

use of model.Team in project jSqlBox by drinkjava2.

the class TeamControllerTest method test_team_listBigger.

// Test from show method
@Test
public void test_team_listBigger() {
    MockPageContext mockPC = new MockPageContext();
    mockPC.setPathParams("10");
    team_list_bigger box = BeanBox.getPrototypeBean(team_list_bigger.class);
    box.show(mockPC);
    Assert.assertEquals(3, ((List<Team>) mockPC.getRequestAttribute("teams")).size());
    Assert.assertEquals(box.getPage(), "/WEB-INF/pages/team_list.jsp");
}
Also used : MockPageContext(com.jsqlboxdemo.mock.MockPageContext) Team(model.Team) com.jsqlboxdemo.controller.team.team_list_bigger(com.jsqlboxdemo.controller.team.team_list_bigger) Test(org.junit.Test)

Example 2 with Team

use of model.Team in project jSqlBox by drinkjava2.

the class TeamControllerTest method test_team_equal.

// Test from dispatcher
@Test
public void test_team_equal() throws Exception {
    MockPageContext mockPC = new MockPageContext();
    mockPC.setRequestURI("/team/list_equal/10.html");
    Dispatcher.dispach(mockPC);
    Assert.assertEquals(1, ((List<Team>) mockPC.getRequestAttribute("teams")).size());
}
Also used : MockPageContext(com.jsqlboxdemo.mock.MockPageContext) Team(model.Team) Test(org.junit.Test)

Example 3 with Team

use of model.Team in project jSqlBox by drinkjava2.

the class Initializer method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent context) {
    // Initialize BeanBox
    BeanBox.regAopAroundAnnotation(TX.class, TxBox.class);
    BeanBox.regAopAroundAnnotation(Transaction.class, TxBox.class);
    // Initialize Global SqlBoxContext
    SqlBoxContextConfig config = new SqlBoxContextConfig();
    config.setConnectionManager(TinyTxConnectionManager.instance());
    SqlBoxContext ctx = new SqlBoxContext((DataSource) BeanBox.getBean(DataSourceBox.class), config);
    SqlBoxContext.setGlobalSqlBoxContext(ctx);
    // Initialize database
    String[] ddls = ctx.toDropAndCreateDDL(Team.class);
    for (String ddl : ddls) ctx.quiteExecute(ddl);
    for (int i = 0; i < 5; i++) new Team().put("name", "Team" + i, "rating", i * 10).insert();
    Assert.assertEquals(5, ctx.nQueryForLongValue("select count(*) from teams"));
    System.out.println("========== com.jsqlboxdemo.init.Initializer initialized=====");
}
Also used : SqlBoxContextConfig(com.github.drinkjava2.jsqlbox.SqlBoxContextConfig) SqlBoxContext(com.github.drinkjava2.jsqlbox.SqlBoxContext) Team(model.Team)

Aggregations

Team (model.Team)3 MockPageContext (com.jsqlboxdemo.mock.MockPageContext)2 Test (org.junit.Test)2 SqlBoxContext (com.github.drinkjava2.jsqlbox.SqlBoxContext)1 SqlBoxContextConfig (com.github.drinkjava2.jsqlbox.SqlBoxContextConfig)1 com.jsqlboxdemo.controller.team.team_list_bigger (com.jsqlboxdemo.controller.team.team_list_bigger)1