* clean up unit test code.
This commit is contained in:
parent
7007718459
commit
772c9cd684
|
@ -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) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -130,6 +130,19 @@ public class AdempiereTestCase extends TestCase {
|
||||||
CLogMgt.setLevel(LogLevel_Value);
|
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
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
|
|
|
@ -1,46 +1,16 @@
|
||||||
//MBPGroupTest.java
|
//MBPGroupTest.java
|
||||||
package test.functional;
|
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.MLocation;
|
||||||
import org.compiere.model.MBPGroup;
|
import org.compiere.model.MBPGroup;
|
||||||
import org.compiere.util.CLogMgt;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.adempiere.test.utils.DBUtils;
|
|
||||||
import org.compiere.util.*;
|
import test.AdempiereTestCase;
|
||||||
|
|
||||||
import java.sql.*;
|
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
|
// Variables needed for importing/migrating business partners
|
||||||
private MLocation location = null;
|
private MLocation location = null;
|
||||||
|
|
||||||
|
@ -486,146 +456,69 @@ public class MBPGroupTest extends TestCase {
|
||||||
private MIssue = null;
|
private MIssue = null;
|
||||||
private MQuery = 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) {
|
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;
|
||||||
String sql = "select c_region_id from c_region where name = ?";
|
ResultSet rs = null;
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
|
|
||||||
int C_Region_ID = -1;
|
|
||||||
|
|
||||||
try {
|
int C_Region_ID = -1;
|
||||||
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName);
|
|
||||||
pstmt.setString(1, Region);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
|
|
||||||
|
try {
|
||||||
while (rs.next()) {
|
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName());
|
||||||
C_Region_ID = rs.getInt(1);
|
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) {
|
return C_Region_ID;
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getC_Country_ID(String Country) {
|
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;
|
||||||
String sql = "select c_country_id from c_country where name = ?";
|
ResultSet rs = null;
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
|
|
||||||
int C_Country_ID = -1;
|
|
||||||
|
|
||||||
try {
|
int C_Country_ID = -1;
|
||||||
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName);
|
|
||||||
pstmt.setString(1, Country);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
|
|
||||||
|
try {
|
||||||
while (rs.next()) {
|
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName());
|
||||||
C_Country_ID = rs.getInt(1);
|
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());
|
return C_Country_ID;
|
||||||
} finally {
|
|
||||||
DBUtils.close( rs);
|
|
||||||
DBUtils.close( pstmt);
|
|
||||||
}
|
|
||||||
System.out.println("C_Country_ID: " + C_Country_ID);
|
|
||||||
|
|
||||||
return C_Country_ID;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateMPBGroup()
|
public void testCreateMBPGroup()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
m_group = new MBPGroup (getCtx(), 0, getTrxName());
|
||||||
m_group = new MBPGroup (m_Ctx, 0, "test");
|
|
||||||
if (m_group != null) {
|
|
||||||
m_group.setName ("Test Group Name"); // N
|
m_group.setName ("Test Group Name"); // N
|
||||||
m_group.setIsConfidentialInfo (false); // N
|
m_group.setIsConfidentialInfo (false); // N
|
||||||
m_group.setIsDefault (false);
|
m_group.setIsDefault (false);
|
||||||
|
|
||||||
m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same);
|
m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same);
|
||||||
m_group.save();
|
m_group.save();
|
||||||
} else {
|
|
||||||
System.out.println("m_group is null");
|
commit();
|
||||||
}
|
} catch(Exception e) {
|
||||||
|
fail(e.getLocalizedMessage());
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,16 @@
|
||||||
//MBPartnerLocationTest.java
|
//MBPartnerLocationTest.java
|
||||||
package test.functional;
|
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.*;
|
||||||
import org.compiere.model.MBPartnerLocation;
|
|
||||||
import org.compiere.util.CLogMgt;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.adempiere.test.utils.DBUtils;
|
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
import test.AdempiereTestCase;
|
||||||
|
|
||||||
import java.sql.*;
|
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
|
// Variables needed for importing/migrating business partners
|
||||||
private MBPartner m_partner = null; //business partner
|
private MBPartner m_partner = null; //business partner
|
||||||
private MLocation location = null;
|
private MLocation location = null;
|
||||||
|
@ -487,160 +457,83 @@ public class MBPartnerLocationTest extends TestCase {
|
||||||
private MIssue = null;
|
private MIssue = null;
|
||||||
private MQuery = 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) {
|
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 = ?";
|
String sql = "select c_region_id from c_region where name = ?";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
|
||||||
int C_Region_ID = -1;
|
|
||||||
|
|
||||||
try {
|
int C_Region_ID = -1;
|
||||||
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName);
|
|
||||||
pstmt.setString(1, Region);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
|
|
||||||
|
try {
|
||||||
while (rs.next()) {
|
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName());
|
||||||
C_Region_ID = rs.getInt(1);
|
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) {
|
return C_Region_ID;
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getC_Country_ID(String Country) {
|
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 {
|
String sql = "select c_country_id from c_country where name = ?";
|
||||||
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName);
|
PreparedStatement pstmt = null;
|
||||||
pstmt.setString(1, Country);
|
ResultSet rs = null;
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
|
int C_Country_ID = -1;
|
||||||
|
|
||||||
|
try {
|
||||||
while (rs.next()) {
|
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName());
|
||||||
C_Country_ID = rs.getInt(1);
|
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());
|
return C_Country_ID;
|
||||||
} finally {
|
|
||||||
DBUtils.close( rs);
|
|
||||||
DBUtils.close( pstmt);
|
|
||||||
}
|
|
||||||
System.out.println("C_Country_ID: " + C_Country_ID);
|
|
||||||
|
|
||||||
return C_Country_ID;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreatePartnerLocation()
|
public void testCreatePartnerLocation()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
location = new MLocation(m_Ctx, 0, "test");
|
location = new MLocation(getCtx(), 0, getTrxName());
|
||||||
location.setC_Country_ID(getC_Country_ID("United States"));
|
location.setC_Country_ID(getC_Country_ID("United States"));
|
||||||
location.setC_Region_ID(getC_Region_ID("CA"));
|
location.setC_Region_ID(getC_Region_ID("CA"));
|
||||||
location.setCity("Windsor");
|
location.setCity("Windsor");
|
||||||
location.setAddress1("Happy Lane");
|
location.setAddress1("Happy Lane");
|
||||||
location.setAddress2("Happy Lane 2");
|
location.setAddress2("Happy Lane 2");
|
||||||
String zipcode = ("95492");
|
String zipcode = ("95492");
|
||||||
location.setPostal(zipcode);
|
location.setPostal(zipcode);
|
||||||
location.setPostal_Add(zipcode);
|
location.setPostal_Add(zipcode);
|
||||||
location.setAD_Org_ID(0);
|
location.setAD_Org_ID(0);
|
||||||
location.save();
|
location.save();
|
||||||
|
|
||||||
m_group = new MBPGroup (m_Ctx, 0, "test");
|
m_group = new MBPGroup (getCtx(), 0, getTrxName());
|
||||||
if (m_group != null) {
|
|
||||||
m_group.setName ("Test Group Name"); // N
|
m_group.setName ("Test Group Name"); // N
|
||||||
m_group.setIsConfidentialInfo (false); // N
|
m_group.setIsConfidentialInfo (false); // N
|
||||||
m_group.setIsDefault (false);
|
m_group.setIsDefault (false);
|
||||||
|
|
||||||
m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same);
|
m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same);
|
||||||
m_group.save();
|
m_group.save();
|
||||||
} else {
|
|
||||||
System.out.println("m_group is null");
|
m_partner = new MBPartner (getCtx(), 0, "test");
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
m_partner = new MBPartner (m_Ctx, 0, "test");
|
|
||||||
if (m_partner != null) {
|
|
||||||
//m_partner.setAD_Client_ID(11);
|
|
||||||
m_partner.setValue ("");
|
m_partner.setValue ("");
|
||||||
m_partner.setName ("Test Business Partner Location");
|
m_partner.setName ("Test Business Partner Location");
|
||||||
m_partner.setName2 (null);
|
m_partner.setName2 (null);
|
||||||
|
@ -660,35 +553,18 @@ public class MBPartnerLocationTest extends TestCase {
|
||||||
m_partner.setBPGroup(m_group);
|
m_partner.setBPGroup(m_group);
|
||||||
// Reset Created, Updated to current system time ( teo_sarca )
|
// Reset Created, Updated to current system time ( teo_sarca )
|
||||||
if(m_partner.save()) {
|
if(m_partner.save()) {
|
||||||
bpl = new MBPartnerLocation (m_Ctx, 0, "test");
|
bpl = new MBPartnerLocation (getCtx(), 0, "test");
|
||||||
//bpl.setAD_Client_ID(11);
|
|
||||||
bpl.setIsActive(true);
|
bpl.setIsActive(true);
|
||||||
bpl.setName("Test Business Partner Location");
|
bpl.setName("Test Business Partner Location");
|
||||||
bpl.setC_BPartner_ID(m_partner.get_ID());
|
bpl.setC_BPartner_ID(m_partner.get_ID());
|
||||||
bpl.setC_Location_ID(location.get_ID());
|
bpl.setC_Location_ID(location.get_ID());
|
||||||
bpl.save();
|
bpl.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
commit();
|
||||||
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");
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
System.out.println("Location not updated");
|
fail(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch(Exception e) {
|
|
||||||
System.out.println("BPL exception");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,16 @@
|
||||||
//MBPartnerTest.java
|
//MBPartnerTest.java
|
||||||
package test.functional;
|
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.*;
|
||||||
import org.compiere.util.CLogMgt;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.adempiere.test.utils.DBUtils;
|
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
import test.AdempiereTestCase;
|
||||||
|
|
||||||
import java.sql.*;
|
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
|
// Variables needed for importing/migrating business partners
|
||||||
private MLocation location = null;
|
private MLocation location = null;
|
||||||
|
|
||||||
|
@ -485,124 +456,61 @@ public class MBPartnerTest extends TestCase {
|
||||||
private MIssue = null;
|
private MIssue = null;
|
||||||
private MQuery = 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) {
|
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;
|
||||||
String sql = "select c_region_id from c_region where name = ?";
|
ResultSet rs = null;
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
|
|
||||||
int C_Region_ID = -1;
|
|
||||||
|
|
||||||
try {
|
int C_Region_ID = -1;
|
||||||
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName);
|
|
||||||
pstmt.setString(1, Region);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
|
|
||||||
|
try {
|
||||||
while (rs.next()) {
|
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName());
|
||||||
C_Region_ID = rs.getInt(1);
|
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());
|
return C_Region_ID;
|
||||||
} finally {
|
|
||||||
DBUtils.close( rs);
|
|
||||||
DBUtils.close( pstmt);
|
|
||||||
}
|
|
||||||
System.out.println("C_Region_ID: " + C_Region_ID);
|
|
||||||
|
|
||||||
return C_Region_ID;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getC_Country_ID(String Country) {
|
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;
|
||||||
String sql = "select c_country_id from c_country where name = ?";
|
ResultSet rs = null;
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
|
|
||||||
int C_Country_ID = -1;
|
|
||||||
|
|
||||||
try {
|
int C_Country_ID = -1;
|
||||||
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName);
|
|
||||||
pstmt.setString(1, Country);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
|
|
||||||
|
try {
|
||||||
while (rs.next()) {
|
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName());
|
||||||
C_Country_ID = rs.getInt(1);
|
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());
|
return C_Country_ID;
|
||||||
} finally {
|
|
||||||
DBUtils.close( rs);
|
|
||||||
DBUtils.close( pstmt);
|
|
||||||
}
|
|
||||||
System.out.println("C_Country_ID: " + C_Country_ID);
|
|
||||||
|
|
||||||
return C_Country_ID;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateMPBPartner()
|
public void testCreateMBPartner()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
m_partner = new MBPartner (getCtx(), 0, getTrxName());
|
||||||
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.setValue ("");
|
||||||
m_partner.setName ("Test MBPartner");
|
m_partner.setName ("Test MBPartner");
|
||||||
m_partner.setName2 (null);
|
m_partner.setName2 (null);
|
||||||
|
@ -619,39 +527,24 @@ public class MBPartnerTest extends TestCase {
|
||||||
m_partner.setAcqusitionCost(Env.ZERO);
|
m_partner.setAcqusitionCost(Env.ZERO);
|
||||||
m_partner.setShareOfCustomer(0);
|
m_partner.setShareOfCustomer(0);
|
||||||
m_partner.setSalesVolume(0);
|
m_partner.setSalesVolume(0);
|
||||||
|
|
||||||
MBPGroup m_group = new MBPGroup (m_Ctx, 0, "test");
|
MBPGroup m_group = new MBPGroup (getCtx(), 0, getTrxName());
|
||||||
// FIXME: determine AD_Client_ID correctly
|
m_group.setName ("Test Group Name"); // N
|
||||||
//m_group.setAD_Client_ID(11);
|
m_group.setIsConfidentialInfo (false); // N
|
||||||
m_group.setName ("Test Group Name"); // N
|
m_group.setIsDefault (false);
|
||||||
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);
|
m_partner.setBPGroup(m_group);
|
||||||
// Reset Created, Updated to current system time ( teo_sarca )
|
// Reset Created, Updated to current system time ( teo_sarca )
|
||||||
m_partner.save();
|
m_partner.save();
|
||||||
} else {
|
|
||||||
fail("m_partner is null");
|
commit();
|
||||||
}
|
} catch(Exception e) {
|
||||||
|
fail(e.getLocalizedMessage());
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,94 +1,17 @@
|
||||||
//MLocationTest.java
|
//MLocationTest.java
|
||||||
package test.functional;
|
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.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
|
// Test: Specific variables
|
||||||
private MLocation location = null;
|
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() {
|
public void testMLocationCreation() {
|
||||||
String trxName = "test";
|
location = new MLocation(getCtx(), 0, getTrxName());
|
||||||
location = new MLocation(m_Ctx, 0, trxName);
|
|
||||||
// location.loadDefaults();
|
// location.loadDefaults();
|
||||||
location.setC_Country_ID(100);
|
location.setC_Country_ID(100);
|
||||||
location.setC_Region_ID(103);
|
location.setC_Region_ID(103);
|
||||||
|
@ -97,20 +20,14 @@ public class MLocationTest extends TestCase {
|
||||||
location.setAddress2("");
|
location.setAddress2("");
|
||||||
location.setPostal("95492");
|
location.setPostal("95492");
|
||||||
location.setPostal_Add("95492");
|
location.setPostal_Add("95492");
|
||||||
// location.setAD_Client_ID(0);
|
|
||||||
location.setAD_Org_ID(0);
|
location.setAD_Org_ID(0);
|
||||||
|
|
||||||
boolean saveResult = location.save();
|
boolean saveResult = location.save();
|
||||||
if (!saveResult) {
|
assertTrue("MLocation.save()", saveResult);
|
||||||
assertEquals("Location not updated!", true, saveResult);
|
try {
|
||||||
} else {
|
commit();
|
||||||
System.out.println("location.getC_Location_ID: " + location.getC_Location_ID());
|
} catch (Exception e) {
|
||||||
try {
|
fail(e.getLocalizedMessage());
|
||||||
DB.commit(true, trxName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
assertEquals("Location not updated!", true, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
assertTrue("TestExample", true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,100 +1,19 @@
|
||||||
//MProductTest.java
|
//MProductTest.java
|
||||||
package test.functional;
|
package test.functional;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
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.MProduct;
|
||||||
import org.compiere.model.X_I_Product;
|
import org.compiere.model.X_I_Product;
|
||||||
import org.compiere.util.CLogMgt;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Ini;
|
|
||||||
|
|
||||||
public class MProductTest extends TestCase {
|
import test.AdempiereTestCase;
|
||||||
|
|
||||||
// Test: General
|
public class MProductTest extends AdempiereTestCase {
|
||||||
private Properties testProperties = null;
|
|
||||||
|
|
||||||
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) {
|
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 = ?";
|
String sql = "select m_product_category_id from m_product_category where name = ?";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
@ -102,7 +21,7 @@ public class MProductTest extends TestCase {
|
||||||
int M_ProductCategory_ID = -1;
|
int M_ProductCategory_ID = -1;
|
||||||
|
|
||||||
try {
|
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());
|
pstmt.setString(1, productCategory.trim());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
|
||||||
|
@ -111,13 +30,10 @@ public class MProductTest extends TestCase {
|
||||||
M_ProductCategory_ID = rs.getInt(1);
|
M_ProductCategory_ID = rs.getInt(1);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage());
|
fail(e.getLocalizedMessage());
|
||||||
} finally {
|
} finally {
|
||||||
DBUtils.close( rs);
|
DB.close( rs, pstmt );
|
||||||
DBUtils.close( pstmt);
|
|
||||||
}
|
}
|
||||||
System.out.println("productCategory: " + productCategory);
|
|
||||||
System.out.println("M_ProductCategory_ID: " + M_ProductCategory_ID);
|
|
||||||
|
|
||||||
return M_ProductCategory_ID;
|
return M_ProductCategory_ID;
|
||||||
|
|
||||||
|
@ -133,7 +49,7 @@ public class MProductTest extends TestCase {
|
||||||
int C_Uom_ID = -1;
|
int C_Uom_ID = -1;
|
||||||
|
|
||||||
try {
|
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());
|
pstmt.setString(1, UOM.trim());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
|
||||||
|
@ -142,10 +58,9 @@ public class MProductTest extends TestCase {
|
||||||
C_Uom_ID = rs.getInt(1);
|
C_Uom_ID = rs.getInt(1);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("Execption; sql = "+sql+"; e.getMessage() = " +e.getMessage());
|
fail(e.getLocalizedMessage());
|
||||||
} finally {
|
} finally {
|
||||||
DBUtils.close( rs);
|
DB.close( rs, pstmt );
|
||||||
DBUtils.close( pstmt);
|
|
||||||
}
|
}
|
||||||
System.out.println("Uom: " + UOM);
|
System.out.println("Uom: " + UOM);
|
||||||
System.out.println("C_Uom_ID: " + C_Uom_ID);
|
System.out.println("C_Uom_ID: " + C_Uom_ID);
|
||||||
|
@ -154,10 +69,8 @@ public class MProductTest extends TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreateMProduct() {
|
||||||
|
MProduct m_product = new MProduct(getCtx(), 0, getTrxName());
|
||||||
public void testMProductCreation() {
|
|
||||||
MProduct m_product = new MProduct(m_Ctx, 0, trxName);
|
|
||||||
m_product.setAD_Org_ID(0);
|
m_product.setAD_Org_ID(0);
|
||||||
m_product.setProductType (X_I_Product.PRODUCTTYPE_Item); // I
|
m_product.setProductType (X_I_Product.PRODUCTTYPE_Item); // I
|
||||||
m_product.setIsBOM (false); // N
|
m_product.setIsBOM (false); // N
|
||||||
|
@ -174,21 +87,8 @@ public class MProductTest extends TestCase {
|
||||||
m_product.setProcessing (false); // N
|
m_product.setProcessing (false); // N
|
||||||
m_product.setName("Test Product"); // N
|
m_product.setName("Test Product"); // N
|
||||||
m_product.setC_UOM_ID(getUOM_ID("Each"));
|
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();
|
boolean saveResult = m_product.save();
|
||||||
if (!saveResult) {
|
assertEquals("Create new product.", true, 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,16 @@
|
||||||
//MUserTest.java
|
//MUserTest.java
|
||||||
package test.functional;
|
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.*;
|
||||||
import org.compiere.util.CLogMgt;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.adempiere.test.utils.DBUtils;
|
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
import test.AdempiereTestCase;
|
||||||
|
|
||||||
import java.sql.*;
|
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
|
// Variables needed for importing/migrating business partners
|
||||||
private MLocation location = null;
|
private MLocation location = null;
|
||||||
|
|
||||||
|
@ -485,180 +456,100 @@ public class MUserTest extends TestCase {
|
||||||
private MIssue = null;
|
private MIssue = null;
|
||||||
private MQuery = 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) {
|
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 = ?";
|
String sql = "select c_region_id from c_region where name = ?";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
|
||||||
int C_Region_ID = -1;
|
|
||||||
|
|
||||||
try {
|
int C_Region_ID = -1;
|
||||||
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName);
|
try {
|
||||||
pstmt.setString(1, Region);
|
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName());
|
||||||
rs = pstmt.executeQuery();
|
pstmt.setString(1, Region);
|
||||||
|
rs = pstmt.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
while (rs.next()) {
|
C_Region_ID = rs.getInt(1);
|
||||||
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());
|
return C_Region_ID;
|
||||||
} finally {
|
|
||||||
DBUtils.close( rs);
|
|
||||||
DBUtils.close( pstmt);
|
|
||||||
}
|
|
||||||
System.out.println("C_Region_ID: " + C_Region_ID);
|
|
||||||
|
|
||||||
return C_Region_ID;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getC_Country_ID(String Country) {
|
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;
|
||||||
String sql = "select c_country_id from c_country where name = ?";
|
ResultSet rs = null;
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
|
|
||||||
int C_Country_ID = -1;
|
|
||||||
|
|
||||||
try {
|
int C_Country_ID = -1;
|
||||||
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, trxName);
|
|
||||||
pstmt.setString(1, Country);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
|
|
||||||
|
try {
|
||||||
while (rs.next()) {
|
pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, getTrxName());
|
||||||
C_Country_ID = rs.getInt(1);
|
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());
|
return C_Country_ID;
|
||||||
} finally {
|
|
||||||
DBUtils.close( rs);
|
|
||||||
DBUtils.close( pstmt);
|
|
||||||
}
|
|
||||||
System.out.println("C_Country_ID: " + C_Country_ID);
|
|
||||||
|
|
||||||
return C_Country_ID;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateMPBPartner()
|
public void testCreateMBPartner()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
m_partner = new MBPartner (m_Ctx, 0, "test");
|
m_partner = new MBPartner (getCtx(), 0, getTrxName());
|
||||||
if (m_partner != null) {
|
m_partner.setValue ("");
|
||||||
// FIXME: determine AD_Client_ID correctly
|
m_partner.setName ("Test MBPartner with contact");
|
||||||
//m_partner.setAD_Client_ID(11);
|
m_partner.setName2 (null);
|
||||||
m_partner.setValue ("");
|
m_partner.setDUNS("");
|
||||||
m_partner.setName ("Test MBPartner with contact");
|
m_partner.setFirstSale(null);
|
||||||
m_partner.setName2 (null);
|
//
|
||||||
m_partner.setDUNS("");
|
m_partner.setSO_CreditLimit (Env.ZERO);
|
||||||
m_partner.setFirstSale(null);
|
m_partner.setSO_CreditUsed (Env.ZERO);
|
||||||
//
|
m_partner.setTotalOpenBalance (Env.ZERO);
|
||||||
m_partner.setSO_CreditLimit (Env.ZERO);
|
// s_m_partner.setRating(null);
|
||||||
m_partner.setSO_CreditUsed (Env.ZERO);
|
//
|
||||||
m_partner.setTotalOpenBalance (Env.ZERO);
|
m_partner.setActualLifeTimeValue(Env.ZERO);
|
||||||
// s_m_partner.setRating(null);
|
m_partner.setPotentialLifeTimeValue(Env.ZERO);
|
||||||
//
|
m_partner.setAcqusitionCost(Env.ZERO);
|
||||||
m_partner.setActualLifeTimeValue(Env.ZERO);
|
m_partner.setShareOfCustomer(0);
|
||||||
m_partner.setPotentialLifeTimeValue(Env.ZERO);
|
m_partner.setSalesVolume(0);
|
||||||
m_partner.setAcqusitionCost(Env.ZERO);
|
|
||||||
m_partner.setShareOfCustomer(0);
|
|
||||||
m_partner.setSalesVolume(0);
|
|
||||||
|
|
||||||
MBPGroup m_group = new MBPGroup (m_Ctx, 0, "test");
|
MBPGroup m_group = new MBPGroup (getCtx(), 0, getTrxName());
|
||||||
// FIXME: determine AD_Client_ID correctly
|
m_group.setName ("Test Group Name"); // N
|
||||||
//m_group.setAD_Client_ID(11);
|
m_group.setIsConfidentialInfo (false); // N
|
||||||
m_group.setName ("Test Group Name"); // N
|
m_group.setIsDefault (false);
|
||||||
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);
|
m_partner.setBPGroup(m_group);
|
||||||
// Reset Created, Updated to current system time ( teo_sarca )
|
// Reset Created, Updated to current system time ( teo_sarca )
|
||||||
if(m_partner.save()) {
|
if(m_partner.save()) {
|
||||||
m_contact = new MUser(m_Ctx, 0, "test2");
|
m_contact = new MUser(getCtx(), 0, getTrxName());
|
||||||
m_contact.setName("Test Contact Name");
|
m_contact.setName("Test Contact Name");
|
||||||
//m_contact.setAD_Client_ID(11);
|
m_contact.setIsActive(true);
|
||||||
m_contact.setIsActive(true);
|
m_contact.setC_BPartner_ID(m_partner.get_ID());
|
||||||
m_contact.setC_BPartner_ID(m_partner.get_ID());
|
m_contact.save();
|
||||||
m_contact.save();
|
}
|
||||||
|
|
||||||
}
|
commit();
|
||||||
} 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");
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
System.out.println("Exception with MBPartnerTest");
|
fail(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,109 +1,30 @@
|
||||||
//PackOutTest.java
|
//PackOutTest.java
|
||||||
package test.functional;
|
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.*;
|
||||||
import org.compiere.process.*;
|
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.compiere.util.*;
|
||||||
|
|
||||||
import org.adempiere.pipo.*;
|
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
|
// Test: Specific variables
|
||||||
private MLocation location = null;
|
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() {
|
public void testPackOut() {
|
||||||
System.out.println("In testPackOut");
|
|
||||||
String trxName = "test";
|
|
||||||
PackOut m_PackOut = new PackOut();
|
PackOut m_PackOut = new PackOut();
|
||||||
PackInHandler m_PackInHandler = new PackInHandler();
|
PackInHandler m_PackInHandler = new PackInHandler();
|
||||||
Trx m_trx = Trx.get(Trx.createTrxName("SvrProcess"), true);
|
Trx m_trx = Trx.get(getTrxName(), true);
|
||||||
int m_ad_process_id = IDFinder.get_IDWithColumn("ad_process", "Name", "PackOut", AD_Client_ID_Value, m_trx.getTrxName());
|
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", AD_Client_ID_Value, m_trx.getTrxName());
|
int m_ad_table_id = IDFinder.get_IDWithColumn("ad_table", "Name", "AD_Package_Exp_ID", getAD_Client_ID(), getTrxName());
|
||||||
|
|
||||||
//Create 2Pack Export Package
|
//Create 2Pack Export Package
|
||||||
|
MPackageExp m_MPackageExp = new MPackageExp(getCtx(), 0, getTrxName());
|
||||||
MPackageExp m_MPackageExp = new MPackageExp(m_Ctx, 0, trxName);
|
|
||||||
m_MPackageExp.setName("testSqlStatement2Pack");
|
m_MPackageExp.setName("testSqlStatement2Pack");
|
||||||
//m_MPackageExp.setOrgId(0);
|
|
||||||
m_MPackageExp.setIsActive(true);
|
m_MPackageExp.setIsActive(true);
|
||||||
m_MPackageExp.setDescription("Test Output Package");
|
m_MPackageExp.setDescription("Test Output Package");
|
||||||
m_MPackageExp.setEMail("wgheath@gmail.com");
|
m_MPackageExp.setEMail("wgheath@gmail.com");
|
||||||
|
@ -114,15 +35,10 @@ public class PackOutTest extends TestCase {
|
||||||
m_MPackageExp.setVersion("1.0");
|
m_MPackageExp.setVersion("1.0");
|
||||||
m_MPackageExp.setPK_Version("1.0");
|
m_MPackageExp.setPK_Version("1.0");
|
||||||
|
|
||||||
boolean saveResult = m_MPackageExp.save();
|
boolean saveResult = m_MPackageExp.save();
|
||||||
if (!saveResult) {
|
assertTrue("MPackageExp.save()", 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(getCtx(), 0, getTrxName());
|
||||||
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_Org_ID(m_MPackageExp.getAD_Org_ID());
|
||||||
m_PackDetail.setAD_Package_Exp_ID(m_MPackageExp.get_ID());
|
m_PackDetail.setAD_Package_Exp_ID(m_MPackageExp.get_ID());
|
||||||
m_MPackageExp.setIsActive(true);
|
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.setAD_ReportView_ID(rs.getInt("AD_REPORTVIEW_ID"));
|
||||||
*/
|
*/
|
||||||
m_PackDetail.setLine(10);
|
m_PackDetail.setLine(10);
|
||||||
m_PackDetail.save();
|
saveResult = m_PackDetail.save();
|
||||||
|
assertTrue("X_AD_Package_Exp_Detail.save()", saveResult);
|
||||||
|
|
||||||
saveResult = m_PackDetail.save();
|
int m_ad_record_id = IDFinder.get_IDWithColumn("ad_package_exp", "Name", "test2packJunit", getAD_Client_ID(), getTrxName());
|
||||||
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", 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());
|
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);
|
m_PackOut.startProcess(getCtx(), m_ProcessInfo, m_trx);
|
||||||
assertTrue("PackOut", true);
|
assertFalse("PackOut", m_ProcessInfo.isError());
|
||||||
|
|
||||||
|
try {
|
||||||
|
commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,91 +1,21 @@
|
||||||
package test.functional;
|
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.MColumn;
|
||||||
import org.compiere.model.MInvoice;
|
import org.compiere.model.MInvoice;
|
||||||
import org.compiere.model.MProduct;
|
import org.compiere.model.MProduct;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.model.X_AD_Reference;
|
import org.compiere.model.X_AD_Reference;
|
||||||
import org.compiere.util.CLogMgt;
|
|
||||||
import org.compiere.util.Env;
|
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
|
// Test: Specific variables
|
||||||
private MProduct product = null;
|
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() {
|
public void testMProductCreation() {
|
||||||
boolean singleCommit = true;
|
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 );
|
MTable mTable = MTable.get(Env.getCtx(), MInvoice.Table_Name );
|
||||||
System.out.println("XML presentation... is: " + mTable.get_xmlDocument(false));
|
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("Desc............ is: " + mcolumn[i].getDescription());
|
||||||
System.out.println("Length.......... is: " + mcolumn[i].getFieldLength());
|
System.out.println("Length.......... is: " + mcolumn[i].getFieldLength());
|
||||||
System.out.println("Reference_ID.... is: " + mcolumn[i].getAD_Reference_ID());
|
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("ReferenceName... is: " + reference.getName());
|
||||||
System.out.println("..............................");
|
System.out.println("..............................");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue