| | |
| | | */
|
| | | package com.gitblit.tests;
|
| | |
|
| | | import static org.junit.Assert.assertEquals;
|
| | | import static org.junit.Assert.assertTrue;
|
| | |
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import java.util.concurrent.atomic.AtomicBoolean;
|
| | |
|
| | | import org.junit.AfterClass;
|
| | | import org.junit.BeforeClass;
|
| | | import org.junit.Test;
|
| | |
|
| | | import com.gitblit.Constants.SearchType;
|
| | | import com.gitblit.models.FeedEntryModel;
|
| | | import com.gitblit.utils.SyndicationUtils;
|
| | |
|
| | | public class SyndicationUtilsTest {
|
| | | public class SyndicationUtilsTest extends GitblitUnitTest {
|
| | |
|
| | | private static final AtomicBoolean started = new AtomicBoolean(false);
|
| | |
|
| | | @BeforeClass
|
| | | public static void startGitblit() throws Exception {
|
| | | started.set(GitBlitSuite.startGitblit());
|
| | | }
|
| | |
|
| | | @AfterClass
|
| | | public static void stopGitblit() throws Exception {
|
| | | if (started.get()) {
|
| | | GitBlitSuite.stopGitblit();
|
| | | }
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void testSyndication() throws Exception {
|
| | |
| | | entries.add(entry);
|
| | | }
|
| | | ByteArrayOutputStream os = new ByteArrayOutputStream();
|
| | | SyndicationUtils.toRSS("http://localhost", "", "Title", "Description", |
| | | SyndicationUtils.toRSS("http://localhost", "", "Title", "Description",
|
| | | entries, os);
|
| | | String feed = os.toString();
|
| | | os.close();
|
| | |
| | | }
|
| | |
|
| | | @Test
|
| | | public void testFeedRead() throws Exception {
|
| | | public void testFeedReadCommits() throws Exception {
|
| | | Set<String> links = new HashSet<String>();
|
| | | for (int i = 0; i < 2; i++) {
|
| | | List<FeedEntryModel> feed = SyndicationUtils.readFeed(GitBlitSuite.url, "ticgit.git",
|
| | |
| | | }
|
| | |
|
| | | @Test
|
| | | public void testFeedReadTags() throws Exception {
|
| | | Set<String> links = new HashSet<String>();
|
| | | for (int i = 0; i < 2; i++) {
|
| | | List<FeedEntryModel> feed = SyndicationUtils.readTags(GitBlitSuite.url, "test/gitective.git",
|
| | | 5, i, GitBlitSuite.account, GitBlitSuite.password.toCharArray());
|
| | | assertTrue(feed != null);
|
| | | assertTrue(feed.size() > 0);
|
| | | assertEquals(5, feed.size());
|
| | | for (FeedEntryModel entry : feed) {
|
| | | links.add(entry.link);
|
| | | }
|
| | | }
|
| | | // confirm we have 10 unique tags
|
| | | assertEquals("Feed pagination failed", 10, links.size());
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void testSearchFeedRead() throws Exception {
|
| | | List<FeedEntryModel> feed = SyndicationUtils
|
| | | .readSearchFeed(GitBlitSuite.url, "ticgit.git", null, "test", null, 5, 0,
|