@Override
  protected void registerComponents() throws Exception {
    super.registerComponents();

    // register the IO mockups
    setup = new AnnotationsMockSetup(getComponentManager(), new TestDocumentFactory());
    setup.setupExpectations(docName);

    // mock the document name serializer to return the document name as the reference to be able to
    // get the
    // documents from the factory
    serializerMock = setup.getMockery().mock(EntityReferenceSerializer.class);
    // register
    DefaultComponentDescriptor<EntityReferenceSerializer> ersDesc =
        new DefaultComponentDescriptor<EntityReferenceSerializer>();
    ersDesc.setRoleType(EntityReferenceSerializer.TYPE_STRING);
    getComponentManager().registerComponent(ersDesc, serializerMock);
    // and setup the mock
    setup
        .getMockery()
        .checking(
            new Expectations() {
              {
                allowing(serializerMock)
                    .serialize(with(any(EntityReference.class)), with(any(Object.class)));
                will(
                    new Action() {
                      public void describeTo(Description description) {
                        description.appendText("Gets the serialization of a reference");
                      }

                      public Object invoke(Invocation invocation) throws Throwable {
                        EntityReference documentRef =
                            (org.xwiki.model.reference.EntityReference) invocation.getParameter(0);
                        // extract the document part and return it
                        if (documentRef.getType() != EntityType.DOCUMENT) {
                          throw new Exception("Expected document reference but got " + documentRef);
                        }
                        return documentRef.getName();
                      }
                    });
              }
            });
  }