CacheManagerEndpoint { @POST @Path( "clear" ) public Response clear() { try { final IPluginCacheManager iPluginCacheManager = PentahoSystem.get( IPluginCacheManager.class ); final IReportContentCache cache = iPluginCacheManager.getCache(); cache.cleanupCurrentSession(); final ICacheManager cacheManager = PentahoSystem.get( ICacheManager.class ); cacheManager.clearRegionCache( "report-output-handlers" ); cacheManager.clearRegionCache( "report-dataset-cache" ); DataCacheFactory.getCache().getCacheManager().clearAll(); return Response.ok().build(); } catch ( final Exception e ) { return Response.serverError().build(); } }  @POST @Path( "clear" ) Response clear();  }
@Test public void clear() throws Exception { try { PowerMockito.mockStatic( DataCacheFactory.class ); final DataCache dataCache = mock( DataCache.class ); when( DataCacheFactory.getCache() ).thenReturn( dataCache ); final DataCacheManager dataCacheManager = mock( DataCacheManager.class ); when( dataCache.getCacheManager() ).thenReturn( dataCacheManager ); final IPluginCacheManager cacheManager = mock( IPluginCacheManager.class ); final IReportContentCache contentCache = mock( IReportContentCache.class ); when( cacheManager.getCache() ).thenReturn( contentCache ); PentahoSystem.registerObject( cacheManager, IPluginCacheManager.class ); final ICacheManager iCacheManager = mock( ICacheManager.class ); PentahoSystem.registerObject( iCacheManager, ICacheManager.class ); final Response clear = new CacheManagerEndpoint().clear(); assertEquals( 200, clear.getStatus() ); verify( contentCache, times( 1 ) ).cleanupCurrentSession(); verify( iCacheManager, times( 1 ) ).clearRegionCache( "report-output-handlers" ); verify( dataCacheManager, times( 1 ) ).clearAll(); } finally { PentahoSystem.shutdown(); } }
@Test public void clearError() throws Exception { final Response clear = new CacheManagerEndpoint().clear(); assertEquals( 500, clear.getStatus() ); }