Wicket
  1. Wicket
  2. WICKET-4810

CLONE - BaseWicketTester.clickLink() does not work with a ResourceLink with ResourceReference

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.4
    • Fix Version/s: 6.2.0, 1.5.9
    • Component/s: wicket
    • Labels:
      None

      Description

      When using BaseWicketTester.clickLink() with a ResourceLink with a ResourceReference, it does not work.
      Clicking link in server (Jetty) it works and opens the resource. See attached quickstart.

      When the ResourceLink is created with the Resource directly, BaseWicketTester.clickLink() works.

      @Test
      public void clickingLink()

      { // doesn't work tester.clickLink("shared"); Assert.assertEquals(tester.getContentTypeFromResponseHeader(), "text/plain"); }

      @Test
      public void usingListener()

      { // doesn't work either tester.executeListener(tester.getComponentFromLastRenderedPage("shared"), IResourceListener.INTERFACE); Assert.assertEquals(tester.getContentTypeFromResponseHeader(), "text/plain"); }

        Issue Links

          Activity

          Hide
          Eric Le Lay added a comment -

          the quickstart (2 tests fail)

          Show
          Eric Le Lay added a comment - the quickstart (2 tests fail)
          Hide
          Martin Grigorov added a comment -

          Improved the code for clicking a ResourceLink. Now it uses Link#getURL() to get the real url for both IResource and ResourceReference. #clickLink() test now works fine

          The second test (tester.executeListener(Component, IResourceListener.INTERFACE) still fails because it tries to use ResourceLink with IResource while in your case it actually uses ResourceReference and this is a bug in the application.

          Show
          Martin Grigorov added a comment - Improved the code for clicking a ResourceLink. Now it uses Link#getURL() to get the real url for both IResource and ResourceReference. #clickLink() test now works fine The second test (tester.executeListener(Component, IResourceListener.INTERFACE) still fails because it tries to use ResourceLink with IResource while in your case it actually uses ResourceReference and this is a bug in the application.
          Hide
          Eric Le Lay added a comment -

          OK, it is fine like this.
          Using executeListener() in the 2nd test was only to show that the work-around provided in WICKET-4437 was not working in this case.

          Thank you very much !

          For somebody not wanting to wait for 6.2.0, it can be done outside BaseWicketTester :
          WicketTester tester;
          ResourceLink<?> lnk = (ResourceLink<?>)tester.getComponentFromLastRenderedPage("myresourcelink");
          try

          { Method getUrlMethod = ResourceLink.class.getDeclaredMethod( "getURL", (Class<?>[])null); getUrlMethod.setAccessible(true); String url = (String)getUrlMethod.invoke( lnk, (Object[])null); tester.executeUrl(url.toString()); }

          catch (Exception e)

          { fail("this shouldn't fail!!"); }
          Show
          Eric Le Lay added a comment - OK, it is fine like this. Using executeListener() in the 2nd test was only to show that the work-around provided in WICKET-4437 was not working in this case. Thank you very much ! For somebody not wanting to wait for 6.2.0, it can be done outside BaseWicketTester : WicketTester tester; ResourceLink<?> lnk = (ResourceLink<?>)tester.getComponentFromLastRenderedPage("myresourcelink"); try { Method getUrlMethod = ResourceLink.class.getDeclaredMethod( "getURL", (Class<?>[])null); getUrlMethod.setAccessible(true); String url = (String)getUrlMethod.invoke( lnk, (Object[])null); tester.executeUrl(url.toString()); } catch (Exception e) { fail("this shouldn't fail!!"); }

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Eric Le Lay
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development