Files
alfresco-community-repo/source/test-java/org/alfresco/repo/tenant/MultiTAdminServiceImplTest.java
Matt Ward 0758dc4431 ACE-2682: MT: Failure occurs when creating tenant with specified contentstore directory
This is not a nice solution, nicer would be if we could allow Spring's ProxyFactoryBean to discover all the interfaces implemented by the underlying bean.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@85696 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2014-09-25 09:56:02 +00:00

181 lines
5.0 KiB
Java

package org.alfresco.repo.tenant;
import static org.junit.Assert.*;
import org.alfresco.repo.content.AbstractContentStore;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.content.ContentStoreCaps;
import org.alfresco.service.cmr.repository.ContentReader;
import org.junit.Before;
import org.junit.Test;
public class MultiTAdminServiceImplTest
{
private MultiTAdminServiceImpl tenantAdmin;
@Before
public void setUp() throws Exception
{
tenantAdmin = new MultiTAdminServiceImpl();
}
@Test
public void testTenantDeployer()
{
ContentStore contentStore = new ConcreteTenantDeployer();
TenantDeployer tenantDeployer = tenantAdmin.tenantDeployer(contentStore);
assertNotNull(tenantDeployer);
}
@Test
public void testTenantDeployerRetrievedByContentStoreCaps()
{
ContentStore contentStore = new FakeSubsystemProxy(false);
TenantDeployer tenantDeployer = tenantAdmin.tenantDeployer(contentStore);
assertNotNull(tenantDeployer);
}
@Test
public void testTenantDeployerMayBeNullWhenInterfaceNotImplemented()
{
ContentStore contentStore = new BaseStore();
TenantDeployer tenantDeployer = tenantAdmin.tenantDeployer(contentStore);
assertNull(tenantDeployer);
}
@Test
public void testTenantDeployerMayBeNullWhenProxyingAndInterfaceNotImplemented()
{
// Represents proxy in front of non-TenantDeployer ContentStore
ContentStore contentStore = new FakeSubsystemProxy(true);
TenantDeployer tenantDeployer = tenantAdmin.tenantDeployer(contentStore);
assertNull(tenantDeployer);
}
@Test
public void testTenantRoutingContentStore()
{
ContentStore contentStore = new ConcreteTenantRoutingContentStore();
TenantRoutingContentStore router = tenantAdmin.tenantRoutingContentStore(contentStore);
assertNotNull(router);
}
@Test
public void testTenantRoutingContentStoreRetrievedByContentStoreCaps()
{
ContentStore contentStore = new FakeSubsystemProxy(false);
TenantRoutingContentStore router = tenantAdmin.tenantRoutingContentStore(contentStore);
assertNotNull(router);
}
@Test
public void testTenantRoutingContentStoreMayBeNullWhenInterfaceNotImplemented()
{
ContentStore contentStore = new BaseStore();
TenantRoutingContentStore router = tenantAdmin.tenantRoutingContentStore(contentStore);
assertNull(router);
}
@Test
public void testTenantRoutingContentStoreMayBeNullWhenProxyingAndInterfaceNotImplemented()
{
// Represents proxy in front of non-TenantRoutingContentStore ContentStore
ContentStore contentStore = new FakeSubsystemProxy(true);
TenantRoutingContentStore router = tenantAdmin.tenantRoutingContentStore(contentStore);
assertNull(router);
}
// This is implemented by the CryptodocSubsystemProxyFactory in real life.
private static class FakeSubsystemProxy extends BaseStore implements ContentStoreCaps
{
private boolean returnNull;
FakeSubsystemProxy(boolean returnNull)
{
this.returnNull = returnNull;
}
@Override
public TenantDeployer getTenantRoutingContentStore()
{
// would return the underlying ContentStore bean in real life (or null).
return returnNull ? null : new ConcreteTenantRoutingContentStore();
}
@Override
public TenantDeployer getTenantDeployer()
{
// would return the underlying ContentStore bean in real life (or null).
return returnNull ? null : new ConcreteTenantDeployer();
}
}
private static class ConcreteTenantDeployer extends BaseStore implements TenantDeployer
{
@Override
public void onEnableTenant()
{
}
@Override
public void onDisableTenant()
{
}
@Override
public void init()
{
}
@Override
public void destroy()
{
}
}
private static class ConcreteTenantRoutingContentStore extends BaseStore implements TenantRoutingContentStore
{
@Override
public void onEnableTenant()
{
}
@Override
public void onDisableTenant()
{
}
@Override
public void init()
{
}
@Override
public void destroy()
{
}
}
private static class BaseStore extends AbstractContentStore
{
@Override
public boolean isWriteSupported()
{
return false;
}
@Override
public ContentReader getReader(String contentUrl)
{
return null;
}
}
}