@Test
public void testWorkspace() {

    String[] names = {"foo", "", "baz", "a"};
    JcrRepository mockRepo = mock(JcrRepository.class);
    Map<String, JcrRepository> jrs = new HashMap<String, JcrRepository>();
    for (String name : names) {
        jrs.put(name, mockRepo);
    }
    JcrService js = new JcrService(jrs);
    js.setCallContext(mock(CallContext.class));
    js.login("foo");
    verify(mockRepo).login(null, null);
    js.login("foo:");
    verify(mockRepo, times(2)).login(null, null);
    js.login("foo:bar");
    verify(mockRepo).login(any(Credentials.class), eq("bar"));
    js.login(":quux");
    verify(mockRepo).login(any(Credentials.class), eq("quux"));
    js.login("a:b:c");
    verify(mockRepo).login(any(Credentials.class), eq("b"));
}