Reorganzation of tests:

functional
performance
This commit is contained in:
trifonnt 2007-05-21 12:22:32 +00:00
parent 9209afdd20
commit 9c2bba3565
7 changed files with 325 additions and 10 deletions

View File

@ -1,13 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig"> <launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> <stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DESTINATION_MONITOR" value="DefaultMonitor"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="test.MLocationTest"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="test.functional.MLocationTest"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> <stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_SET" value="tptp-dummy-profiling-set-MLocationTest"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="extend"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> <listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute> </listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DESTINATION_FILE" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DATA_COLLECTOR" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="extend"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILE_TO_FILE" value="false"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DESTINATION_PROJECT" value="ProfileProject"/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/> <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
</launchConfiguration> </launchConfiguration>

View File

@ -1,13 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig"> <launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> <stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_SET" value="tptp-dummy-profiling-set-MProductTest"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="test.MProductTest"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="extend"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> <listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute> </listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<intAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_LIMIT_INVOCATIONS_NUM" value="10000"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DESTINATION_FILE" value="J:\Trifon-CD-0.3\workspace\adempiere-trunk\ProfileProject\MProductTest-profile.trcxml"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DATA_COLLECTOR" value="org.eclipse.tptp.trace.ui.jvmpiMechanism:org.eclipse.tptp.analysisType.memoryHeap,org.eclipse.tptp.analysisType.execution"/>
<intAttribute key="org.eclipse.hyades.trace.ui.ATTR_EXEC_POLLING_FREQ" value="60"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_LIMIT_SECONDS" value="false"/>
<intAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_LIMIT_SECONDS_NUM" value="5"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_SHOW_EXEC_CPU_TIME" value="true"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILE_TO_FILE" value="false"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_SHOW_EXEC_INSTANCES" value="false"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_LIMIT_INVOCATIONS" value="false"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_EXEC_POLLING_FREQ_MODE" value="true"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DESTINATION_MONITOR" value="DefaultMonitor"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="test.performance.MProductTest"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_AUTO_MONITORING" value="true"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_FILTER_SET" value="org.eclipse.hyades.trace.ui.filterSet.default"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_SHOW_EXEC_BOUNDARY_CLASS" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="extend"/>
<intAttribute key="org.eclipse.hyades.trace.ui.ATTR_SHOW_EXEC_BOUNDARY_CLASS_DEPTH" value="1"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DESTINATION_PROJECT" value="ProfileProject"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_SHOW_EXECUTION_FLOW" value="true"/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/> <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
</launchConfiguration> </launchConfiguration>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_LIMIT_INVOCATIONS" value="false"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DESTINATION_MONITOR" value="DefaultMonitor"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="test.performance.SingleMProductTest"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_AUTO_MONITORING" value="true"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_SET" value="tptp-dummy-profiling-set-Profile-SingleMProductTest"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.profile"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<intAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_LIMIT_INVOCATIONS_NUM" value="10000"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DESTINATION_FILE" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DATA_COLLECTOR" value="org.eclipse.tptp.trace.ui.jvmpiMechanism:org.eclipse.tptp.analysisType.memoryHeap,org.eclipse.tptp.analysisType.execution"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_FILTER_SET" value="org.eclipse.hyades.trace.ui.filterSet.default"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_LIMIT_SECONDS" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<intAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILING_LIMIT_SECONDS_NUM" value="5"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="extend"/>
<booleanAttribute key="org.eclipse.hyades.trace.ui.ATTR_PROFILE_TO_FILE" value="false"/>
<stringAttribute key="org.eclipse.hyades.trace.ui.ATTR_DESTINATION_PROJECT" value="ProfileProject"/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
</launchConfiguration>

View File

@ -1,5 +1,5 @@
//MLocationTest.java //MLocationTest.java
package test; package test.functional;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.util.Properties; import java.util.Properties;

View File

@ -0,0 +1,110 @@
package test.functional;
import java.io.FileInputStream;
import java.util.Properties;
import java.util.logging.Level;
import junit.framework.TestCase;
import org.compiere.model.MColumn;
import org.compiere.model.MInvoice;
import org.compiere.model.MProduct;
import org.compiere.model.MTable;
import org.compiere.model.X_AD_Reference;
import org.compiere.util.CLogMgt;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Ini;
public class TrifonTest 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;
// Test: Specific variables
private MProduct product = null;
@Override
protected void setUp() throws Exception {
super.setUp();
testProperties = new Properties();
testProperties.load(new FileInputStream("test.properties"));
fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue);
isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) );
AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) );
m_Ctx = new Properties();
m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString());
System.out.println("m_Ctx: " + m_Ctx);
if (fileName_Value.length() < 1) {
assertEquals("Please specify path to Adempiere.properties file!", true, false);
}
System.setProperty("PropertyFile", fileName_Value);
Ini.setClient (isClient_Value);
org.compiere.Adempiere.startup(isClient_Value);
// Force connection if there are enough parameters. Else we work with Adempiere.properties
// if (args.length >= 6) {
// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]);
// System.out.println("DB UserID:"+cc.getDbUid());
// DB.setDBTarget(cc);
// }
CLogMgt.setLevel(Level.SEVERE);
/* Available levels:
Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO,
Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL
*/
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
testProperties = null;
m_Ctx = null;
}
public void testMProductCreation() {
boolean singleCommit = true;
String trxName = "test";
m_Ctx.setProperty("#AD_Client_ID", new Integer(11).toString());
MTable mTable = MTable.get(Env.getCtx(), MInvoice.Table_Name );
System.out.println("XML presentation... is: " + mTable.get_xmlDocument(false));
MColumn mcolumn[] = mTable.getColumns(true);
for (int i = 0; i < mcolumn.length; i++) {
System.out.println("Name............ is: " + mcolumn[i].getName());
System.out.println("ColumnName...... is: " + mcolumn[i].getColumnName());
System.out.println("Desc............ is: " + mcolumn[i].getDescription());
System.out.println("Length.......... is: " + mcolumn[i].getFieldLength());
System.out.println("Reference_ID.... is: " + mcolumn[i].getAD_Reference_ID());
X_AD_Reference reference = new X_AD_Reference(Env.getCtx(), mcolumn[i].getAD_Reference_ID(), trxName);
System.out.println("ReferenceName... is: " + reference.getName());
System.out.println("..............................");
}
assertTrue(this.getClass().getName(), true);
}
}

