use of javax.jcr.Repository in project jackrabbit by apache.
the class RepositoryFactoryImplTest method testGetSpi2davexRepository.
public void testGetSpi2davexRepository() throws RepositoryException {
Map<String, String> parameters = Collections.singletonMap("org.apache.jackrabbit.spi.RepositoryServiceFactory", "org.apache.jackrabbit.spi2davex.Spi2davexRepositoryServiceFactory");
try {
Repository repo = factory.getRepository(parameters);
assertNotNull(repo);
} catch (RepositoryException e) {
// factory is working correctly, it is safe to ignore them.
if (!(ConnectException.class.isInstance(e.getCause()) || DavException.class.isInstance(e.getCause()))) {
throw e;
}
}
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class RepositoryFactoryImplTest method testGetDefaultRepository.
public void testGetDefaultRepository() throws RepositoryException {
Repository repo = factory.getRepository(null);
assertNotNull(repo);
assertEquals("Jackrabbit", repo.getDescriptor(Repository.REP_NAME_DESC));
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class RepositoryFactoryImplTest method testGetRepositoryFromServiceFactory.
public void testGetRepositoryFromServiceFactory() throws RepositoryException {
Map<String, RepositoryServiceFactory> parameters = Collections.singletonMap("org.apache.jackrabbit.spi.RepositoryServiceFactory", RepositoryServiceFactoryImpl.INSTANCE);
Repository repo = factory.getRepository(parameters);
assertNotNull(repo);
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class RepositoryFactoryImplTest method testGetRepositoryFromRepositoryConfig.
public void testGetRepositoryFromRepositoryConfig() throws RepositoryException {
Map<String, RepositoryConfig> parameters = Collections.singletonMap("org.apache.jackrabbit.jcr2spi.RepositoryConfig", RepositoryConfigImpl.INSTANCE);
Repository repo = factory.getRepository(parameters);
assertNotNull(repo);
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class FilterRepositoryFactory method getRepository.
/**
* Looks up and returns a repository bound in the servlet context of
* the given filter.
*
* @return repository from servlet context
* @throws RepositoryException if the repository is not available
*/
public Repository getRepository() throws RepositoryException {
String name = config.getInitParameter(Repository.class.getName());
if (name == null) {
name = Repository.class.getName();
}
ServletContext context = config.getServletContext();
Object repository = context.getAttribute(name);
if (repository instanceof Repository) {
return (Repository) repository;
} else if (repository != null) {
throw new RepositoryException("Invalid repository: Attribute " + name + " in servlet context " + context.getServletContextName() + " is an instance of " + repository.getClass().getName());
} else {
throw new RepositoryException("Repository not found: Attribute " + name + " does not exist in servlet context " + context.getServletContextName());
}
}
Aggregations