1

I'm currently trying to test the UI of an Eclipse RCP application. When executed manually, the application starts fine and can be used correctly. However, when QF-Test launches the application, I get a ClassCastException in a 3pp module:

java.lang.ClassCastException: java.io.File cannot be cast to java.lang.String
at com.solarmetric.conf.ConfigurationImpl.fromProperties(ConfigurationImpl.java:560)
at com.solarmetric.conf.ConfigurationImpl.loadDefaults(ConfigurationImpl.java:186)

After analyzing the code of the 3pp library I see that the exception occurs when trying to cast a System's property value to a String. This shouldn't be a problem because all properties values should be String (see this answer). However, QF-Test is adding 3 properties which their values are File (java.io.File) objects. More precisely:

jython.home = C:\Program Files\qfs\qftest\qftest-4.2.0\jython
groovy.home = C:\Program Files\qfs\qftest\qftest-4.2.0\groovy
javascript.home = C:\Program Files\qfs\qftest\qftest-4.2.0\javascript

I would like to remove those wrong property values. I've already tried to define them manually as parameters of the QF-Test command line call without success.

Some help would be very appreciated.

2 Answers2

2

This behaviour of QF-Test was fixed with QF-Test 4.2.1 (released February 26, 2018), see https://www.qfs.de/en/qf-test-manual/lc/manual-en-history.html#sec_N1D715:

Bug fixed:

In a few cases a broken system property set by QF-Test could interfere with SUT startup.

So the answer is to simply update your QF-Test!

quant
  • 2,184
  • 2
  • 19
  • 29
  • Hmmm currently I'm using version 4.2.2 – Alejandro González Oct 29 '18 at 06:56
  • version 4.2.2? Then it should be C:\Program Files\qfs\qftest\qftest-4.2.2\jython instead of C:\Program Files\qfs\qftest\qftest-4.2.0\jython ... right? Probably there is a misconfiguration. Maybe try reinstalling QF-Test 4.2.2 (not via the sfx-Installer) ... – quant Oct 29 '18 at 18:55
  • 1
    the problem was that I had 2 different versions installed in the testing machine. After removing one and using the version 4.2.2, the problem does not appear anymore. Thanks for the kelp! – Alejandro González Nov 14 '18 at 07:23
1

Unfortunately, I do not know a fix for QF-Test. If possible, I recommend the workaround to correct the properties before use.

    Properties sysProps = System.getProperties();

    Properties copyProps = new Properties();
    synchronized (sysProps) {
        copyProps.putAll(sysProps);
    }

    Set<Entry<Object, Object>> entrySet = copyProps.entrySet();
    for (Entry<Object, Object> entry : entrySet) {
        if (!(entry.getKey() instanceof String) || !(entry.getValue() instanceof String)) {
            sysProps.remove(entry.getKey());
            sysProps.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
        }
    }
Markus Lausberg
  • 12,177
  • 6
  • 40
  • 66