/**
   * {@inheritDoc}
   *
   * @see com.xpn.xwiki.test.AbstractBridgedXWikiComponentTestCase#setUp()
   */
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    XWikiConfig config = new XWikiConfig();

    Mock mockServletContext = mock(ServletContext.class);
    ByteArrayInputStream bais =
        new ByteArrayInputStream("code=wiki:code:type:content".getBytes("UTF-8"));
    mockServletContext
        .stubs()
        .method("getResourceAsStream")
        .with(eq("/templates/macros.txt"))
        .will(returnValue(bais));
    mockServletContext
        .stubs()
        .method("getResourceAsStream")
        .with(eq("/WEB-INF/oscache.properties"))
        .will(returnValue(new ByteArrayInputStream("".getBytes("UTF-8"))));
    mockServletContext
        .stubs()
        .method("getResourceAsStream")
        .with(eq("/WEB-INF/oscache-local.properties"))
        .will(returnValue(new ByteArrayInputStream("".getBytes("UTF-8"))));
    XWikiServletContext engineContext =
        new XWikiServletContext((ServletContext) mockServletContext.proxy());

    xwiki =
        new XWiki(config, getContext(), engineContext, false) {
          public String getSkin(XWikiContext context) {
            return "skin";
          }

          public String getXWikiPreference(
              String prefname, String defaultValue, XWikiContext context) {
            return defaultValue;
          }

          public String getSpacePreference(
              String prefname, String defaultValue, XWikiContext context) {
            return defaultValue;
          }

          protected void registerWikiMacros() {}

          public XWikiRightService getRightService() {
            return new XWikiRightServiceImpl() {
              public boolean hasProgrammingRights(XWikiDocument doc, XWikiContext context) {
                return true;
              }
            };
          }
        };
    xwiki.setVersion("1.0");

    // Ensure that no Velocity Templates are going to be used when executing Velocity since
    // otherwise
    // the Velocity init would fail (since by default the macros.vm templates wouldn't be found as
    // we're
    // not providing it in our unit test resources).
    xwiki.getConfig().setProperty("xwiki.render.velocity.macrolist", "");

    this.engine = (DefaultXWikiRenderingEngine) xwiki.getRenderingEngine();

    // Make sure the wiki in the context will say that we have programming permission.
    getContext().setWiki(this.xwiki);
  }