Kawai Wiki

Compare Revisions

Ignore whitespace Rev 188 → Rev 189

/trunk/src/test/java/org/kawai/action/PageActionTest.java
New file
0,0 → 1,143
package org.kawai.action;
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.kawai.dao.PageDAO;
import org.kawai.dao.UserDAO;
import org.kawai.dao.jdbc.JdbcPageDAO;
import org.kawai.dao.jdbc.JdbcUserDAO;
import org.kawai.model.Page;
import org.kawai.model.User;
import org.mentabean.BeanConfig;
import org.mentabean.BeanManager;
import org.mentabean.BeanSession;
import org.mentabean.DBTypes;
import org.mentabean.jdbc.MySQLBeanSession;
import org.mentawai.util.MockAction;
import org.mentawai.validation.Validator;
 
/**
* Test class PageActionTest.
* @author helio frota
*
*/
public class PageActionTest {
 
/**
* Attribute action of PageActionTest.
*/
private PageAction action;
/**
* Attribute mockAction of PageActionTest.
*/
private MockAction mockAction;
/**
* Attribute userDAO of PageActionTest.
*/
private UserDAO userDAO;
/**
* Attribute pageDAO of PageActionTest.
*/
private PageDAO pageDAO;
/**
* Attribute jdbcUserDAO of PageActionTest.
*/
private JdbcUserDAO jdbcUserDAO;
/**
* Attribute jdbcPageDAO of PageActionTest.
*/
private JdbcPageDAO jdbcPageDAO;
/**
* Attribute beanSession of PageActionTest.
*/
private BeanSession beanSession;
 
/**
* Default setUp method.
* @throws Exception
*/
@Before
public void setUp() throws Exception {
 
BeanManager beanManager = new BeanManager();
BeanConfig beanConfig = new BeanConfig(Page.class, "Pages");
beanConfig.pk("id", "id", DBTypes.AUTOINCREMENT);
beanConfig.field("name", DBTypes.STRING);
beanConfig.field("title", DBTypes.STRING);
beanConfig.field("body", DBTypes.STRING);
beanConfig.field("languageId", "language_id", DBTypes.STRING);
beanConfig.field("systemPage", "system_page", DBTypes.BOOLEANSTRING);
beanConfig.field("frontPage", "front_page", DBTypes.BOOLEANSTRING);
beanConfig.field("modifiedById", "modified_by", DBTypes.INTEGER);
beanConfig.field("modifiedOn", "modified_on", DBTypes.NOW_ON_UPDATE_TIMESTAMP);
beanConfig.field("createdById", "created_by", DBTypes.INTEGER);
beanConfig.field("createdOn", "created_on", DBTypes.NOW_ON_INSERT_TIMESTAMP);
beanConfig.field("deleted", DBTypes.BOOLEANSTRING);
 
beanManager.addBeanConfig(beanConfig);
 
beanConfig = new BeanConfig(User.class, "Users");
beanConfig.pk("id", DBTypes.AUTOINCREMENT);
beanConfig.field("username", DBTypes.STRING);
beanConfig.field("password", DBTypes.STRING);
beanConfig.field("groupId", "group_id", DBTypes.INTEGER);
 
beanManager.addBeanConfig(beanConfig);
 
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/Kawai?autoReconnect=true", "kawai", "1kawai23");
beanSession = new MySQLBeanSession(beanManager, conn);
 
userDAO = new JdbcUserDAO(beanSession);
pageDAO = new JdbcPageDAO(beanSession);
 
action = new PageAction(userDAO, pageDAO);
mockAction = new MockAction(action);
action.setInput(mockAction.getInput());
action.setOutput(mockAction.getOutput());
}
 
/**
* Test method executeTest.
*/
@Ignore
@Test
public void executeTest() {
action.getInput().setValue("name", "Page");
action.getInput().setValue("lang", "pt");
action.execute();
}
 
/**
* Test method getLastRevisionsTest.
*/
@Ignore
@Test
public void getLastRevisionsTest() {
action.getInput().setValue("lang", "en_US");
action.getLastRevisions();
}
 
/**
* Test method prepareValidatorTest.
*/
@Test
public void prepareValidatorTest() {
Map<String, Object> ruleMap = new HashMap< String, Object >();
List < String > valueList = new ArrayList < String >();
ruleMap.put("ruleMap", valueList);
Map<String, Object> errorMap = new HashMap< String, Object >();
errorMap.put("errorMap", new HashMap < String, Object >());
Validator validator = new Validator(ruleMap, errorMap);
action.prepareValidator(validator, "add");
}
 
}
/trunk/src/test/java/AllTests.java
2,6 → 2,7
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.kawai.action.LoginActionTest;
import org.kawai.action.PageActionTest;
import org.kawai.model.ModelTest;
 
/**
12,7 → 13,8
@RunWith(value = Suite.class)
@SuiteClasses(value = {
ModelTest.class,
LoginActionTest.class
LoginActionTest.class,
PageActionTest.class
})
public class AllTests {
 
/trunk/src/test/resources/WEB-INF/conf/dev/appManager.properties
New file
0,0 → 1,6
# MentaBean with MySQL
mentabean.dialect = org.mentabean.jdbc.MySQLBeanSession
jdbc.driver = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://localhost/Kawai?autoReconnect=true
jdbc.user = kawai
jdbc.pass = 1kawai23