@Test public void testWithAndWithoutXWikiContext() throws Exception { XWikiContext stubContext = new XWikiContext(); when(this.stubContextProvider.createStubContext()).thenReturn(stubContext); final ExecutionContext daemonContext = new ExecutionContext(); this.initializer.initialize(daemonContext); XWikiContext daemonXcontext = (XWikiContext) daemonContext.getProperty("xwikicontext"); assertNotNull(daemonXcontext); }
@Override public void initialize(ExecutionContext context) throws ExecutionContextException { if (!context.hasProperty(XWikiContext.EXECUTIONCONTEXT_KEY)) { XWikiContext stubContext = this.stubContextProvider.createStubContext(); if (stubContext != null) { stubContext.declareInExecutionContext(context); if (this.container.getRequest() == null) { this.container.setRequest(new ServletRequest(stubContext.getRequest())); } if (this.container.getResponse() == null) { this.container.setResponse(new ServletResponse(stubContext.getResponse())); } } } }
XWikiStubContextInitializer implements ExecutionContextInitializer { @Override public void initialize(ExecutionContext context) throws ExecutionContextException { if (!context.hasProperty(XWikiContext.EXECUTIONCONTEXT_KEY)) { XWikiContext stubContext = this.stubContextProvider.createStubContext(); if (stubContext != null) { stubContext.declareInExecutionContext(context); if (this.container.getRequest() == null) { this.container.setRequest(new ServletRequest(stubContext.getRequest())); } if (this.container.getResponse() == null) { this.container.setResponse(new ServletResponse(stubContext.getResponse())); } } } } }
XWikiStubContextInitializer implements ExecutionContextInitializer { @Override public void initialize(ExecutionContext context) throws ExecutionContextException { if (!context.hasProperty(XWikiContext.EXECUTIONCONTEXT_KEY)) { XWikiContext stubContext = this.stubContextProvider.createStubContext(); if (stubContext != null) { stubContext.declareInExecutionContext(context); if (this.container.getRequest() == null) { this.container.setRequest(new ServletRequest(stubContext.getRequest())); } if (this.container.getResponse() == null) { this.container.setResponse(new ServletResponse(stubContext.getResponse())); } } } }  }
XWikiStubContextInitializer implements ExecutionContextInitializer { @Override public void initialize(ExecutionContext context) throws ExecutionContextException { if (!context.hasProperty(XWikiContext.EXECUTIONCONTEXT_KEY)) { XWikiContext stubContext = this.stubContextProvider.createStubContext(); if (stubContext != null) { stubContext.declareInExecutionContext(context); if (this.container.getRequest() == null) { this.container.setRequest(new ServletRequest(stubContext.getRequest())); } if (this.container.getResponse() == null) { this.container.setResponse(new ServletResponse(stubContext.getResponse())); } } } }  @Override void initialize(ExecutionContext context); }
XWikiStubContextInitializer implements ExecutionContextInitializer { @Override public void initialize(ExecutionContext context) throws ExecutionContextException { if (!context.hasProperty(XWikiContext.EXECUTIONCONTEXT_KEY)) { XWikiContext stubContext = this.stubContextProvider.createStubContext(); if (stubContext != null) { stubContext.declareInExecutionContext(context); if (this.container.getRequest() == null) { this.container.setRequest(new ServletRequest(stubContext.getRequest())); } if (this.container.getResponse() == null) { this.container.setResponse(new ServletResponse(stubContext.getResponse())); } } } }  @Override void initialize(ExecutionContext context);  }