tackle-test-generator-cli icon indicating copy to clipboard operation
tackle-test-generator-cli copied to clipboard

MissingResourceException with Servlets classes in the source code

Open rmarting opened this issue 3 years ago • 1 comments

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:

  • The toml file containing the configuration information used
[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 = ""
  • Command to generate tests:
❯ 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
  • Source code of the application available here, analyzing the Web module of the application.

  • Content of tkltest_classpath.txt file identified in app_classpath_file option:

/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
  • Files generated from generate command:
    • simple-sample-web_ctd_models_and_test_plans.json
{
  "models_and_test_plans" : {
    "monolithic" : {
      "com.acme.anvil.AuthenticateFilter" : {
        "doFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljavax/servlet/FilterChain;)V" : {
          "formatted_signature" : "void doFilter(javax.servlet.ServletRequest,javax.servlet.ServletResponse,javax.servlet.FilterChain)",
          "attributes" : [ {
            "attribute_name" : "attr_0",
            "values" : [ {
              "val_0" : "javax.servlet.ServletRequest"
            } ]
          }, {
            "attribute_name" : "attr_1",
            "values" : [ {
              "val_0" : "javax.servlet.ServletResponse"
            } ]
          }, {
            "attribute_name" : "attr_2",
            "values" : [ {
              "val_0" : "javax.servlet.FilterChain"
            } ]
          } ],
          "test_plan" : [ [ {
            "type" : "javax.servlet.ServletRequest"
          }, {
            "type" : "javax.servlet.ServletResponse"
          }, {
            "type" : "javax.servlet.FilterChain"
          } ] ]
        },
        "init(Ljavax/servlet/FilterConfig;)V" : {
          "formatted_signature" : "void init(javax.servlet.FilterConfig)",
          "attributes" : [ {
            "attribute_name" : "attr_0",
            "values" : [ {
              "val_0" : "javax.servlet.FilterConfig"
            } ]
          } ],
          "test_plan" : [ [ {
            "type" : "javax.servlet.FilterConfig"
          } ] ]
        }
      },
      "com.acme.anvil.AnvilWebServlet" : {
        "doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V" : {
          "formatted_signature" : "void doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)",
          "attributes" : [ {
            "attribute_name" : "attr_0",
            "values" : [ {
              "val_0" : "javax.servlet.http.HttpServletRequest"
            } ]
          }, {
            "attribute_name" : "attr_1",
            "values" : [ {
              "val_0" : "javax.servlet.http.HttpServletResponse"
            } ]
          } ],
          "test_plan" : [ [ {
            "type" : "javax.servlet.http.HttpServletRequest"
          }, {
            "type" : "javax.servlet.http.HttpServletResponse"
          } ] ]
        }
      },
      "com.acme.anvil.LoginFilter" : {
        "init(Ljavax/servlet/FilterConfig;)V" : {
          "formatted_signature" : "void init(javax.servlet.FilterConfig)",
          "attributes" : [ {
            "attribute_name" : "attr_0",
            "values" : [ {
              "val_0" : "javax.servlet.FilterConfig"
            } ]
          } ],
          "test_plan" : [ [ {
            "type" : "javax.servlet.FilterConfig"
          } ] ]
        },
        "doFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljavax/servlet/FilterChain;)V" : {
          "formatted_signature" : "void doFilter(javax.servlet.ServletRequest,javax.servlet.ServletResponse,javax.servlet.FilterChain)",
          "attributes" : [ {
            "attribute_name" : "attr_0",
            "values" : [ {
              "val_0" : "javax.servlet.ServletRequest"
            } ]
          }, {
            "attribute_name" : "attr_1",
            "values" : [ {
              "val_0" : "javax.servlet.ServletResponse"
            } ]
          }, {
            "attribute_name" : "attr_2",
            "values" : [ {
              "val_0" : "javax.servlet.FilterChain"
            } ]
          } ],
          "test_plan" : [ [ {
            "type" : "javax.servlet.ServletRequest"
          }, {
            "type" : "javax.servlet.ServletResponse"
          }, {
            "type" : "javax.servlet.FilterChain"
          } ] ]
        }
      }
    }
  },
  "statistics" : {
    "total_classes" : 3,
    "target_classes" : 3,
    "non_public_classes" : 0,
    "classes_no_public_methods" : 0,
    "target_methods" : 5,
    "total_tests" : 5
  }
}
- `simple-sample-web_EvoSuiteTestGenerator_bb_test_sequences.json` too long to be attached here.

Environment information

  • CLI version 1.0.0 generated from main branch
  • OS:
❯ cat /etc/redhat-release 
Fedora release 35 (Thirty Five)
❯ uname -a
Linux redhat 5.14.18-300.fc35.x86_64 #1 SMP Fri Nov 12 16:43:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

rmarting avatar Nov 22 '21 11:11 rmarting

@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)

rachelt44 avatar Jan 04 '22 13:01 rachelt44