Related to issue 36288: (Expected) duplicate pk on insert of Logclient apart from info message still logs 2* error
authorGorka Gil <gorka.gil@openbravo.com>
Fri, 22 Sep 2017 14:23:23 +0200
changeset 6794 51f5c83109d9
parent 6793 111d74a56c6c
child 6795 32bbc2c4e1de
Related to issue 36288: (Expected) duplicate pk on insert of Logclient apart from info message still logs 2* error

Force added info and warn log
force the sync to the backend
check that are inserted into the db correctly

Note: not tested error log, since if info and warn works error should also work, and also not needed to add to the
allowed errors with the risk of hide other errors.
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I36288_CheckLogClientLoad.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I36288_CheckLogClientLoad.java	Fri Sep 22 14:23:23 2017 +0200
@@ -0,0 +1,87 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2017 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author GGI
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.system;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.retail.mobilecore.database.MobileCoreDatabaseHelper;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
+
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class I36288_CheckLogClientLoad extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    SeleniumHelper.executeScript("OB.info('I36288_logline_info')");
+    SeleniumHelper.executeScript("OB.warn('I36288_logline_warn')");
+    // not checking error log, to not needed to add to the allowed errors and hide another error
+    SeleniumHelper.executeScript("OB.UTIL.processLogClientAll()");
+
+    ArrayList<String> line1LogClient = new ArrayList<String>();
+    line1LogClient.add("VBS1001");
+    line1LogClient.add("I36288_logline_info");
+    line1LogClient.add("Info");
+    line1LogClient.add("Y");
+    checkLogClientInBackend(line1LogClient, "I36288_logline_info");
+
+    ArrayList<String> line2LogClient = new ArrayList<String>();
+    line2LogClient.add("VBS1001");
+    line2LogClient.add("I36288_logline_warn");
+    line2LogClient.add("Warn");
+    line2LogClient.add("Y");
+    checkLogClientInBackend(line2LogClient, "I36288_logline_warn");
+
+  }
+
+  private void checkLogClientInBackend(final ArrayList<String> lineLogClient, String message) {
+
+    final String sql = "select * from obmobc_logclient where msg like '" + message
+        + "%' and cache_session_id is not null";
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        final String deviceid = rs.getString("deviceid");
+        final String msg = rs.getString("msg");
+        final String loglevel = rs.getString("loglevel");
+        final String isonline = rs.getString("isonline");
+
+        final String msg_clean = msg.split(";")[0];
+
+        assertThat(lineLogClient.get(0), equalTo(deviceid));
+        assertThat(lineLogClient.get(1), equalTo(msg_clean));
+        assertThat(lineLogClient.get(2), equalTo(loglevel));
+        assertThat(lineLogClient.get(3), equalTo(isonline));
+
+      }
+    }.execute(MobileCoreDatabaseHelper.getTOP(sql, 1), 1);
+  }
+}