use of org.eclipse.jgit.internal.storage.dfs.DfsRepository in project gitiles by GerritCodeReview.
the class TestGitilesServlet method create.
/**
* Create a servlet backed by a single test repository.
*
* <p>The servlet uses the same filter lists as a real servlet, but only knows about a single
* repo, having the name returned by {@link
* org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription#getRepositoryName()}. Pass a
* {@link FakeHttpServletRequest} and {@link FakeHttpServletResponse} to the servlet's {@code
* service} method to test.
*
* @param repo the test repo backing the servlet.
* @param gitwebRedirect optional redirect filter for gitweb URLs.
* @return a servlet.
*/
public static GitilesServlet create(final TestRepository<DfsRepository> repo, GitwebRedirectFilter gitwebRedirect) throws ServletException {
final String repoName = repo.getRepository().getDescription().getRepositoryName();
GitilesServlet servlet = new GitilesServlet(new Config(), new DefaultRenderer(GitilesServlet.STATIC_PREFIX, ImmutableList.<URL>of(), repoName + " test site"), TestGitilesUrls.URLS, new TestGitilesAccess(repo.getRepository()), new RepositoryResolver<HttpServletRequest>() {
@Override
public Repository open(HttpServletRequest req, String name) throws RepositoryNotFoundException {
if (!repoName.equals(name)) {
throw new RepositoryNotFoundException(name);
}
return repo.getRepository();
}
}, null, null, null, gitwebRedirect);
servlet.init(new ServletConfig() {
@Override
public String getInitParameter(String name) {
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return Collections.enumeration(ImmutableList.<String>of());
}
@Override
public ServletContext getServletContext() {
return null;
}
@Override
public String getServletName() {
return TestGitilesServlet.class.getName();
}
});
return servlet;
}
use of org.eclipse.jgit.internal.storage.dfs.DfsRepository in project gitiles by GerritCodeReview.
the class ServletTest method setUp.
@Before
public void setUp() throws Exception {
MockSystemReader mockSystemReader = new MockSystemReader();
SystemReader.setInstance(mockSystemReader);
DfsRepository r = new InMemoryRepository(new DfsRepositoryDescription("repo"));
repo = new TestRepository<>(r, new RevWalk(r), mockSystemReader);
servlet = TestGitilesServlet.create(repo);
}
Aggregations