Re: ServletUnitServletContext
Adam Hardy <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Wolfgang, I'd be happy to oblige. What format do you want this? I can supply the testcase on its own but it will need the JSP, the struts jar, the tiles jar and probably some other stuff to run. I can zip a project for you, but where do you want it submitted? I saw the issue tracker doesn't contain an issue for svn881. regards Adam Wolfgang Fahl on 02/04/08 12:50, wrote: > Dear Adam, > > svn 881 has your change. Would you please supply a short JUnit testcase > in return that proves that the class is public now? > > Yours > Wolfgnag > > > > Date sent: Wed, 02 Apr 2008 11:55:57 +0100 > From: Adam Hardy <[email protected]> > To: [email protected] > Subject: [Httpunit-develop] ServletUnitServletContext > Send reply to: Discussion of use and development of HttpUnit > <[email protected]> > <httpunit- develop.lists.sourceforge.net> > <mailto:httpunit-develop- > [email protected]?subject=unsubscribe> > <mailto:httpunit-develop- > [email protected]?subject=subscribe> > >> Hi, >> >> I am trying to test a website built with a templating package called > Tiles - ( >> http://tiles.apache.org ) you may well have heard of it, it is quite > popular. >> >> I am doing the following: >> >> StringBuilder xml = new StringBuilder(); >> xml.append("<?xml version=\"1.0\" etc etc etc.... >> ServletRunner servletRunner = >> new ServletRunner(new ByteArrayInputStream(xml.toString() >> .getBytes()), "/pattern-repo"); >> servletRunner.registerServlet("bla", EmptyServlet.class.getName()); >> WebRequest getRequest = >> new GetMethodWebRequest( >> "http://localhost/pattern-repo/test-result/edit.html"); >> getRequest.setParameter("code", "1"); >> WebForm form = >> servletRunner.getResponse(getRequest).getFormWithName( >> "testResultForm"); >> >> >> The problem occurs when the ServletRunner invokes Tiles. Tiles tries > to retrieve >> its config from the ServletContext, but the ServletUnitServletContext >> implementation from ServletUnit has package default access modifier so > this call >> fails: >> >> private static Object getAttribute(Object context, String > attributeName) { >> try { >> Class<?> contextClass = context.getClass(); >> Method attrMethod = contextClass.getMethod("getAttribute", > String.class); >> return attrMethod.invoke(context, attributeName); >> } catch (Exception e) { >> LOG.warn("Unable to retrieve container from specified context: > '" + >> context + "'", e); >> return null; >> } >> } >> >> >> java.lang.IllegalAccessException: Class > org.apache.tiles.access.TilesAccess can >> not access a member of class > com.meterware.servletunit.ServletUnitServletContext >> with modifiers "public" >> at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65) >> at java.lang.reflect.Method.invoke(Method.java:578) >> at > org.apache.tiles.access.TilesAccess.getAttribute(TilesAccess.java:125) >> at > org.apache.tiles.access.TilesAccess.getContainer(TilesAccess.java:74) >> at > org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:99) >> >> >> Is there chance that ServletUnitServletContext can be made public? ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace