Fix up google doc tests

- Added service initialisation method to service so the "health" of the service can be determined
- Unit tests do not fail if the google doc service has not been configured correctly



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20046 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2010-04-30 09:04:09 +00:00
parent 6563c1c008
commit 4678f1420f
5 changed files with 189 additions and 55 deletions

View File

@@ -208,7 +208,7 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
/**
* Initialise google docs services
*/
public void initialiseGoogleDocsService()
public void initialise() throws GoogleDocsServiceInitException
{
if (initialised == false)
{
@@ -219,7 +219,7 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
if (username == null ||username.length() == 0 || password == null)
{
throw new AlfrescoRuntimeException("No Goolge Docs credentials found. Please set the Google Docs authentication configuration.");
throw new GoogleDocsServiceInitException("No Goolge Docs credentials found. Please set the Google Docs authentication configuration.");
}
try
@@ -230,7 +230,7 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
}
catch (AuthenticationException e)
{
throw new AlfrescoRuntimeException("Unable to connect to Google Docs. Please check the Google Docs authentication configuration.", e);
throw new GoogleDocsServiceInitException("Unable to connect to Google Docs. Please check the Google Docs authentication configuration.", e);
}
initialised = true;
@@ -250,7 +250,14 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
ParameterCheck.mandatory("nodeRef", nodeRef);
// Initialise google doc services
initialiseGoogleDocsService();
try
{
initialise();
}
catch (GoogleDocsServiceInitException e)
{
throw new AlfrescoRuntimeException("Unable to create google doc, because service could not be initialised.", e);
}
// Get property values
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
@@ -295,7 +302,14 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
ParameterCheck.mandatory("nodeRef", nodeRef);
// Initialise google doc services
initialiseGoogleDocsService();
try
{
initialise();
}
catch (GoogleDocsServiceInitException e)
{
throw new AlfrescoRuntimeException("Unable to create google doc, because service could not be initialised.", e);
}
try
{
@@ -485,7 +499,14 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
ParameterCheck.mandatory("nodeRef", nodeRef);
// Initialise google doc services
initialiseGoogleDocsService();
try
{
initialise();
}
catch (GoogleDocsServiceInitException e)
{
throw new AlfrescoRuntimeException("Unable to create google doc, because service could not be initialised.", e);
}
try
{