Junit-testing Forms.

19 views
Skip to first unread message

andreas.h...@commercetools.de

unread,
Feb 27, 2015, 10:10:44 AM2/27/15
to hippo-c...@googlegroups.com
Hi,

I try to write a Junit-test for submitting  forms (Method to test: doAction of a component).  But when I run this test, I get a Error, when the form should be made persistent using the method "FormUtils.persistFormMap(request, response, formMap, null)", because the Hipposession is null. Can you give me a  hint, how I can mock the Hipposession properly, to make this test running.

cheers Andi

commercetools GmbH
SPHERE.IO - Enterprise E-Commerce Software without Enterprise Hassles

e-commerce banner

Amtsgericht München, HRB 161496
Geschäftsführer: Denis Werner, Dirk Hörig, Dr. Robert Zores

Ard Schrijvers

unread,
Mar 2, 2015, 4:31:47 AM3/2/15
to hippo-c...@googlegroups.com
Hey Andi,

You can use org.onehippo.repository.mock for mocking jcr nodes and sessions. For example

org.onehippo.repository.mock.MockNode#getSession

Most likely you will need to set this mocked session on a thread local for the HST as well via org.hippoecm.hst.container.ModifiableRequestContextProvider (and in tear down remove this thread local)

Regards Ard

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.



--
Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
Hippo USA, Inc.- 745 Atlantic Ave, Eight Floor, Boston MA 02111, United states of America.

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
Reply all
Reply to author
Forward
0 new messages