001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id$
023: */
024: package com.bostechcorp.cbesb.common.util.runtimedb;
025:
026: import java.sql.Timestamp;
027: import java.util.List;
028:
029: import com.bostechcorp.cbesb.common.util.runtimedb.vo.EndpointSettingVO;
030: import com.ibatis.sqlmap.client.SqlMapClient;
031:
032: import junit.framework.TestCase;
033:
034: public class TestRuntimeDB extends TestCase {
035:
036: DaoConfig daoConfig = new DaoConfig();
037: SqlMapClient sqlMap = daoConfig.getSqlMapInstance();
038:
039: public void testInsertEndpointSettingTable() throws Exception {
040: EndpointSettingVO settingVO = new EndpointSettingVO();
041: settingVO.setSaName("saName");
042: settingVO.setSuName("suName");
043: settingVO.setEndpointName("endpointName");
044: settingVO.setType("type");
045: settingVO.setPropertyName("propertyName");
046: settingVO.setPropertyValue("propertyValue");
047: settingVO.setLastUpdated(new Timestamp(System
048: .currentTimeMillis()));
049: Object keyOfInsertedRow = sqlMap.insert(
050: "insertEndpointSetting", settingVO);
051: assertNotNull(keyOfInsertedRow);
052: }
053:
054: public void testSelectEndpointSettingTable() throws Exception {
055: List<EndpointSettingVO> resultList = sqlMap.queryForList(
056: "queryEndpointSetting", null);
057: System.out.println("total rows: " + resultList.size());
058: for (EndpointSettingVO settingVO : resultList) {
059: System.out.println("-----------Start-----------");
060: System.out.println(settingVO.getSaName());
061: System.out.println(settingVO.getSuName());
062: System.out.println(settingVO.getEndpointName());
063: System.out.println(settingVO.getType());
064: System.out.println(settingVO.getPropertyName());
065: System.out.println(settingVO.getPropertyValue());
066: System.out.println(settingVO.getLastUpdated());
067: System.out.println("------------End------------");
068: }
069: }
070:
071: public void testSelectEndpointSettingTableForUpdate()
072: throws Exception {
073: EndpointSettingVO settingVO = new EndpointSettingVO();
074: settingVO.setSaName("fileStandard");
075: settingVO.setSuName("fileStandard_File");
076: settingVO.setEndpointName("fileStandard_File_Input");
077: settingVO.setType("consumer");
078: settingVO.setPropertyName("SOURCE_DIRECTORY");
079: settingVO.setPropertyValue("inbox23");
080: List<EndpointSettingVO> resultList = sqlMap.queryForList(
081: "queryEndpointSettingForUpdate", settingVO);
082: System.out.println("total rows: " + resultList.size());
083: }
084:
085: public void testUpdateEndpointSettingTable() throws Exception {
086: EndpointSettingVO settingVO = new EndpointSettingVO();
087: settingVO.setSaName("saName");
088: settingVO.setSuName("suName");
089: settingVO.setEndpointName("endpointName");
090: settingVO.setType("consumer");
091: settingVO.setPropertyName("scandir");
092: settingVO.setPropertyValue("inbox");
093: settingVO.setLastUpdated(new Timestamp(System
094: .currentTimeMillis()));
095: int numberOfRowsEffected = sqlMap.update(
096: "updateEndpointSetting", settingVO);
097: System.out.println("The number of rows updated: "
098: + numberOfRowsEffected);
099: }
100:
101: public void testDeleteEndpointSettingTable() throws Exception {
102: EndpointSettingVO settingVO = new EndpointSettingVO();
103: settingVO.setSaName("saName");
104: settingVO.setSuName("suName");
105: settingVO.setEndpointName("endpointName");
106: settingVO.setType("consumer");
107: int numberOfRowsEffected = sqlMap.delete(
108: "deleteEndpointSetting", settingVO);
109: System.out.println("The number of rows deleted: "
110: + numberOfRowsEffected);
111: }
112: }
|