Re: ServletUnitServletContext
"Wolfgang Fahl" <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Organization | BITPlan GmbH |
| Message-ID | <[email protected]> |
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? > > Regards > Adam > > ------------------------------------------------------------------------- > 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 > _______________________________________________ > Httpunit-develop mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/httpunit-develop BITPlan - smart solutions Pater-Delp-Str. 1, D-47877 Willich Schiefbahn Tel. +49 1805 - BITPLAN / +49 1805 248 752, Fax +49 2154 811-481 Web: http://www.bitplan.de bitplan GmbH, Willich - HRB 6820 Krefeld, VAT-ID: 10258040548, Geschäftsführer: Wolfgang Fahl ------------------------------------------------------------------------- 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 _______________________________________________ Httpunit-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/httpunit-develop