Uploaded image for project: 'WildFly Arquillian'
  1. WildFly Arquillian
  2. WFARQ-115

Adding the REST contexts may result in the wrong URL getting injected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 5.0.0.Alpha4, 5.0.0.Final
    • None
    • None

      While adding support for the REST protocol there was a requirement to look at the REST resources to register the context. This is one possibly using the wrong context because of how the context is parsed. Two it's causing a different context path to be registered. When more than one context is registered and a URI or URL are injected, then no context is appended.

      The URLResourceProvider has something like:

      ...
                  // TODO: evaluate, if all servlets are in the same context, and only one context exists, we can find the context
                  else if (allInSameContext(context.getServlets())) {
                      return toURL(context.getServlets().get(0));
                  } else {
                      return toURL(context);
                  }
      ...
      private boolean allInSameContext(List<Servlet> servlets) {
          Set<String> context = new HashSet<String>();
          for (Servlet servlet : servlets) {
              context.add(servlet.getContextRoot());
          }
          return context.size() == 1;
      }
      

      This could be an issue for previously working injection where the context was expected.

      The simplest option is to only define the web context. As an example assuming the REST path is http://localhost:8080/test-deployment/rest/greet. We should register the context path as "test-deployment" not "test-deployment/rest".

      We could, if not servlet is registered, register the context as "test-deployment/rest". However, that could introduce confusing failures if a servlet is ever added. It would be consistent behavior if we leave it as "test-deployment" given the above example.

              jperkins-rhn James Perkins
              jperkins-rhn James Perkins
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: