Skip to content
Snippets Groups Projects
Commit ff081f6d authored by tmortagne's avatar tmortagne
Browse files

[misc] Fix test

parent 1cc41268
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
import org.junit.Assert; import org.junit.Assert;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.xwiki.component.util.DefaultParameterizedType;
import org.xwiki.context.Execution; import org.xwiki.context.Execution;
import org.xwiki.context.ExecutionContext; import org.xwiki.context.ExecutionContext;
import org.xwiki.script.ScriptContextManager; import org.xwiki.script.ScriptContextManager;
...@@ -79,7 +78,7 @@ public void getVelocityContextUpdatesXContext() throws Exception ...@@ -79,7 +78,7 @@ public void getVelocityContextUpdatesXContext() throws Exception
executionContext.newProperty("velocityContext").initial(velocityContext).inherited().cloneValue().declare(); executionContext.newProperty("velocityContext").initial(velocityContext).inherited().cloneValue().declare();
XWikiContext mockContext = mock(XWikiContext.class); XWikiContext mockContext = mock(XWikiContext.class);
Provider<XWikiContext> xcontextProvider = this.mocker.getInstance(XWikiContext.TYPE_PROVIDER); Provider<XWikiContext> xcontextProvider = this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
when(xcontextProvider.get()).thenReturn(mockContext); when(xcontextProvider.get()).thenReturn(mockContext);
this.mocker.getComponentUnderTest().getVelocityContext(); this.mocker.getComponentUnderTest().getVelocityContext();
...@@ -95,7 +94,7 @@ public void getVelocityEngineWhenNoVelocityEngineInCache() throws Exception ...@@ -95,7 +94,7 @@ public void getVelocityEngineWhenNoVelocityEngineInCache() throws Exception
when(execution.getContext()).thenReturn(executionContext); when(execution.getContext()).thenReturn(executionContext);
XWikiContext xwikiContext = mock(XWikiContext.class); XWikiContext xwikiContext = mock(XWikiContext.class);
Provider<XWikiContext> xcontextProvider = this.mocker.getInstance(XWikiContext.TYPE_PROVIDER); Provider<XWikiContext> xcontextProvider = this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
when(xcontextProvider.get()).thenReturn(xwikiContext); when(xcontextProvider.get()).thenReturn(xwikiContext);
com.xpn.xwiki.XWiki xwiki = mock(com.xpn.xwiki.XWiki.class); com.xpn.xwiki.XWiki xwiki = mock(com.xpn.xwiki.XWiki.class);
when(xwikiContext.getWiki()).thenReturn(xwiki); when(xwikiContext.getWiki()).thenReturn(xwiki);
...@@ -110,10 +109,7 @@ public void getVelocityEngineWhenNoVelocityEngineInCache() throws Exception ...@@ -110,10 +109,7 @@ public void getVelocityEngineWhenNoVelocityEngineInCache() throws Exception
VelocityEngine velocityEngine = mock(VelocityEngine.class); VelocityEngine velocityEngine = mock(VelocityEngine.class);
when(velocityFactory.createVelocityEngine(eq("default"), any(Properties.class))).thenReturn(velocityEngine); when(velocityFactory.createVelocityEngine(eq("default"), any(Properties.class))).thenReturn(velocityEngine);
TemplateManager templates = mock(TemplateManager.class); this.mocker.registerMockComponent(TemplateManager.class);
Provider<TemplateManager> templatesProvider = this.mocker.getInstance(new DefaultParameterizedType(null, Provider.class,
TemplateManager.class));
when(templatesProvider.get()).thenReturn(templates);
Assert.assertSame(velocityEngine, this.mocker.getComponentUnderTest().getVelocityEngine()); Assert.assertSame(velocityEngine, this.mocker.getComponentUnderTest().getVelocityEngine());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment