public class GitCodeHistoryTest {

	private SFCodeHistory  codeHistory;
	private File file;
	private Date calendar;
	
	@Before
	public void setup(){
		file = new File("C:\\Users\\fjsj\\Downloads\\EponaProjects\\playframework");
		calendar = new GregorianCalendar(2012, 5, 23).getTime();
	}
	
	@Test
	public void main() throws Exception {
		if(file.exists()){
			File result = codeHistory.checkoutToDate("javacv", file, calendar);
			assertNotNull(result);
		}
	}
} @Deprecated
public class SFCodeHistoryTest {
	
	private GitCodeHistory gitCodeHistory;
	private File file;
	private Date calendar;
	
	@Before
	public void setup(){
		file = new File("C:\\Users\\fjsj\\Downloads\\EponaProjects\\playframework");
		calendar = new GregorianCalendar(2012, 5, 23).getTime();
	}
	
	@Test(expected=AssertionError.class)
	public void main() throws Exception {
		assertTrue(file.exists());
		File result = gitCodeHistory.checkoutToDate("javacv", file, calendar);
		assertNotNull(result);
	}
} public class CrawlGitHubTest {

	private GitClient gitClient;

	@Before
	public void setup() {
		Injector injector = Guice.createInjector(new ScmModule());
		this.gitClient = injector.getInstance(GitClient.class);
	}

	@Test
	public void testCrawlGithub() throws InterruptedException, ExecutionException {
		CrawlGitHub crawl = new CrawlGitHub(gitClient, Files.createTempDir());
		Project p = new Project("modules.playframework.org", "description", "https://github.com/spgroup/groundhog.git");
		List<Future<File>> fs = crawl.asyncDownloadProjects(Lists.newArrayList(p));
		for (Future<File> f : fs) {
			File file = f.get();
			Assert.assertNotNull(file);
		}
	}
} @Deprecated
public class CrawlGoogleCodeTest {

	private GitClient gitClient;

	@Before
	public void setup() {
		Injector injector = Guice.createInjector(new ScmModule());
		gitClient = injector.getInstance(GitClient.class);
	}

	/**
	 * methods from google-code is not supported anymore
	 */
	@Test
	public void testCrawlGithub() {
		try {
			Project project = new Project("fake", "fake", "http://googletransitdatafeed.googlecode.com/svn/trunk/");
			CrawlGoogleCode crawl = new CrawlGoogleCode(gitClient, Files.createTempDir());
			
			List<Future<File>> fs = crawl.asyncDownloadProjects(Arrays.asList(project));
			for (Future<File> f : fs) {
				File file = f.get();
				Assert.assertNotNull(file);
			}
			
		} catch (Exception e) {
			Assert.assertTrue(true);
		}
	}
} @Deprecated
public class CrawlSourceForgeTest {

	private SearchSourceForge searchSourceForge;
	private Requests requests;

