-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
one more attempt to fix broken tests. rel #6
- Loading branch information
Gustavo
committed
Jul 18, 2013
1 parent
4c55a94
commit 3d8de46
Showing
14 changed files
with
130 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package br.ufpe.cin.groundhog; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
import org.junit.runners.Suite.SuiteClasses; | ||
|
||
import br.ufpe.cin.groundhog.answers.ToGetProjectsWithMoreThanOneLanguage; | ||
import br.ufpe.cin.groundhog.answers.ToGetTopMostUsedLanguages; | ||
|
||
@RunWith(Suite.class) | ||
@SuiteClasses({ ToGetProjectsWithMoreThanOneLanguage.class, | ||
ToGetTopMostUsedLanguages.class }) | ||
public class AllAnswers { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/java/test/br/ufpe/cin/groundhog/answers/ToGetProjectsWithMoreThanOneLanguage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package br.ufpe.cin.groundhog.answers; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.google.inject.Guice; | ||
import com.google.inject.Injector; | ||
|
||
import br.ufpe.cin.groundhog.Language; | ||
import br.ufpe.cin.groundhog.Project; | ||
import br.ufpe.cin.groundhog.http.HttpModule; | ||
import br.ufpe.cin.groundhog.search.SearchGitHub; | ||
import br.ufpe.cin.groundhog.search.SearchModule; | ||
|
||
public class ToGetProjectsWithMoreThanOneLanguage { | ||
|
||
private SearchGitHub searchGitHub; | ||
|
||
@Before | ||
public void init() { | ||
Injector injector = Guice.createInjector(new SearchModule(), new HttpModule()); | ||
searchGitHub = injector.getInstance(SearchGitHub.class); | ||
} | ||
|
||
@Test | ||
public void testProjectsWIthMoreThanOneLanguage() throws IOException{ | ||
List<Project> rawData = searchGitHub.getAllProjects(1, 8); | ||
|
||
List<Project> projects = new ArrayList<Project>(); | ||
for (Project project : rawData) { | ||
List<Language> languages = searchGitHub.fetchProjectLanguages(project); | ||
|
||
if(languages.size() > 1){ | ||
projects.add(project); | ||
} | ||
} | ||
|
||
float percent = ((Float.intBitsToFloat(projects.size())/Float.intBitsToFloat(rawData.size()))*100); | ||
|
||
String result = "There are " + rawData.size() + " projects in github \n" + | ||
"There are " + projects.size() +" projects with more than one language \n" + | ||
"This is " + percent + "% of the total"; | ||
|
||
System.out.println(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 10 additions & 26 deletions
36
src/java/test/br/ufpe/cin/groundhog/crawler/CrawlGitHubTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,41 @@ | ||
package br.ufpe.cin.groundhog.crawler; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.Future; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import br.ufpe.cin.groundhog.Project; | ||
import br.ufpe.cin.groundhog.http.HttpModule; | ||
import br.ufpe.cin.groundhog.SCM; | ||
import br.ufpe.cin.groundhog.scmclient.GitClient; | ||
import br.ufpe.cin.groundhog.scmclient.ScmModule; | ||
import br.ufpe.cin.groundhog.search.SearchGitHub; | ||
import br.ufpe.cin.groundhog.search.SearchModule; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.google.common.io.Files; | ||
import com.google.inject.Guice; | ||
import com.google.inject.Injector; | ||
|
||
public class CrawlGitHubTest { | ||
|
||
private SearchGitHub searchGitHub; | ||
private GitClient gitClient; | ||
|
||
@Before | ||
public void setup() { | ||
Injector injector = Guice.createInjector(new SearchModule(), new ScmModule(), new HttpModule()); | ||
searchGitHub = injector.getInstance(SearchGitHub.class); | ||
Injector injector = Guice.createInjector(new ScmModule()); | ||
gitClient = injector.getInstance(GitClient.class); | ||
} | ||
|
||
@Test | ||
public void testCrawlGithub() { | ||
long time = System.nanoTime(); | ||
|
||
try { | ||
|
||
Project playframework = searchGitHub.getProjects("playframework", 1,-1).get(0); | ||
List<Project> projects = Arrays.asList(playframework); | ||
CrawlGitHub crawl = new CrawlGitHub(gitClient, Files.createTempDir()); | ||
List<Future<File>> fs = crawl.downloadProjects(projects); | ||
for (Future<File> f : fs) { | ||
File file = f.get(); | ||
Assert.assertNotNull(file); | ||
} | ||
|
||
System.out.printf("Elapsed: %.2f", | ||
(System.nanoTime() - time) / 1000000000.0); | ||
|
||
} catch (Exception e) { | ||
Assert.fail(); | ||
public void testCrawlGithub() throws InterruptedException, ExecutionException { | ||
CrawlGitHub crawl = new CrawlGitHub(gitClient, Files.createTempDir()); | ||
List<Future<File>> fs = crawl.downloadProjects(Lists.newArrayList(new Project("modules.playframework.org", "", SCM.GIT, "[email protected]:playframework/modules.playframework.org.git"))); | ||
for (Future<File> f : fs) { | ||
File file = f.get(); | ||
Assert.assertNotNull(file); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.