### Question:
JackrabbitRepositorySource extends JcrRepositorySource { @Override public RepositoryConnection getConnection() throws RepositorySourceException { if (null == url || 0 == url.trim().length()) { I18n msg = JcrConnectorI18n.propertyIsRequired; throw new RepositorySourceException(url, msg.text("url")); } try { setRepository(getRepositoryFactory().createRepository(url)); } catch (RepositoryException e) { e.printStackTrace(); } Credentials credentials = getCredentialsFactory().createCredentials(getUsername(), getPassword()); return getRepositoryConnectionFactory().createRepositoryConnection(this, getRepository(), credentials); }  @Override synchronized Reference getReference(); @Override void initialize( RepositoryContext context ); @Override RepositoryConnection getConnection(); @Override RepositorySourceCapabilities getCapabilities(); String getUrl(); void setUrl( String url );  }### Answer:
@Test( expected = RepositorySourceException.class ) public void shouldThrowExceptionWhenTryingToGetAConnectionWithParameterUrlNull() throws Exception { repositorySource.getConnection(); }
@Test public void shouldThrowALocalizedExceptionWhenUrlPropertyIsNotDefined() throws Exception { try { repositorySource.getConnection(); fail("Should throw an exception"); } catch (RepositorySourceException rse) { String message = rse.getMessage(); assertEquals("The url property is required but has no value", message); } }
@Test public void shouldReturnAJackrabbitRepositoryConnectionUsingAllInjectedFactories() throws Exception { JackrabbitRepositorySource jackrabbitRepositorySource = setupJackrabbitRepositorySource(); jackrabbitRepositorySource.getConnection(); verify(mockedRepositoryFactory).createRepository("http: verify(mockedCredentialsFactory).createCredentials("scott", "tiger"); }
@Test public void shouldAllowMultipleConnectionsToBeOpenAtTheSameTime() throws Exception { JackrabbitRepositorySource jackrabbitRepositorySource = setupJackrabbitRepositorySource(); List<RepositoryConnection> connections = new ArrayList<RepositoryConnection>(); try { for (int i = 0; i != 10; ++i) { RepositoryConnection conn = jackrabbitRepositorySource.getConnection(); assertThat(conn, is(notNullValue())); connections.add(conn); } } finally { for (RepositoryConnection conn : connections) { if (conn != null) { try { conn.close(); } catch (Throwable t) { t.printStackTrace(); } } } } }