	@Before
	public void setup() {
		Injector injector = Guice.createInjector(new SearchModule(), new HttpModule());
		searchSourceForge = injector.getInstance(SearchSourceForge.class);
		requests = injector.getInstance(Requests.class);
	}

//	@Test
	public void testCrawlGithub() {
		try {
			Project project = searchSourceForge.getProjects("geom-java", 1, -1).get(0);
			List<Project> projects = Arrays.asList(project);
			
			CrawlSourceForge crawl = new CrawlSourceForge(requests, Files.createTempDir());
			List<Future<File>> fs = crawl.asyncDownloadProjects(projects);
			for (Future<File> f : fs) {
				File file = f.get();
				Assert.assertNotNull(file);
			}
			
		} catch (Exception e) {
			Assert.fail();
		}
	}
} public class OptionsTest {

	@Test
	public void testJsonInputFile() {
		CmdOptions op = new CmdOptions();
		op.setInputFile(new File("groundhog.json"));
		Assert.assertNotNull(op.getInputFile());
	}
} public class SearchGitHubTest {
	
	private SearchGitHub searchGitHub;
	private Project fakeProject;

	@Before
	public void setup() {
		Injector injector = Guice.createInjector(new SearchModule(), new HttpModule());
		searchGitHub = injector.getInstance(SearchGitHub.class);
		User user = new User("elixir-lang");
		fakeProject = new Project("elixir", "", "git@github.com:elixir-lang/elixir.git");
		fakeProject.setUser(user);
	}
	
	@Test
	public void testSearchByProjectName() {
		try {			
			List<Project> projects = searchGitHub.getProjects("groundhog", 1, SearchGitHub.INFINITY);
			searchGitHub.getProjectLanguages(projects.get(0));
			Assert.assertNotNull(projects);
		} catch (Exception e) {
			e.printStackTrace();
			Assert.fail();
		}
	}
	
	@Test
	public void testFetchByProjectLanguages() {
		try {
			List<Language> langs = searchGitHub.getProjectLanguages(fakeProject);
			Assert.assertNotNull(langs);
		} catch (Exception e) {
			e.printStackTrace();
			Assert.fail();
		}
	}
	
	@Test
	public void testGetAllProjects() {
		try {
			List<Project> projects = searchGitHub.getAllProjects(0, 5);
			Assert.assertNotNull(projects);
		} catch (Exception e) {
			e.printStackTrace();
			Assert.fail();
		}
	}
	
	@Test
	public void testGetProjectsByLanguage() {
		try {
			List<Project> projects = searchGitHub.getAllProjectsByLanguage("java");
			Assert.assertNotNull(projects);
		} catch (Exception e) {
			e.printStackTrace();
			Assert.fail();
		}
	}
	
	@Test
	public void testGetAllProjectCommits() {
		try {

			Project project = new Project(new User("github"),"android");
		 
			List<Commit> commits = searchGitHub.getAllProjectCommits(project);
			
			Assert.assertNotNull(commits);	
		} catch (Exception e) {
			e.printStackTrace();
			Assert.fail();
		}
	}
	
	@Test
	public void testGetAllProjectContributors() {
		try {
			
			/*Sanity test, if the list of contributors is null, something is wrong*/
			Project project = new Project(new User("twitter"), "ambrose");
			List<Contributor> contributors = searchGitHub.getAllProjectContributors(project);
			Assert.assertNotNull(contributors);
			
			
			
			
		} catch (Exception e) {
			e.printStackTrace();
			Assert.fail();
		}
	}
	
	@Test
	public void testGetAllProjectReleases() {
		try {
			User u = new User("twbs");
			Project project = new Project(u, "bootstrap");
			
			List<Release> releases = searchGitHub.getAllProjectReleases(project);
						
			Assert.assertNotNull(releases);
			
			
			
		} catch (Exception e) {
			e.printStackTrace();
			Assert.fail();
		}
	}
} @Deprecated
public class SearchGoogleCodeTest {
	private SearchGoogleCode searchGoogleCode;

	@Before
	public void setup() {
		Injector injector = Guice.createInjector(new SearchModule(), new HttpModule());
		searchGoogleCode = injector.getInstance(SearchGoogleCode.class);
	}

	public void testSimpleSearch() {
		List<Project> projects = searchGoogleCode.getProjects("java", 1, -1);
		Assert.assertNotNull(projects);
	}
} @Deprecated
public class SearchSourceForgeTest {
	private SearchSourceForge searchSourceForge;

	@Before
	public void setup() {
		Injector injector = Guice.createInjector(new SearchModule(), new HttpModule());
		searchSourceForge = injector.getInstance(SearchSourceForge.class);
	}

	@Test
	public void testSimpleSearch() {
		List<Project> projects = searchSourceForge.getProjects("", 1, -1);
		Assert.assertNotNull(projects);
	}
} public class FileUtilTest {

	@Test
	public void testIsFile() throws IOException {
		File files[] = new File(".").listFiles();

		for (File file : files) {
			boolean is = FileUtil.getInstance().isTextFile(file);
			System.out.println(is + ", " + file.getAbsolutePath());
		}
	}
}
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import br.ufpe.cin.groundhog.codehistory.GitCodeHistoryTest;
import br.ufpe.cin.groundhog.codehistory.SFCodeHistoryTest;
import br.ufpe.cin.groundhog.crawler.CrawlGitHubTest;
import br.ufpe.cin.groundhog.crawler.CrawlGoogleCodeTest;
import br.ufpe.cin.groundhog.crawler.CrawlSourceForgeTest;
import br.ufpe.cin.groundhog.main.OptionsTest;
import br.ufpe.cin.groundhog.search.SearchGitHubTest;
import br.ufpe.cin.groundhog.search.SearchGoogleCodeTest;
import br.ufpe.cin.groundhog.search.SearchSourceForgeTest;
import br.ufpe.cin.groundhog.util.FileUtilTest;
package br.ufpe.cin.groundhog;



@RunWith(Suite.class)
@SuiteClasses({ GitCodeHistoryTest.class, SFCodeHistoryTest.class,
		CrawlGitHubTest.class, CrawlGoogleCodeTest.class,
		CrawlSourceForgeTest.class, OptionsTest.class,
		SearchGoogleCodeTest.class, SearchSourceForgeTest.class,
		SearchGitHubTest.class, FileUtilTest.class, EntityTest.class })