mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fixed failing test
- Abstract base class required injection of more generally-used services Fixed 'property not set' error message to display the correct property name git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2654 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -72,7 +72,7 @@ public abstract class AbstractPatch implements Patch
|
|||||||
/** support service */
|
/** support service */
|
||||||
protected SearchService searchService;
|
protected SearchService searchService;
|
||||||
/** support service */
|
/** support service */
|
||||||
protected AuthenticationComponent authComponent;
|
protected AuthenticationComponent authenticationComponent;
|
||||||
|
|
||||||
public AbstractPatch()
|
public AbstractPatch()
|
||||||
{
|
{
|
||||||
@@ -137,9 +137,12 @@ public abstract class AbstractPatch implements Patch
|
|||||||
this.searchService = searchService;
|
this.searchService = searchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthenticationComponent(AuthenticationComponent authComponent)
|
/**
|
||||||
|
* Set a generally-used service
|
||||||
|
*/
|
||||||
|
public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
|
||||||
{
|
{
|
||||||
this.authComponent = authComponent;
|
this.authenticationComponent = authenticationComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -295,7 +298,7 @@ public abstract class AbstractPatch implements Patch
|
|||||||
checkPropertyNotNull(namespaceService, "namespaceService");
|
checkPropertyNotNull(namespaceService, "namespaceService");
|
||||||
checkPropertyNotNull(nodeService, "nodeService");
|
checkPropertyNotNull(nodeService, "nodeService");
|
||||||
checkPropertyNotNull(searchService, "searchService");
|
checkPropertyNotNull(searchService, "searchService");
|
||||||
checkPropertyNotNull(authComponent, "authComponent");
|
checkPropertyNotNull(authenticationComponent, "authenticationComponent");
|
||||||
if (fixesFromSchema == -1 || fixesToSchema == -1 || targetSchema == -1)
|
if (fixesFromSchema == -1 || fixesToSchema == -1 || targetSchema == -1)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException(
|
throw new AlfrescoRuntimeException(
|
||||||
|
@@ -23,7 +23,12 @@ import junit.framework.TestCase;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.domain.AppliedPatch;
|
import org.alfresco.repo.domain.AppliedPatch;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.service.cmr.admin.PatchException;
|
import org.alfresco.service.cmr.admin.PatchException;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@@ -40,6 +45,10 @@ public class PatchTest extends TestCase
|
|||||||
private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
|
|
||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
|
private NamespaceService namespaceService;
|
||||||
|
private NodeService nodeService;
|
||||||
|
private SearchService searchService;
|
||||||
|
private AuthenticationComponent authenticationComponent;
|
||||||
private PatchService patchService;
|
private PatchService patchService;
|
||||||
private PatchDaoService patchDaoComponent;
|
private PatchDaoService patchDaoComponent;
|
||||||
|
|
||||||
@@ -51,6 +60,11 @@ public class PatchTest extends TestCase
|
|||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
transactionService = (TransactionService) ctx.getBean("transactionComponent");
|
transactionService = (TransactionService) ctx.getBean("transactionComponent");
|
||||||
|
namespaceService = (NamespaceService) ctx.getBean("namespaceService");
|
||||||
|
nodeService = (NodeService) ctx.getBean("nodeService");
|
||||||
|
searchService = (SearchService) ctx.getBean("searchService");
|
||||||
|
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
||||||
|
|
||||||
patchService = (PatchService) ctx.getBean("PatchService");
|
patchService = (PatchService) ctx.getBean("PatchService");
|
||||||
patchDaoComponent = (PatchDaoService) ctx.getBean("patchDaoComponent");
|
patchDaoComponent = (PatchDaoService) ctx.getBean("patchDaoComponent");
|
||||||
|
|
||||||
@@ -66,9 +80,20 @@ public class PatchTest extends TestCase
|
|||||||
assertNotNull(patchDaoComponent);
|
assertNotNull(patchDaoComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SamplePatch constructSamplePatch(boolean mustFail)
|
||||||
|
{
|
||||||
|
SamplePatch patch = new SamplePatch(mustFail, transactionService);
|
||||||
|
patch.setNamespaceService(namespaceService);
|
||||||
|
patch.setNodeService(nodeService);
|
||||||
|
patch.setSearchService(searchService);
|
||||||
|
patch.setAuthenticationComponent(authenticationComponent);
|
||||||
|
// done
|
||||||
|
return patch;
|
||||||
|
}
|
||||||
|
|
||||||
public void testSimplePatchSuccess() throws Exception
|
public void testSimplePatchSuccess() throws Exception
|
||||||
{
|
{
|
||||||
Patch patch = new SamplePatch(false, transactionService);
|
Patch patch = constructSamplePatch(false);
|
||||||
String report = patch.apply();
|
String report = patch.apply();
|
||||||
// check that the report was generated
|
// check that the report was generated
|
||||||
assertEquals("Patch report incorrect", SamplePatch.MSG_SUCCESS, report);
|
assertEquals("Patch report incorrect", SamplePatch.MSG_SUCCESS, report);
|
||||||
@@ -77,7 +102,7 @@ public class PatchTest extends TestCase
|
|||||||
public void testPatchReapplication()
|
public void testPatchReapplication()
|
||||||
{
|
{
|
||||||
// successfully apply a patch
|
// successfully apply a patch
|
||||||
Patch patch = new SamplePatch(false, transactionService);
|
Patch patch = constructSamplePatch(false);
|
||||||
patch.apply();
|
patch.apply();
|
||||||
// check that the patch cannot be reapplied
|
// check that the patch cannot be reapplied
|
||||||
try
|
try
|
||||||
@@ -91,7 +116,7 @@ public class PatchTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// apply an unsuccessful patch
|
// apply an unsuccessful patch
|
||||||
patch = new SamplePatch(true, transactionService);
|
patch = constructSamplePatch(true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
patch.apply();
|
patch.apply();
|
||||||
|
@@ -165,13 +165,13 @@ public class EmailTemplatesContentPatch extends AbstractPatch
|
|||||||
// import the content
|
// import the content
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
authComponent.setCurrentUser(authComponent.getSystemUserName());
|
authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||||
|
|
||||||
importContent();
|
importContent();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
authComponent.clearCurrentSecurityContext();
|
authenticationComponent.clearCurrentSecurityContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
// output a message to describe the result
|
// output a message to describe the result
|
||||||
|
Reference in New Issue
Block a user