import java.util.Date;\r
import java.util.concurrent.Executors;\r
\r
-import junit.framework.TestCase;\r
-\r
import org.eclipse.jgit.api.CloneCommand;\r
import org.eclipse.jgit.api.Git;\r
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;\r
import org.eclipse.jgit.util.FileUtils;\r
+import org.junit.AfterClass;\r
+import org.junit.BeforeClass;\r
+import org.junit.Test;\r
\r
import com.gitblit.GitBlitServer;\r
\r
-public class GitServletTest extends TestCase {\r
+public class GitServletTest {\r
\r
File folder = new File(GitBlitSuite.REPOSITORIES, "working/ticgit");\r
\r
- int port = 8180;\r
+ static int port = 8180;\r
\r
- int shutdownPort = 8181;\r
+ static int shutdownPort = 8181;\r
\r
- @Override\r
- protected void setUp() throws Exception {\r
+ @BeforeClass\r
+ public static void startGitblit() throws Exception {\r
// Start a Gitblit instance\r
Executors.newSingleThreadExecutor().execute(new Runnable() {\r
public void run() {\r
Thread.sleep(2500);\r
}\r
\r
- @Override\r
- protected void tearDown() throws Exception {\r
+ @AfterClass\r
+ public static void stopGitblit() throws Exception {\r
// Stop Gitblit\r
GitBlitServer.main("--stop", "--shutdownPort", "" + shutdownPort);\r
\r
Thread.sleep(2500);\r
}\r
\r
+ @Test\r
public void testClone() throws Exception {\r
if (folder.exists()) {\r
FileUtils.delete(folder, FileUtils.RECURSIVE);\r
clone.call();\r
}\r
\r
+ @Test\r
public void testAnonymousCommit() throws Exception {\r
Git git = Git.open(folder);\r
File file = new File(folder, "TODO");\r
git.push().setPushAll().call();\r
git.getRepository().close();\r
}\r
- \r
+\r
+ @Test\r
public void testBogusLoginClone() throws Exception {\r
File folder = new File(GitBlitSuite.REPOSITORIES, "working/gitblit");\r
if (folder.exists()) {\r
*/\r
package com.gitblit.tests;\r
\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertTrue;\r
+\r
import java.io.IOException;\r
import java.util.Collection;\r
import java.util.HashMap;\r
import java.util.List;\r
import java.util.Map;\r
+import java.util.concurrent.Executors;\r
\r
-import junit.framework.TestCase;\r
+import org.junit.AfterClass;\r
+import org.junit.BeforeClass;\r
+import org.junit.Test;\r
\r
import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.GitBlitException.UnauthorizedException;\r
+import com.gitblit.GitBlitServer;\r
import com.gitblit.Keys;\r
import com.gitblit.models.FederationModel;\r
import com.gitblit.models.FederationProposal;\r
* @author James Moger\r
* \r
*/\r
-public class RpcTests extends TestCase {\r
+public class RpcTests {\r
+\r
+ static int port = 8180;\r
+ static int shutdownPort = 8181;\r
\r
- String url = "https://localhost:8443";\r
+ String url = "http://localhost:" + port;\r
String account = "admin";\r
String password = "admin";\r
\r
+ @BeforeClass\r
+ public static void startGitblit() throws Exception {\r
+ // Start a Gitblit instance\r
+ Executors.newSingleThreadExecutor().execute(new Runnable() {\r
+ public void run() {\r
+ GitBlitServer.main("--httpPort", "" + port, "--httpsPort", "0", "--shutdownPort",\r
+ "" + shutdownPort, "--repositoriesFolder",\r
+ "\"" + GitBlitSuite.REPOSITORIES.getAbsolutePath() + "\"", "--userService",\r
+ "distrib/users.properties");\r
+ }\r
+ });\r
+\r
+ // Wait a few seconds for it to be running\r
+ Thread.sleep(2500);\r
+ }\r
+\r
+ @AfterClass\r
+ public static void stopGitblit() throws Exception {\r
+ // Stop Gitblit\r
+ GitBlitServer.main("--stop", "--shutdownPort", "" + shutdownPort);\r
+\r
+ // Wait a few seconds for it to be running\r
+ Thread.sleep(2500);\r
+ }\r
+\r
+ @Test\r
public void testListRepositories() throws IOException {\r
Map<String, RepositoryModel> map = RpcUtils.getRepositories(url, null, null);\r
assertTrue("Repository list is null!", map != null);\r
assertTrue("Repository list is empty!", map.size() > 0);\r
}\r
\r
+ @Test\r
public void testListUsers() throws IOException {\r
List<UserModel> list = null;\r
try {\r
assertTrue("User list is empty!", list.size() > 0);\r
}\r
\r
+ @Test\r
public void testUserAdministration() throws IOException {\r
UserModel user = new UserModel("garbage");\r
user.canAdmin = true;\r
return retrievedUser;\r
}\r
\r
+ @Test\r
public void testRepositoryAdministration() throws IOException {\r
RepositoryModel model = new RepositoryModel();\r
model.name = "garbagerepo.git";\r
return retrievedRepository;\r
}\r
\r
+ @Test\r
public void testFederationRegistrations() throws Exception {\r
List<FederationModel> registrations = RpcUtils.getFederationRegistrations(url, account,\r
password.toCharArray());\r
- assertTrue("No federation registrations wre retrieved!", registrations.size() > 0);\r
+ assertTrue("No federation registrations were retrieved!", registrations.size() >= 0);\r
}\r
\r
+ @Test\r
public void testFederationResultRegistrations() throws Exception {\r
List<FederationModel> registrations = RpcUtils.getFederationResultRegistrations(url,\r
account, password.toCharArray());\r
- assertTrue("No federation result registrations were retrieved!", registrations.size() > 0);\r
+ assertTrue("No federation result registrations were retrieved!", registrations.size() >= 0);\r
}\r
\r
+ @Test\r
public void testFederationProposals() throws Exception {\r
List<FederationProposal> proposals = RpcUtils.getFederationProposals(url, account,\r
password.toCharArray());\r
- assertTrue("No federation proposals were retrieved!", proposals.size() > 0);\r
+ assertTrue("No federation proposals were retrieved!", proposals.size() >= 0);\r
}\r
\r
+ @Test\r
public void testFederationSets() throws Exception {\r
List<FederationSet> sets = RpcUtils.getFederationSets(url, account, password.toCharArray());\r
- assertTrue("No federation sets were retrieved!", sets.size() > 0);\r
+ assertTrue("No federation sets were retrieved!", sets.size() >= 0);\r
}\r
\r
+ @Test\r
public void testSettings() throws Exception {\r
ServerSettings settings = RpcUtils.getSettings(url, account, password.toCharArray());\r
assertTrue("No settings were retrieved!", settings != null);\r
}\r
\r
+ @Test\r
public void testServerStatus() throws Exception {\r
ServerStatus status = RpcUtils.getStatus(url, account, password.toCharArray());\r
assertTrue("No status was retrieved!", status != null);\r
}\r
\r
+ @Test\r
public void testUpdateSettings() throws Exception {\r
Map<String, String> updated = new HashMap<String, String>();\r
\r
\r
// update setting\r
updated.put(Keys.web.showRepositorySizes, String.valueOf(showSizes));\r
- boolean success = RpcUtils.updateSettings(updated, "http://localhost:8080/gb", account,\r
- password.toCharArray());\r
+ boolean success = RpcUtils.updateSettings(updated, url, account, password.toCharArray());\r
assertTrue("Failed to update server settings", success);\r
\r
// confirm setting change\r
updated.put(Keys.web.showRepositorySizes, String.valueOf(newValue));\r
}\r
\r
+ @Test\r
public void testBranches() throws Exception {\r
Map<String, Collection<String>> branches = RpcUtils.getBranches(url, account,\r
password.toCharArray());\r