Fixed InviteSender tests broken by r32893.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32931 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2011-12-21 19:20:09 +00:00
parent 047d9b2fff
commit 6bf23e2176
2 changed files with 19 additions and 12 deletions

View File

@@ -174,9 +174,8 @@ public class InviteSender
private Map<String, String> buildArgs(Map<String, String> properties, NodeRef inviter, NodeRef invitee)
{
String params = buildUrlParamString(properties);
String serverPath = ensureEndsWithSlash(properties.get(wfVarServerPath));
String acceptLink = serverPath + properties.get(wfVarAcceptUrl) + params;
String rejectLink = serverPath + properties.get(wfVarRejectUrl) + params;
String acceptLink = makeLink(properties.get(wfVarServerPath), properties.get(wfVarAcceptUrl), params);
String rejectLink = makeLink(properties.get(wfVarServerPath), properties.get(wfVarRejectUrl), params);
Map<String, String> args = new HashMap<String, String>();
args.put("inviteePersonRef", invitee.toString());
@@ -190,9 +189,12 @@ public class InviteSender
return args;
}
protected static String ensureEndsWithSlash(String thePath)
protected String makeLink(String location, String endpoint, String queryParams)
{
return thePath.endsWith("/")?thePath:thePath+"/";
location = location.endsWith("/") ? location : location + "/";
endpoint = endpoint.startsWith("/") ? endpoint.substring(1) : endpoint;
queryParams = queryParams.startsWith("?") ? queryParams : "?" + queryParams;
return location + endpoint + queryParams;
}
private String getRoleName(Map<String, String> properties)

View File

@@ -231,12 +231,17 @@ public class InviteSenderTest extends TestCase
public void testValidServerPath() throws Exception
{
String validPath = "test://test/path/";
String serverPath = InviteSender.ensureEndsWithSlash("test://test/path");
assertEquals(validPath,serverPath);
serverPath = InviteSender.ensureEndsWithSlash("test://test/path/");
assertEquals(validPath,serverPath);
String validPath = "test://test/path/accept?hello";
String link = sender.makeLink("test://test/path", "accept", "hello");
assertEquals(validPath, link);
link = sender.makeLink("test://test/path/", "accept", "hello");
assertEquals(validPath, link);
link = sender.makeLink("test://test/path", "/accept", "hello");
assertEquals(validPath, link);
link = sender.makeLink("test://test/path/", "/accept", "hello");
assertEquals(validPath, link);
link = sender.makeLink("test://test/path", "/accept", "?hello");
assertEquals(validPath, link);
}
protected static String ensureEndsWithSlash(String thePath)