Fixes issue 12633: XML Conversion from integer numbers should be more robust
authorMartin Taal <martin.taal@openbravo.com>
Tue, 06 Apr 2010 09:52:40 +0200
changeset 6925 0a2aa53b170f
parent 6924 fb97b5f3e905
child 6926 907297079fbe
Fixes issue 12633: XML Conversion from integer numbers should be more robust
src-test/org/openbravo/test/xml/EntityXMLIssues.java
--- a/src-test/org/openbravo/test/xml/EntityXMLIssues.java	Tue Apr 06 09:45:31 2010 +0200
+++ b/src-test/org/openbravo/test/xml/EntityXMLIssues.java	Tue Apr 06 09:52:40 2010 +0200
@@ -20,12 +20,14 @@
 package org.openbravo.test.xml;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.datamodel.Column;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.common.businesspartner.Greeting;
 import org.openbravo.model.common.enterprise.Organization;
@@ -134,4 +136,31 @@
     assertTrue(uom != newUom);
     assertEquals(uom.getSymbol(), newUom.getSymbol());
   }
+
+  /**
+   * Test mantis issue 12633: XML Conversion from integer numbers should be more robust
+   */
+  public void testMantis12633() {
+    setBigBazaarAdminContext();
+    // read the column
+    final Column column = OBDal.getInstance().get(Column.class, "102");
+    String xml = getXML(Collections.singletonList(column));
+    xml = xml.replace("60</length>", "61.0</length>");
+    assertTrue(xml.contains("<length>61.0</length>"));
+    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
+        OBDal.getInstance().get(Client.class, "0"),
+        OBDal.getInstance().get(Organization.class, "0"), xml);
+    assertTrue(ir.getWarningMessages() == null);
+    assertTrue(ir.getErrorMessages() == null);
+    assertTrue(column.getLength() == 61);
+    OBDal.getInstance().flush();
+    // prevent the database from really being updated
+    OBDal.getInstance().rollbackAndClose();
+
+    // now be sure that we did not update the db
+    final Column column2 = OBDal.getInstance().get(Column.class, "102");
+    assertTrue(column2 != column);
+    assertTrue(column2.getLength() == 60);
+    OBDal.getInstance().rollbackAndClose();
+  }
 }
\ No newline at end of file