Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6714

Please add better getResource-Support for MockServletContext

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 8.0.0, 9.0.0-M3
    • 8.7.0, 9.0.0-M4
    • wicket-core
    • None

    Description

      Hello!

      WicketTester does not provide a useful MockServletContext#getResource(). As WicketTester always instantiates MockServletContext passing a null-Value as path (webappRoot), the method MockServletContext#getResource always returns null, even if a resource in the classpath exists.
      My proposal for the implementation of Method MockServletContext#getResource() is:
      URL result = null;
      if (name.startsWith("/")) {
         name = name.substring(1);
      }

      if (webappRoot != null) {
        final File f = new File(webappRoot, name);
        if (f.exists())

      {      result = f.toURI().toURL(); }

      if (result == null) {
         result = getClass().getClassLoader().getResource("META-INF/resources/" + name);
      }
      return result;

      Best regards

      Hans

      Attachments

        1. wicket-case-include.tar
          50 kB
          Hans Schäfer

        Issue Links

          Activity

            People

              svenmeier Sven Meier
              hosea Hans Schäfer
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: