diff --git a/extend/Profile-SingleMProductTest.launch b/extend/Profile-SingleMProductTest.launch
index 2842b6f377..9f5d7519f6 100644
--- a/extend/Profile-SingleMProductTest.launch
+++ b/extend/Profile-SingleMProductTest.launch
@@ -1,28 +1,31 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extend/src/test/performance/MProductTest.java b/extend/src/test/performance/MProductTest.java
index d4bd5d2ade..59b947bef2 100644
--- a/extend/src/test/performance/MProductTest.java
+++ b/extend/src/test/performance/MProductTest.java
@@ -1,137 +1,124 @@
package test.performance;
-import java.io.FileInputStream;
-import java.util.Properties;
-import java.util.logging.Level;
-
-import junit.framework.TestCase;
+/**********************************************************************
+* This file is part of ADempiere Business Suite *
+* http://www.adempiere.org *
+* *
+* Copyright (C) Trifon Trifonov. *
+* Copyright (C) Contributors *
+* *
+* This program is free software; you can redistribute it and/or *
+* modify it under the terms of the GNU General Public License *
+* as published by the Free Software Foundation; either version 2 *
+* of the License, or (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the Free Software *
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
+* MA 02110-1301, USA. *
+* *
+* Contributors: *
+* - Trifon Trifonov (trifonnt@users.sourceforge.net) *
+* *
+* Sponsors: *
+* - Catura AG (http://www.catura.de) *
+***********************************************************************/
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
import org.compiere.model.MProduct;
-import org.compiere.util.CLogMgt;
-import org.compiere.util.DB;
-import org.compiere.util.Ini;
+import test.AdempiereTestCase;
-public class MProductTest extends TestCase {
+/**
+ * @author Trifon Trifonov
+ */
+public class MProductTest extends AdempiereTestCase {
- // Test: General
- private Properties testProperties = null;
-
- private Properties m_Ctx = null;
-
- private String fileName_DefaultValue = "J:/Trifon-CD-0.3/workspace/adempiere-trunk/adempiere/Adempiere/Adempiere.properties";
- private String fileName_Key = "AdempiereProperties";
- private String fileName_Value = "";
-
- private String isClient_DefaultValue = "Y";
- private String isClient_Key = "isClient";
- private boolean isClient_Value = true;
-
- private String AD_User_ID_DefaultValue = "0";
- private String AD_User_ID_Key = "AD_User_ID";
- private int AD_User_ID_Value = 0;
-
- // Test: Specific variables
private MProduct product = null;
+ private int AD_Org_ID = 0;
+ private int M_Product_Category_ID = 0;
+ private int C_TaxCategory_ID = 0;
+ private int C_UOM_ID = 0;
+ private String ProductType = null;
-
- @Override
- protected void setUp() throws Exception {
+
+ protected void setUp() throws Exception
+ {
super.setUp();
+ // How to setup language
+ //Env.setContext(getCtx(), Env.LANGUAGE, "en_US");
- 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) );
+ // Organization
+ AD_Org_ID = Integer.parseInt( testProperties.getProperty("AD_Org_ID", "0") ); // 0 in Any Tenant
+ // M_Product_Category
+ M_Product_Category_ID = Integer.parseInt( testProperties.getProperty("M_Product_Category_ID", "105") ); // 105 in GardenWorld
+ // C_TaxCategory
+ C_TaxCategory_ID = Integer.parseInt( testProperties.getProperty("C_TaxCategory_ID", "107") ); // 107 in GardenWorld
+ // C_UOM
+ C_UOM_ID = Integer.parseInt( testProperties.getProperty("C_UOM_ID", "100") ); // 100 in GardenWorld
+ // C_UOM
+ ProductType = testProperties.getProperty("ProductType", "I"); // 'I' in GardenWorld
- m_Ctx = new Properties();
- m_Ctx.setProperty("#AD_User_ID", Integer.valueOf(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);
+ // How to setup Log Level. Not necessary as AdempiereTestCase is taking care of it!
+// CLogMgt.setLevel(Level.OFF);
/* Available levels:
Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO,
Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL
*/
+
+// assertEquals("Client is NOT GardenWorld", 11, Env.getAD_Client_ID(getCtx()));
+
}
- @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 = 570000;
- int count = 10000;
+ int startCount = 43000;
+ int count = 500;
+ // The 0 symbol shows a digit or 0 if no digit present
+ // The # symbol shows a digit or nothing if no digit present
+ NumberFormat formatter = new DecimalFormat("00000"); // -001235
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-Product-" + idx);
- product.setName("Test-Product-" + idx);
+ System.out.println("idx = " + idx);
+ product = new MProduct(getCtx(), 0, getTrxName());
- // M_Product_Category
- int M_Product_Category_ID = 105; // TODO - Trifon
+ String formattedIdx = formatter.format( idx );
+ product.setValue("test-product-" + formattedIdx);
+ product.setName("Test Product " + formattedIdx);
+
+ product.setAD_Org_ID(AD_Org_ID);
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
+ assertTrue("MProduct.save()", saveResult);
+ //System.out.println("product.getM_Product_ID: " + product.getM_Product_ID());
+ if (singleCommit) {
+ try {
+ commit();
+ } catch (Exception e) {
+ fail(e.getLocalizedMessage());
+ }
+ }
+ } // end 'for' loop
if (!singleCommit) {
try {
- DB.commit(true, trxName);
+ commit();
} catch (Exception e) {
- assertEquals("Product not updated!", true, false);
+ fail(e.getLocalizedMessage());
}
}
long endTime = System.currentTimeMillis();
@@ -152,4 +139,4 @@ public class MProductTest extends TestCase {
assertTrue(this.getClass().getName(), true);
}
-}
\ No newline at end of file
+}
diff --git a/extend/test.properties.template b/extend/test.properties.template
index e70df1f911..53ea4bf9c0 100644
--- a/extend/test.properties.template
+++ b/extend/test.properties.template
@@ -1,4 +1,21 @@
AdempiereProperties=C:/Adempiere/Adempiere.properties
isClient=Y
AD_Client_ID=11
-AD_User_ID=0
\ No newline at end of file
+#AD_Client_ID=1000006
+AD_User_ID=0
+# LogLevel: OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL
+LogLevel=OFF
+
+# MProductTest - Tenant: GardenWorld
+AD_Org_ID=0
+M_Product_Category_ID=105
+C_TaxCategory_ID=107
+C_UOM_ID=100
+ProductType=I
+
+# MProductTest - Tenant: Test6
+#AD_Org_ID=0
+#M_Product_Category_ID=1000006
+#C_TaxCategory_ID=1000010
+#C_UOM_ID=100
+#ProductType=I