From cd8f9d14c972764e5e14ea43811744652a11dcd2 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 28 Oct 2011 08:09:55 -0400
Subject: [PATCH] Documentation
---
tests/com/gitblit/tests/RpcTests.java | 40 +++++++++++++++++++++++++++++++++++++---
1 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/tests/com/gitblit/tests/RpcTests.java b/tests/com/gitblit/tests/RpcTests.java
index 3c2f61f..637d488 100644
--- a/tests/com/gitblit/tests/RpcTests.java
+++ b/tests/com/gitblit/tests/RpcTests.java
@@ -16,6 +16,8 @@
package com.gitblit.tests;
import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -23,12 +25,13 @@
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.GitBlitException.UnauthorizedException;
+import com.gitblit.Keys;
import com.gitblit.models.FederationModel;
import com.gitblit.models.FederationProposal;
import com.gitblit.models.FederationSet;
import com.gitblit.models.RepositoryModel;
+import com.gitblit.models.ServerSettings;
import com.gitblit.models.ServerStatus;
-import com.gitblit.models.SettingModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.RpcUtils;
@@ -207,12 +210,43 @@
}
public void testSettings() throws Exception {
- Map<String, SettingModel> settings = RpcUtils.getSettings(url, account, password.toCharArray());
+ ServerSettings settings = RpcUtils.getSettings(url, account, password.toCharArray());
assertTrue("No settings were retrieved!", settings != null);
}
-
+
public void testServerStatus() throws Exception {
ServerStatus status = RpcUtils.getStatus(url, account, password.toCharArray());
assertTrue("No status was retrieved!", status != null);
}
+
+ public void testUpdateSettings() throws Exception {
+ Map<String, String> updated = new HashMap<String, String>();
+
+ // grab current setting
+ ServerSettings settings = RpcUtils.getSettings(url, account, password.toCharArray());
+ boolean showSizes = settings.get(Keys.web.showRepositorySizes).getBoolean(true);
+ showSizes = !showSizes;
+
+ // update setting
+ updated.put(Keys.web.showRepositorySizes, String.valueOf(showSizes));
+ boolean success = RpcUtils.updateSettings(updated, "http://localhost:8080/gb", account,
+ password.toCharArray());
+ assertTrue("Failed to update server settings", success);
+
+ // confirm setting change
+ settings = RpcUtils.getSettings(url, account, password.toCharArray());
+ boolean newValue = settings.get(Keys.web.showRepositorySizes).getBoolean(false);
+ assertEquals(newValue, showSizes);
+
+ // restore setting
+ newValue = !newValue;
+ updated.put(Keys.web.showRepositorySizes, String.valueOf(newValue));
+ }
+
+ public void testBranches() throws Exception {
+ Map<String, Collection<String>> branches = RpcUtils.getAllBranches(url, account,
+ password.toCharArray());
+ assertTrue(branches != null);
+ assertTrue(branches.size() > 0);
+ }
}
--
Gitblit v1.9.1