konveyor / tackle-test-generator-cli

Apache License 2.0
58 stars 34 forks source link

MissingResourceException with Servlets classes in the source code #121

Open rmarting opened 2 years ago

rmarting commented 2 years ago

Describe the bug

Generating test classes for a Web application with Servlets fails with the following exception:

Caused by: java.util.MissingResourceException: Can't find bundle for base name javax.servlet.LocalStrings, locale en_US
        at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1581)
        at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1396)
        at java.util.ResourceBundle.getBundle(ResourceBundle.java:782)
        at javax.servlet.GenericServlet.<clinit>(GenericServlet.java:95)
        ... 6 more

Attachments

To help us diagnose the failure, please add these attachments to the issue, as appropriate:

[general]
    app_name = "simple-sample-web"
    app_classpath_file = "/home/rmarting/Workspaces/ws-konveyor/sample-apps/migration-sample-app/simple-sample-web/tkltest_classpath.txt"
    monolith_app_path = [
        "/home/rmarting/Workspaces/ws-konveyor/sample-apps/migration-sample-app/simple-sample-web/target/classes"
    ]
    java_jdk_home = ""
    test_directory = ""
    reports_path = ""
    verbose = true

[generate]
    jee_support = true
    no_diff_assertions = false
    partitions_file = ""
    target_class_list = []
    excluded_class_list = []
    time_limit = 10
    app_build_config_file = "pom.xml"
    app_build_settings_file = ""

[generate.ctd_amplified]
    base_test_generator = "combined"
    augment_coverage = false
    no_ctd_coverage = false
    interaction_level = 1
    num_seq_executions = 10
    refactored_app_path_prefix = ""
    refactored_app_path_suffix = []
    reuse_base_tests = false

[generate.evosuite]
    criterion = [ "BRANCH",]

[generate.randoop]
    no_error_revealing_tests = false

[execute]
    app_packages = ["com.acme.anvil.*"]
    build_type = "maven"
    create_build_file = false
    code_coverage = true
    online_instrumentation = false
    test_class = ""
❯ tkltest \
    --config-file ~/Workspaces/ws-konveyor/sample-apps/migration-sample-app/simple-sample-web/tkltest_config.toml \
    generate \
    ctd-amplified
[tkltest|11:40:57.965] Loading config file /home/rmarting/Workspaces/ws-konveyor/sample-apps/migration-sample-app/simple-sample-web/tkltest_config.toml
[tkltest|11:40:57.971] Computing coverage goals using CTD
* CTD interaction level: 1
* Total number of classes: 3
* Targeting 3 classes
* Created a total of 5 test combinations for 5 target methods of 3 target classes
[tkltest|11:40:58.686] Computing test plans with CTD took 0.71 seconds
[tkltest|11:40:58.686] Generating basic block test sequences using CombinedTestGenerator
[tkltest|11:40:58.686] Test generator output will be written to simple-sample-web_CombinedTestGenerator_output.log
[tkltest|11:41:27.769] Generating basic block test sequences with CombinedTestGenerator took 29.08 seconds
[tkltest|11:41:27.769] Extending sequences to reach coverage goals and generating junit tests
* Read test plans for: 3 classes, 5 methods
* Read 441 base test sequences
* Starting sequence parsing
*   Full:434  Part:0  Skip:0  Excp:7
* Class sequence pool: 2 classes, 2 sequences
* Method sequence pool: 2 methods, 60 sequences
[tkltest|11:41:38.013] ERROR: Extending sequences and generating JUnit tests failed with return code 1: Exception in thread "main" java.lang.ExceptionInInitializerError
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at randoop.types.Type.forName(Type.java:73)
        at org.konveyor.tackle.testgen.core.extender.TestSequenceExtender.augmentClassSequencePool(TestSequenceExtender.java:1649)
        at org.konveyor.tackle.testgen.core.extender.TestSequenceExtender.<init>(TestSequenceExtender.java:262)
        at org.konveyor.tackle.testgen.core.extender.TestSequenceExtender.main(TestSequenceExtender.java:1856)
Caused by: java.util.MissingResourceException: Can't find bundle for base name javax.servlet.LocalStrings, locale en_US
        at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1581)
        at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1396)
        at java.util.ResourceBundle.getBundle(ResourceBundle.java:782)
        at javax.servlet.GenericServlet.<clinit>(GenericServlet.java:95)
        ... 6 more
/home/rmarting/.m2/repository/org/jboss/windup/test/apps/weblogic/simple-sample-weblogic-services/1.0.0-SNAPSHOT/simple-sample-weblogic-services-1.0.0-SNAPSHOT.jar
/home/rmarting/.m2/repository/org/jboss/ejb3/jboss-ejb3-ext-api/2.1.0/jboss-ejb3-ext-api-2.1.0.jar
/home/rmarting/.m2/repository/javax/javaee-api/7.0/javaee-api-7.0.jar
/home/rmarting/.m2/repository/com/sun/mail/javax.mail/1.5.0/javax.mail-1.5.0.jar
/home/rmarting/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar
/home/rmarting/.m2/repository/org/jboss/windup/test/apps/weblogic/proprietary-stub/1.0.0-SNAPSHOT/proprietary-stub-1.0.0-SNAPSHOT.jar
/home/rmarting/.m2/repository/javaee/javaee-api/5/javaee-api-5.jar
/home/rmarting/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
/home/rmarting/.m2/repository/org/jboss/logging/jboss-logging/3.1.4.GA/jboss-logging-3.1.4.GA.jar
/home/rmarting/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar
/home/rmarting/.m2/repository/javax/ejb/ejb-api/3.0/ejb-api-3.0.jar

Environment information

rachelt44 commented 2 years ago

@rmarting I added the dependency below to the pom.xml of simple-sample-web, then recompiled and got this jar in my maven repo: javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar, which I added to the classpath.txt file.

<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
</dependency>

With the additional jar I was able to complete generate and execute commands successfully. If I turn on the augmentation flag, tackle-test reaches 57.5% instruction coverage:

[tkltest|15:00:46.144] Final test-suite coverage rate: instruction=131/228(57.5%), branch=4/8(50.0%), line=36/59(61.0%), method=12/13(92.3%)
                                                 coverage_efficiency=0.05223285486443381 (11 test methods)