2009-01-30 01:04:06 +07:00
|
|
|
/******************************************************************************
|
|
|
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
|
|
|
* Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms version 2 of the GNU General Public License as published *
|
|
|
|
* by the Free Software Foundation. This program is distributed in the hope *
|
|
|
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
|
|
* See the GNU General Public License for more details. *
|
|
|
|
* You should have received a copy of the GNU General Public License along *
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
|
|
|
*****************************************************************************/
|
2008-02-14 00:03:15 +07:00
|
|
|
package test.functional;
|
|
|
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
import org.compiere.model.MSysConfig;
|
|
|
|
import org.compiere.util.DB;
|
|
|
|
|
|
|
|
import test.AdempiereTestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MSysConfig Test Case
|
|
|
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class MSysConfigTest extends AdempiereTestCase {
|
|
|
|
private String varname = null;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void setUp() throws Exception {
|
|
|
|
super.setUp();
|
|
|
|
//
|
|
|
|
varname = "MSysConfigTestVariable" + System.currentTimeMillis();
|
2009-04-24 20:16:19 +07:00
|
|
|
new TestableSysConfig(getCtx(), 0, 0, varname, "0_0", null).saveEx();
|
|
|
|
new TestableSysConfig(getCtx(), 11, 0, varname, "11_0", null).saveEx();
|
|
|
|
new TestableSysConfig(getCtx(), 11, 11, varname, "11_11", null).saveEx();
|
2008-02-14 00:03:15 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void tearDown() throws Exception {
|
|
|
|
super.tearDown();
|
|
|
|
//
|
|
|
|
String sql = "DELETE FROM "+MSysConfig.Table_Name
|
|
|
|
+" WHERE "+MSysConfig.COLUMNNAME_Name+"=?";
|
2009-04-24 20:16:19 +07:00
|
|
|
DB.executeUpdateEx(sql, new Object[]{varname}, null);
|
2008-02-14 00:03:15 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void testGetSet1() throws Exception {
|
|
|
|
//
|
|
|
|
assertEquals("0_0", MSysConfig.getValue(varname));
|
|
|
|
//
|
|
|
|
assertEquals("0_0", MSysConfig.getValue(varname, 0));
|
|
|
|
assertEquals("11_0", MSysConfig.getValue(varname, 11));
|
|
|
|
assertEquals("0_0", MSysConfig.getValue(varname, 12345));
|
|
|
|
//
|
|
|
|
assertEquals("0_0", MSysConfig.getValue(varname, 0, 0));
|
|
|
|
assertEquals("11_0", MSysConfig.getValue(varname, 11, 0));
|
|
|
|
assertEquals("11_11", MSysConfig.getValue(varname, 11, 11));
|
|
|
|
assertEquals("0_0", MSysConfig.getValue(varname, 12345, 12345));
|
|
|
|
assertEquals("11_0", MSysConfig.getValue(varname, 11, 12345));
|
|
|
|
}
|
|
|
|
|
2009-04-24 20:16:19 +07:00
|
|
|
private static class TestableSysConfig extends MSysConfig
|
|
|
|
{
|
2009-05-03 06:19:26 +07:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = -536206101431286540L;
|
|
|
|
|
2009-04-24 20:16:19 +07:00
|
|
|
public TestableSysConfig(Properties ctx,
|
2008-02-14 00:03:15 +07:00
|
|
|
int AD_Client_ID, int AD_Org_ID,
|
|
|
|
String Name, String Value,
|
|
|
|
String trxName)
|
|
|
|
{
|
|
|
|
super(ctx, 0, trxName);
|
|
|
|
setAD_Client_ID(AD_Client_ID);
|
|
|
|
setAD_Org_ID(AD_Org_ID);
|
|
|
|
setName(Name);
|
|
|
|
setValue(Value);
|
|
|
|
setConfigurationLevel(CONFIGURATIONLEVEL_Organization);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|