use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.
the class SessionCachingMetadataDomainRepositoryIT method testGetDomain_null_session.
public void testGetDomain_null_session() throws Exception {
final String SESSION_ID = null;
// $NON-NLS-1$
final String ID = "1";
MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
mock.storeDomain(getTestDomain(ID), false);
SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
// $NON-NLS-1$
PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", SESSION_ID));
Domain domain = repo.getDomain(ID);
// Description will equal the id when no description is provided (null session)
assertEquals(ID, domain.getDescription(TEST_LOCALE));
}
use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.
the class SessionCachingMetadataDomainRepositoryIT method testRemoveDomain.
/**
* Make sure removing a domain removes all cached instances of the domain
*/
public void testRemoveDomain() throws Exception {
// $NON-NLS-1$
final String ID1 = "1";
// $NON-NLS-1$
final String ID2 = "2";
MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
mock.storeDomain(getTestDomain(ID1), false);
mock.storeDomain(getTestDomain(ID2), false);
SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
// $NON-NLS-1$ //$NON-NLS-2$
PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "1"));
Domain domainFromSession1 = repo.getDomain(ID1);
assertNotNull(domainFromSession1);
// $NON-NLS-1$
assertEquals(1, mock.getInvocationCount("getDomain"));
// $NON-NLS-1$ //$NON-NLS-2$
PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "2"));
Domain domainFromSession2 = repo.getDomain(ID1);
assertNotNull(domainFromSession2);
// $NON-NLS-1$
assertEquals(2, mock.getInvocationCount("getDomain"));
assertEquals(2, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
repo.removeDomain(ID1);
assertEquals(0, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
// Calling getDomain() now should increment the call count to the delegate
repo.getDomain(ID2);
// $NON-NLS-1$
assertEquals(3, mock.getInvocationCount("getDomain"));
// There should now only be one in the cache
assertEquals(1, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
}
use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.
the class SessionCachingMetadataDomainRepositoryIT method testOnLogout.
public void testOnLogout() throws Exception {
// $NON-NLS-1$
final String ID1 = "1";
// $NON-NLS-1$
final String ID2 = "2";
MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
repo.storeDomain(getTestDomain(ID1), false);
repo.storeDomain(getTestDomain(ID2), false);
// $NON-NLS-1$ //$NON-NLS-2$
PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "1"));
repo.getDomain(ID1);
// $NON-NLS-1$ //$NON-NLS-2$
IPentahoSession session2 = new StandaloneSession("Standalone Session", "2");
PentahoSessionHolder.setSession(session2);
repo.getDomain(ID2);
assertEquals(2, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
// Logging out session 2 should only remove cached domains from session 2
repo.onLogout(session2);
assertEquals(1, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
}
use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.
the class SessionCachingMetadataDomainRepositoryIT method testGenerateRowLevelSecurityConstraint.
public void testGenerateRowLevelSecurityConstraint() throws Exception {
MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
// Only thing to do here is make sure the return value is the same; cache shouldn't do anything here
assertEquals(mock.generateRowLevelSecurityConstraint(null), repo.generateRowLevelSecurityConstraint(null));
// $NON-NLS-1$
assertEquals(2, mock.getInvocationCount("generateRowLevelSecurityConstraint"));
}
use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.
the class SessionCachingMetadataDomainRepositoryIT method testFlushDomains.
public void testFlushDomains() throws Exception {
// $NON-NLS-1$
final String ID = "1";
MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
// $NON-NLS-1$ //$NON-NLS-2$
PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "1"));
repo.storeDomain(getTestDomain(ID), false);
repo.getDomain(ID);
assertEquals(1, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
// $NON-NLS-1$ //$NON-NLS-2$
PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "2"));
repo.getDomain(ID);
assertEquals(2, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
assertEquals(1, repo.getDomainIds().size());
repo.flushDomains();
// $NON-NLS-1$
assertEquals(1, mock.getInvocationCount("flushDomains"));
assertEquals(0, repo.getDomainIds().size());
assertEquals(0, mock.getDomainIds().size());
assertEquals(1, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
}
Aggregations