@Test
public void testRegisterNamespaces() throws Exception {

    Properties namespaces = new Properties();
    namespaces.put("foo", "bar");
    namespaces.put("hocus", "pocus");
    factory.setNamespaces(namespaces);
    Session session = createMock(Session.class);
    Workspace workspace = createMock(Workspace.class);
    NamespaceRegistry namespaceRegistry = createMock(NamespaceRegistry.class);
    // afterPropertiesSet
    expect(repository.login(null, null)).andReturn(session);
    expect(session.getWorkspace()).andReturn(workspace);
    expect(workspace.getNamespaceRegistry()).andReturn(namespaceRegistry);
    expect(namespaceRegistry.getPrefixes()).andReturn(new String[0]);
    // destroy
    namespaceRegistry.registerNamespace("foo", "bar");
    namespaceRegistry.registerNamespace("hocus", "pocus");
    session.logout();
    replay(namespaceRegistry, workspace, session, repository);
    factory.afterPropertiesSet();
    factory.destroy();
    verify(namespaceRegistry, workspace, session);
}