Fixed up blog service test

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10398 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-08-18 13:31:36 +00:00
parent 68e75f18c5
commit 6cd48e1cbf

View File

@@ -50,6 +50,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
*/ */
public class BlogServiceTest extends BaseWebScriptTest public class BlogServiceTest extends BaseWebScriptTest
{ {
@SuppressWarnings("unused")
private static Log logger = LogFactory.getLog(BlogServiceTest.class); private static Log logger = LogFactory.getLog(BlogServiceTest.class);
private AuthenticationService authenticationService; private AuthenticationService authenticationService;
@@ -58,9 +59,9 @@ public class BlogServiceTest extends BaseWebScriptTest
private SiteService siteService; private SiteService siteService;
private static final String USER_ADMIN = "admin"; private static final String USER_ADMIN = "admin";
private static final String USER_ONE = "UserOneSecond"; private static final String USER_ONE = "UserOneSecondToo";
private static final String USER_TWO = "UserTwoSecond"; private static final String USER_TWO = "UserTwoSecondToo";
private static final String SITE_SHORT_NAME_BLOG = "BlogSiteShortName"; private static final String SITE_SHORT_NAME_BLOG = "BlogSiteShortNameTest";
private static final String COMPONENT_BLOG = "blog"; private static final String COMPONENT_BLOG = "blog";
private static final String URL_BLOG_POST = "/api/blog/post/site/" + SITE_SHORT_NAME_BLOG + "/" + COMPONENT_BLOG + "/"; private static final String URL_BLOG_POST = "/api/blog/post/site/" + SITE_SHORT_NAME_BLOG + "/" + COMPONENT_BLOG + "/";
@@ -80,15 +81,17 @@ public class BlogServiceTest extends BaseWebScriptTest
this.authenticationService = (AuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService"); this.authenticationService = (AuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService");
this.authenticationComponent = (AuthenticationComponent)getServer().getApplicationContext().getBean("authenticationComponent"); this.authenticationComponent = (AuthenticationComponent)getServer().getApplicationContext().getBean("authenticationComponent");
this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService"); this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
this.siteService = (SiteService)getServer().getApplicationContext().getBean("siteService"); this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService");
// Authenticate as user
this.authenticationComponent.setCurrentUser(USER_ADMIN);
// Create test site // Create test site
// - only create the site if it doesn't already exist // - only create the site if it doesn't already exist
SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_BLOG); SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_BLOG);
if (siteInfo == null) if (siteInfo == null)
{ {
this.siteService.createSite("BlogSitePreset", SITE_SHORT_NAME_BLOG, "BlogSiteTitle", this.siteService.createSite("BlogSitePreset", SITE_SHORT_NAME_BLOG, "BlogSiteTitle", "BlogSiteDescription", true);
"BlogSiteDescription", true);
} }
// Create users // Create users
@@ -107,9 +110,12 @@ public class BlogServiceTest extends BaseWebScriptTest
// admin user required to delete user // admin user required to delete user
this.authenticationComponent.setCurrentUser(USER_ADMIN); this.authenticationComponent.setCurrentUser(USER_ADMIN);
// TODO don't delete them as it seems they don't get cleaned up correctly
// delete the inviter user // delete the inviter user
personService.deletePerson(USER_ONE); // personService.deletePerson(USER_ONE);
personService.deletePerson(USER_TWO); // this.authenticationService.deleteAuthentication(USER_ONE);
// personService.deletePerson(USER_TWO);
// this.authenticationService.deleteAuthentication(USER_TWO);
// delete invite site // delete invite site
siteService.deleteSite(SITE_SHORT_NAME_BLOG); siteService.deleteSite(SITE_SHORT_NAME_BLOG);
@@ -137,7 +143,7 @@ public class BlogServiceTest extends BaseWebScriptTest
} }
// add the user as a member with the given role // add the user as a member with the given role
this.siteService.setMembership(SITE_SHORT_NAME_BLOG, USER_ONE, role); this.siteService.setMembership(SITE_SHORT_NAME_BLOG, userName, role);
} }