View File

@ -1,4 +1,4 @@
package test; package test.performance;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.util.Properties; import java.util.Properties;

View File

@ -0,0 +1,155 @@
package test.performance;
import java.io.FileInputStream;
import java.util.Properties;
import java.util.logging.Level;
import junit.framework.TestCase;
import org.compiere.model.MProduct;
import org.compiere.util.CLogMgt;
import org.compiere.util.DB;
import org.compiere.util.Ini;
public class SingleMProductTest 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;
// Test: Specific variables
private MProduct product = null;
@Override
protected void setUp() throws Exception {
super.setUp();
testProperties = new Properties();
testProperties.load(new FileInputStream("test.properties"));
fileName_Value = testProperties.getProperty(fileName_Key, fileName_DefaultValue);
isClient_Value = "Y".equals( testProperties.getProperty(isClient_Key, isClient_DefaultValue) );
AD_User_ID_Value = Integer.parseInt(testProperties.getProperty(AD_User_ID_Key, AD_User_ID_DefaultValue) );
m_Ctx = new Properties();
m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString());
System.out.println("m_Ctx: " + m_Ctx);
if (fileName_Value.length() < 1) {
assertEquals("Please specify path to Adempiere.properties file!", true, false);
}
System.setProperty("PropertyFile", fileName_Value);
Ini.setClient (isClient_Value);
org.compiere.Adempiere.startup(isClient_Value);
// Force connection if there are enough parameters. Else we work with Adempiere.properties
// if (args.length >= 6) {
// CConnection cc = CConnection.get(Database.DB_ORACLE, args[1], Integer.valueOf(args[2]).intValue(), args[3], args[4], args[5]);
// System.out.println("DB UserID:"+cc.getDbUid());
// DB.setDBTarget(cc);
// }
//CLogMgt.setLevel(Level.ALL);
CLogMgt.setLevel(Level.OFF);
/* Available levels:
Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO,
Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL
*/
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
testProperties = null;
m_Ctx = null;
}
public void testMProductCreation() {
boolean singleCommit = true;
String trxName = "test";
m_Ctx.setProperty("#AD_Client_ID", new Integer(11).toString());
// Start time - 20:16
long startTime = System.currentTimeMillis();
System.out.println("Start Time(ms) = " + startTime);
System.out.println("Start Time = " + new java.util.Date(startTime));
int startCount = 5;
int count = 1;
for (int idx= startCount; idx < (startCount + count); idx++) {
//product = MProduct.get(m_Ctx, int M_Product_ID)
product = new MProduct(m_Ctx, 0, trxName);
//
product.setAD_Org_ID(0);
product.setValue("Test-Single-Product-" + idx);
product.setName("Test-Single-Product-" + idx);
// M_Product_Category
int M_Product_Category_ID = 105; // TODO - Trifon
product.setM_Product_Category_ID(M_Product_Category_ID);
// C_TaxCategory
int C_TaxCategory_ID = 107; // TODO - Trifon
product.setC_TaxCategory_ID(C_TaxCategory_ID);
// C_UOM
int C_UOM_ID = 100; // TODO - Trifon
product.setC_UOM_ID(C_UOM_ID);
// C_UOM
String ProductType = "I"; // TODO - Trifon
product.setProductType(ProductType);
boolean saveResult = product.save();
if (!saveResult) {
assertEquals("Product not updated!", true, saveResult);
} else {
//System.out.println("product.getM_Product_ID: " + product.getM_Product_ID());
if (singleCommit) {
try {
DB.commit(true, trxName);
} catch (Exception e) {
assertEquals("Product not updated!", true, false);
}
}
}
} // end loop
if (!singleCommit) {
try {
DB.commit(true, trxName);
} catch (Exception e) {
assertEquals("Product not updated!", true, false);
}
}
long endTime = System.currentTimeMillis();
System.out.println("End Time(ms) = " + endTime);
System.out.println("End Time = " + new java.util.Date(endTime));
long time = endTime - startTime;
System.out.println("Duration(ms) = " + time);
time = time / 1000;
System.out.println("Duration(sec.) = " + time);
if (time > 0) {
System.out.println("Duration(min.) = " + time / 60);
}
System.out.println(
"Count = " + count
+ "; Time(seconds) = " + time + "; Produsts/Second = " + ((float)count/time) + "; ");
assertTrue(this.getClass().getName(), true);
}
}