That's because DefaultDocumentAccessBridge is trying to get the current user from the XWikiContext which is supposed to be stored in the ExecutionContext. All that require special setup in your test because default archetype does not take care of that (thoses thing don't even exist at its level).
It depends on what exactly you macro is doing and what you want to test but generally the best is to override the component with role DocumentAccessBridge with default hint and implement getCurrentUser in it (and any other thing you require in your macro). You can also setup the ExecutionContext etc but that's more complex and I doubt you really need to test that. You can look at https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-useravatar/src/test/java/org/xwiki/rendering/macro/useravatar/IntegrationTests.java for an example of how to mock DocumentAccessBridge (you don't need to do all that, this test is mocking other things too and use many thing in DocumentAccessBridge) On Wed, Jun 13, 2012 at 2:15 PM, David Delbecq <[email protected]> wrote: > Hello, > > i try to test a macro in a maven project created using maven archetype. It > has .test files and an IntegrationTests class. Where running, it crashed due > to nullpointerexception when trying to, probably, find out current user? > > Is ther some configuration i am missing? > > java.lang.NullPointerException: null > at > com.xpn.xwiki.doc.DefaultDocumentAccessBridge.getCurrentUser(DefaultDocumentAccessBridge.java:981) > ~[xwiki-platform-oldcore-3.2.jar:na] > at > org.xwiki.component.internal.UserComponentManager.getKey(UserComponentManager.java:74) > ~[xwiki-platform-component-multi-3.2.jar:na] > at > org.xwiki.component.internal.AbstractGenericComponentManager.getComponentManager(AbstractGenericComponentManager.java:72) > ~[xwiki-platform-component-multi-3.2.jar:na] > at > org.xwiki.component.internal.DelegateComponentManager.lookup(DelegateComponentManager.java:103) > ~[xwiki-platform-component-multi-3.2.jar:na] > at > org.xwiki.component.internal.DelegateComponentManager.lookup(DelegateComponentManager.java:103) > ~[xwiki-platform-component-multi-3.2.jar:na] > at > org.xwiki.rendering.internal.macro.DefaultMacroManager.getMacro(DefaultMacroManager.java:132) > ~[xwiki-rendering-transformation-macro-3.2.jar:na] > at > org.xwiki.rendering.internal.transformation.macro.MacroTransformation.getHighestPriorityMacro(MacroTransformation.java:232) > ~[xwiki-rendering-transformation-macro-3.2.jar:na] > at > org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transformOnce(MacroTransformation.java:152) > ~[xwiki-rendering-transformation-macro-3.2.jar:na] > at > org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transform(MacroTransformation.java:141) > ~[xwiki-rendering-transformation-macro-3.2.jar:na] > at > org.xwiki.rendering.internal.transformation.DefaultTransformationManager.performTransformations(DefaultTransformationManager.java:81) > ~[xwiki-rendering-api-3.2.jar:na] > at > org.xwiki.rendering.test.integration.RenderingTest.runTestInternal(RenderingTest.java:133) > [xwiki-rendering-test-3.2.jar:na] > at > org.xwiki.rendering.test.integration.RenderingTest.execute(RenderingTest.java:103) > [xwiki-rendering-test-3.2.jar:na] > > > David Delbecq > > _______________________________________________ > devs mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/devs -- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

