My mistake : I tried to do integration test with mocks...
I think I have to use @ContextConfiguration instead
ApplicationContextMock...


2011/5/31 Mathilde Pellerin <mathilde.pelle...@statlife.fr>

> Hi all,
>
> I have a Wicket application which works with Spring, JPA and Hibernate. I
> used this archetype to create the project (archetype found through Wicket
> More archetype page) :
> mvn archetype:generate -B -DarchetypeCatalog=
> http://legup.googlecode.com/svn/repo/archetype-catalog.xml-DarchetypeArtifactId=wicket-spring-jpa-archetype
> -DarchetypeGroupId=com.jweekend -DarchetypeVersion=0.8.4
> -DgroupId=com.mycompany -DartifactId=mycompany -Dversion=1.0-SNAPSHOT
> -Dpackage=com.mycompany
>
> in the project generated, there is a class DataInitialiser which initialize
> database and which is called by applicationContext.xml :
>     <bean class="fr.statlife.protoE4N.DataInitialiser"
> init-method="dataInit">
>         <property name="serviceMembre" ref="serviceMembre"></property>
>         <property name="serviceLienBaseE4N"
> ref="serviceLienE4N"></property>
>     </bean>
>
> it's work well when I test my application manually, but database is not
> initialized when I used WicketTester.
> This is the setup method used with wicket tester :
>
> public class TestStory04 {
>     protected WicketTester tester;
>
>     @Before
>     public void setup()
>     {
>         final ApplicationContextMock acm = new ApplicationContextMock();
>
>         ServiceIdentification serviceIdentif =
> Mockito.mock(ServiceIdentification.class);
>         acm.putBean("serviceIdentif", serviceIdentif);
>
>         ServiceInscription serviceInscription =
> Mockito.mock(ServiceInscription.class);
>         acm.putBean("serviceInscription", serviceInscription);
>
>         tester = new WicketTester(new WicketApplication(){
>             /* (non-Javadoc)
>              * @see
> fr.statlife.protoE4N.WicketApplication#getGuiceInjector()
>              */
>             @Override
>             protected SpringComponentInjector getSpringInjector() {
>                 return  new SpringComponentInjector(this, acm, true);
>             }
>         });
>     }
> [some tests]
> }
>
> In setup method, I tried to add
>         DataInitialiser dataInitialiser =
> Mockito.mock(DataInitialiser.class);
>         acm.putBean("initData", dataInitialiser);
>         try {
>             dataInitialiser.dataInit();
>         } catch (ParseException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>         }
>
> but it doesn't work : database is not initialized.
>
> So how can I initialize my database ?
>
> Thanks
>
> --
> *Mathilde Pellerin*
> Ingénieur en développement de logiciel
>
> STATLIFE
> tel : 01.42.11.64.88
> mail : mathilde.pelle...@statlife.fr
>
>
>
>


-- 
*Mathilde Pellerin*
Ingénieur en développement de logiciel

STATLIFE
tel : 01.42.11.64.88
mail : mathilde.pelle...@statlife.fr

Reply via email to