Top-Q / jsystem

JSystem is a professional open-source framework for writing and managing automated system tests.
http://www.jsystem.org/
Apache License 2.0
45 stars 48 forks source link

Java 8 support #361

Closed ukalifon closed 6 months ago

ukalifon commented 2 years ago

This bug is to ask for Java 1.8 support in the runner, so that we can use Java 8 features like lambdas and streams in our test cases.

I tried to compile JSystem with Java 8, and had to replace several packages and some code with "Java 8 equivalents". Unfortunately I didn't know how to fix everything and had to comment out some lines to get the project to compile, and the result is that I can't pass parameters to the test cases (at least I got as far as being able to see all the scenarios and test cases, and I can even run the test cases that take no parameters).

Can you make a Java 8 version? If you want to see exactly the changes I made - I can create a PR, and maybe someone can help me complete the work. Thanks in advance!

itaiag commented 2 years ago

I fixed (hopefully) most of the issue. You can try it with the latest 6.1.12 deployed snapshot.

Make sure to remove the compiler plugin section from your project:

                         <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

And add the following properties:

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
ukalifon commented 2 years ago

There are still a lot of failures in compilation, mainly around javax.xml.bind:

[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /home/ukalifon/code/runner-java8/jsystem/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java:[14,22] package javax.xml.bind does not exist [ERROR] /home/ukalifon/code/runner-java8/jsystem/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java:[15,22] package javax.xml.bind does not exist [ERROR] /home/ukalifon/code/runner-java8/jsystem/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java:[16,33] package javax.xml.bind.annotation does not exist [ERROR] /home/ukalifon/code/runner-java8/jsystem/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java:[17,33] package javax.xml.bind.annotation does not exist

I fix it by adding to pom.xml:

            <dependency>
                    <groupId>jakarta.xml.bind</groupId>
                    <artifactId>jakarta.xml.bind-api</artifactId>
                    <version>3.0.0</version>
            </dependency>
            <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-impl</artifactId>
                    <version>3.0.0</version>
                    <scope>runtime</scope>
            </dependency>

Then I also need to replace "import javax.xml.bind" with "import jakarta.xml.bind" in JUnitReporter.java. There are additional compilation errors after that, and currently I am stuck on:

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 10.651 s [INFO] Finished at: 2022-03-10T17:39:10+01:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jsystemApp: Compilation failure: Compilation failure: [ERROR] /home/ukalifon/code/runner-java8/jsystem/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/AssetNode.java:[91,36] incompatible types: java.util.Vector cannot be converted to java.util.Vector [ERROR] /home/ukalifon/code/runner-java8/jsystem/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/AssetNode.java:[249,36] no suitable method found for sort(java.util.Vector)

How do you get it to compile? Thanks for your help so far!

itaiag commented 2 years ago

I can't seem to reproduce the problem. I cloned a fresh copy of the project and compiled it on a Windows machine with Oracle's JDK 8 (301)

What JDK are you using? What is the full Maven command you are using?

The following are my commands.

C:\Users\itai\git\jsystem\jsystem-parent>echo %JAVA_HOME%
c:\Program Files\Java\jdk1.8.0_301

C:\Users\itai\git\jsystem\jsystem-parent>mvn clean install -P dist -DskipTests=true
ukalifon commented 2 years ago

Update: Indeed, I had jdk11 instead of jdk8 for some reason. I switched to jdk8 and got things to compile smoothly. I still haven't been able to run my tests but I will update when that is solved too. Thanks a lot!