Hi Pulasthi,

You can initiate a new cache manager and a cache with a proper cache expiry
time.

CacheManager cacheManager =
Caching.getCacheManagerFactory().getCacheManager(
cacheManagerName);
Cache<String, String> cache = cacheManager.<String, String>
createCacheBuilder(cacheName).
setExpiry(CacheConfiguration.ExpiryType.MODIFIED,
new CacheConfiguration.Duration(TimeUnit.SECONDS, 10)).
setStoreByValue(false).build();

and put items in to that cache and sleep the thread until the cache expiry
time. After waking up you can assert whether the inserted item is null. If
null, the cache has expired.

There are some existing test cases [1] in the kernel.

[1]
https://github.com/wso2/carbon4-kernel/blob/master/core/javax.cache/src/test/java/org/wso2/carbon/caching/impl/CachingTestCase.java#L246


Thank you.
/Gayashan

On Wed, May 20, 2015 at 12:26 PM, Pulasthi Supun <[email protected]> wrote:

> Hi All,
>
> Is there a way to write automation tests to tests the timeout
> configurations of the cache. The test needs to be able to test if the cache
> values were invalidated after the given timeout.
>
> Best Regards,
> Pulasthi
>
> --
> --
> Pulasthi Supun
> Software Engineer; WSO2 Inc.; http://wso2.com,
> Email: [email protected]
> Mobile: +94 (71) 9258281
> Blog : http://pulasthisupun.blogspot.com/
> Git hub profile: https://github.com/pulasthi
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
*Gayashan Amarasinghe*
Software Engineer | Platform TG
WSO2, Inc. | http://wso2.com
lean. enterprise. middleware

Mobile : +94718314517
Blog : gayashan-a.blogspot.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to