diff --git a/extend/src/org/adempiere/test/utils/DBUtils.java b/extend/src/org/adempiere/test/utils/DBUtils.java deleted file mode 100644 index 7e9e781fbe..0000000000 --- a/extend/src/org/adempiere/test/utils/DBUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.adempiere.test.utils; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -public class DBUtils { -/* - static { - try { - DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver()); - } catch (SQLException e) { - System.out.println("ERROR !!!"); - e.printStackTrace(); - } - } -*/ - - // logger - //private static CLogger log = CLogger.getCLogger(DBUtils.class); - - public static Connection getConnection( String db, String user, String password) throws SQLException { - return DriverManager.getConnection( db, user, password); - } - - public static void close( ResultSet rs) { - try { - if (rs!=null) rs.close(); - } catch (SQLException e) { - ; - } - } - public static void close( Statement st) { - try { - if (st!=null) st.close(); - } catch (SQLException e) { - ; - } - } -} diff --git a/extend/src/test/AdempiereTestCase.java b/extend/src/test/AdempiereTestCase.java index db1a173834..72027ce613 100644 --- a/extend/src/test/AdempiereTestCase.java +++ b/extend/src/test/AdempiereTestCase.java @@ -130,6 +130,19 @@ public class AdempiereTestCase extends TestCase { CLogMgt.setLevel(LogLevel_Value); } + protected void commit() throws Exception { + Trx trx = null; + if (trxName != null) + trx = Trx.get(trxName, false); + if (trx != null && trx.isActive()) { + try { + trx.commit(true); + } finally { + trx.close(); + } + } + trx = null; + } @Override protected void tearDown() throws Exception { diff --git a/extend/src/test/functional/MBPGroupTest.java b/extend/src/test/functional/MBPGroupTest.java index 7b79073039..0fb9b32d78 100644 --- a/extend/src/test/functional/MBPGroupTest.java +++ b/extend/src/test/functional/MBPGroupTest.java @@ -1,46 +1,16 @@ //MBPGroupTest.java package test.functional; -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - import org.compiere.model.MLocation; import org.compiere.model.MBPGroup; -import org.compiere.util.CLogMgt; import org.compiere.util.DB; -import org.adempiere.test.utils.DBUtils; -import org.compiere.util.*; + +import test.AdempiereTestCase; + import java.sql.*; -public class MBPGroupTest extends TestCase { +public class MBPGroupTest extends AdempiereTestCase { - // Test: General - private Properties testProperties = null; - - private Properties m_Ctx = null; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - - private String AD_Client_ID_DefaultValue = "11"; - private String AD_Client_ID_Key = "AD_Client_ID"; - private int AD_Client_ID_Value = 11; - - // Test: Specific variables - java.sql.Connection c = null; - // Variables needed for importing/migrating business partners private MLocation location = null; @@ -486,146 +456,69 @@ public class MBPGroupTest extends TestCase { private MIssue = null; private MQuery = null; */ - private String trxName = "test"; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - AD_Client_ID_Value = Integer.parseInt(testProperties.getProperty(AD_Client_ID_Key, AD_Client_ID_DefaultValue) ); - - - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - assertEquals("Please specify path to Adempiere.properties file!", true, false); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.FINEST); -/* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL -*/ - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } public int getC_Region_ID(String Region) { - System.out.println("In getC_Region_ID"); - - String sql = "select c_region_id from c_region where name = ?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - - int C_Region_ID = -1; + String sql = "select c_region_id from c_region where name = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; - try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); - pstmt.setString(1, Region); - rs = pstmt.executeQuery(); + int C_Region_ID = -1; - - while (rs.next()) { - C_Region_ID = rs.getInt(1); + try { + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); + pstmt.setString(1, Region); + rs = pstmt.executeQuery(); + + + while (rs.next()) { + C_Region_ID = rs.getInt(1); + } + } catch (SQLException e) { + fail(e.getLocalizedMessage()); + } finally { + DB.close( rs, pstmt ); } - } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); - } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); - } - System.out.println("C_Region_ID: " + C_Region_ID); - - return C_Region_ID; - + return C_Region_ID; } public int getC_Country_ID(String Country) { - System.out.println("In getC_Country_ID"); - - String sql = "select c_country_id from c_country where name = ?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - - int C_Country_ID = -1; + String sql = "select c_country_id from c_country where name = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; - try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); - pstmt.setString(1, Country); - rs = pstmt.executeQuery(); + int C_Country_ID = -1; - - while (rs.next()) { - C_Country_ID = rs.getInt(1); + try { + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); + pstmt.setString(1, Country); + rs = pstmt.executeQuery(); + while (rs.next()) { + C_Country_ID = rs.getInt(1); + } + } catch (SQLException e) { + fail(e.getLocalizedMessage()); + } finally { + DB.close( rs, pstmt ); } - } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); - } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); - } - System.out.println("C_Country_ID: " + C_Country_ID); - - return C_Country_ID; - + + return C_Country_ID; } - public void testCreateMPBGroup() + public void testCreateMBPGroup() { - try { - - m_group = new MBPGroup (m_Ctx, 0, "test"); - if (m_group != null) { + try { + m_group = new MBPGroup (getCtx(), 0, getTrxName()); m_group.setName ("Test Group Name"); // N m_group.setIsConfidentialInfo (false); // N m_group.setIsDefault (false); - + m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same); - m_group.save(); - } else { - System.out.println("m_group is null"); - } - - try { - boolean saveResult = DB.commit(true, "test"); - assertTrue("DB.commit failed", saveResult); - if( saveResult) { - System.out.println("MBPGroup saved successfully"); - } - - //DB.commit(true, "test"); - } catch(Exception e) { - System.out.println("Location not updated"); - } - } catch(Exception e) { - System.out.println("Exception with MBPGroupTest"); - } + m_group.save(); + + commit(); + } catch(Exception e) { + fail(e.getLocalizedMessage()); + } } diff --git a/extend/src/test/functional/MBPartnerLocationTest.java b/extend/src/test/functional/MBPartnerLocationTest.java index df3379ce3b..a9f650c536 100644 --- a/extend/src/test/functional/MBPartnerLocationTest.java +++ b/extend/src/test/functional/MBPartnerLocationTest.java @@ -1,46 +1,16 @@ //MBPartnerLocationTest.java package test.functional; -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - import org.compiere.model.*; -import org.compiere.model.MBPartnerLocation; -import org.compiere.util.CLogMgt; import org.compiere.util.DB; -import org.adempiere.test.utils.DBUtils; import org.compiere.util.*; + +import test.AdempiereTestCase; + import java.sql.*; -public class MBPartnerLocationTest extends TestCase { +public class MBPartnerLocationTest extends AdempiereTestCase { - // Test: General - private Properties testProperties = null; - - private Properties m_Ctx = null; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - - private String AD_Client_ID_DefaultValue = "11"; - private String AD_Client_ID_Key = "AD_Client_ID"; - private int AD_Client_ID_Value = 11; - - // Test: Specific variables - java.sql.Connection c = null; - // Variables needed for importing/migrating business partners private MBPartner m_partner = null; //business partner private MLocation location = null; @@ -487,160 +457,83 @@ public class MBPartnerLocationTest extends TestCase { private MIssue = null; private MQuery = null; */ - private String trxName = "test"; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - AD_Client_ID_Value = Integer.parseInt(testProperties.getProperty(AD_Client_ID_Key, AD_Client_ID_DefaultValue) ); - - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - assertEquals("Please specify path to Adempiere.properties file!", true, false); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.FINEST); -/* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL -*/ - try { - if(c == null || c.isClosed()) { - Class.forName("org.objectweb.rmijdbc.Driver").newInstance(); - String url = "jdbc:odbc:vfpdsn"; - - // RMI host will point to local host - String rmiHost = new String( "//" + "172.16.1.98"); - c = DriverManager.getConnection("jdbc:rmi:" + rmiHost + "/" + url); - } - - } catch(Exception e) { - c = null; - - } - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } public int getC_Region_ID(String Region) { - System.out.println("In getC_Region_ID"); - String sql = "select c_region_id from c_region where name = ?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - - int C_Region_ID = -1; + String sql = "select c_region_id from c_region where name = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; - try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); - pstmt.setString(1, Region); - rs = pstmt.executeQuery(); + int C_Region_ID = -1; - - while (rs.next()) { - C_Region_ID = rs.getInt(1); + try { + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); + pstmt.setString(1, Region); + rs = pstmt.executeQuery(); + + + while (rs.next()) { + C_Region_ID = rs.getInt(1); + } + } catch (SQLException e) { + fail(e.getLocalizedMessage()); + } finally { + DB.close( rs, pstmt ); } - } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); - } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); - } - System.out.println("C_Region_ID: " + C_Region_ID); - - return C_Region_ID; - + return C_Region_ID; } public int getC_Country_ID(String Country) { - System.out.println("In getC_Country_ID"); - - String sql = "select c_country_id from c_country where name = ?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - - int C_Country_ID = -1; - try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); - pstmt.setString(1, Country); - rs = pstmt.executeQuery(); + String sql = "select c_country_id from c_country where name = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; + + int C_Country_ID = -1; - - while (rs.next()) { - C_Country_ID = rs.getInt(1); + try { + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); + pstmt.setString(1, Country); + rs = pstmt.executeQuery(); + + + while (rs.next()) { + C_Country_ID = rs.getInt(1); + } + } catch (SQLException e) { + fail(e.getLocalizedMessage()); + } finally { + DB.close( rs, pstmt ); } - } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); - } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); - } - System.out.println("C_Country_ID: " + C_Country_ID); - - return C_Country_ID; + + return C_Country_ID; } public void testCreatePartnerLocation() { - try { - location = new MLocation(m_Ctx, 0, "test"); - location.setC_Country_ID(getC_Country_ID("United States")); - location.setC_Region_ID(getC_Region_ID("CA")); - location.setCity("Windsor"); - location.setAddress1("Happy Lane"); - location.setAddress2("Happy Lane 2"); - String zipcode = ("95492"); - location.setPostal(zipcode); - location.setPostal_Add(zipcode); - location.setAD_Org_ID(0); - location.save(); - - m_group = new MBPGroup (m_Ctx, 0, "test"); - if (m_group != null) { + try { + location = new MLocation(getCtx(), 0, getTrxName()); + location.setC_Country_ID(getC_Country_ID("United States")); + location.setC_Region_ID(getC_Region_ID("CA")); + location.setCity("Windsor"); + location.setAddress1("Happy Lane"); + location.setAddress2("Happy Lane 2"); + String zipcode = ("95492"); + location.setPostal(zipcode); + location.setPostal_Add(zipcode); + location.setAD_Org_ID(0); + location.save(); + + m_group = new MBPGroup (getCtx(), 0, getTrxName()); m_group.setName ("Test Group Name"); // N m_group.setIsConfidentialInfo (false); // N m_group.setIsDefault (false); - + m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same); m_group.save(); - } else { - System.out.println("m_group is null"); - } - - - m_partner = new MBPartner (m_Ctx, 0, "test"); - if (m_partner != null) { - //m_partner.setAD_Client_ID(11); + + m_partner = new MBPartner (getCtx(), 0, "test"); m_partner.setValue (""); m_partner.setName ("Test Business Partner Location"); m_partner.setName2 (null); @@ -660,35 +553,18 @@ public class MBPartnerLocationTest extends TestCase { m_partner.setBPGroup(m_group); // Reset Created, Updated to current system time ( teo_sarca ) if(m_partner.save()) { - bpl = new MBPartnerLocation (m_Ctx, 0, "test"); - //bpl.setAD_Client_ID(11); + bpl = new MBPartnerLocation (getCtx(), 0, "test"); bpl.setIsActive(true); bpl.setName("Test Business Partner Location"); bpl.setC_BPartner_ID(m_partner.get_ID()); bpl.setC_Location_ID(location.get_ID()); bpl.save(); } - - } else { - System.out.println("m_partner is null"); - } - - try { - boolean saveResult = DB.commit(true, "test"); - assertTrue("DB.commit failed", saveResult); - if( saveResult) { - System.out.println("Business partner saved successfully"); - } - - //DB.commit(true, "test"); + + commit(); } catch(Exception e) { - System.out.println("Location not updated"); - } - - - } catch(Exception e) { - System.out.println("BPL exception"); - } + fail(e.getLocalizedMessage()); + } - } + } } diff --git a/extend/src/test/functional/MBPartnerTest.java b/extend/src/test/functional/MBPartnerTest.java index 95a1fbb3b8..2094508713 100644 --- a/extend/src/test/functional/MBPartnerTest.java +++ b/extend/src/test/functional/MBPartnerTest.java @@ -1,45 +1,16 @@ //MBPartnerTest.java package test.functional; -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - import org.compiere.model.*; -import org.compiere.util.CLogMgt; import org.compiere.util.DB; -import org.adempiere.test.utils.DBUtils; import org.compiere.util.*; + +import test.AdempiereTestCase; + import java.sql.*; -public class MBPartnerTest extends TestCase { +public class MBPartnerTest extends AdempiereTestCase { - // Test: General - private Properties testProperties = null; - - private Properties m_Ctx = null; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - - private String AD_Client_ID_DefaultValue = "11"; - private String AD_Client_ID_Key = "AD_Client_ID"; - private int AD_Client_ID_Value = 11; - - // Test: Specific variables - java.sql.Connection c = null; - // Variables needed for importing/migrating business partners private MLocation location = null; @@ -485,124 +456,61 @@ public class MBPartnerTest extends TestCase { private MIssue = null; private MQuery = null; */ - private String trxName = "test"; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - AD_Client_ID_Value = Integer.parseInt(testProperties.getProperty(AD_Client_ID_Key, AD_Client_ID_DefaultValue) ); - - - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - fail("Please specify path to Adempiere.properties file!"); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.FINEST); -/* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL -*/ - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } public int getC_Region_ID(String Region) { - System.out.println("In getC_Region_ID"); - - String sql = "select c_region_id from c_region where name = ?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - - int C_Region_ID = -1; + String sql = "select c_region_id from c_region where name = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; - try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); - pstmt.setString(1, Region); - rs = pstmt.executeQuery(); + int C_Region_ID = -1; - - while (rs.next()) { - C_Region_ID = rs.getInt(1); + try { + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); + pstmt.setString(1, Region); + rs = pstmt.executeQuery(); + + + while (rs.next()) { + C_Region_ID = rs.getInt(1); + } + } catch (SQLException e) { + fail(e.getLocalizedMessage()); + } finally { + DB.close( rs, pstmt ); } - } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); - } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); - } - System.out.println("C_Region_ID: " + C_Region_ID); - - return C_Region_ID; - + + return C_Region_ID; } public int getC_Country_ID(String Country) { - System.out.println("In getC_Country_ID"); - - String sql = "select c_country_id from c_country where name = ?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - - int C_Country_ID = -1; + String sql = "select c_country_id from c_country where name = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; - try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); - pstmt.setString(1, Country); - rs = pstmt.executeQuery(); + int C_Country_ID = -1; - - while (rs.next()) { - C_Country_ID = rs.getInt(1); + try { + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); + pstmt.setString(1, Country); + rs = pstmt.executeQuery(); + + + while (rs.next()) { + C_Country_ID = rs.getInt(1); + } + } catch (SQLException e) { + fail(e.getLocalizedMessage()); + } finally { + DB.close( rs, pstmt ); } - } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); - } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); - } - System.out.println("C_Country_ID: " + C_Country_ID); - - return C_Country_ID; - + + return C_Country_ID; } - public void testCreateMPBPartner() + public void testCreateMBPartner() { - try { - - m_partner = new MBPartner (m_Ctx, 0, "test"); - if (m_partner != null) { - // FIXME: determine AD_Client_ID correctly - //m_partner.setAD_Client_ID(11); + try { + m_partner = new MBPartner (getCtx(), 0, getTrxName()); m_partner.setValue (""); m_partner.setName ("Test MBPartner"); m_partner.setName2 (null); @@ -619,39 +527,24 @@ public class MBPartnerTest extends TestCase { m_partner.setAcqusitionCost(Env.ZERO); m_partner.setShareOfCustomer(0); m_partner.setSalesVolume(0); - - MBPGroup m_group = new MBPGroup (m_Ctx, 0, "test"); - // FIXME: determine AD_Client_ID correctly - //m_group.setAD_Client_ID(11); - m_group.setName ("Test Group Name"); // N - m_group.setIsConfidentialInfo (false); // N - m_group.setIsDefault (false); - - m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same); - - m_group.save(); - + + MBPGroup m_group = new MBPGroup (getCtx(), 0, getTrxName()); + m_group.setName ("Test Group Name"); // N + m_group.setIsConfidentialInfo (false); // N + m_group.setIsDefault (false); + + m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same); + + m_group.save(); + m_partner.setBPGroup(m_group); // Reset Created, Updated to current system time ( teo_sarca ) m_partner.save(); - } else { - fail("m_partner is null"); - } - - try { - boolean saveResult = DB.commit(true, "test"); - assertTrue("DB.commit failed", saveResult); - if( saveResult) { - System.out.println("MBPartner saved successfully"); - } - - //DB.commit(true, "test"); - } catch(Exception e) { - fail("Location not updated"); - } - } catch(Exception e) { - fail(e.getLocalizedMessage()); - } + + commit(); + } catch(Exception e) { + fail(e.getLocalizedMessage()); + } } diff --git a/extend/src/test/functional/MLocationTest.java b/extend/src/test/functional/MLocationTest.java index 5109aeca4c..69f6b987cc 100644 --- a/extend/src/test/functional/MLocationTest.java +++ b/extend/src/test/functional/MLocationTest.java @@ -1,94 +1,17 @@ //MLocationTest.java package test.functional; -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - import org.compiere.model.MLocation; -import org.compiere.util.CLogMgt; -import org.compiere.util.DB; -import org.compiere.util.Ini; -public class MLocationTest extends TestCase { +import test.AdempiereTestCase; + +public class MLocationTest extends AdempiereTestCase { - // Test: General - private Properties testProperties = null; - - private Properties m_Ctx = null; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - - private String AD_Client_ID_DefaultValue = "11"; - private String AD_Client_ID_Key = "AD_Client_ID"; - private int AD_Client_ID_Value = 11; - // Test: Specific variables private MLocation location = null; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - AD_Client_ID_Value = Integer.parseInt(testProperties.getProperty(AD_Client_ID_Key, AD_Client_ID_DefaultValue) ); - - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - assertEquals("Please specify path to Adempiere.properties file!", true, false); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.FINEST); -/* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL -*/ - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } - public void testMLocationCreation() { - String trxName = "test"; - location = new MLocation(m_Ctx, 0, trxName); + location = new MLocation(getCtx(), 0, getTrxName()); // location.loadDefaults(); location.setC_Country_ID(100); location.setC_Region_ID(103); @@ -97,20 +20,14 @@ public class MLocationTest extends TestCase { location.setAddress2(""); location.setPostal("95492"); location.setPostal_Add("95492"); - // location.setAD_Client_ID(0); location.setAD_Org_ID(0); boolean saveResult = location.save(); - if (!saveResult) { - assertEquals("Location not updated!", true, saveResult); - } else { - System.out.println("location.getC_Location_ID: " + location.getC_Location_ID()); - try { - DB.commit(true, trxName); - } catch (Exception e) { - assertEquals("Location not updated!", true, false); - } + assertTrue("MLocation.save()", saveResult); + try { + commit(); + } catch (Exception e) { + fail(e.getLocalizedMessage()); } - assertTrue("TestExample", true); } } diff --git a/extend/src/test/functional/MProductTest.java b/extend/src/test/functional/MProductTest.java index 21e6083d41..ee8000f196 100644 --- a/extend/src/test/functional/MProductTest.java +++ b/extend/src/test/functional/MProductTest.java @@ -1,100 +1,19 @@ //MProductTest.java package test.functional; -import java.io.FileInputStream; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Properties; -import java.util.logging.Level; -import junit.framework.TestCase; - -import org.adempiere.test.utils.DBUtils; import org.compiere.model.MProduct; import org.compiere.model.X_I_Product; -import org.compiere.util.CLogMgt; import org.compiere.util.DB; -import org.compiere.util.Ini; -public class MProductTest extends TestCase { +import test.AdempiereTestCase; - // Test: General - private Properties testProperties = null; +public class MProductTest extends AdempiereTestCase { - private Properties m_Ctx = null; - String trxName = "test"; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - - private String AD_Client_ID_DefaultValue = "11"; - private String AD_Client_ID_Key = "AD_Client_ID"; - private int AD_Client_ID_Value = 11; - - // Test: Specific variables -// private MProduct location = null; - - - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - AD_Client_ID_Value = Integer.parseInt(testProperties.getProperty(AD_Client_ID_Key, AD_Client_ID_DefaultValue) ); - - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - assertEquals("Please specify path to Adempiere.properties file!", true, false); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.FINEST); - /* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL - */ - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } - public int getProduct_Category_ID(String productCategory) { - System.out.println("In getProduct_Category_ID"); - String sql = "select m_product_category_id from m_product_category where name = ?"; PreparedStatement pstmt = null; ResultSet rs = null; @@ -102,7 +21,7 @@ public class MProductTest extends TestCase { int M_ProductCategory_ID = -1; try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); pstmt.setString(1, productCategory.trim()); rs = pstmt.executeQuery(); @@ -111,13 +30,10 @@ public class MProductTest extends TestCase { M_ProductCategory_ID = rs.getInt(1); } } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); + fail(e.getLocalizedMessage()); } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); + DB.close( rs, pstmt ); } - System.out.println("productCategory: " + productCategory); - System.out.println("M_ProductCategory_ID: " + M_ProductCategory_ID); return M_ProductCategory_ID; @@ -133,7 +49,7 @@ public class MProductTest extends TestCase { int C_Uom_ID = -1; try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); pstmt.setString(1, UOM.trim()); rs = pstmt.executeQuery(); @@ -142,10 +58,9 @@ public class MProductTest extends TestCase { C_Uom_ID = rs.getInt(1); } } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); + fail(e.getLocalizedMessage()); } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); + DB.close( rs, pstmt ); } System.out.println("Uom: " + UOM); System.out.println("C_Uom_ID: " + C_Uom_ID); @@ -154,10 +69,8 @@ public class MProductTest extends TestCase { } - - - public void testMProductCreation() { - MProduct m_product = new MProduct(m_Ctx, 0, trxName); + public void testCreateMProduct() { + MProduct m_product = new MProduct(getCtx(), 0, getTrxName()); m_product.setAD_Org_ID(0); m_product.setProductType (X_I_Product.PRODUCTTYPE_Item); // I m_product.setIsBOM (false); // N @@ -174,21 +87,8 @@ public class MProductTest extends TestCase { m_product.setProcessing (false); // N m_product.setName("Test Product"); // N m_product.setC_UOM_ID(getUOM_ID("Each")); - //m_product.setM_Product_ID(getProduct_Category_ID("Documentation")); - m_product.setM_Product_ID(111); - boolean saveResult = m_product.save(); - if (!saveResult) { - assertEquals("Product not updated!", true, saveResult); - } else { - System.out.println("m_product.get_ID: " + m_product.get_ID()); - /* try { - DB.commit(true, trxName); - } catch (Exception e) { - assertEquals("Location not updated!", true, false); - } */ - } - assertTrue("MProductTest", true); + assertEquals("Create new product.", true, saveResult); } } diff --git a/extend/src/test/functional/MUserTest.java b/extend/src/test/functional/MUserTest.java index ae88f6cc47..b6cad3d463 100644 --- a/extend/src/test/functional/MUserTest.java +++ b/extend/src/test/functional/MUserTest.java @@ -1,45 +1,16 @@ //MUserTest.java package test.functional; -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - import org.compiere.model.*; -import org.compiere.util.CLogMgt; import org.compiere.util.DB; -import org.adempiere.test.utils.DBUtils; import org.compiere.util.*; + +import test.AdempiereTestCase; + import java.sql.*; -public class MUserTest extends TestCase { +public class MUserTest extends AdempiereTestCase { - // Test: General - private Properties testProperties = null; - - private Properties m_Ctx = null; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - - private String AD_Client_ID_DefaultValue = "11"; - private String AD_Client_ID_Key = "AD_Client_ID"; - private int AD_Client_ID_Value = 11; - - // Test: Specific variables - java.sql.Connection c = null; - // Variables needed for importing/migrating business partners private MLocation location = null; @@ -485,180 +456,100 @@ public class MUserTest extends TestCase { private MIssue = null; private MQuery = null; */ - private String trxName = "test"; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - AD_Client_ID_Value = Integer.parseInt(testProperties.getProperty(AD_Client_ID_Key, AD_Client_ID_DefaultValue) ); - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - assertEquals("Please specify path to Adempiere.properties file!", true, false); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.FINEST); -/* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL -*/ - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } public int getC_Region_ID(String Region) { - System.out.println("In getC_Region_ID"); - String sql = "select c_region_id from c_region where name = ?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - - int C_Region_ID = -1; + String sql = "select c_region_id from c_region where name = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; - try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); - pstmt.setString(1, Region); - rs = pstmt.executeQuery(); - - - while (rs.next()) { - C_Region_ID = rs.getInt(1); + int C_Region_ID = -1; + try { + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); + pstmt.setString(1, Region); + rs = pstmt.executeQuery(); + while (rs.next()) { + C_Region_ID = rs.getInt(1); + } + } catch (SQLException e) { + fail(e.getLocalizedMessage()); + } finally { + DB.close( rs, pstmt ); } - } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); - } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); - } - System.out.println("C_Region_ID: " + C_Region_ID); - - return C_Region_ID; - + + return C_Region_ID; } public int getC_Country_ID(String Country) { - System.out.println("In getC_Country_ID"); - - String sql = "select c_country_id from c_country where name = ?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - - int C_Country_ID = -1; + String sql = "select c_country_id from c_country where name = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; - try { - pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName); - pstmt.setString(1, Country); - rs = pstmt.executeQuery(); + int C_Country_ID = -1; - - while (rs.next()) { - C_Country_ID = rs.getInt(1); + try { + pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName()); + pstmt.setString(1, Country); + rs = pstmt.executeQuery(); + + + while (rs.next()) { + C_Country_ID = rs.getInt(1); + } + } catch (SQLException e) { + fail(e.getLocalizedMessage()); + } finally { + DB.close( rs, pstmt ); } - } catch (SQLException e) { - System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage()); - } finally { - DBUtils.close( rs); - DBUtils.close( pstmt); - } - System.out.println("C_Country_ID: " + C_Country_ID); - - return C_Country_ID; + + return C_Country_ID; } - public void testCreateMPBPartner() + public void testCreateMBPartner() { try { - m_partner = new MBPartner (m_Ctx, 0, "test"); - if (m_partner != null) { - // FIXME: determine AD_Client_ID correctly - //m_partner.setAD_Client_ID(11); - m_partner.setValue (""); - m_partner.setName ("Test MBPartner with contact"); - m_partner.setName2 (null); - m_partner.setDUNS(""); - m_partner.setFirstSale(null); - // - m_partner.setSO_CreditLimit (Env.ZERO); - m_partner.setSO_CreditUsed (Env.ZERO); - m_partner.setTotalOpenBalance (Env.ZERO); - // s_m_partner.setRating(null); - // - m_partner.setActualLifeTimeValue(Env.ZERO); - m_partner.setPotentialLifeTimeValue(Env.ZERO); - m_partner.setAcqusitionCost(Env.ZERO); - m_partner.setShareOfCustomer(0); - m_partner.setSalesVolume(0); + m_partner = new MBPartner (getCtx(), 0, getTrxName()); + m_partner.setValue (""); + m_partner.setName ("Test MBPartner with contact"); + m_partner.setName2 (null); + m_partner.setDUNS(""); + m_partner.setFirstSale(null); + // + m_partner.setSO_CreditLimit (Env.ZERO); + m_partner.setSO_CreditUsed (Env.ZERO); + m_partner.setTotalOpenBalance (Env.ZERO); + // s_m_partner.setRating(null); + // + m_partner.setActualLifeTimeValue(Env.ZERO); + m_partner.setPotentialLifeTimeValue(Env.ZERO); + m_partner.setAcqusitionCost(Env.ZERO); + m_partner.setShareOfCustomer(0); + m_partner.setSalesVolume(0); - MBPGroup m_group = new MBPGroup (m_Ctx, 0, "test"); - // FIXME: determine AD_Client_ID correctly - //m_group.setAD_Client_ID(11); - m_group.setName ("Test Group Name"); // N - m_group.setIsConfidentialInfo (false); // N - m_group.setIsDefault (false); + MBPGroup m_group = new MBPGroup (getCtx(), 0, getTrxName()); + m_group.setName ("Test Group Name"); // N + m_group.setIsConfidentialInfo (false); // N + m_group.setIsDefault (false); - m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same); + m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same); - m_group.save(); + m_group.save(); - m_partner.setBPGroup(m_group); - // Reset Created, Updated to current system time ( teo_sarca ) - if(m_partner.save()) { - m_contact = new MUser(m_Ctx, 0, "test2"); - m_contact.setName("Test Contact Name"); - //m_contact.setAD_Client_ID(11); - m_contact.setIsActive(true); - m_contact.setC_BPartner_ID(m_partner.get_ID()); - m_contact.save(); - - } - } else { - System.out.println("m_partner is null"); - } - - try { - boolean saveResult = DB.commit(true, "test"); - boolean saveResult2 = DB.commit(true, "test2"); - assertTrue("DB.commit failed", saveResult); - assertTrue("DB.commit failed", saveResult2); - if( saveResult) { - System.out.println("MBPartner saved successfully"); - } - - //DB.commit(true, "test"); - } catch(Exception e) { - System.out.println("Location not updated"); - } + m_partner.setBPGroup(m_group); + // Reset Created, Updated to current system time ( teo_sarca ) + if(m_partner.save()) { + m_contact = new MUser(getCtx(), 0, getTrxName()); + m_contact.setName("Test Contact Name"); + m_contact.setIsActive(true); + m_contact.setC_BPartner_ID(m_partner.get_ID()); + m_contact.save(); + } + + commit(); } catch(Exception e) { - System.out.println("Exception with MBPartnerTest"); + fail(e.getLocalizedMessage()); } } diff --git a/extend/src/test/functional/PackInTest.java b/extend/src/test/functional/PackInTest.java deleted file mode 100644 index ca13fd5151..0000000000 --- a/extend/src/test/functional/PackInTest.java +++ /dev/null @@ -1,129 +0,0 @@ -//PackInTest.java -package test.functional; - -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - -import org.compiere.model.*; -import org.compiere.process.*; -import org.compiere.util.CLogMgt; -import org.compiere.util.DB; -import org.compiere.util.Ini; -import org.compiere.util.*; - -import org.adempiere.pipo.*; - -public class PackInTest extends TestCase { - - // Test: General - private Properties testProperties = null; - - private Properties m_Ctx = null; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - - private String AD_Client_ID_DefaultValue = "0"; - private String AD_Client_ID_Key = "AD_Client_ID"; - private int AD_Client_ID_Value = 0; - - // Test: Specific variables - private MLocation location = null; - - - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - AD_Client_ID_Value = Integer.parseInt(testProperties.getProperty(AD_Client_ID_Key, AD_Client_ID_DefaultValue) ); - - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - assertEquals("Please specify path to Adempiere.properties file!", true, false); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.FINEST); -/* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL -*/ - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } - - public void testPackIn() { - System.out.println("In testPackIn"); - String trxName = "test"; - PackIn m_PackIn = new PackIn(); - PackInHandler m_PackInHandler = new PackInHandler(); - Trx m_trx = Trx.get(Trx.createTrxName("SvrProcess"), true); - int m_ad_process_id = IDFinder.get_IDWithColumn("ad_process", "Name", "PackIn", AD_Client_ID_Value, m_trx.getTrxName()); - int m_ad_table_id = IDFinder.get_IDWithColumn("ad_table", "Name", "AD_Package_Imp_Proc_ID", AD_Client_ID_Value, m_trx.getTrxName()); - - //Create 2Pack Export Package - - X_AD_Package_Imp_Proc m_MPackageImpProc = new X_AD_Package_Imp_Proc(m_Ctx, 0, trxName); - m_MPackageImpProc.setIsActive(true); - m_MPackageImpProc.setAD_Package_Dir("/work2/adempiere/adempiere/Adempiere/packages"); - m_MPackageImpProc.setAD_Package_Source("/work2/adempiere/adempiere/Adempiere/packages/testPrintFormat2.zip"); - m_MPackageImpProc.setAD_Package_Source_Type(m_MPackageImpProc.AD_PACKAGE_SOURCE_TYPE_File); - - boolean saveResult = m_MPackageImpProc.save(); - if (!saveResult) { - assertEquals("Import Package not saved!", true, saveResult); - } else { - System.out.println("m_MPackageImpProc.get_ID: " + m_MPackageImpProc.get_ID()); - try { - DB.commit(true, trxName); - } catch (Exception e) { - assertEquals("m_MPackageImp not updated!", true, false); - } - } - - - //int m_ad_record_id = m_PackInHandler.get_IDWithColumn("ad_package_imp", "Name", "testManufacturingMenu"); - - ProcessInfo m_ProcessInfo = new ProcessInfo("PackIn", m_ad_process_id, m_ad_table_id, m_MPackageImpProc.get_ID()); - m_PackIn.startProcess(m_Ctx, m_ProcessInfo, m_trx); - assertTrue("PackIn", true); - } -} diff --git a/extend/src/test/functional/PackOutBug1723733Test.java b/extend/src/test/functional/PackOutBug1723733Test.java deleted file mode 100644 index 283533eefb..0000000000 --- a/extend/src/test/functional/PackOutBug1723733Test.java +++ /dev/null @@ -1,177 +0,0 @@ -//PackOutBug1723733Test.java -package test.functional; - -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - -import org.compiere.model.*; -import org.compiere.process.*; -import org.compiere.util.CLogMgt; -import org.compiere.util.DB; -import org.compiere.util.Ini; -import org.compiere.util.*; - -import org.adempiere.pipo.*; - -public class PackOutBug1723733Test extends TestCase { - - // Test: General - private Properties testProperties = null; - - private Properties m_Ctx = null; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - - private String AD_Client_ID_DefaultValue = "0"; - private String AD_Client_ID_Key = "AD_Client_ID"; - private int AD_Client_ID_Value = 0; - - // Test: Specific variables - private MLocation location = null; - - - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - AD_Client_ID_Value = Integer.parseInt(testProperties.getProperty(AD_Client_ID_Key, AD_Client_ID_DefaultValue) ); - - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - assertEquals("Please specify path to Adempiere.properties file!", true, false); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.FINEST); -/* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL -*/ - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } - - public void testPackOut() { - System.out.println("In testPackOut"); - String trxName = "test"; - PackOut m_PackOut = new PackOut(); - PackInHandler m_PackInHandler = new PackInHandler(); - Trx m_trx = Trx.get(Trx.createTrxName("SvrProcess"), true); - int m_ad_process_id = IDFinder.get_IDWithColumn("ad_process", "Name", "PackOut", AD_Client_ID_Value, m_trx.getTrxName()); - int m_ad_table_id = IDFinder.get_IDWithColumn("ad_table", "Name", "AD_Package_Exp_ID", AD_Client_ID_Value, m_trx.getTrxName()); - - //Create 2Pack Export Package - - MPackageExp m_MPackageExp = new MPackageExp(m_Ctx, 0, trxName); - m_MPackageExp.setName("testPrintFormatSub2Pack"); - //m_MPackageExp.setOrgId(0); - m_MPackageExp.setIsActive(true); - m_MPackageExp.setDescription("Test PrintFormat Output Package for bug 1723733"); - m_MPackageExp.setEMail("wgheath@gmail.com"); - m_MPackageExp.setUserName("wgheath@gmail.com"); - m_MPackageExp.setFile_Directory("packages/"); - m_MPackageExp.setInstructions("use 2pack to import this package"); - m_MPackageExp.setReleaseNo( X_AD_Package_Exp_Detail.RELEASENO_NoSpecificRelease); - m_MPackageExp.setVersion("1.0"); - m_MPackageExp.setPK_Version("1.0"); - - boolean saveResult = m_MPackageExp.save(); - if (!saveResult) { - assertEquals("Export Package not saved!", true, saveResult); - } else { - System.out.println("m_MPackageExp.get_ID: " + m_MPackageExp.get_ID()); - } - - - X_AD_Package_Exp_Detail m_PackDetail =new X_AD_Package_Exp_Detail(m_Ctx, 0, null); - m_PackDetail.setAD_Org_ID(m_MPackageExp.getAD_Org_ID()); - m_PackDetail.setAD_Package_Exp_ID(m_MPackageExp.get_ID()); - m_MPackageExp.setIsActive(true); - m_PackDetail.setType(X_AD_Package_Exp_Detail.TYPE_PrintFormat); - m_PackDetail.setDBType("ALL"); - m_PackDetail.setSQLStatement("select * from ad_table"); - m_PackDetail.setDescription("Order_Header ** TEMPLATE ** with subformat Order_LineTax ** TEMPLATE **"); - m_PackDetail.setAD_PrintFormat_ID(IDFinder.get_IDWithColumn("ad_printformat", "Name", "Order_Header ** TEMPLATE **", AD_Client_ID_Value, m_trx.getTrxName()) ); - - /*m_PackDetail.setFileName(rs.getString("FILENAME")); - m_PackDetail.setAD_Client_ID(m_MPackageExp.getAD_Client_ID()); - m_PackDetail.setDescription(rs.getString("DESCRIPTION")); - m_PackDetail.setTarget_Directory(rs.getString("TARGET_DIRECTORY")); - m_PackDetail.setFile_Directory(rs.getString("FILE_DIRECTORY")); - m_PackDetail.setDestination_Directory(rs.getString("DESTINATION_DIRECTORY"); - m_PackDetail.setAD_Workflow_ID(rs.getInt("AD_WORKFLOW_ID")); - m_PackDetail.setAD_Window_ID(rs.getInt("AD_WINDOW_ID")); - m_PackDetail.setAD_Role_ID(rs.getInt("AD_ROLE_ID")); - m_PackDetail.setAD_Process_ID(rs.getInt("AD_PROCESS_ID")); - m_PackDetail.setAD_Menu_ID(rs.getInt("AD_MENU_ID")); - m_PackDetail.setAD_ImpFormat_ID(rs.getInt("AD_IMPFORMAT_ID")); - m_PackDetail.setAD_Workbench_ID(rs.getInt("AD_WORKBENCH_ID")); - m_PackDetail.setAD_Table_ID(rs.getInt("AD_TABLE_ID")); - m_PackDetail.setAD_Form_ID(rs.getInt("AD_FORM_ID")); - m_PackDetail.setAD_ReportView_ID(rs.getInt("AD_REPORTVIEW_ID")); - */ - m_PackDetail.setLine(10); - m_PackDetail.save(); - - - saveResult = m_PackDetail.save(); - if (!saveResult) { - assertEquals("Package detail not saved!", true, saveResult); - } else { - System.out.println("m_PackDetail.get_ID: " + m_PackDetail.get_ID()); - try { - DB.commit(true, trxName); - } catch (Exception e) { - assertEquals("m_PackDetail not updated!", true, false); - } - } - assertTrue("PackOutBug1723733Test", true); - - - int m_ad_record_id = IDFinder.get_IDWithColumn("ad_package_exp", "Name", "test2packJunit", AD_Client_ID_Value, m_trx.getTrxName()); - - //ProcessInfo m_ProcessInfo = new ProcessInfo("PackOut", m_ad_process_id, m_ad_table_id, m_ad_record_id); - ProcessInfo m_ProcessInfo = new ProcessInfo("PackOut", m_ad_process_id, m_ad_table_id, m_MPackageExp.get_ID()); - m_PackOut.startProcess(m_Ctx, m_ProcessInfo, m_trx); - assertTrue("PackOut", true); - } -} diff --git a/extend/src/test/functional/PackOutTest.java b/extend/src/test/functional/PackOutTest.java index 4661979e34..99214b0108 100644 --- a/extend/src/test/functional/PackOutTest.java +++ b/extend/src/test/functional/PackOutTest.java @@ -1,109 +1,30 @@ //PackOutTest.java package test.functional; -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - import org.compiere.model.*; import org.compiere.process.*; -import org.compiere.util.CLogMgt; -import org.compiere.util.DB; -import org.compiere.util.Ini; import org.compiere.util.*; import org.adempiere.pipo.*; -public class PackOutTest extends TestCase { +import test.AdempiereTestCase; + +public class PackOutTest extends AdempiereTestCase { - // Test: General - private Properties testProperties = null; - - private Properties m_Ctx = null; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - - private String AD_Client_ID_DefaultValue = "0"; - private String AD_Client_ID_Key = "AD_Client_ID"; - private int AD_Client_ID_Value = 0; - // Test: Specific variables private MLocation location = null; - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - AD_Client_ID_Value = Integer.parseInt(testProperties.getProperty(AD_Client_ID_Key, AD_Client_ID_DefaultValue) ); - - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - assertEquals("Please specify path to Adempiere.properties file!", true, false); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.FINEST); -/* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL -*/ - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } - public void testPackOut() { - System.out.println("In testPackOut"); - String trxName = "test"; PackOut m_PackOut = new PackOut(); PackInHandler m_PackInHandler = new PackInHandler(); - Trx m_trx = Trx.get(Trx.createTrxName("SvrProcess"), true); - int m_ad_process_id = IDFinder.get_IDWithColumn("ad_process", "Name", "PackOut", AD_Client_ID_Value, m_trx.getTrxName()); - int m_ad_table_id = IDFinder.get_IDWithColumn("ad_table", "Name", "AD_Package_Exp_ID", AD_Client_ID_Value, m_trx.getTrxName()); + Trx m_trx = Trx.get(getTrxName(), true); + int m_ad_process_id = IDFinder.get_IDWithColumn("ad_process", "Name", "PackOut", getAD_Client_ID(), getTrxName()); + int m_ad_table_id = IDFinder.get_IDWithColumn("ad_table", "Name", "AD_Package_Exp_ID", getAD_Client_ID(), getTrxName()); //Create 2Pack Export Package - - MPackageExp m_MPackageExp = new MPackageExp(m_Ctx, 0, trxName); + MPackageExp m_MPackageExp = new MPackageExp(getCtx(), 0, getTrxName()); m_MPackageExp.setName("testSqlStatement2Pack"); - //m_MPackageExp.setOrgId(0); m_MPackageExp.setIsActive(true); m_MPackageExp.setDescription("Test Output Package"); m_MPackageExp.setEMail("wgheath@gmail.com"); @@ -114,15 +35,10 @@ public class PackOutTest extends TestCase { m_MPackageExp.setVersion("1.0"); m_MPackageExp.setPK_Version("1.0"); - boolean saveResult = m_MPackageExp.save(); - if (!saveResult) { - assertEquals("Export Package not saved!", true, saveResult); - } else { - System.out.println("m_MPackageExp.get_ID: " + m_MPackageExp.get_ID()); - } + boolean saveResult = m_MPackageExp.save(); + assertTrue("MPackageExp.save()", saveResult); - - X_AD_Package_Exp_Detail m_PackDetail =new X_AD_Package_Exp_Detail(m_Ctx, 0, null); + X_AD_Package_Exp_Detail m_PackDetail =new X_AD_Package_Exp_Detail(getCtx(), 0, getTrxName()); m_PackDetail.setAD_Org_ID(m_MPackageExp.getAD_Org_ID()); m_PackDetail.setAD_Package_Exp_ID(m_MPackageExp.get_ID()); m_MPackageExp.setIsActive(true); @@ -148,28 +64,19 @@ public class PackOutTest extends TestCase { m_PackDetail.setAD_ReportView_ID(rs.getInt("AD_REPORTVIEW_ID")); */ m_PackDetail.setLine(10); - m_PackDetail.save(); - + saveResult = m_PackDetail.save(); + assertTrue("X_AD_Package_Exp_Detail.save()", saveResult); - saveResult = m_PackDetail.save(); - if (!saveResult) { - assertEquals("Package detail not saved!", true, saveResult); - } else { - System.out.println("m_PackDetail.get_ID: " + m_PackDetail.get_ID()); - try { - DB.commit(true, trxName); - } catch (Exception e) { - assertEquals("m_PackDetail not updated!", true, false); - } - } - assertTrue("PackOutTest", true); + int m_ad_record_id = IDFinder.get_IDWithColumn("ad_package_exp", "Name", "test2packJunit", getAD_Client_ID(), getTrxName()); - - int m_ad_record_id = IDFinder.get_IDWithColumn("ad_package_exp", "Name", "test2packJunit", AD_Client_ID_Value, m_trx.getTrxName()); - - //ProcessInfo m_ProcessInfo = new ProcessInfo("PackOut", m_ad_process_id, m_ad_table_id, m_ad_record_id); ProcessInfo m_ProcessInfo = new ProcessInfo("PackOut", m_ad_process_id, m_ad_table_id, m_MPackageExp.get_ID()); - m_PackOut.startProcess(m_Ctx, m_ProcessInfo, m_trx); - assertTrue("PackOut", true); + m_PackOut.startProcess(getCtx(), m_ProcessInfo, m_trx); + assertFalse("PackOut", m_ProcessInfo.isError()); + + try { + commit(); + } catch (Exception e) { + fail(e.getLocalizedMessage()); + } } } diff --git a/extend/src/test/functional/TrifonTest.java b/extend/src/test/functional/TrifonTest.java index ae6b521afb..505c00444c 100644 --- a/extend/src/test/functional/TrifonTest.java +++ b/extend/src/test/functional/TrifonTest.java @@ -1,91 +1,21 @@ package test.functional; -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - import org.compiere.model.MColumn; import org.compiere.model.MInvoice; import org.compiere.model.MProduct; import org.compiere.model.MTable; import org.compiere.model.X_AD_Reference; -import org.compiere.util.CLogMgt; import org.compiere.util.Env; -import org.compiere.util.Ini; -public class TrifonTest extends TestCase { +import test.AdempiereTestCase; + +public class TrifonTest extends AdempiereTestCase { - // Test: General - private Properties testProperties = null; - - private Properties m_Ctx = null; - - private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties"; - private String fileName_Key = "AdempiereProperties"; - private String fileName_Value = ""; - - private String isClient_DefaultValue = "Y"; - private String isClient_Key = "isClient"; - private boolean isClient_Value = true; - - private String AD_User_ID_DefaultValue = "0"; - private String AD_User_ID_Key = "AD_User_ID"; - private int AD_User_ID_Value = 0; - // Test: Specific variables private MProduct product = null; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - testProperties = new Properties(); - testProperties.load(new FileInputStream("test.properties")); - fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue); - isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) ); - AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) ); - - m_Ctx = new Properties(); - m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString()); - System.out.println("m_Ctx: " + m_Ctx); - - if (fileName_Value.length() < 1) { - assertEquals("Please specify path to Adempiere.properties file!", true, false); - } - - System.setProperty("PropertyFile", fileName_Value); - Ini.setClient (isClient_Value); - org.compiere.Adempiere.startup(isClient_Value); - - // Force connection if there are enough parameters. Else we work with Adempiere.properties -// if (args.length >= 6) { -// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]); -// System.out.println("DB UserID:"+cc.getDbUid()); -// DB.setDBTarget(cc); -// } - - CLogMgt.setLevel(Level.SEVERE); -/* Available levels: - Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, - Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL -*/ - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - testProperties = null; - m_Ctx = null; - } - public void testMProductCreation() { boolean singleCommit = true; - String trxName = "test"; - m_Ctx.setProperty("#AD_Client_ID", new Integer(11).toString()); MTable mTable = MTable.get(Env.getCtx(), MInvoice.Table_Name ); System.out.println("XML presentation... is: " + mTable.get_xmlDocument(false)); @@ -99,7 +29,7 @@ public class TrifonTest extends TestCase { System.out.println("Desc............ is: " + mcolumn[i].getDescription()); System.out.println("Length.......... is: " + mcolumn[i].getFieldLength()); System.out.println("Reference_ID.... is: " + mcolumn[i].getAD_Reference_ID()); - X_AD_Reference reference = new X_AD_Reference(Env.getCtx(), mcolumn[i].getAD_Reference_ID(), trxName); + X_AD_Reference reference = new X_AD_Reference(Env.getCtx(), mcolumn[i].getAD_Reference_ID(), getTrxName()); System.out.println("ReferenceName... is: " + reference.getName()); System.out.println(".............................."); } diff --git a/extend/src/test/functional/XMLValidateTest.java b/extend/src/test/functional/XMLValidateTest.java deleted file mode 100644 index 100612e09a..0000000000 --- a/extend/src/test/functional/XMLValidateTest.java +++ /dev/null @@ -1,47 +0,0 @@ -//XMLValidateTest.java -package test.functional; - -import java.io.FileInputStream; -import java.util.Properties; -import java.util.logging.Level; - -import junit.framework.TestCase; - -import org.compiere.model.MLocation; -import org.compiere.util.CLogMgt; -import org.compiere.util.DB; -import org.compiere.util.Ini; -import org.adempiere.pipo.*; -import org.compiere.util.*; - -import javax.xml.parsers.*; -import org.w3c.dom.*; -import java.io.File; -import org.xml.sax.SAXException; -import java.io.IOException; - - -public class XMLValidateTest extends TestCase { - - public void testValidateXML() { - try { - DocumentBuilder parser = - DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document document = parser.parse(new File("PackOut.xml")); - } catch (ParserConfigurationException e) { - // exception handling - System.out.println("ParserConfigurationException: " + e.getMessage()); - assertTrue("testValidateXML", false); - } catch (SAXException e) { - // exception handling - document not valid! - System.out.println("SAXException: " + e.getMessage()); - assertTrue("testValidateXML", false); - } catch (IOException e) { - // exception handling - System.out.println("IOException: " + e.getMessage()); - assertTrue("testValidateXML", false); - } - - assertTrue("testValidateXML", true); - } -}