*/
protected Graph graphFor( String sourceName,
String workspaceName ) {
CheckArg.isNotNull(sourceName, "sourceName");
CheckArg.isNotNull(workspaceName, "workspaceName");
InMemoryRepositorySource source = sources.get(sourceName);
if (source == null) {
// Add a new source with this name ...
source = new InMemoryRepositorySource();
source.setName(sourceName);
sources.put(sourceName, source);
final InMemoryRepositorySource newSource = source;
// Stub the repository connection factory to return a new connection for this source ...
stub(connectionFactory.createConnection(sourceName)).toAnswer(new Answer<RepositoryConnection>() {
public RepositoryConnection answer( InvocationOnMock invocation ) throws Throwable {
return newSource.getConnection();
}
});
}
// Make sure there's a workspace for it ...
Graph sourceGraph = Graph.create(sourceName, connectionFactory, context);