use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-kettle by pentaho.
the class UIEERepositoryDirectoryIT method setUp.
@Before
public void setUp() throws Exception {
this.testContextManager = new TestContextManager(getClass());
this.testContextManager.prepareTestInstance(this);
loginAsRepositoryAdmin();
SimpleJcrTestUtils.deleteItem(testJcrTemplate, ServerRepositoryPaths.getPentahoRootFolderPath());
mp = new MicroPlatform();
// used by DefaultPentahoJackrabbitAccessControlHelper
mp.defineInstance("tenantedUserNameUtils", userNameUtils);
mp.defineInstance("tenantedRoleNameUtils", roleNameUtils);
mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
mp.defineInstance(ITenantManager.class, tenantManager);
mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(testJcrTemplate, repositoryFileDao));
mp.defineInstance("useMultiByteEncoding", new Boolean(false));
mp.defineInstance(IAclService.class, new Boolean(false));
// Start the micro-platform
mp.start();
loginAsRepositoryAdmin();
setAclManagement();
systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
userRoleDao.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { singleTenantAdminRoleName });
logout();
super.setUp();
KettleEnvironment.init();
// programmatically register plugins, annotation based plugins do not get loaded unless
// they are in kettle's plugins folder.
JobEntryPluginType.getInstance().registerCustom(JobEntryAttributeTesterJobEntry.class, "test", "JobEntryAttributeTester", "JobEntryAttributeTester", "JobEntryAttributeTester", "");
StepPluginType.getInstance().registerCustom(TransStepAttributeTesterTransStep.class, "test", "StepAttributeTester", "StepAttributeTester", "StepAttributeTester", "");
repositoryMeta = new PurRepositoryMeta();
repositoryMeta.setName("JackRabbit");
repositoryMeta.setDescription("JackRabbit test repository");
userInfo = new UserInfo(EXP_LOGIN, "password", EXP_USERNAME, "Apache Tomcat user", true);
repository = new PurRepository();
repository.init(repositoryMeta);
login(sysAdminUserName, systemTenant, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
ITenant tenantAcme = tenantManager.createTenant(systemTenant, EXP_TENANT, singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
userRoleDao.createUser(tenantAcme, EXP_LOGIN, "password", "", new String[] { singleTenantAdminRoleName });
logout();
setUpUser();
PurRepository purRep = (PurRepository) repository;
final PurRepositoryConnector purRepositoryConnector = new PurRepositoryConnector(purRep, (PurRepositoryMeta) repositoryMeta, purRep.getRootRef());
purRep.setPurRepositoryConnector(purRepositoryConnector);
purRep.setTest(repo);
repository.connect(EXP_LOGIN, "password");
login(EXP_LOGIN, tenantAcme, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
System.out.println("PUR NAME!!!: " + repo.getClass().getCanonicalName());
RepositoryFile repositoryFile = repo.getFile(ClientRepositoryPaths.getPublicFolderPath());
Serializable repositoryFileId = repositoryFile.getId();
List<RepositoryFile> files = repo.getChildren(repositoryFileId);
StringBuilder buf = new StringBuilder();
for (RepositoryFile file : files) {
buf.append("\n").append(file);
}
assertTrue("files not deleted: " + buf, files.isEmpty());
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class RepositoryCleanerTest method gc.
@Test
public void gc() throws Exception {
GarbageCollector collector = mock(GarbageCollector.class);
RepositoryImpl repository = mock(RepositoryImpl.class);
when(repository.createDataStoreGarbageCollector()).thenReturn(collector);
MicroPlatform mp = new MicroPlatform(getSolutionPath());
mp.defineInstance(Repository.class, repository);
mp.defineInstance("jcrRepository", repository);
mp.start();
RepositoryCleaner cleaner = new RepositoryCleaner();
Session systemSession = mock(Session.class);
IPentahoSystemSessionFactory sessionFactory = mock(IPentahoSystemSessionFactory.class);
when(sessionFactory.create(repository)).thenReturn(systemSession);
cleaner.setSystemSessionFactory(sessionFactory);
try {
cleaner.gc();
} finally {
mp.stop();
}
verify(collector, times(1)).mark();
verify(collector, times(1)).sweep();
verify(collector, times(1)).close();
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class RepositoryGCOrphanTest method testOrphanNodePurge.
@Test
public void testOrphanNodePurge() throws Exception {
GarbageCollector collector = mock(GarbageCollector.class);
RepositoryImpl repository = mock(RepositoryImpl.class);
RepositoryContext context = mock(RepositoryContext.class);
when(repository.getRepositoryContext()).thenReturn(context);
RepositoryImpl.WorkspaceInfo workspaceInfo = mock(RepositoryImpl.WorkspaceInfo.class);
when(repository.getWorkspaceInfo("default")).thenReturn(workspaceInfo);
WorkspaceConfig config = mock(WorkspaceConfig.class);
when(workspaceInfo.getConfig()).thenReturn(config);
when(repository.createDataStoreGarbageCollector()).thenReturn(collector);
RepositoryCleaner cleaner = new RepositoryCleaner();
Session systemSession = mock(Session.class);
IPentahoSystemSessionFactory sessionFactory = mock(IPentahoSystemSessionFactory.class);
when(sessionFactory.create(repository)).thenReturn(systemSession);
cleaner.setSystemSessionFactory(sessionFactory);
Node rootNode = mock(Node.class);
when(systemSession.getNode("/jcr:system/jcr:versionStorage")).thenReturn(rootNode);
when(rootNode.getName()).thenReturn("jcr:frozenNode");
Property uuid = mock(Property.class);
when(rootNode.getProperty("jcr:frozenUuid")).thenReturn(uuid);
when(rootNode.hasProperty("jcr:frozenUuid")).thenReturn(true);
Value value = mock(Value.class);
when(uuid.getValue()).thenReturn(value);
when(uuid.getString()).thenReturn("Foo");
when(systemSession.getNodeByIdentifier(anyString())).thenThrow(new RepositoryException("err"));
Version parent = mock(Version.class);
VersionHistory grandParent = mock(VersionHistory.class);
when(rootNode.getParent()).thenReturn(parent);
when(parent.getParent()).thenReturn(grandParent);
when(parent.getName()).thenReturn("Bar");
NodeIterator nodes = mock(NodeIterator.class);
when(rootNode.getNodes()).thenReturn(nodes);
when(nodes.hasNext()).thenReturn(false);
MicroPlatform mp = new MicroPlatform(getSolutionPath());
mp.defineInstance(Repository.class, repository);
mp.defineInstance("jcrRepository", repository);
mp.start();
try {
cleaner.gc();
} finally {
mp.stop();
}
verify(grandParent, times(1)).removeVersion("Bar");
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class SpringSecurityPrincipalProvider_Caching_Test method setUp.
@Before
public void setUp() throws Exception {
userResolver = mock(ITenantedPrincipleNameResolver.class);
roleResolver = mock(ITenantedPrincipleNameResolver.class);
cacheManager = spy(new SimpleMapCacheManager());
doReturn(false).when(cacheManager).cacheEnabled(USER_CACHE_REGION);
doReturn(false).when(cacheManager).cacheEnabled(ROLE_CACHE_REGION);
userTenant = new Tenant(USER_PRINCIPLE, true);
roleTenant = new Tenant(ROLE_PRINCIPLE, true);
mp = new MicroPlatform(getSolutionPath());
mp.defineInstance("tenantedUserNameUtils", userResolver);
mp.defineInstance("tenantedRoleNameUtils", roleResolver);
mp.defineInstance(ICacheManager.class, cacheManager);
mp.start();
provider = new SpringSecurityPrincipalProvider();
provider.init(new Properties());
provider = spy(provider);
User user = new User(USER_PRINCIPLE, "", true, true, true, true, new ArrayList<GrantedAuthority>());
doReturn(user).when(provider).internalGetUserDetails(USER_PRINCIPLE);
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class SpringSecurityPrincipalProvider_PrincipalCreation_Test method setUp.
@Before
public void setUp() throws Exception {
userResolver = mock(ITenantedPrincipleNameResolver.class);
mp = new MicroPlatform(getSolutionPath());
mp.defineInstance("tenantedUserNameUtils", userResolver);
mp.start();
setUpProvider(createBasicProperties());
}
Aggregations