Hi, 2011/2/9 Dmitriy Neretin <dmitriy.nere...@googlemail.com>
> Thank you it finally works! :) > Great! > But what I still don't understand: the problem appeared after I inserted > following in the custom session constructor: > > InjectorHolder.getInjector().inject(this); > > And why it worked with only one WicketTester constructor parameter (new > MyApplication)? And after Spring integration there schould be 2 parameters? > Only spring's XmlWebApplicationContext needed the real web app resources (the WEB-INF/applicationContext.xml file) wicket itself did not. So without injection nothing was using it. P.S. My assertion for ServletContext looks like this: > > > Assert.assertNotNull(tester.getServletSession().getServletContext().getContext("WEB-INF/web.xml")); > You are right. tester.getServletContext() is only available in 1.5, not in 1.4. Attila > > On 9 February 2011 14:27, Attila Király <kiralyattila...@gmail.com> wrote: > > > The problem is that your test is not actualy running in a servlet > > container, > > only in a wicket mocked servlet context. To access webapp resources in > the > > test you have to specify in the second parameter of WicketTester > > constructor > > where your web app's root is. Like this (in a maven project): > > > > WicketTester tester = new WicketTester(new MockApplication(), > > "target/my-webapp-name"); > > > > > Assert.assertNotNull(tester.getServletContext().getResource("WEB-INF/web.xml")); > > > > Attila > > > > 2011/2/9 Dmitriy Neretin <dmitriy.nere...@googlemail.com> > > > > > Hi, > > > > > > thank you! Now I know how to get the ServletContext :) But it didn't > > solve > > > the main problem. This time I got following exception: > > > > > > IOException parsing XML document from ServletContext resource > > > [/WEB-INF/applicationContext.xml]; nested exception is > > > java.io.FileNotFoundException: Could not open ServletContext resource > > > [/WEB-INF/applicationContext.xml] > > > > > > This is the right path. The xml file is there. It also schouldn't be a > > > problem with file system permissions :( > > > > > > On 9 February 2011 12:57, Attila Király <kiralyattila...@gmail.com> > > wrote: > > > > > > > Hi, > > > > > > > > Try this in your application's #init() method (before calling > > #refresh() > > > on > > > > ctx) > > > > > > > > ctx.setServletContext(getServletContext()); > > > > > > > > Attila > > > > > > > > 2011/2/9 Dmitriy Neretin <dmitriy.nere...@googlemail.com> > > > > > > > > > Thank you for reply, > > > > > > > > > > yes! And I get then another exception :) > > > > > > > > > > Cannot resolve ServletContextResource without ServletContext > > > > > > > > > > Does andybody know how can I get/set the servletContext? > > > > > > > > > > Dmitriy > > > > > > > > > > On 8 February 2011 18:01, Igor Vaynberg <igor.vaynb...@gmail.com> > > > wrote: > > > > > > > > > > > did you call context.refresh() ? like the error message said? > > > > > > > > > > > > -igor > > > > > > > > > > > > On Tue, Feb 8, 2011 at 1:31 AM, Dmitriy Neretin > > > > > > <dmitriy.nere...@googlemail.com> wrote: > > > > > > > Hi, > > > > > > > > > > > > > > my complete setUp looks like this: > > > > > > > > > > > > > > @Before > > > > > > > public void setUp() { > > > > > > > MworldWicketApplication wicketWebApp = new > > > > > > MworldWicketApplication() > > > > > > > { > > > > > > > > > > > > > > ApplicationContext ctx = new > > XmlWebApplicationContext(); > > > > > > > > > > > > > > @Override > > > > > > > public void init() { > > > > > > > addComponentInstantiationListener(new > > > > > > > SpringComponentInjector(this, ctx, true)); > > > > > > > } > > > > > > > }; > > > > > > > > > > > > > > tester = new WicketTester(wicketWebApp); > > > > > > > pageParams = new HashMap<String, String>(); > > > > > > > } > > > > > > > > > > > > > > So the wickettester instance is created after the Appllication > > > class > > > > is > > > > > > > overriden. Even if I extract the wickettester creation from > setup > > > and > > > > > > will > > > > > > > make it in each test (it is actually the same) I have the same > > > > problem. > > > > > > > > > > > > > > After debuggin the tests I have seen that my appcontext > instance > > > was > > > > > > created > > > > > > > and the .xml file was correctly recognized :( But I still get > the > > > > > > > exception... > > > > > > > > > > > > > > On 8 February 2011 07:37, Igor Vaynberg < > igor.vaynb...@gmail.com > > > > > > > > wrote: > > > > > > > > > > > > > >> make sure your setup() code runs before wicket tester instance > > is > > > > > > created. > > > > > > >> > > > > > > >> -igor > > > > > > >> > > > > > > >> On Mon, Feb 7, 2011 at 7:41 AM, Dmitriy Neretin > > > > > > >> > > > > > > >> > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > > > > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > "I would rather write programs to write programs than write > programs." > > > > > > > > > >