code will then look like this:

                mockery.checking(new Expectations() {
                        {
                                
oneOf(eventRepository).update(with(any(Event.class)));

                        }
                });
                tester.clickLink("content:events:0:delete");
                mockery.assertIsSatisfied();

pretty simple yet powerfull :)


2009/4/7 nino martinez wael <[email protected]>:
> Instead of using a test stub, i'd use jmock or some similar mock
> framework and get a little more control :)
>
> 2009/4/6 Olivier Michallat <[email protected]>:
>> The problem is that your unit tests run out of the web container, you
>> can't rely on a servlet context listener to load the Spring context in
>> this situation.
>>
>> You need a hook to inject a mock context when testing. This post
>> describes a solution: http://blog.ehour.nl/index.php/archives/21
>>
>>
>> 2009/4/6 HHB <[email protected]>:
>>> Hey,
>>> I'm trying to integrate Spring 2.5 into our Wicket
>>> application, I did the following:
>>>
>>> web.xml:
>>>    <context-param>
>>>        <param-name>contextConfigLocation</param-name>
>>>        <param-value>classpath:applicationContext.xml</param-value>
>>>    </context-param>
>>>    <listener>
>>>        <listener-class>org.springframework.web.
>>> context.ContextLoaderListener</listener-class>
>>>    </listener>
>>>    <filter>
>>>        <filter-name>OpenSessionInViewFilter</filter-name>
>>>        <filter-class>org.springframework.orm.hibernate3.
>>> support.OpenSessionInViewFilter</filter-class>
>>>    </filter>
>>>
>>>    <filter>
>>>        <filter-name>WicketFilter</filter-name>
>>>        <filter-class>org.apache.wicket.
>>> protocol.http.WicketFilter</filter-class>
>>>        <init-param>
>>>            <param-name>applicationFactoryClassName</param-name>
>>>            <param-value>org.apache.wicket.spring.
>>> SpringWebApplicationFactory</param-value>
>>>        </init-param>
>>>    </filter>
>>>    <filter>
>>>        <filter-name>WicketFilter</filter-name>
>>>        <filter-class>org.apache.wicket.
>>> protocol.http.WicketFilter</filter-class>
>>>        <init-param>
>>>            <param-name>applicationFactoryClassName</param-name>
>>>            <param-value>org.apache.wicket.spring.
>>> SpringWebApplicationFactory</param-value>
>>>        </init-param>
>>>    </filter>
>>>
>>> applicationContext.xml:
>>>
>>>    <bean id="wicketApplication" class="domain.WicketApplication"/>
>>>
>>>
>>> pom.xml:
>>>
>>>        <dependency>
>>>            <groupId>org.springframework</groupId>
>>>            <artifactId>spring</artifactId>
>>>            <version>2.5.6</version>
>>>        </dependency>
>>>
>>>        <dependency>
>>>            <groupId>org.apache.wicket</groupId>
>>>            <artifactId>wicket-spring</artifactId>
>>>            <version>1.3.5</version>
>>>        </dependency>
>>>        <dependency>
>>>            <groupId>org.apache.wicket</groupId>
>>>            <artifactId>wicket-spring-annot</artifactId>
>>>            <version>1.3.5</version>
>>>        </dependency>
>>>
>>> WicketApplication:
>>>
>>>   @Override
>>>    protected void init() {
>>>        super.init();
>>>        addComponentInstantiationListener
>>> (new SpringComponentInjector(this));
>>>    }
>>>
>>> But when trying:
>>> mvn test
>>> I got the following exception:
>>> ------------------------------------
>>> -------------------------------------------
>>> Test set: TestSuite
>>> ------------------------------------
>>> -------------------------------------------
>>> Tests run: 2, Failures: 1, Errors: 0,
>>> Skipped: 1, Time elapsed: 0.498 sec <<< FAILURE!
>>> init(domain.TestHomePage)  Time elapsed: 0 sec  <<< FAILURE!
>>> java.lang.IllegalStateException:
>>> No WebApplicationContext found: no ContextLoaderListener registered?
>>>        at org.springframework.web.context.support.
>>> WebApplicationContextUtils.
>>> getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
>>>        at org.apache.wicket.spring.
>>> injection.annot.SpringComponentInjector.
>>> <init>(SpringComponentInjector.java:74)
>>>
>>> Any ideas?
>>> Thanks.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to