2 Replies Latest reply on Apr 14, 2010 3:08 PM by nickarls

    Setting ID:s for mocked components

    nickarls

      Hi,

       

        How are  you supposed to set ID:s manually for mocked components?

       

       

            UIComponent c = new MockUIComponent();
            c.setId("foo");
            System.out.println(c.getId());

       

      and I get "null"

        • 1. Re: Setting ID:s for mocked components
          ssilvert

          Hi Nicklas,

           

          You don't normally need to use mocks with JSFUnit.  Since you are in container and you are running the real JSF implementation you just use the real component references.

           

          I don't know why your mock doesn't return the ID you set for it.  That's up to the mock implementation.  Is there some reason you think it has to do with the JSFUnit environment?

           

          Stan

          • 2. Re: Setting ID:s for mocked components
            nickarls

            Actually I just need some standalone, concrete UIComponent to pass along to a JSF component event in a unit test and since I already had JSFUnit as a dependency I thought I could get away with the snippet I posted but apparently it's not designed for isolated usage like that (the setter/getter don't appear to be directly linked to a field in the implementation).