mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
WW-1353 Move the MailReader iBATIS code to the sandbox, until it is ready.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@433103 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1,230 +0,0 @@
|
||||
package mailreader2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p/>
|
||||
* Provide properties to transfer data values between
|
||||
* the view and model layers (data transfer object).
|
||||
* </p>
|
||||
*
|
||||
* @version $Revision: 1.0 $ $Date: Jul 30, 2006 9:29:50 AM $
|
||||
*/
|
||||
public class AppData {
|
||||
|
||||
private boolean nominal;
|
||||
|
||||
private String locale_key;
|
||||
private String locale_code;
|
||||
private String locale_name;
|
||||
private List locale_list;
|
||||
|
||||
private String registration_key;
|
||||
private String username;
|
||||
private String password;
|
||||
private String password2;
|
||||
private String fullname;
|
||||
private String email_from;
|
||||
private String email_replyto;
|
||||
|
||||
private String protocol_key;
|
||||
private String protocol_code;
|
||||
private String protocol_name;
|
||||
|
||||
private String subscription_key;
|
||||
private String subscription_host;
|
||||
private String host_user;
|
||||
private String host_pass;
|
||||
private Integer host_auto;
|
||||
|
||||
/**
|
||||
* <p>Adapt internal Integer value to external boolean value. </p>
|
||||
*
|
||||
* @return False if host_auto==0, True otherwise
|
||||
*/
|
||||
public boolean isHost_auto_checkbox() {
|
||||
Integer _host_auto = getHost_auto();
|
||||
if (_host_auto == null) _host_auto = Constants.DB_FALSE;
|
||||
return (_host_auto == Constants.DB_TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Adapt internal Integer value to external boolean value. </p>
|
||||
*/
|
||||
public void setHost_auto_checkbox(boolean host_auto_checkbox) {
|
||||
if (host_auto_checkbox)
|
||||
setHost_auto(Constants.DB_TRUE);
|
||||
else setHost_auto(Constants.DB_FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Return true if a logic or state test passed,
|
||||
* such as whether a record already exists.</p>
|
||||
*
|
||||
* @return True if a business logic test passed.
|
||||
*/
|
||||
public boolean isNominal() {
|
||||
return nominal;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Record outcome of a logic or state test,
|
||||
* such as whether a record already exists.</p>
|
||||
*/
|
||||
public void setNominal(boolean nominal) {
|
||||
this.nominal = nominal;
|
||||
}
|
||||
|
||||
public String getLocale_key() {
|
||||
return locale_key;
|
||||
}
|
||||
|
||||
public void setLocale_key(String locale_key) {
|
||||
this.locale_key = locale_key;
|
||||
}
|
||||
|
||||
public String getLocale_code() {
|
||||
return locale_code;
|
||||
}
|
||||
|
||||
public void setLocale_code(String locale_code) {
|
||||
this.locale_code = locale_code;
|
||||
}
|
||||
|
||||
public String getLocale_name() {
|
||||
return locale_name;
|
||||
}
|
||||
|
||||
public void setLocale_name(String locale_name) {
|
||||
this.locale_name = locale_name;
|
||||
}
|
||||
|
||||
public List getLocale_list() {
|
||||
return locale_list;
|
||||
}
|
||||
|
||||
public void setLocale_list(List locale_list) {
|
||||
this.locale_list = locale_list;
|
||||
}
|
||||
|
||||
public String getRegistration_key() {
|
||||
return registration_key;
|
||||
}
|
||||
|
||||
public void setRegistration_key(String registration_key) {
|
||||
this.registration_key = registration_key;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPassword2() {
|
||||
return password2;
|
||||
}
|
||||
|
||||
public void setPassword2(String password2) {
|
||||
this.password2 = password2;
|
||||
}
|
||||
|
||||
public String getFullname() {
|
||||
return fullname;
|
||||
}
|
||||
|
||||
public void setFullname(String fullname) {
|
||||
this.fullname = fullname;
|
||||
}
|
||||
|
||||
public String getEmail_from() {
|
||||
return email_from;
|
||||
}
|
||||
|
||||
public void setEmail_from(String email_from) {
|
||||
this.email_from = email_from;
|
||||
}
|
||||
|
||||
public String getEmail_replyto() {
|
||||
return email_replyto;
|
||||
}
|
||||
|
||||
public void setEmail_replyto(String email_replyto) {
|
||||
this.email_replyto = email_replyto;
|
||||
}
|
||||
|
||||
public String getProtocol_key() {
|
||||
return protocol_key;
|
||||
}
|
||||
|
||||
public void setProtocol_key(String protocol_key) {
|
||||
this.protocol_key = protocol_key;
|
||||
}
|
||||
|
||||
public String getProtocol_code() {
|
||||
return protocol_code;
|
||||
}
|
||||
|
||||
public void setProtocol_code(String protocol_code) {
|
||||
this.protocol_code = protocol_code;
|
||||
}
|
||||
|
||||
public String getSubscription_key() {
|
||||
return subscription_key;
|
||||
}
|
||||
|
||||
public void setSubscription_key(String subscription_key) {
|
||||
this.subscription_key = subscription_key;
|
||||
}
|
||||
|
||||
public String getSubscription_host() {
|
||||
return subscription_host;
|
||||
}
|
||||
|
||||
public void setSubscription_host(String subscription_host) {
|
||||
this.subscription_host = subscription_host;
|
||||
}
|
||||
|
||||
public String getHost_user() {
|
||||
return host_user;
|
||||
}
|
||||
|
||||
public void setHost_user(String host_user) {
|
||||
this.host_user = host_user;
|
||||
}
|
||||
|
||||
public String getHost_pass() {
|
||||
return host_pass;
|
||||
}
|
||||
|
||||
public void setHost_pass(String host_pass) {
|
||||
this.host_pass = host_pass;
|
||||
}
|
||||
|
||||
public String getProtocol_name() {
|
||||
return protocol_name;
|
||||
}
|
||||
|
||||
public void setProtocol_name(String protocol_name) {
|
||||
this.protocol_name = protocol_name;
|
||||
}
|
||||
|
||||
public Integer getHost_auto() {
|
||||
return host_auto;
|
||||
}
|
||||
|
||||
public void setHost_auto(Integer host_auto) {
|
||||
this.host_auto = host_auto;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package mailreader2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AppService {
|
||||
|
||||
public List getLocaleList() throws Exception;
|
||||
|
||||
public void insertUser(AppData data) throws Exception;
|
||||
|
||||
}
|
||||
@@ -51,32 +51,7 @@ import java.util.Map;
|
||||
* avoids creating unnecessary local properties. Pick your poison.</p>
|
||||
*/
|
||||
public class MailreaderSupport extends ActionSupport
|
||||
implements SessionAware, ApplicationAware, ModelDriven {
|
||||
|
||||
private AppService appService;
|
||||
|
||||
public AppService getAppService() {
|
||||
return appService;
|
||||
}
|
||||
|
||||
public void setAppService(AppService appService) {
|
||||
this.appService = appService;
|
||||
}
|
||||
|
||||
private AppData appData = new AppData();
|
||||
|
||||
public Object getModel() {
|
||||
return appData;
|
||||
}
|
||||
|
||||
public void setAppData(AppData appData) {
|
||||
this.appData = appData;
|
||||
}
|
||||
|
||||
public AppData getAppData() {
|
||||
return appData;
|
||||
}
|
||||
|
||||
implements SessionAware, ApplicationAware {
|
||||
|
||||
/**
|
||||
* Return CANCEL so apropriate result can be selected.
|
||||
|
||||
@@ -7,12 +7,7 @@ import java.util.List;
|
||||
/**
|
||||
* Verify that essential resources are available.
|
||||
*/
|
||||
public class Welcome extends MailreaderSupport implements Preparable {
|
||||
|
||||
public void prepare() throws Exception {
|
||||
List value = getAppService().getLocaleList();
|
||||
getAppData().setLocale_list(value);
|
||||
}
|
||||
public class Welcome extends MailreaderSupport {
|
||||
|
||||
public String execute() {
|
||||
|
||||
@@ -33,5 +28,4 @@ public class Welcome extends MailreaderSupport implements Preparable {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
package mailreader2.service;
|
||||
|
||||
import com.ibatis.common.resources.Resources;
|
||||
import com.ibatis.common.jdbc.ScriptRunner;
|
||||
import com.ibatis.sqlmap.client.SqlMapClient;
|
||||
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.io.Reader;
|
||||
import java.util.Properties;
|
||||
|
||||
public class SqlMapAppConfig {
|
||||
|
||||
// ---- TEST MODE SETUP ----
|
||||
|
||||
protected void runScript(String script) throws Exception {
|
||||
DataSource ds = getSqlMap().getDataSource();
|
||||
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
Reader reader = Resources.getResourceAsReader(script);
|
||||
|
||||
ScriptRunner runner = new ScriptRunner(conn, false, false);
|
||||
runner.setLogWriter(null);
|
||||
runner.setErrorLogWriter(null);
|
||||
|
||||
runner.runScript(reader);
|
||||
conn.commit();
|
||||
conn.close();
|
||||
reader.close();
|
||||
}
|
||||
|
||||
final static String[] CONFIG_SCRIPTS =
|
||||
{"sql/mailreader-schema.sql","sql/mailreader-sample.sql"};
|
||||
|
||||
private boolean testMode = true;
|
||||
|
||||
public boolean isTestMode() {
|
||||
return testMode;
|
||||
}
|
||||
|
||||
public void setTestMode(boolean testMode) {
|
||||
this.testMode = testMode;
|
||||
}
|
||||
|
||||
// ---- SQL MAP SETUP ----
|
||||
|
||||
final static String CONFIG_FILE = "sql-map-config.xml";
|
||||
|
||||
protected String configFile;
|
||||
|
||||
public String getConfigFile() {
|
||||
if (configFile==null) return CONFIG_FILE;
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void setConfigFile(String configFile) {
|
||||
this.configFile = configFile;
|
||||
}
|
||||
|
||||
protected Properties configProps;
|
||||
|
||||
public Properties getConfigProps() {
|
||||
return configProps;
|
||||
}
|
||||
|
||||
public void setConfigProps(Properties configProps) {
|
||||
this.configProps = configProps;
|
||||
}
|
||||
|
||||
private SqlMapClient sqlMap;
|
||||
|
||||
public SqlMapClient getSqlMap() {
|
||||
return sqlMap;
|
||||
}
|
||||
|
||||
public void setSqlMap(SqlMapClient sqlMap) {
|
||||
this.sqlMap = sqlMap;
|
||||
}
|
||||
|
||||
public SqlMapAppConfig() {
|
||||
try {
|
||||
Reader reader =
|
||||
Resources.getResourceAsReader(getConfigFile());
|
||||
setSqlMap(SqlMapClientBuilder.buildSqlMapClient(reader,
|
||||
getConfigProps()));
|
||||
reader.close();
|
||||
|
||||
if (isTestMode())
|
||||
for (String script : CONFIG_SCRIPTS) {
|
||||
runScript(script);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package mailreader2.service;
|
||||
|
||||
import mailreader2.AppService;
|
||||
import mailreader2.Constants;
|
||||
import mailreader2.AppData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SqlMapAppService extends SqlMapAppConfig implements AppService {
|
||||
|
||||
// ---- APPSERVICE IMPLEMENTATION ----
|
||||
|
||||
public List getLocaleList() throws Exception {
|
||||
return getSqlMap().queryForList(Constants.LOCALE_LIST, null);
|
||||
}
|
||||
|
||||
public void insertUser(AppData data) throws Exception {
|
||||
getSqlMap().insert(Constants.REGISTRATION_INSERT, data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,10 +2,5 @@
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
|
||||
<beans default-autowire="autodetect">
|
||||
|
||||
<bean id="appService" class="mailreader2.service.SqlMapAppService">
|
||||
<property name="testMode" value="true"/>
|
||||
</bean>
|
||||
|
||||
<!-- add your spring beans here -->
|
||||
</beans>
|
||||
@@ -24,7 +24,6 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!--
|
||||
<h3>Language Options</h3>
|
||||
<ul>
|
||||
<li>
|
||||
@@ -46,17 +45,6 @@
|
||||
<s:a href="%{ru}">Russian</s:a>
|
||||
</li>
|
||||
</ul>
|
||||
-->
|
||||
<h3>Language Options</h3>
|
||||
<form>
|
||||
<s:select
|
||||
name="request_locale"
|
||||
list="locale_list"
|
||||
listKey="locale_code"
|
||||
listValue="locale_name"
|
||||
/>
|
||||
<s:submit />
|
||||
</form>
|
||||
|
||||
<hr/>
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package mailreader2;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BaseAppDataTest extends TestCase {
|
||||
|
||||
protected void assertNotEmpty(String value) {
|
||||
assertNotNull(value);
|
||||
assertTrue(value.length()>0);
|
||||
}
|
||||
|
||||
protected void assertNotEmpty(String message, String value, int min, int max) {
|
||||
assertNotNull(message,value);
|
||||
assertTrue(message,value.length()>=min);
|
||||
assertTrue(message,value.length()<=max);
|
||||
}
|
||||
|
||||
protected void assertNotEmpty(String message, String value) {
|
||||
assertNotEmpty(message,value,0,1024);
|
||||
}
|
||||
|
||||
protected void assertLocale_list(List list) {
|
||||
assertNotNull(list);
|
||||
assertTrue("Expected one or more locales",list.size()>0);
|
||||
AppData entry = null;
|
||||
try {
|
||||
entry = (AppData) list.get(0);
|
||||
} catch (Throwable t) {
|
||||
fail("Expected a list of AppData objects");
|
||||
}
|
||||
assertNotEmpty("Expected a locale code",entry.getLocale_code(),2,2);
|
||||
assertNotEmpty("Expected a locale name",entry.getLocale_name());
|
||||
assertNotEmpty("Expected a locale kehy",entry.getLocale_key());
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package mailreader2;
|
||||
|
||||
import com.ibatis.common.jdbc.ScriptRunner;
|
||||
import com.ibatis.common.resources.Resources;
|
||||
import com.ibatis.sqlmap.client.SqlMapClient;
|
||||
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.Reader;
|
||||
import java.sql.Connection;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author Ted Husted
|
||||
* @version $Revision: 1.0 $ $Date: Jul 29, 2006 4:59:19 PM $
|
||||
*/
|
||||
public class BaseSqlMapTest extends BaseAppDataTest {
|
||||
|
||||
private SqlMapClient sqlMap;
|
||||
|
||||
protected void initSqlMap(String configFile, Properties props) throws Exception {
|
||||
Reader reader = Resources.getResourceAsReader(configFile);
|
||||
setSqlMap(SqlMapClientBuilder.buildSqlMapClient(reader, props));
|
||||
reader.close();
|
||||
}
|
||||
|
||||
protected void runScript(String script) throws Exception {
|
||||
DataSource ds = getSqlMap().getDataSource();
|
||||
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
Reader reader = Resources.getResourceAsReader(script);
|
||||
|
||||
ScriptRunner runner = new ScriptRunner(conn, false, false);
|
||||
runner.setLogWriter(null);
|
||||
runner.setErrorLogWriter(null);
|
||||
|
||||
runner.runScript(reader);
|
||||
conn.commit();
|
||||
conn.close();
|
||||
reader.close();
|
||||
}
|
||||
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
initSqlMap("sql-map-config.xml", null);
|
||||
runScript("sql/mailreader-schema.sql");
|
||||
runScript("sql/mailreader-sample.sql");
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
runScript("sql/mailreader-schema-drop.sql");
|
||||
}
|
||||
|
||||
public void testInit() throws Exception {
|
||||
assertNotNull(getSqlMap());
|
||||
}
|
||||
|
||||
public SqlMapClient getSqlMap() {
|
||||
return sqlMap;
|
||||
}
|
||||
|
||||
public void setSqlMap(SqlMapClient sqlMap) {
|
||||
this.sqlMap = sqlMap;
|
||||
}
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
package mailreader2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.0 $ $Date: Jul 29, 2006 5:34:31 PM $
|
||||
*/
|
||||
public class SqlMapTest extends BaseSqlMapTest {
|
||||
|
||||
// DEFAULTS FROM SAMPLE SCRIPT
|
||||
|
||||
private static int SAMPLE_SIZE = 2;
|
||||
|
||||
private static String locale_key = "01-en";
|
||||
|
||||
private static String registration_key = "01-user";
|
||||
private static String username = "user";
|
||||
private static String password = "pass";
|
||||
private static String fullname = "John Q. User";
|
||||
private static String email_from = "John.User@somewhere.com";
|
||||
private static String email_replyto = "";
|
||||
private static String subscription_key = "01-hotmail";
|
||||
private static String subscription_host = "mail.hotmail.com";
|
||||
private static String host_user = "user1234";
|
||||
private static String host_pass = "bar";
|
||||
private static Integer host_auto = Constants.DB_FALSE;
|
||||
|
||||
private static String registration_key2 = "02-zaphod";
|
||||
private static String username2 = "zaphod";
|
||||
private static String password2 = "G4rgl3Bl4st3r";
|
||||
private static String fullname2 = "Zaphod Beeblebrox";
|
||||
private static String email_from2 = "zaphod@magrathea.com";
|
||||
private static String email_replyto2 = "zb42@igmail.net";
|
||||
|
||||
private static String protocol_name = "POP3 Protoocol";
|
||||
private static String protocol_key2 = "02-smtp";
|
||||
|
||||
private static String subscription_key2 = "04-igmail";
|
||||
private static String subscription_host2 = "mail.igmail.net";
|
||||
private static String host_user2 = "zb42";
|
||||
private static String host_pass2 = "J4nxSp1r1t";
|
||||
private static Integer host_auto2 = Constants.DB_TRUE;
|
||||
|
||||
// SETUP & TEARDOWN
|
||||
|
||||
private AppData input;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
input = new AppData();
|
||||
}
|
||||
|
||||
public void testLOCALE_LIST() throws Exception {
|
||||
List list = getSqlMap().queryForList(Constants.LOCALE_LIST, null);
|
||||
assertLocale_list(list);
|
||||
}
|
||||
|
||||
public void testREGISTRATION_INSERT_ASSERT_fail() throws Exception {
|
||||
input.setUsername(username);
|
||||
Object output = getSqlMap().queryForObject(Constants.REGISTRATION_INSERT_ASSERT, input);
|
||||
Long count = (Long) output;
|
||||
assertTrue("Expected user to already exist", count.intValue() > 0);
|
||||
}
|
||||
|
||||
public void testREGISTRATION_INSERT_ASSERT() throws Exception {
|
||||
input.setUsername(username2);
|
||||
Object output = getSqlMap().queryForObject(Constants.REGISTRATION_INSERT_ASSERT, input);
|
||||
Long count = (Long) output;
|
||||
assertTrue("Did not expected user to exist", count.intValue() == 0);
|
||||
}
|
||||
|
||||
public void testREGISTRATION_INSERT() throws Exception {
|
||||
input.setRegistration_key(registration_key2);
|
||||
input.setLocale_key(locale_key);
|
||||
input.setUsername(username2);
|
||||
input.setPassword(password2);
|
||||
input.setFullname(fullname2);
|
||||
input.setEmail_from(email_from2);
|
||||
input.setEmail_replyto(email_replyto2);
|
||||
getSqlMap().insert(Constants.REGISTRATION_INSERT, input);
|
||||
// Trust but verify
|
||||
input.setPassword(null);
|
||||
AppData output = (AppData) getSqlMap().queryForObject(Constants.REGISTRATION_PASSWORD, input);
|
||||
assertEquals(password2, output.getPassword());
|
||||
}
|
||||
|
||||
public void testREGISTRATION_PASSWORD() throws Exception {
|
||||
input.setUsername(username);
|
||||
AppData output = (AppData) getSqlMap().queryForObject(Constants.REGISTRATION_PASSWORD, input);
|
||||
assertEquals(password, output.getPassword());
|
||||
}
|
||||
|
||||
public void testREGISTRATION_FULLNAME() throws Exception {
|
||||
input.setUsername(username);
|
||||
AppData output = (AppData) getSqlMap().queryForObject(Constants.REGISTRATION_FULLNAME, input);
|
||||
assertEquals(fullname, output.getFullname());
|
||||
assertNull("Expected other fields to be null", output.getPassword());
|
||||
assertNull("Expected other fields to be null", output.getEmail_from());
|
||||
}
|
||||
|
||||
public void testREGISTRATION_EDIT() throws Exception {
|
||||
input.setRegistration_key(registration_key);
|
||||
AppData output = (AppData) getSqlMap().queryForObject(Constants.REGISTRATION_EDIT, input);
|
||||
assertNotNull("Support not found!", output);
|
||||
assertEquals(fullname, output.getFullname());
|
||||
assertEquals(email_from, output.getEmail_from());
|
||||
assertEquals(email_replyto, output.getEmail_replyto());
|
||||
}
|
||||
|
||||
public void testREGISTRATION_UPDATE() throws Exception {
|
||||
input.setRegistration_key(registration_key);
|
||||
input.setUsername(username2);
|
||||
input.setPassword(password2);
|
||||
input.setFullname(fullname2);
|
||||
input.setEmail_from(email_from2);
|
||||
input.setEmail_replyto(email_replyto2);
|
||||
getSqlMap().update(Constants.REGISTRATION_UPDATE, input);
|
||||
// Trust but verify
|
||||
input.setPassword(null);
|
||||
AppData output = (AppData) getSqlMap().queryForObject(Constants.REGISTRATION_PASSWORD, input);
|
||||
assertEquals(password2, output.getPassword());
|
||||
}
|
||||
|
||||
public void testREGISTRATION_UPDATE_fails() throws Exception {
|
||||
input.setRegistration_key(null);
|
||||
getSqlMap().update(Constants.REGISTRATION_UPDATE, input);
|
||||
}
|
||||
|
||||
public void testSUBSCRIPTION_INSERT_ASSERT_fail() throws Exception {
|
||||
input.setRegistration_key(registration_key);
|
||||
input.setSubscription_host(subscription_host);
|
||||
Object output = getSqlMap().queryForObject(Constants.SUBSCRIPTION_INSERT_ASSERT, input);
|
||||
Long count = (Long) output;
|
||||
assertTrue("Expected subscription to already exist", count.intValue() > 0);
|
||||
}
|
||||
|
||||
public void SUBSCRIPTION_INSERT_ASSERT() throws Exception {
|
||||
input.setSubscription_key(subscription_key2);
|
||||
input.setSubscription_host(subscription_host2);
|
||||
Object output = getSqlMap().queryForObject(Constants.SUBSCRIPTION_INSERT_ASSERT, input);
|
||||
Long count = (Long) output;
|
||||
assertTrue("Did not expect subscription to exist", count.intValue() == 0);
|
||||
}
|
||||
|
||||
public void testSUBSCRIPTION_INSERT() throws Exception {
|
||||
input.setSubscription_key(subscription_key2);
|
||||
input.setRegistration_key(registration_key2);
|
||||
input.setProtocol_key(protocol_key2);
|
||||
input.setSubscription_host(subscription_host2);
|
||||
input.setHost_user(host_user2);
|
||||
input.setHost_pass(host_pass2);
|
||||
input.setHost_auto(host_auto2);
|
||||
getSqlMap().insert(Constants.SUBSCRIPTION_INSERT, input);
|
||||
// Trust but verify
|
||||
Object output = getSqlMap().queryForObject(Constants.SUBSCRIPTION_INSERT_ASSERT, input);
|
||||
Long count = (Long) output;
|
||||
assertTrue("Expected subscription to NOW exist", count.intValue() > 0);
|
||||
}
|
||||
|
||||
private void assertSubscription(AppData output) throws Exception {
|
||||
assertEquals(host_user, output.getHost_user());
|
||||
assertEquals(host_pass, output.getHost_pass());
|
||||
assertEquals(protocol_name, output.getProtocol_name());
|
||||
assertEquals(host_auto, output.getHost_auto());
|
||||
assertFalse(output.isHost_auto_checkbox());
|
||||
}
|
||||
|
||||
public void testSUBSCRIPTION_LIST() throws Exception {
|
||||
input.setRegistration_key(registration_key);
|
||||
Object output = getSqlMap().queryForList(Constants.SUBSCRIPTION_LIST, input);
|
||||
assertNotNull("Query failed!", output);
|
||||
List list = (List) output;
|
||||
assertEquals(SAMPLE_SIZE, list.size());
|
||||
AppData row1 = (AppData) list.get(0);
|
||||
assertSubscription(row1);
|
||||
}
|
||||
|
||||
public void testSUBSCRIPTION_EDIT() throws Exception {
|
||||
input.setSubscription_key(subscription_key);
|
||||
AppData output = (AppData) getSqlMap().queryForObject(Constants.SUBSCRIPTION_EDIT, input);
|
||||
assertNotNull("Support not found!", output);
|
||||
assertSubscription(output);
|
||||
}
|
||||
|
||||
public void testSUBSCRIPTION_UPDATE() throws Exception {
|
||||
input.setSubscription_key(subscription_key);
|
||||
input.setRegistration_key(registration_key2);
|
||||
input.setProtocol_key(protocol_key2);
|
||||
input.setSubscription_host(subscription_host2);
|
||||
input.setHost_user(host_user2);
|
||||
input.setHost_pass(host_pass2);
|
||||
input.setHost_auto(host_auto2);
|
||||
getSqlMap().update(Constants.SUBSCRIPTION_UPDATE, input);
|
||||
// Trust but verify
|
||||
Object output = getSqlMap().queryForObject(Constants.SUBSCRIPTION_INSERT_ASSERT, input);
|
||||
Long count = (Long) output;
|
||||
assertTrue("Expected subscription to exist", count.intValue() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package mailreader2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WelcomeTest extends BaseAppDataTest {
|
||||
|
||||
private Welcome welcome = new Welcome();
|
||||
|
||||
public void setUp() {
|
||||
|
||||
}
|
||||
|
||||
public void testLocaleList() throws Exception {
|
||||
welcome.prepare();
|
||||
List list = welcome.getAppData().getLocale_list();
|
||||
assertLocale_list(list);
|
||||
assertTrue("Expected locale list",list.size()>2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
INSERT INTO locale
|
||||
(pk_locale, locale_code, locale_name)
|
||||
VALUES ('01-en','en','English');
|
||||
|
||||
INSERT INTO locale
|
||||
(pk_locale, locale_code, locale_name)
|
||||
VALUES ('02-ru','ru','Russian');
|
||||
|
||||
INSERT INTO locale
|
||||
(pk_locale, locale_code, locale_name)
|
||||
VALUES ('03-ja','ja','Japanese');
|
||||
|
||||
INSERT INTO protocol
|
||||
(pk_protocol, protocol_code, protocol_name)
|
||||
VALUES ('01-pop3','pop3','POP3 Protoocol');
|
||||
|
||||
INSERT INTO protocol
|
||||
(pk_protocol, protocol_code, protocol_name)
|
||||
VALUES ('02-smtp','smtp','SMTP Protocol');
|
||||
|
||||
INSERT INTO registration
|
||||
(pk_registration, fk_locale, username, password, fullname, email_from, email_replyto)
|
||||
VALUES ('01-user','01-en','user','pass','John Q. User','John.User@somewhere.com','');
|
||||
|
||||
INSERT INTO subscription
|
||||
(pk_subscription, fk_registration, fk_protocol, subscription_host, host_user, host_pass, host_auto)
|
||||
VALUES ('01-hotmail','01-user','01-pop3','mail.hotmail.com','user1234','bar',0);
|
||||
|
||||
INSERT INTO subscription
|
||||
(pk_subscription, fk_registration, fk_protocol, subscription_host, host_user, host_pass, host_auto)
|
||||
VALUES ('02-yahoo','01-user','02-smtp','mail.yahoo.com','jquser','foo',1);
|
||||
@@ -1,4 +0,0 @@
|
||||
DROP TABLE locale;
|
||||
DROP TABLE registration;
|
||||
DROP TABLE protocol;
|
||||
DROP TABLE subscription;
|
||||
@@ -9,4 +9,4 @@ struts.url.http.port = 8080
|
||||
struts.freemarker.manager.classname=customFreemarkerManager
|
||||
struts.serve.static=true
|
||||
struts.serve.static.browserCache=false
|
||||
struts.compatibilityMode = true
|
||||
struts.compatibilityMode.WebWork = true
|
||||
|
||||
Reference in New Issue
Block a user