Package org.pentaho.platform.plugin.services.metadata

Examples of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository$CacheKey


  public void testStoreDomain() throws Exception {
    final String ID = "1"; //$NON-NLS-1$
    MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();

    SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository( mock );
    PentahoSessionHolder.setSession( new StandaloneSession( "Standalone Session", "1" ) ); //$NON-NLS-1$ //$NON-NLS-2$

    repo.storeDomain( getTestDomain( ID ), false );

    // No cache values when storing a domain
    assertEquals( 0, PentahoSystem.getCacheManager( null ).getAllKeysFromRegionCache( CACHE_NAME ).size() );

    // Cache one domain
    repo.getDomain( ID );

    // Storing a domain under a different session should wipe out all cached domains with the same id
    PentahoSessionHolder.setSession( new StandaloneSession( "Standalone Session", "2" ) ); //$NON-NLS-1$ //$NON-NLS-2$
    try {
      repo.storeDomain( getTestDomain( ID ), false );
      fail( "Should have thrown a " + DomainAlreadyExistsException.class.getSimpleName() ); //$NON-NLS-1$
    } catch ( DomainAlreadyExistsException ex ) {
      // expected
    }
    repo.storeDomain( getTestDomain( ID ), true );
    // Storing a domain under a different session should wipe out all cached domains with the same id
    assertEquals( 0, PentahoSystem.getCacheManager( null ).getAllKeysFromRegionCache( CACHE_NAME ).size() );

    assertEquals( 1, repo.getDomainIds().size() );
    repo.getDomain( ID );
    assertEquals( 2, PentahoSystem.getCacheManager( null ).getAllKeysFromRegionCache( CACHE_NAME ).size() );

    // Storing a domain should only wipe out the cached domains with the same id
    repo.storeDomain( getTestDomain( "2" ), false ); //$NON-NLS-1$
    assertEquals( 2, repo.getDomainIds().size() );
    assertEquals( 2, PentahoSystem.getCacheManager( null ).getAllKeysFromRegionCache( CACHE_NAME ).size() );
  }
View Full Code Here


  public void testRemoveModel() throws Exception {
    final String ID1 = "1"; //$NON-NLS-1$
    final String ID2 = "2"; //$NON-NLS-1$
    MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();

    SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository( mock );
    PentahoSessionHolder.setSession( new StandaloneSession( "Standalone Session", "1" ) ); //$NON-NLS-1$ //$NON-NLS-2$

    Domain domain = getTestDomain( ID1 );
    LogicalModel model = new LogicalModel();
    model.setId( "test" ); //$NON-NLS-1$
    domain.addLogicalModel( model );

    repo.storeDomain( domain, false );
    repo.storeDomain( getTestDomain( ID2 ), false );

    repo.getDomain( ID1 );
    assertEquals( 1, PentahoSystem.getCacheManager( null ).getAllKeysFromRegionCache( CACHE_NAME ).size() );
    repo.getDomain( ID2 );
    assertEquals( 2, PentahoSystem.getCacheManager( null ).getAllKeysFromRegionCache( CACHE_NAME ).size() );

    PentahoSessionHolder.setSession( new StandaloneSession( "Standalone Session", "2" ) ); //$NON-NLS-1$ //$NON-NLS-2$
    repo.getDomain( ID1 );
    assertEquals( 3, PentahoSystem.getCacheManager( null ).getAllKeysFromRegionCache( CACHE_NAME ).size() );

    repo.removeModel( ID1, "test" ); //$NON-NLS-1$
    // Removing a model should remove all domains with that same id, leaving others intact
    assertEquals( 1, PentahoSystem.getCacheManager( null ).getAllKeysFromRegionCache( CACHE_NAME ).size() );
    assertEquals( 1, mock.getInvocationCount( "removeModel" ) ); //$NON-NLS-1$
  }
View Full Code Here

    assertEquals( 1, mock.getInvocationCount( "removeModel" ) ); //$NON-NLS-1$
  }

  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 ) );
    assertEquals( 2, mock.getInvocationCount( "generateRowLevelSecurityConstraint" ) ); //$NON-NLS-1$
  }
View Full Code Here

    assertEquals( 2, mock.getInvocationCount( "generateRowLevelSecurityConstraint" ) ); //$NON-NLS-1$
  }

  public void testHasAccess() 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.hasAccess( 0, null ), repo.hasAccess( 0, null ) );
    assertEquals( 2, mock.getInvocationCount( "hasAccess" ) ); //$NON-NLS-1$
  }
View Full Code Here

  public void testOnLogout() throws Exception {
    final String ID1 = "1"; //$NON-NLS-1$
    final String ID2 = "2"; //$NON-NLS-1$
    MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();

    SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository( mock );
    repo.storeDomain( getTestDomain( ID1 ), false );
    repo.storeDomain( getTestDomain( ID2 ), false );

    PentahoSessionHolder.setSession( new StandaloneSession( "Standalone Session", "1" ) ); //$NON-NLS-1$ //$NON-NLS-2$
    repo.getDomain( ID1 );

    IPentahoSession session2 = new StandaloneSession( "Standalone Session", "2" ); //$NON-NLS-1$ //$NON-NLS-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() );
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository$CacheKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.