Re: [xwiki-users] Components : Bridge to old core and objects ?
On Tue, Apr 10, 2012 at 6:08 PM, Diego Jesus wrote: > Ok, got it to work. The small test component is running just fine in > XWiki. However, if I try to run unit tests with maven I get the > following error: > > Results : > > Failed tests: > testGetDocument(com.aims.DocumentScriptTest): unexpected invocation: > context.getContext() > no expectations specified: did you... > - forget to start an expectation with a cardinality clause? > - call a mocked method to specify the parameter of an expectation? > what happened before this: nothing! > > This are the relevant parts of my code: > > @Component > @Named("documentScript") > @Singleton > public class DocumentScript implements ScriptService > { > @Inject > Execution context; You get a mock Execution injected when the test is run, most probably, so you have to specify the behaviour of getContext() method before calling GetDocument(int). It should probably return a mock ExecutionContext which in turn should return a mock XWikiContext when calling getProperty("xwikicontext"). You need to specify these expectations at the beginning of your test, or in the setUp (@Before) if more tests share the same expectations. Hope this helps, Marius > > > public Document GetDocument(int id){ > try { > ExecutionContext context = this.context.getContext(); > // The exception trace points here > XWikiContext wikiContext = > (XWikiContext)context.getProperty("xwikicontext"); > XWiki wiki = wikiContext.getWiki(); > > > > > No dia 10 de Abril de 2012 14:37, Marius Dumitru Florea > escreveu: >> >> On Tue, Apr 10, 2012 at 4:34 PM, Thomas Mortagne >> wrote: >> > Probably mean you don't have the right configuration in your >> > .m2/settings.xml. See >> > http://dev.xwiki.org/xwiki/bin/view/Community/Building#HInstallingMaven >> >> Yes, I can see the 4.0-SNAPSHOT version of xwiki-platform-oldcore in >> the maven repo >> http://maven.xwiki.org/snapshots/org/xwiki/platform/xwiki-platform-oldcore/4.0-SNAPSHOT/ >> . >> >> Hope this helps, >> Marius >> >> > >> > On Tue, Apr 10, 2012 at 3:24 PM, _diego wrote: >> >> Well, I've been trying, but maven doesn't find that dependency. >> >> >> >> I've tried with several versions of the following: >> >> >> >> >> >> org.xwiki.platform >> >> xwiki-platform-oldcore >> >> 4.0-SNAPSHOT >> >> >> >> >> >> I also search in maven repository but there is no reference there to the >> >> old >> >> core. Should I build the source from git and include the jar in my >> >> project? >> >> >> >> -- >> >> View this message in context: >> >> http://xwiki.475771.n2.nabble.com/Components-Bridge-to-old-core-and-objects-tp7208056p7452865.html >> >> Sent from the XWiki- Users mailing list archive at Nabble.com. >> >> ___ >> >> users mailing list >> >> users@xwiki.org >> >> http://lists.xwiki.org/mailman/listinfo/users >> > >> > >> > >> > -- >> > Thomas Mortagne >> > ___ >> > users mailing list >> > users@xwiki.org >> > http://lists.xwiki.org/mailman/listinfo/users >> ___ >> users mailing list >> users@xwiki.org >> http://lists.xwiki.org/mailman/listinfo/users > ___ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Components : Bridge to old core and objects ?
Ok, got it to work. The small test component is running just fine in XWiki. However, if I try to run unit tests with maven I get the following error: Results : Failed tests: testGetDocument(com.aims.DocumentScriptTest): unexpected invocation: context.getContext() no expectations specified: did you... - forget to start an expectation with a cardinality clause? - call a mocked method to specify the parameter of an expectation? what happened before this: nothing! This are the relevant parts of my code: @Component @Named("documentScript") @Singleton public class DocumentScript implements ScriptService { @Inject Execution context; public Document GetDocument(int id){ try { ExecutionContext context = this.context.getContext(); // The exception trace points here XWikiContext wikiContext = (XWikiContext)context.getProperty("xwikicontext"); XWiki wiki = wikiContext.getWiki(); No dia 10 de Abril de 2012 14:37, Marius Dumitru Florea escreveu: > > On Tue, Apr 10, 2012 at 4:34 PM, Thomas Mortagne > wrote: > > Probably mean you don't have the right configuration in your > > .m2/settings.xml. See > > http://dev.xwiki.org/xwiki/bin/view/Community/Building#HInstallingMaven > > Yes, I can see the 4.0-SNAPSHOT version of xwiki-platform-oldcore in > the maven repo > http://maven.xwiki.org/snapshots/org/xwiki/platform/xwiki-platform-oldcore/4.0-SNAPSHOT/ > . > > Hope this helps, > Marius > > > > > On Tue, Apr 10, 2012 at 3:24 PM, _diego wrote: > >> Well, I've been trying, but maven doesn't find that dependency. > >> > >> I've tried with several versions of the following: > >> > >> > >> org.xwiki.platform > >> xwiki-platform-oldcore > >> 4.0-SNAPSHOT > >> > >> > >> I also search in maven repository but there is no reference there to the > >> old > >> core. Should I build the source from git and include the jar in my project? > >> > >> -- > >> View this message in context: > >> http://xwiki.475771.n2.nabble.com/Components-Bridge-to-old-core-and-objects-tp7208056p7452865.html > >> Sent from the XWiki- Users mailing list archive at Nabble.com. > >> ___ > >> users mailing list > >> users@xwiki.org > >> http://lists.xwiki.org/mailman/listinfo/users > > > > > > > > -- > > Thomas Mortagne > > ___ > > users mailing list > > users@xwiki.org > > http://lists.xwiki.org/mailman/listinfo/users > ___ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Components : Bridge to old core and objects ?
On Tue, Apr 10, 2012 at 4:34 PM, Thomas Mortagne wrote: > Probably mean you don't have the right configuration in your > .m2/settings.xml. See > http://dev.xwiki.org/xwiki/bin/view/Community/Building#HInstallingMaven Yes, I can see the 4.0-SNAPSHOT version of xwiki-platform-oldcore in the maven repo http://maven.xwiki.org/snapshots/org/xwiki/platform/xwiki-platform-oldcore/4.0-SNAPSHOT/ . Hope this helps, Marius > > On Tue, Apr 10, 2012 at 3:24 PM, _diego wrote: >> Well, I've been trying, but maven doesn't find that dependency. >> >> I've tried with several versions of the following: >> >> >> org.xwiki.platform >> xwiki-platform-oldcore >> 4.0-SNAPSHOT >> >> >> I also search in maven repository but there is no reference there to the old >> core. Should I build the source from git and include the jar in my project? >> >> -- >> View this message in context: >> http://xwiki.475771.n2.nabble.com/Components-Bridge-to-old-core-and-objects-tp7208056p7452865.html >> Sent from the XWiki- Users mailing list archive at Nabble.com. >> ___ >> users mailing list >> users@xwiki.org >> http://lists.xwiki.org/mailman/listinfo/users > > > > -- > Thomas Mortagne > ___ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Components : Bridge to old core and objects ?
Probably mean you don't have the right configuration in your .m2/settings.xml. See http://dev.xwiki.org/xwiki/bin/view/Community/Building#HInstallingMaven On Tue, Apr 10, 2012 at 3:24 PM, _diego wrote: > Well, I've been trying, but maven doesn't find that dependency. > > I've tried with several versions of the following: > > > org.xwiki.platform > xwiki-platform-oldcore > 4.0-SNAPSHOT > > > I also search in maven repository but there is no reference there to the old > core. Should I build the source from git and include the jar in my project? > > -- > View this message in context: > http://xwiki.475771.n2.nabble.com/Components-Bridge-to-old-core-and-objects-tp7208056p7452865.html > Sent from the XWiki- Users mailing list archive at Nabble.com. > ___ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users -- Thomas Mortagne ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Components : Bridge to old core and objects ?
Well, I've been trying, but maven doesn't find that dependency. I've tried with several versions of the following: org.xwiki.platform xwiki-platform-oldcore 4.0-SNAPSHOT I also search in maven repository but there is no reference there to the old core. Should I build the source from git and include the jar in my project? -- View this message in context: http://xwiki.475771.n2.nabble.com/Components-Bridge-to-old-core-and-objects-tp7208056p7452865.html Sent from the XWiki- Users mailing list archive at Nabble.com. ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Components : Bridge to old core and objects ?
On Mon, Apr 9, 2012 at 5:44 PM, _diego wrote: > Hi, > > I'm also trying to do something similar and I have already followed that > guide. However, I still can't use the API, since I can't find the > XWikiContext class in my classpath, or any other class from com.xpn.xwiki in > eclipse. Am I missing some maven dependency? I also can't find anything on > google to solve this. Did you add a dependency to old core ( https://github.com/xwiki/xwiki-platform/tree/master/xwiki-platform-core/xwiki-platform-oldcore ) as I suggested? Hope this helps, Marius > > Thanks in advance > > -- > View this message in context: > http://xwiki.475771.n2.nabble.com/Components-Bridge-to-old-core-and-objects-tp7208056p7449893.html > Sent from the XWiki- Users mailing list archive at Nabble.com. > ___ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Components : Bridge to old core and objects ?
Hi, I'm also trying to do something similar and I have already followed that guide. However, I still can't use the API, since I can't find the XWikiContext class in my classpath, or any other class from com.xpn.xwiki in eclipse. Am I missing some maven dependency? I also can't find anything on google to solve this. Thanks in advance -- View this message in context: http://xwiki.475771.n2.nabble.com/Components-Bridge-to-old-core-and-objects-tp7208056p7449893.html Sent from the XWiki- Users mailing list archive at Nabble.com. ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Components : Bridge to old core and objects ?
If you don't mind depending on the old core then you can access it from a component as indicated on http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HAccessingLegacycode . Once you have the XWikiContext object (from the ExecutionContext) then you have access to all the old core APIs. Hope this helps, Marius On Fri, Jan 20, 2012 at 6:03 PM, jerem wrote: > Hello, > > I'm trying to convert a groovy class (in a wiki page) to a proper xwiki > component in Java. > > Problem is : my groovy code makes heavy use of the document model, for > example : > - setting documents creator/author, dates, with and without triggering > change events (modifying also internal xwikidocument) > - accessing multiple objects of same class created in a unique page > - ... > > I could not find anything to do that in the DocumentAccessBridge ... > > My question is, would it be better for me to wait for the xwiki model to be > properly externalized from the old core (so I could target this from my > component), or expect missing methods to be added to the bridge, ... or add > them by myself ? > Obviously, the last option seems both too heavy and too "risky" for me. > Obviously too, rewriting my (big) groovy class for using the bridge api > seems cumbersome : I'd prefer to wait for a dedicated component for > accessing the core model. > > Best regards, > Jeremie > > -- > View this message in context: > http://xwiki.475771.n2.nabble.com/Components-Bridge-to-old-core-and-objects-tp7208056p7208056.html > Sent from the XWiki- Users mailing list archive at Nabble.com. > ___ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
[xwiki-users] Components : Bridge to old core and objects ?
Hello, I'm trying to convert a groovy class (in a wiki page) to a proper xwiki component in Java. Problem is : my groovy code makes heavy use of the document model, for example : - setting documents creator/author, dates, with and without triggering change events (modifying also internal xwikidocument) - accessing multiple objects of same class created in a unique page - ... I could not find anything to do that in the DocumentAccessBridge ... My question is, would it be better for me to wait for the xwiki model to be properly externalized from the old core (so I could target this from my component), or expect missing methods to be added to the bridge, ... or add them by myself ? Obviously, the last option seems both too heavy and too "risky" for me. Obviously too, rewriting my (big) groovy class for using the bridge api seems cumbersome : I'd prefer to wait for a dedicated component for accessing the core model. Best regards, Jeremie -- View this message in context: http://xwiki.475771.n2.nabble.com/Components-Bridge-to-old-core-and-objects-tp7208056p7208056.html Sent from the XWiki- Users mailing list archive at Nabble.com. ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users