Package org.apache.jcs.engine.control

Examples of org.apache.jcs.engine.control.CompositeCacheManagerMockImpl


     */
    public void testSinglePut()
        throws Exception
    {
        // SETUP
        CompositeCacheManagerMockImpl compositeCacheManager = new CompositeCacheManagerMockImpl();

        RemoteCacheAttributes attributes = new RemoteCacheAttributes();
        attributes.setRemoteHost( "localhost" );
        attributes.setLocalPort( 1202 );
        attributes.setRemotePort( 1101 );
View Full Code Here


     */
    public void testPutRemove()
        throws Exception
    {
        // SETUP
        CompositeCacheManagerMockImpl compositeCacheManager = new CompositeCacheManagerMockImpl();

        RemoteCacheAttributes attributes = new RemoteCacheAttributes();
        attributes.setRemoteHost( "localhost" );
        attributes.setLocalPort( 1202 );
        attributes.setRemotePort( 1101 );
View Full Code Here

     */
    public void testPutAndListen()
        throws Exception
    {
        // SETUP
        CompositeCacheManagerMockImpl compositeCacheManager = new CompositeCacheManagerMockImpl();

        RemoteCacheAttributes attributes = new RemoteCacheAttributes();
        attributes.setRemoteHost( "localhost" );
        attributes.setLocalPort( 1202 );
        attributes.setRemotePort( 1101 );
View Full Code Here

     */
    public void testPutaMultipleAndListen()
        throws Exception
    {
        // SETUP
        CompositeCacheManagerMockImpl compositeCacheManager = new CompositeCacheManagerMockImpl();

        RemoteCacheAttributes attributes = new RemoteCacheAttributes();
        attributes.setRemoteHost( "localhost" );
        attributes.setLocalPort( 1202 );
        attributes.setRemotePort( 1101 );
View Full Code Here

        throws Exception
    {
        TCPLateralCacheAttributes lattr = new TCPLateralCacheAttributes();
        lattr.setTcpListenerPort( 1101 );
        lattr.setTransmissionTypeName( "TCP" );
        CompositeCacheManagerMockImpl cacheMgr = new CompositeCacheManagerMockImpl();
        System.out.println( "mock cache = " + cacheMgr.getCache( "test" ) );

        // force initialization
        //LateralTCPCacheFactory fact = new LateralTCPCacheFactory();
        //.getInstance( lattr, cacheMgr );
        //LateralCacheNoWait nwait1 = (LateralCacheNoWait)lcMgr1.getCache(
        // "test" );
        //AuxiliaryCache nowait1 = fact.createCache( lattr, cacheMgr );

        //nowait1.update( );

        // start the listener
        //LateralTCPListener listener = (LateralTCPListener)
        LateralTCPListener.getInstance( lattr, cacheMgr );

        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
        lattr2.setTcpListenerPort( 1102 );
        lattr2.setTransmissionTypeName( "TCP" );
        lattr2.setTcpServer( "localhost:1101" );

        LateralTCPService service = new LateralTCPService( lattr2 );
        service.setListenerId( 123456 );

        int cnt = 100;
        for ( int i = 0; i < cnt; i++ )
        {
            ICacheElement element = new CacheElement( "test", "key" + i, "value1" );
            service.update( element );
        }

        SleepUtil.sleepAtLeast( 1000 );

        System.out.println( "cache. getPutCount = " + cacheMgr.getCache().getUpdateCount() );

        assertEquals( "Didn't get the correct number", cnt, cacheMgr.getCache().getUpdateCount() );
    }
View Full Code Here

        throws Exception
    {
        // setup a listener
        TCPLateralCacheAttributes lattr = new TCPLateralCacheAttributes();
        lattr.setTcpListenerPort( 1103 );
        CompositeCacheManagerMockImpl cacheMgr = new CompositeCacheManagerMockImpl();
        System.out.println( "mock cache = " + cacheMgr.getCache( "test" ) );

        // get the listener started
        // give it our mock cache manager
        //LateralTCPListener listener = (LateralTCPListener)
        LateralTCPListener.getInstance( lattr, cacheMgr );

        // setup a service to talk to the listener started above.
        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
        lattr2.setTcpListenerPort( 1104 );
        lattr2.setTcpServer( "localhost:1103" );

        LateralTCPService service = new LateralTCPService( lattr2 );
        service.setListenerId( 123456 );

        ICacheElement element = new CacheElement( "test", "key", "value1" );
        service.update( element );

        SleepUtil.sleepAtLeast( 300 );

        ICacheElement element2 = new CacheElement( "test", "key", "value2" );
        service.update( element2 );

        SleepUtil.sleepAtLeast1000 );

        ICacheElement cacheElement = cacheMgr.getCache().get( "key" );
        System.out.println( "cacheElement = " + cacheElement );
        assertEquals( "Didn't get the correct object", element2.getVal(), cacheElement.getVal() );
    }
View Full Code Here

        throws Exception
    {
        TCPLateralCacheAttributes lattr = new TCPLateralCacheAttributes();
        lattr.setTcpListenerPort( 1105 );
        lattr.setTransmissionTypeName( "TCP" );
        CompositeCacheManagerMockImpl cacheMgr = new CompositeCacheManagerMockImpl();
        System.out.println( "mock cache = " + cacheMgr.getCache( "test" ) );

        // get the listener started
        // give it our mock cache manager
        //LateralTCPListener listener = (LateralTCPListener)
        LateralTCPListener.getInstance( lattr, cacheMgr );

        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
        lattr2.setTcpListenerPort( 1106);
        lattr2.setTransmissionTypeName( "TCP" );
        lattr2.setTcpServer( "localhost:1105" );

        LateralTCPService service = new LateralTCPService( lattr2 );
        service.setListenerId( 123456 );

        String key = "key";
        ICacheElement element = new CacheElement( "test", key, "value1" );
        service.update( element );

        SleepUtil.sleepAtLeast( 300 );

        ICacheElement element2 = new CacheElement( "test", key, "value2" );
        service.update( element2 );

        SleepUtil.sleepAtLeast( 1000 );

        ICacheElement cacheElement = cacheMgr.getCache().get( "key" );
        System.out.println( "cacheElement = " + cacheElement );
        assertEquals( "Didn't get the correct object", element2.getVal(), cacheElement.getVal() );
    }
View Full Code Here

        throws Exception
    {
        // setup a listener
        TCPLateralCacheAttributes lattr = new TCPLateralCacheAttributes();
        lattr.setTcpListenerPort( 1107 );
        CompositeCacheManagerMockImpl cacheMgr = new CompositeCacheManagerMockImpl();
        System.out.println( "mock cache = " + cacheMgr.getCache( "test" ) );

        // get the listener started
        // give it our mock cache manager
        //LateralTCPListener listener = (LateralTCPListener)
        LateralTCPListener.getInstance( lattr, cacheMgr );

        // add the item to the listeners cache
        ICacheElement element = new CacheElement( "test", "key", "value1" );
        cacheMgr.getCache().update( element );

        // setup a service to talk to the listener started above.
        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
        lattr2.setTcpListenerPort( 1108 );
        lattr2.setTcpServer( "localhost:1107" );
View Full Code Here

    public void testUpdate()
        throws Exception
    {
        IRemoteCacheAttributes irca = new RemoteCacheAttributes();
        irca.setRemoveUponRemotePut( false );
        ICompositeCacheManager cacheMgr = new CompositeCacheManagerMockImpl();
        RemoteCacheListener listener = new RemoteCacheListener( irca, cacheMgr );

        String cacheName = "testName";
        String key = "key";
        String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
        IElementAttributes attr = new ElementAttributes();
        attr.setMaxLifeSeconds( 34 );

        IElementSerializer elementSerializer = new StandardSerializer();

        ICacheElementSerialized element = new CacheElementSerialized( cacheName, key, elementSerializer
            .serialize( value ), attr );
        listener.handlePut( element );

        ICacheElement after = cacheMgr.getCache( cacheName ).get( key );

        assertNotNull( "Should have a deserialized object.", after );
        assertEquals( "Values should be the same.", value, after.getVal() );
        assertEquals( "Attributes should be the same.", attr.getMaxLifeSeconds(), after
            .getElementAttributes().getMaxLifeSeconds() );
View Full Code Here

    public void testUpdate_RemoveOnPut()
        throws Exception
    {
        IRemoteCacheAttributes irca = new RemoteCacheAttributes();
        irca.setRemoveUponRemotePut( true );
        ICompositeCacheManager cacheMgr = new CompositeCacheManagerMockImpl();
        RemoteCacheListener listener = new RemoteCacheListener( irca, cacheMgr );

        String cacheName = "testName";
        String key = "key";
        String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
        IElementAttributes attr = new ElementAttributes();
        attr.setMaxLifeSeconds( 34 );

        IElementSerializer elementSerializer = new StandardSerializer();

        ICacheElementSerialized element = new CacheElementSerialized( cacheName, key, elementSerializer
            .serialize( value ), attr );
        listener.handlePut( element );

        ICacheElement after = cacheMgr.getCache( cacheName ).get( key );

        assertNull( "Should not have a deserialized object since remove on put is true.", after );
    }
View Full Code Here

TOP

Related Classes of org.apache.jcs.engine.control.CompositeCacheManagerMockImpl

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.