We also use spring-security and ran into some issues as well.  What we
ended up doing was adding something like this to the JUnit #setUp
method

    /* (non-Javadoc)
     * @see junit.framework.TestCase#setUp()
     */
        protected void setUp() throws Exception {
        super.setUp();

        _tester = new PageTester(_ROOT_PACKAGE_NAME, _APP_MODULE,
                PageTester.DEFAULT_CONTEXT_PATH, TestHarnessModule.class);

        _encoder = _tester.getService(ContextPathEncoder.class);

        Registry registry = _tester.getRegistry();
        registry.performRegistryStartup();

        UserDetailsService userDetailsSvc =
_tester.getService(UserDetailsService.class);
        UserDetails ud = userDetailsSvc.loadUserByUsername(someuser);

        handleIfLogIn();

        SecurityContext context = new SecurityContextImpl();
        Authentication currentUser = new
UsernamePasswordAuthenticationToken(ud.getUsername(),
                        somepassword);
        context.setAuthentication(currentUser);
        SecurityContextHolder.setContext(context);
    }

Hope that helps.. and if anyone has a better solution please let me know.

-Mark

On Mon, Dec 22, 2008 at 3:23 PM, Michał Jedynak <m.jedy...@gmail.com> wrote:
>
> I have a similar issue:
> http://www.nabble.com/Tapestry-5-with-Spring-Security---problem-with-unit-tests.-td21126486.html.
> The problem is not about PageLinkTarget -> PageRenderTarget, but about the
> way to properly initialize ComponentInvocationImpl.
>
>
>
> nille hammer wrote:
>>
>>
>> Hi Mark,
>> first I have to admit I am not familliar with Tapestry´s testing
>> mechanisms so this information is based on browsing through the javadocs
>> rather than experience. I think this is the class you are looking for:
>> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/services/PageRenderTarget.html
>> Hope that helps, cheers nillehammer
>>
>> ----- original Nachricht --------
>>
>> Betreff: PageLinkTarget, where did it go?
>> Gesendet: Mo, 15. Dez 2008
>> Von: Mark Horn<mark.h...@agilesrc.com>
>>
>>> I am in the process of updating our application from Tapestry version
>>> 5.0.15 to 5.0.18 and it looks like PageLinkTarget has disappeared.  We
>>> have been following the Unit testing as outlined
>>> http://tapestry.apache.org/tapestry5/guide/unit-testing-pages.html
>>> which uses the PageLinkTarget when testing a page with a context.  I
>>> looked around and can't find the class or any documentation on what
>>> its replacement is.
>>>
>>> Any help is greatly appreciated.
>>>
>>> Thanks,
>>> Mark
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>
>>>
>>
>> --- original Nachricht Ende ----
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/PageLinkTarget%2C-where-did-it-go--tp21022001p21134364.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to