Examples of JCS


Examples of org.apache.jcs.JCS

     * <p>
     * @throws CacheException
     */
    public void testSwapConfig() throws CacheException
    {
        JCS swap = JCS.getInstance( "Swap" );
        assertEquals( ICompositeCacheAttributes.DISK_USAGE_PATTERN_SWAP, swap.getCacheAttributes().getDiskUsagePattern() );
    }
View Full Code Here

Examples of org.apache.jcs.JCS

     * <p>
     * @throws CacheException
     */
    public void testUpdateConfig() throws CacheException
    {
        JCS swap = JCS.getInstance( "Update" );
        assertEquals( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE, swap.getCacheAttributes().getDiskUsagePattern() );
    }
View Full Code Here

Examples of org.apache.jcs.JCS

        throws Exception
    {
        int items = 300000;
        String region = "testCache1";

        JCS jcs = JCS.getInstance( region );

        try
        {

            System.out.println( "Start: " + measureMemoryUse() );

            // Add items to cache

            for ( int i = 0; i <= items; i++ )
            {
                jcs.put( i + ":key", region + " data " + i );
            }

            System.out.println( jcs.getStats() );
            System.out.println( "--------------------------" );
            System.out.println( "After put: " + measureMemoryUse() );

            Thread.sleep( 5000 );

            System.out.println( jcs.getStats() );
            System.out.println( "--------------------------" );
            System.out.println( "After wait: " + measureMemoryUse() );

            // Test that all items are in cache

            for ( int i = 0; i <= items; i++ )
            {
                String value = (String) jcs.get( i + ":key" );

                assertEquals( region + " data " + i, value );
            }

            System.out.println( "After get: " + measureMemoryUse() );

            // // Remove all the items
            // for ( int i = 0; i <= items; i++ )
            // {
            // jcs.remove( i + ":key" );
            // }
            //
            // // Verify removal
            // for ( int i = 0; i <= items; i++ )
            // {
            // assertNull( "Removed key should be null: " + i + ":key" + "\n
            // stats " + jcs.getStats(), jcs.get( i + ":key" ) );
            // }

        }
        finally
        {
            // dump the stats to the report
            System.out.println( jcs.getStats() );
            System.out.println( "--------------------------" );
            System.out.println( "End: " + measureMemoryUse() );
        }
    }
View Full Code Here

Examples of org.apache.jcs.JCS

     *
     * @throws Exception
     */
    public void testSimpleGetStats() throws Exception
    {
        JCS cache = JCS.getInstance( "testCache1" );

        // 1 miss, 1 hit, 1 put
        cache.get( "testKey" );
        cache.put( "testKey", "testdata" );
        // should have 4 hits
        cache.get( "testKey" );
        cache.get( "testKey" );
        cache.get( "testKey" );
        cache.get( "testKey" );

        CompositeCacheManager mgr = CompositeCacheManager.getInstance();
        String statsString = mgr.getStats();

        System.out.println( statsString );
View Full Code Here

Examples of org.apache.jcs.JCS

     *                If an error occurs
     */
    public void runTestForRegion( String region )
        throws Exception
    {
        JCS jcs = JCS.getInstance( region );

        // Add items to cache
        for ( int i = 0; i <= items; i++ )
        {
            jcs.put( i + ":key", region + " data " + i );
        }

        // Test that all items are in cache
        for ( int i = 0; i <= items; i++ )
        {
            String value = (String) jcs.get( i + ":key" );

            assertEquals( region + " data " + i, value );
        }

        // Remove all the items
        for ( int i = 0; i <= items; i++ )
        {
            jcs.remove( i + ":key" );
        }

        // Verify removal
        // another thread may have inserted since
        for ( int i = 0; i <= items; i++ )
        {
            assertNull( "Removed key should be null: " + i + ":key" + "\n stats " + jcs.getStats(), jcs
                .get( i + ":key" ) );
        }
    }
View Full Code Here

Examples of org.apache.jcs.JCS

     */
    public void testGetRegionInfo()
        throws Exception
    {
        String regionName = "myRegion";
        JCS cache = JCS.getInstance( regionName );

        cache.put( "key", "value" );

        JCSAdminBean admin = new JCSAdminBean();

        List regions = admin.buildCacheInfo();

View Full Code Here

Examples of org.apache.jcs.JCS

     */
    public void testGetElementForRegionInfo()
        throws Exception
    {
        String regionName = "myRegion";
        JCS cache = JCS.getInstance( regionName );

        // clear the region
        cache.clear();

        String key = "myKey";
        cache.put( key, "value" );

        JCSAdminBean admin = new JCSAdminBean();

        List elements = admin.buildElementInfo( regionName );

View Full Code Here

Examples of org.apache.jcs.JCS

        throws Exception
    {
        JCSAdminBean admin = new JCSAdminBean();

        String regionName = "myRegion";
        JCS cache = JCS.getInstance( regionName );

        // clear the region
        cache.clear();
        admin.clearRegion( regionName );

        String key = "myKey";
        cache.put( key, "value" );

        List elements = admin.buildElementInfo( regionName );

        assertEquals( "Wrong number of elements in the region.", 1, elements.size() );
View Full Code Here

Examples of org.apache.jcs.JCS

        throws Exception
    {
        JCSAdminBean admin = new JCSAdminBean();

        String regionName = "myRegion";
        JCS cache = JCS.getInstance( regionName );

        String key = "myKey";
        cache.put( key, "value" );

        admin.clearAllRegions();

        List elements2 = admin.buildElementInfo( regionName );
        assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.size() );
View Full Code Here

Examples of org.apache.jcs.JCS

     * @throws Exception
     */
    public void testJCS()
        throws Exception
    {
        JCS jcs = JCS.getInstance( "testCache1" );

        LinkedList list = buildList();

        jcs.put( "some:key", list );

        assertEquals( list, jcs.get( "some:key" ) );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.