Site service membership API (Java and JavaScript) and associated unit tests

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9012 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-05-06 17:35:32 +00:00
parent 1763e48306
commit 7f192494de
2 changed files with 23 additions and 2 deletions

View File

@@ -129,7 +129,7 @@ public abstract class BaseWebScriptTest extends TestCase
throws IOException
{
MockHttpServletResponse response = BaseWebScriptTest.getServer().submitRequest(method, url, new HashMap<String, String>(), body, contentType);
if (expectedStatus != response.getStatus())
if (expectedStatus > 0 && expectedStatus != response.getStatus())
{
if (response.getStatus() == 500)
{

View File

@@ -24,6 +24,9 @@
*/
package org.alfresco.repo.web.scripts.site;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.util.GUID;
import org.json.JSONArray;
@@ -40,6 +43,23 @@ public class SiteServiceTest extends BaseWebScriptTest
private static final String URL_SITES = "/api/sites";
private static final String URL_SITE = "/api/site/";
private List<String> createdSites = new ArrayList<String>(5);
@Override
protected void tearDown() throws Exception
{
super.tearDown();
// Tidy-up any site's create during the execution of the test
for (String shortName : this.createdSites)
{
deleteRequest(URL_SITE + shortName, 0);
}
// Clear the list
this.createdSites.clear();
}
public void testCreateSite() throws Exception
{
String shortName = GUID.generate();
@@ -66,6 +86,7 @@ public class SiteServiceTest extends BaseWebScriptTest
site.put("description", description);
site.put("isPublic", isPublic);
MockHttpServletResponse response = postRequest(URL_SITES, expectedStatus, site.toString(), "application/json");
this.createdSites.add(shortName);
return new JSONObject(response.getContentAsString());
}