Many thanks, I'll give that a go. ________________________________________ From: Thomas Mortagne [[email protected]] Sent: 27 November 2014 23:14 To: Bryn Jeffries Subject: Re: [xwiki-users] Registering components
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-display/xwiki-platform-display-api/src/test/java/org/xwiki/display/internal/DocumentContentDisplayerTest.java is a good up to date (we changed several time the mocking system to use in XWiki by default, it's Mockito currently) example of how to manipuated a mock of DocumentAccessBridge in a component oriented unit test. On Thu, Nov 27, 2014 at 11:42 AM, Bryn Jeffries <[email protected]> wrote: > Useful to know, thanks. Incidentally, are there any useful mocks, etc, for > unit testing xwiki component code ( to avoid frequently restarting tomcat)? > Like a mock execution context, for instance? > > Thanks, > > Bryn > > > > ----- Reply message ----- > From: "Thomas Mortagne" <[email protected]> > To: "XWiki Users" <[email protected]> > Subject: Re: [xwiki-users] Registering components > Date: Thu, Nov 27, 2014 18:38 > > On Thu, Nov 27, 2014 at 8:36 AM, Thomas Mortagne > <[email protected]> wrote: >> What you have in XE_WAR_HOME/WEB-INF/lib is loaded by Tomcat at >> startup, there is not much XWiki can do about it. >> >> But you can install your jar as an extension using Extension Manager >> as long as it's on some supported repository (which mean a Maven >> repository or XWiki repository, see >> >> http://extensions.xwiki.org/xwiki/bin/view/Extension/Repository+Application >> for this last one) and you indicate your repository in >> xwiki.properties. > > Note that Extension Manager is not the best fit right now to test > snapshot jars since it does not have the required special handling of > SNAPSHOT needed to update to a new version of the same SNAPSHOT > version. > >> >> On Thu, Nov 27, 2014 at 5:20 AM, Bryn Jeffries >> <[email protected]> wrote: >>> Having been put off writing Java components a number of times I've >>> decided to really tackle the problem head on. I would greatly appreciate any >>> help in this. >>> >>> I've been following the advice in >>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents and I >>> have compiled a Jar identical to the Hello World example except that the >>> class and method names differ, hopefully consistently. I've placed the jar >>> in XE_WAR_HOME/WEB-INF/lib and written a page, which consists only of >>> {{velocity}} >>> $services.mycomponent.greet() >>> {{/velocity}} >>> >>> The output when viewed is simple "$services.alertdb.greet()", so nothing >>> seems to have happened. However, if I restart Tomcat (and then wait a minute >>> or so for XWiki to restart) the output is "Hello", as desired. >>> >>> So is a restart of Tomcat always required? This wasn't mentioned in the >>> guide. And since extensions can be added via the extension manager without a >>> restart, is there a sneaky trick to doing the same with my own components. >>> >>> Also, is a restart necessary when I update the Jar, either with fixed >>> methods or modified interface? >>> _______________________________________________ >>> users mailing list >>> [email protected] >>> http://lists.xwiki.org/mailman/listinfo/users >> >> >> >> -- >> Thomas Mortagne > > > > -- > Thomas Mortagne > -- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
