### Question:
JcrRepositorySource implements RepositorySource, ObjectFactory { public synchronized RepositoryConnection getConnection() throws RepositorySourceException { if (name == null || name.trim().length() == 0) { I18n msg = JcrConnectorI18n.propertyIsRequired; throw new RepositorySourceException(name, msg.text("name")); } if (repositoryJndiName == null || repositoryJndiName.trim().length() == 0) { I18n msg = JcrConnectorI18n.propertyIsRequired; throw new RepositorySourceException(getName(), msg.text("repositoryJndiName")); } if (this.repository == null) { Context context = getContext(); if (context == null) { try { context = new InitialContext(); } catch (NamingException err) { throw new RepositorySourceException(name, err); } } Repository repository = null; Object object = null; try { object = context.lookup(repositoryJndiName); if (object != null) repository = (Repository)object; } catch (ClassCastException err) { I18n msg = JcrConnectorI18n.objectFoundInJndiWasNotRepository; String className = object != null ? object.getClass().getName() : "null"; throw new RepositorySourceException(getName(), msg.text(repositoryJndiName, this.getName(), className), err); } catch (Throwable err) { if (err instanceof RuntimeException) throw (RuntimeException)err; throw new RepositorySourceException(getName(), err); } if (repository == null) { I18n msg = JcrConnectorI18n.repositoryObjectNotFoundInJndi; throw new RepositorySourceException(getName(), msg.text(repositoryJndiName)); } this.repository = repository; } assert this.repository != null; Credentials credentials = getCredentials(); if (credentials == null || (username != null || password != null)) { char[] passwd = this.password != null ? password.toCharArray() : new char[] {}; credentials = new SimpleCredentials(username, passwd); } return new JcrRepositoryConnection(this, repository, credentials); } JcrRepositorySource(); String getName(); void setName( String name ); RepositorySourceCapabilities getCapabilities(); @Description( i18n = JcrConnectorI18n.class, value = "updatesAllowedPropertyDescription" ) @Label( i18n = JcrConnectorI18n.class, value = "updatesAllowedPropertyLabel" ) @Category( i18n = JcrConnectorI18n.class, value = "updatesAllowedPropertyCategory" ) boolean getUpdatesAllowed(); String getRepositoryJndiName(); void setRepositoryJndiName( String repositoryJndiName ); String getUsername(); synchronized void setUsername( String username ); String getPassword(); synchronized void setPassword( String password ); Credentials getCredentials(); void setCredentials( Credentials credentials ); CachePolicy getDefaultCachePolicy(); synchronized void setDefaultCachePolicy( CachePolicy defaultCachePolicy ); int getRetryLimit(); synchronized void setRetryLimit( int limit ); void initialize( RepositoryContext context ); synchronized Reference getReference(); Object getObjectInstance( Object obj,
                                     javax.naming.Name name,
                                     Context nameCtx,
                                     Hashtable<?, ?> environment ); synchronized RepositoryConnection getConnection(); void close(); static final int DEFAULT_RETRY_LIMIT; }### Answer:
@Test public void shouldCreateConnection() throws Exception { connection = source.getConnection(); assertThat(connection, is(notNullValue())); }