You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2021/08/04 05:57:40 UTC

svn commit: r1076287 [26/35] - in /websites/production/turbine/content/fulcrum/fulcrum-cache: ./ announcements/ apidocs/ apidocs/org/apache/fulcrum/cache/ apidocs/org/apache/fulcrum/cache/class-use/ apidocs/org/apache/fulcrum/cache/impl/ apidocs/org/ap...

Modified: websites/production/turbine/content/fulcrum/fulcrum-cache/testapidocs/src-html/org/apache/fulcrum/cache/CacheTest.html
==============================================================================
--- websites/production/turbine/content/fulcrum/fulcrum-cache/testapidocs/src-html/org/apache/fulcrum/cache/CacheTest.html (original)
+++ websites/production/turbine/content/fulcrum/fulcrum-cache/testapidocs/src-html/org/apache/fulcrum/cache/CacheTest.html Wed Aug  4 05:57:38 2021
@@ -1,701 +1,746 @@
-<HTML>
-<BODY BGCOLOR="white">
-<PRE>
-<FONT color="green">001</FONT>    /*<a name="line.1"></a>
-<FONT color="green">002</FONT>     * Licensed to the Apache Software Foundation (ASF) under one<a name="line.2"></a>
-<FONT color="green">003</FONT>     * or more contributor license agreements.  See the NOTICE file<a name="line.3"></a>
-<FONT color="green">004</FONT>     * distributed with this work for additional information<a name="line.4"></a>
-<FONT color="green">005</FONT>     * regarding copyright ownership.  The ASF licenses this file<a name="line.5"></a>
-<FONT color="green">006</FONT>     * to you under the Apache License, Version 2.0 (the<a name="line.6"></a>
-<FONT color="green">007</FONT>     * "License"); you may not use this file except in compliance<a name="line.7"></a>
-<FONT color="green">008</FONT>     * with the License.  You may obtain a copy of the License at<a name="line.8"></a>
-<FONT color="green">009</FONT>     *<a name="line.9"></a>
-<FONT color="green">010</FONT>     *   http://www.apache.org/licenses/LICENSE-2.0<a name="line.10"></a>
-<FONT color="green">011</FONT>     *<a name="line.11"></a>
-<FONT color="green">012</FONT>     * Unless required by applicable law or agreed to in writing,<a name="line.12"></a>
-<FONT color="green">013</FONT>     * software distributed under the License is distributed on an<a name="line.13"></a>
-<FONT color="green">014</FONT>     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY<a name="line.14"></a>
-<FONT color="green">015</FONT>     * KIND, either express or implied.  See the License for the<a name="line.15"></a>
-<FONT color="green">016</FONT>     * specific language governing permissions and limitations<a name="line.16"></a>
-<FONT color="green">017</FONT>     * under the License.<a name="line.17"></a>
-<FONT color="green">018</FONT>     */<a name="line.18"></a>
-<FONT color="green">019</FONT>    <a name="line.19"></a>
-<FONT color="green">020</FONT>    package org.apache.fulcrum.cache;<a name="line.20"></a>
-<FONT color="green">021</FONT>    <a name="line.21"></a>
-<FONT color="green">022</FONT>    // Cactus and Junit imports<a name="line.22"></a>
-<FONT color="green">023</FONT>    <a name="line.23"></a>
-<FONT color="green">024</FONT>    import java.util.ConcurrentModificationException;<a name="line.24"></a>
-<FONT color="green">025</FONT>    import java.util.Date;<a name="line.25"></a>
-<FONT color="green">026</FONT>    import java.util.Iterator;<a name="line.26"></a>
-<FONT color="green">027</FONT>    import java.util.List;<a name="line.27"></a>
-<FONT color="green">028</FONT>    <a name="line.28"></a>
-<FONT color="green">029</FONT>    import org.apache.avalon.framework.component.ComponentException;<a name="line.29"></a>
-<FONT color="green">030</FONT>    import org.apache.commons.logging.Log;<a name="line.30"></a>
-<FONT color="green">031</FONT>    import org.apache.commons.logging.LogFactory;<a name="line.31"></a>
-<FONT color="green">032</FONT>    import org.apache.fulcrum.cache.impl.DefaultGlobalCacheService;<a name="line.32"></a>
-<FONT color="green">033</FONT>    import org.apache.fulcrum.testcontainer.BaseUnitTest;<a name="line.33"></a>
-<FONT color="green">034</FONT>    <a name="line.34"></a>
-<FONT color="green">035</FONT>    /**<a name="line.35"></a>
-<FONT color="green">036</FONT>     * CacheTest<a name="line.36"></a>
-<FONT color="green">037</FONT>     * <a name="line.37"></a>
-<FONT color="green">038</FONT>     * @author &lt;a href="paulsp@apache.org"&gt;Paul Spencer&lt;/a&gt;<a name="line.38"></a>
-<FONT color="green">039</FONT>     * @author &lt;a href="epugh@upstate.com"&gt;Eric Pugh&lt;/a&gt;<a name="line.39"></a>
-<FONT color="green">040</FONT>     * @author &lt;a href="mailto:peter@courcoux.biz"&gt;Peter Courcoux&lt;/a&gt;<a name="line.40"></a>
-<FONT color="green">041</FONT>     * @version $Id: CacheTest.java 927153 2010-03-24 18:55:08Z tv $<a name="line.41"></a>
-<FONT color="green">042</FONT>     */<a name="line.42"></a>
-<FONT color="green">043</FONT>    public class CacheTest extends BaseUnitTest<a name="line.43"></a>
-<FONT color="green">044</FONT>    {<a name="line.44"></a>
-<FONT color="green">045</FONT>    <a name="line.45"></a>
-<FONT color="green">046</FONT>        protected GlobalCacheService globalCache = null;<a name="line.46"></a>
-<FONT color="green">047</FONT>    <a name="line.47"></a>
-<FONT color="green">048</FONT>        protected static final String cacheKey = "CacheKey";<a name="line.48"></a>
-<FONT color="green">049</FONT>    <a name="line.49"></a>
-<FONT color="green">050</FONT>        protected static final String cacheKey_2 = "CacheKey_2";<a name="line.50"></a>
-<FONT color="green">051</FONT>    <a name="line.51"></a>
-<FONT color="green">052</FONT>        public static final String SKIP_TESTS_KEY = "fulcrum.cache.skip.long.tests";<a name="line.52"></a>
-<FONT color="green">053</FONT>    <a name="line.53"></a>
-<FONT color="green">054</FONT>        protected static final Log LOG = LogFactory.getLog(CacheTest.class);<a name="line.54"></a>
-<FONT color="green">055</FONT>    <a name="line.55"></a>
-<FONT color="green">056</FONT>        /**<a name="line.56"></a>
-<FONT color="green">057</FONT>         * Defines the testcase name for JUnit.<a name="line.57"></a>
-<FONT color="green">058</FONT>         * <a name="line.58"></a>
-<FONT color="green">059</FONT>         * @param name<a name="line.59"></a>
-<FONT color="green">060</FONT>         *            the testcase's name.<a name="line.60"></a>
-<FONT color="green">061</FONT>         */<a name="line.61"></a>
-<FONT color="green">062</FONT>        public CacheTest(String name)<a name="line.62"></a>
-<FONT color="green">063</FONT>        {<a name="line.63"></a>
-<FONT color="green">064</FONT>            super(name);<a name="line.64"></a>
-<FONT color="green">065</FONT>        }<a name="line.65"></a>
-<FONT color="green">066</FONT>    <a name="line.66"></a>
-<FONT color="green">067</FONT>        /**<a name="line.67"></a>
-<FONT color="green">068</FONT>         * Method to configure the role name of the service used<a name="line.68"></a>
-<FONT color="green">069</FONT>         * <a name="line.69"></a>
-<FONT color="green">070</FONT>         * @return the role name of the service to lookup<a name="line.70"></a>
-<FONT color="green">071</FONT>         */<a name="line.71"></a>
-<FONT color="green">072</FONT>        protected String getCacheRoleName()<a name="line.72"></a>
-<FONT color="green">073</FONT>        {<a name="line.73"></a>
-<FONT color="green">074</FONT>            return GlobalCacheService.ROLE;<a name="line.74"></a>
-<FONT color="green">075</FONT>        }<a name="line.75"></a>
-<FONT color="green">076</FONT>        <a name="line.76"></a>
-<FONT color="green">077</FONT>        protected void setUp() throws Exception<a name="line.77"></a>
-<FONT color="green">078</FONT>        {<a name="line.78"></a>
-<FONT color="green">079</FONT>            super.setUp();<a name="line.79"></a>
-<FONT color="green">080</FONT>            <a name="line.80"></a>
-<FONT color="green">081</FONT>            try<a name="line.81"></a>
-<FONT color="green">082</FONT>            {<a name="line.82"></a>
-<FONT color="green">083</FONT>                this.globalCache = (GlobalCacheService) this<a name="line.83"></a>
-<FONT color="green">084</FONT>                        .lookup(getCacheRoleName());<a name="line.84"></a>
-<FONT color="green">085</FONT>            }<a name="line.85"></a>
-<FONT color="green">086</FONT>            catch (ComponentException e)<a name="line.86"></a>
-<FONT color="green">087</FONT>            {<a name="line.87"></a>
-<FONT color="green">088</FONT>                e.printStackTrace();<a name="line.88"></a>
-<FONT color="green">089</FONT>                fail(e.getMessage());<a name="line.89"></a>
-<FONT color="green">090</FONT>            }<a name="line.90"></a>
-<FONT color="green">091</FONT>        }<a name="line.91"></a>
-<FONT color="green">092</FONT>    <a name="line.92"></a>
-<FONT color="green">093</FONT>        /**<a name="line.93"></a>
-<FONT color="green">094</FONT>         * Simple test that verify an object can be created and deleted.<a name="line.94"></a>
-<FONT color="green">095</FONT>         * <a name="line.95"></a>
-<FONT color="green">096</FONT>         * @throws Exception<a name="line.96"></a>
-<FONT color="green">097</FONT>         */<a name="line.97"></a>
-<FONT color="green">098</FONT>        public void testSimpleAddGetCacheObject() throws Exception<a name="line.98"></a>
-<FONT color="green">099</FONT>        {<a name="line.99"></a>
-<FONT color="green">100</FONT>            String testString = "This is a test";<a name="line.100"></a>
-<FONT color="green">101</FONT>            Object retrievedObject = null;<a name="line.101"></a>
-<FONT color="green">102</FONT>            CachedObject cacheObject1 = null;<a name="line.102"></a>
-<FONT color="green">103</FONT>            // Create object<a name="line.103"></a>
-<FONT color="green">104</FONT>            cacheObject1 = new CachedObject(testString);<a name="line.104"></a>
-<FONT color="green">105</FONT>            assertNotNull("Failed to create a cachable object 1", cacheObject1);<a name="line.105"></a>
-<FONT color="green">106</FONT>            // Add object to cache<a name="line.106"></a>
-<FONT color="green">107</FONT>            this.globalCache.addObject(cacheKey, cacheObject1);<a name="line.107"></a>
-<FONT color="green">108</FONT>            // Get object from cache<a name="line.108"></a>
-<FONT color="green">109</FONT>            retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.109"></a>
-<FONT color="green">110</FONT>            assertNotNull("Did not retrieve a cached object 1", retrievedObject);<a name="line.110"></a>
-<FONT color="green">111</FONT>            assertSame("Did not retrieve a correct, expected cached object 1",<a name="line.111"></a>
-<FONT color="green">112</FONT>                    retrievedObject, cacheObject1);<a name="line.112"></a>
-<FONT color="green">113</FONT>            // Remove object from cache<a name="line.113"></a>
-<FONT color="green">114</FONT>            this.globalCache.removeObject(cacheKey);<a name="line.114"></a>
-<FONT color="green">115</FONT>            // Verify object removed from cache<a name="line.115"></a>
-<FONT color="green">116</FONT>            retrievedObject = null;<a name="line.116"></a>
-<FONT color="green">117</FONT>            cacheObject1 = null;<a name="line.117"></a>
-<FONT color="green">118</FONT>            try<a name="line.118"></a>
-<FONT color="green">119</FONT>            {<a name="line.119"></a>
-<FONT color="green">120</FONT>                retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.120"></a>
-<FONT color="green">121</FONT>                assertNull(<a name="line.121"></a>
-<FONT color="green">122</FONT>                        "Retrieved the deleted cached object 1 and did not get expected ObjectExpiredException",<a name="line.122"></a>
-<FONT color="green">123</FONT>                        retrievedObject);<a name="line.123"></a>
-<FONT color="green">124</FONT>                assertNotNull(<a name="line.124"></a>
-<FONT color="green">125</FONT>                        "Did not get expected ObjectExpiredException retrieving a deleted object",<a name="line.125"></a>
-<FONT color="green">126</FONT>                        retrievedObject);<a name="line.126"></a>
-<FONT color="green">127</FONT>            }<a name="line.127"></a>
-<FONT color="green">128</FONT>            catch (ObjectExpiredException e)<a name="line.128"></a>
-<FONT color="green">129</FONT>            {<a name="line.129"></a>
-<FONT color="green">130</FONT>                assertNull(<a name="line.130"></a>
-<FONT color="green">131</FONT>                        "Retrieved the deleted cached object 1, but caught expected ObjectExpiredException exception",<a name="line.131"></a>
-<FONT color="green">132</FONT>                        retrievedObject);<a name="line.132"></a>
-<FONT color="green">133</FONT>            }<a name="line.133"></a>
-<FONT color="green">134</FONT>            // Remove object from cache that does NOT exist in the cache<a name="line.134"></a>
-<FONT color="green">135</FONT>            this.globalCache.removeObject(cacheKey);<a name="line.135"></a>
-<FONT color="green">136</FONT>        }<a name="line.136"></a>
-<FONT color="green">137</FONT>    <a name="line.137"></a>
-<FONT color="green">138</FONT>        /**<a name="line.138"></a>
-<FONT color="green">139</FONT>         * Simple test that adds, retrieves, and deletes 2 object.<a name="line.139"></a>
-<FONT color="green">140</FONT>         * <a name="line.140"></a>
-<FONT color="green">141</FONT>         * @throws Exception<a name="line.141"></a>
-<FONT color="green">142</FONT>         */<a name="line.142"></a>
-<FONT color="green">143</FONT>        public void test2ObjectAddGetCachedObject() throws Exception<a name="line.143"></a>
-<FONT color="green">144</FONT>        {<a name="line.144"></a>
-<FONT color="green">145</FONT>            String testString = "This is a test";<a name="line.145"></a>
-<FONT color="green">146</FONT>            Object retrievedObject = null;<a name="line.146"></a>
-<FONT color="green">147</FONT>            CachedObject cacheObject1 = null;<a name="line.147"></a>
-<FONT color="green">148</FONT>            CachedObject cacheObject2 = null;<a name="line.148"></a>
-<FONT color="green">149</FONT>            // Create and add Object #1<a name="line.149"></a>
-<FONT color="green">150</FONT>            cacheObject1 = new CachedObject(testString);<a name="line.150"></a>
-<FONT color="green">151</FONT>            assertNotNull("Failed to create a cachable object 1", cacheObject1);<a name="line.151"></a>
-<FONT color="green">152</FONT>            this.globalCache.addObject(cacheKey, cacheObject1);<a name="line.152"></a>
-<FONT color="green">153</FONT>            retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.153"></a>
-<FONT color="green">154</FONT>            assertNotNull("Did not retrieve a cached object 1", retrievedObject);<a name="line.154"></a>
-<FONT color="green">155</FONT>            assertEquals("Did not retrieve correct cached object", cacheObject1,<a name="line.155"></a>
-<FONT color="green">156</FONT>                    retrievedObject);<a name="line.156"></a>
-<FONT color="green">157</FONT>            // Create and add Object #2<a name="line.157"></a>
-<FONT color="green">158</FONT>            cacheObject2 = new CachedObject(testString);<a name="line.158"></a>
-<FONT color="green">159</FONT>            assertNotNull("Failed to create a cachable object 2", cacheObject2);<a name="line.159"></a>
-<FONT color="green">160</FONT>            this.globalCache.addObject(cacheKey_2, cacheObject2);<a name="line.160"></a>
-<FONT color="green">161</FONT>            retrievedObject = this.globalCache.getObject(cacheKey_2);<a name="line.161"></a>
-<FONT color="green">162</FONT>            assertNotNull("Did not retrieve a cached object 2", retrievedObject);<a name="line.162"></a>
-<FONT color="green">163</FONT>            assertEquals("Did not retrieve correct cached object 2", cacheObject2,<a name="line.163"></a>
-<FONT color="green">164</FONT>                    retrievedObject);<a name="line.164"></a>
-<FONT color="green">165</FONT>            // Get object #1<a name="line.165"></a>
-<FONT color="green">166</FONT>            retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.166"></a>
-<FONT color="green">167</FONT>            assertNotNull("Did not retrieve a cached object 1. Attempt #2",<a name="line.167"></a>
-<FONT color="green">168</FONT>                    retrievedObject);<a name="line.168"></a>
-<FONT color="green">169</FONT>            assertEquals("Did not retrieve correct cached object 1. Attempt #2",<a name="line.169"></a>
-<FONT color="green">170</FONT>                    cacheObject1, retrievedObject);<a name="line.170"></a>
-<FONT color="green">171</FONT>            // Get object #1<a name="line.171"></a>
-<FONT color="green">172</FONT>            retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.172"></a>
-<FONT color="green">173</FONT>            assertNotNull("Did not retrieve a cached object 1. Attempt #3",<a name="line.173"></a>
-<FONT color="green">174</FONT>                    retrievedObject);<a name="line.174"></a>
-<FONT color="green">175</FONT>            assertEquals("Did not retrieve correct cached object 1. Attempt #3",<a name="line.175"></a>
-<FONT color="green">176</FONT>                    cacheObject1, retrievedObject);<a name="line.176"></a>
-<FONT color="green">177</FONT>            // Get object #2<a name="line.177"></a>
-<FONT color="green">178</FONT>            retrievedObject = this.globalCache.getObject(cacheKey_2);<a name="line.178"></a>
-<FONT color="green">179</FONT>            assertNotNull("Did not retrieve a cached object 2. Attempt #2",<a name="line.179"></a>
-<FONT color="green">180</FONT>                    retrievedObject);<a name="line.180"></a>
-<FONT color="green">181</FONT>            assertEquals("Did not retrieve correct cached object 2 Attempt #2",<a name="line.181"></a>
-<FONT color="green">182</FONT>                    cacheObject2, retrievedObject);<a name="line.182"></a>
-<FONT color="green">183</FONT>            // Remove objects<a name="line.183"></a>
-<FONT color="green">184</FONT>            this.globalCache.removeObject(cacheKey);<a name="line.184"></a>
-<FONT color="green">185</FONT>            this.globalCache.removeObject(cacheKey_2);<a name="line.185"></a>
-<FONT color="green">186</FONT>        }<a name="line.186"></a>
-<FONT color="green">187</FONT>    <a name="line.187"></a>
-<FONT color="green">188</FONT>        /**<a name="line.188"></a>
-<FONT color="green">189</FONT>         * Verify that an object will throw the ObjectExpiredException when it now<a name="line.189"></a>
-<FONT color="green">190</FONT>         * longer exists in cache.<a name="line.190"></a>
-<FONT color="green">191</FONT>         * <a name="line.191"></a>
-<FONT color="green">192</FONT>         * @throws Exception<a name="line.192"></a>
-<FONT color="green">193</FONT>         */<a name="line.193"></a>
-<FONT color="green">194</FONT>        public void testObjectExpiration() throws Exception<a name="line.194"></a>
-<FONT color="green">195</FONT>        {<a name="line.195"></a>
-<FONT color="green">196</FONT>            String testString = "This is a test";<a name="line.196"></a>
-<FONT color="green">197</FONT>            Object retrievedObject = null;<a name="line.197"></a>
-<FONT color="green">198</FONT>            CachedObject cacheObject = null;<a name="line.198"></a>
-<FONT color="green">199</FONT>            // Create and add Object that expires in 1000 millis (1 second)<a name="line.199"></a>
-<FONT color="green">200</FONT>            cacheObject = new CachedObject(testString, 1000);<a name="line.200"></a>
-<FONT color="green">201</FONT>            assertNotNull("Failed to create a cachable object", cacheObject);<a name="line.201"></a>
-<FONT color="green">202</FONT>            long addTime = System.currentTimeMillis();<a name="line.202"></a>
-<FONT color="green">203</FONT>            this.globalCache.addObject(cacheKey, cacheObject);<a name="line.203"></a>
-<FONT color="green">204</FONT>            // Try to get un-expired object<a name="line.204"></a>
-<FONT color="green">205</FONT>            try<a name="line.205"></a>
-<FONT color="green">206</FONT>            {<a name="line.206"></a>
-<FONT color="green">207</FONT>                retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.207"></a>
-<FONT color="green">208</FONT>                assertNotNull("Did not retrieve a cached object", retrievedObject);<a name="line.208"></a>
-<FONT color="green">209</FONT>                assertEquals("Did not retrieve correct cached object",<a name="line.209"></a>
-<FONT color="green">210</FONT>                        cacheObject, retrievedObject);<a name="line.210"></a>
-<FONT color="green">211</FONT>            }<a name="line.211"></a>
-<FONT color="green">212</FONT>            catch (ObjectExpiredException e)<a name="line.212"></a>
-<FONT color="green">213</FONT>            {<a name="line.213"></a>
-<FONT color="green">214</FONT>                assertTrue("Object expired early ( "<a name="line.214"></a>
-<FONT color="green">215</FONT>                        + (System.currentTimeMillis() - addTime) + " millis)",<a name="line.215"></a>
-<FONT color="green">216</FONT>                        false);<a name="line.216"></a>
-<FONT color="green">217</FONT>            }<a name="line.217"></a>
-<FONT color="green">218</FONT>            // Sleep 1500 Millis (1.5 seconds)<a name="line.218"></a>
-<FONT color="green">219</FONT>            Thread.sleep(1500);<a name="line.219"></a>
-<FONT color="green">220</FONT>            // Try to get expired object<a name="line.220"></a>
-<FONT color="green">221</FONT>            try<a name="line.221"></a>
-<FONT color="green">222</FONT>            {<a name="line.222"></a>
-<FONT color="green">223</FONT>                retrievedObject = null;<a name="line.223"></a>
-<FONT color="green">224</FONT>                retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.224"></a>
-<FONT color="green">225</FONT>                assertNull(<a name="line.225"></a>
-<FONT color="green">226</FONT>                        "Retrieved the expired cached object  and did not get expected ObjectExpiredException",<a name="line.226"></a>
-<FONT color="green">227</FONT>                        retrievedObject);<a name="line.227"></a>
-<FONT color="green">228</FONT>                assertNotNull(<a name="line.228"></a>
-<FONT color="green">229</FONT>                        "Did not get expected ObjectExpiredException retrieving an expired object",<a name="line.229"></a>
-<FONT color="green">230</FONT>                        retrievedObject);<a name="line.230"></a>
-<FONT color="green">231</FONT>            }<a name="line.231"></a>
-<FONT color="green">232</FONT>            catch (ObjectExpiredException e)<a name="line.232"></a>
-<FONT color="green">233</FONT>            {<a name="line.233"></a>
-<FONT color="green">234</FONT>                assertNull(<a name="line.234"></a>
-<FONT color="green">235</FONT>                        "Retrieved the expired cached object, but caught expected ObjectExpiredException exception",<a name="line.235"></a>
-<FONT color="green">236</FONT>                        retrievedObject);<a name="line.236"></a>
-<FONT color="green">237</FONT>            }<a name="line.237"></a>
-<FONT color="green">238</FONT>            // Remove objects<a name="line.238"></a>
-<FONT color="green">239</FONT>            this.globalCache.removeObject(cacheKey);<a name="line.239"></a>
-<FONT color="green">240</FONT>        }<a name="line.240"></a>
-<FONT color="green">241</FONT>    <a name="line.241"></a>
-<FONT color="green">242</FONT>        /**<a name="line.242"></a>
-<FONT color="green">243</FONT>         * Verify the all object will be flushed from the cache.<a name="line.243"></a>
-<FONT color="green">244</FONT>         * <a name="line.244"></a>
-<FONT color="green">245</FONT>         * This test can take server minutes.<a name="line.245"></a>
-<FONT color="green">246</FONT>         * <a name="line.246"></a>
-<FONT color="green">247</FONT>         * @throws Exception<a name="line.247"></a>
-<FONT color="green">248</FONT>         */<a name="line.248"></a>
-<FONT color="green">249</FONT>        public void testCacheFlush() throws Exception<a name="line.249"></a>
-<FONT color="green">250</FONT>        {<a name="line.250"></a>
-<FONT color="green">251</FONT>            String testString = "This is a test";<a name="line.251"></a>
-<FONT color="green">252</FONT>            CachedObject cacheObject = null;<a name="line.252"></a>
-<FONT color="green">253</FONT>            // Create and add Object that expires in 1 turbine Refresh + 1 millis<a name="line.253"></a>
-<FONT color="green">254</FONT>            cacheObject = new CachedObject(testString, (getCacheRefresh() * 5) + 1);<a name="line.254"></a>
-<FONT color="green">255</FONT>            assertNotNull("Failed to create a cachable object", cacheObject);<a name="line.255"></a>
-<FONT color="green">256</FONT>            this.globalCache.addObject(cacheKey, cacheObject);<a name="line.256"></a>
-<FONT color="green">257</FONT>            // 1 Refresh<a name="line.257"></a>
-<FONT color="green">258</FONT>            Thread.sleep(getCacheRefresh() + 1);<a name="line.258"></a>
-<FONT color="green">259</FONT>            assertTrue("No object in cache before flush", (0 &lt; this.globalCache<a name="line.259"></a>
-<FONT color="green">260</FONT>                    .getNumberOfObjects()));<a name="line.260"></a>
-<FONT color="green">261</FONT>            // Flush Cache<a name="line.261"></a>
-<FONT color="green">262</FONT>            this.globalCache.flushCache();<a name="line.262"></a>
-<FONT color="green">263</FONT>            // Wait 15 seconds, 3 Refresh<a name="line.263"></a>
-<FONT color="green">264</FONT>            Thread.sleep((getCacheRefresh() * 2) + 1);<a name="line.264"></a>
-<FONT color="green">265</FONT>            assertEquals("After refresh", 0, this.globalCache.getNumberOfObjects());<a name="line.265"></a>
-<FONT color="green">266</FONT>            // Remove objects<a name="line.266"></a>
-<FONT color="green">267</FONT>            this.globalCache.removeObject(cacheKey);<a name="line.267"></a>
-<FONT color="green">268</FONT>        }<a name="line.268"></a>
-<FONT color="green">269</FONT>    <a name="line.269"></a>
-<FONT color="green">270</FONT>        /**<a name="line.270"></a>
-<FONT color="green">271</FONT>         * Verify the Cache count is correct.<a name="line.271"></a>
-<FONT color="green">272</FONT>         * <a name="line.272"></a>
-<FONT color="green">273</FONT>         * @throws Exception<a name="line.273"></a>
-<FONT color="green">274</FONT>         */<a name="line.274"></a>
-<FONT color="green">275</FONT>        public void testObjectCount() throws Exception<a name="line.275"></a>
-<FONT color="green">276</FONT>        {<a name="line.276"></a>
-<FONT color="green">277</FONT>            assertNotNull("Could not retrieve cache service.", this.globalCache);<a name="line.277"></a>
-<FONT color="green">278</FONT>            <a name="line.278"></a>
-<FONT color="green">279</FONT>            long cacheRefresh = getCacheRefresh();<a name="line.279"></a>
-<FONT color="green">280</FONT>            <a name="line.280"></a>
-<FONT color="green">281</FONT>            // Create and add Object that expires in 1.5 turbine Refresh<a name="line.281"></a>
-<FONT color="green">282</FONT>            long expireTime = cacheRefresh + cacheRefresh / 2;<a name="line.282"></a>
-<FONT color="green">283</FONT>            <a name="line.283"></a>
-<FONT color="green">284</FONT>            CachedObject cacheObject = new CachedObject("This is a test",<a name="line.284"></a>
-<FONT color="green">285</FONT>                    expireTime);<a name="line.285"></a>
-<FONT color="green">286</FONT>            assertNotNull("Failed to create a cachable object", cacheObject);<a name="line.286"></a>
-<FONT color="green">287</FONT>            <a name="line.287"></a>
-<FONT color="green">288</FONT>            this.globalCache.addObject(cacheKey, cacheObject);<a name="line.288"></a>
-<FONT color="green">289</FONT>            assertEquals("After adding 1 Object", 1, this.globalCache<a name="line.289"></a>
-<FONT color="green">290</FONT>                    .getNumberOfObjects());<a name="line.290"></a>
-<FONT color="green">291</FONT>            <a name="line.291"></a>
-<FONT color="green">292</FONT>            // Wait until we're passed 1 refresh, but not half way.<a name="line.292"></a>
-<FONT color="green">293</FONT>            Thread.sleep(cacheRefresh + cacheRefresh / 3);<a name="line.293"></a>
-<FONT color="green">294</FONT>            assertEquals("After one refresh", 1, this.globalCache<a name="line.294"></a>
-<FONT color="green">295</FONT>                    .getNumberOfObjects());<a name="line.295"></a>
-<FONT color="green">296</FONT>            <a name="line.296"></a>
-<FONT color="green">297</FONT>            // Wait until we're passed 2 more refreshes<a name="line.297"></a>
-<FONT color="green">298</FONT>            Thread.sleep((cacheRefresh * 2) + cacheRefresh / 3);<a name="line.298"></a>
-<FONT color="green">299</FONT>            assertEquals("After three refreshes", 0, this.globalCache<a name="line.299"></a>
-<FONT color="green">300</FONT>                    .getNumberOfObjects());<a name="line.300"></a>
-<FONT color="green">301</FONT>        }<a name="line.301"></a>
-<FONT color="green">302</FONT>    <a name="line.302"></a>
-<FONT color="green">303</FONT>        /**<a name="line.303"></a>
-<FONT color="green">304</FONT>         * Verfy a refreshable object will refreshed in the following cases: o The<a name="line.304"></a>
-<FONT color="green">305</FONT>         * object is retrieved via getObject an it is stale. o The object is<a name="line.305"></a>
-<FONT color="green">306</FONT>         * determied to be stale during a cache refresh<a name="line.306"></a>
-<FONT color="green">307</FONT>         * <a name="line.307"></a>
-<FONT color="green">308</FONT>         * This test can take serveral minutes.<a name="line.308"></a>
-<FONT color="green">309</FONT>         * <a name="line.309"></a>
-<FONT color="green">310</FONT>         * @throws Exception<a name="line.310"></a>
-<FONT color="green">311</FONT>         */<a name="line.311"></a>
-<FONT color="green">312</FONT>        public void testRefreshableObject() throws Exception<a name="line.312"></a>
-<FONT color="green">313</FONT>        {<a name="line.313"></a>
-<FONT color="green">314</FONT>            Object retrievedObject = null;<a name="line.314"></a>
-<FONT color="green">315</FONT>            RefreshableCachedObject cacheObject = null;<a name="line.315"></a>
-<FONT color="green">316</FONT>            // Create and add Object that expires in TEST_EXPIRETIME millis.<a name="line.316"></a>
-<FONT color="green">317</FONT>            cacheObject = new RefreshableCachedObject(new RefreshableObject(),<a name="line.317"></a>
-<FONT color="green">318</FONT>                    getTestExpireTime());<a name="line.318"></a>
-<FONT color="green">319</FONT>            assertNotNull("Failed to create a cachable object", cacheObject);<a name="line.319"></a>
-<FONT color="green">320</FONT>            long addTime = System.currentTimeMillis();<a name="line.320"></a>
-<FONT color="green">321</FONT>            this.globalCache.addObject(cacheKey, cacheObject);<a name="line.321"></a>
-<FONT color="green">322</FONT>            // Try to get un-expired object<a name="line.322"></a>
-<FONT color="green">323</FONT>            try<a name="line.323"></a>
-<FONT color="green">324</FONT>            {<a name="line.324"></a>
-<FONT color="green">325</FONT>                retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.325"></a>
-<FONT color="green">326</FONT>                assertNotNull("Did not retrieve a cached object", retrievedObject);<a name="line.326"></a>
-<FONT color="green">327</FONT>                assertEquals("Did not retrieve correct cached object",<a name="line.327"></a>
-<FONT color="green">328</FONT>                        cacheObject, retrievedObject);<a name="line.328"></a>
-<FONT color="green">329</FONT>            }<a name="line.329"></a>
-<FONT color="green">330</FONT>            catch (ObjectExpiredException e)<a name="line.330"></a>
-<FONT color="green">331</FONT>            {<a name="line.331"></a>
-<FONT color="green">332</FONT>                assertTrue("Object expired early ( "<a name="line.332"></a>
-<FONT color="green">333</FONT>                        + (System.currentTimeMillis() - addTime) + " millis)",<a name="line.333"></a>
-<FONT color="green">334</FONT>                        false);<a name="line.334"></a>
-<FONT color="green">335</FONT>            }<a name="line.335"></a>
-<FONT color="green">336</FONT>            // Wait 1 Turbine cache refresh + 1 second.<a name="line.336"></a>
-<FONT color="green">337</FONT>            Thread.sleep(getTestExpireTime() + 1000);<a name="line.337"></a>
-<FONT color="green">338</FONT>            // Try to get expired object<a name="line.338"></a>
-<FONT color="green">339</FONT>            try<a name="line.339"></a>
-<FONT color="green">340</FONT>            {<a name="line.340"></a>
-<FONT color="green">341</FONT>                retrievedObject = null;<a name="line.341"></a>
-<FONT color="green">342</FONT>                retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.342"></a>
-<FONT color="green">343</FONT>                assertNotNull("Did not retrieve a cached object, after sleep",<a name="line.343"></a>
-<FONT color="green">344</FONT>                        retrievedObject);<a name="line.344"></a>
-<FONT color="green">345</FONT>                assertNotNull("Cached object has no contents, after sleep.",<a name="line.345"></a>
-<FONT color="green">346</FONT>                        ((RefreshableCachedObject) retrievedObject).getContents());<a name="line.346"></a>
-<FONT color="green">347</FONT>                assertTrue(<a name="line.347"></a>
-<FONT color="green">348</FONT>                        "Object did not refresh.",<a name="line.348"></a>
-<FONT color="green">349</FONT>                        (((RefreshableObject) ((RefreshableCachedObject) retrievedObject)<a name="line.349"></a>
-<FONT color="green">350</FONT>                                .getContents()).getRefreshCount() &gt; 0));<a name="line.350"></a>
-<FONT color="green">351</FONT>            }<a name="line.351"></a>
-<FONT color="green">352</FONT>            catch (ObjectExpiredException e)<a name="line.352"></a>
-<FONT color="green">353</FONT>            {<a name="line.353"></a>
-<FONT color="green">354</FONT>                assertTrue("Received unexpected ObjectExpiredException exception "<a name="line.354"></a>
-<FONT color="green">355</FONT>                        + "when retrieving refreshable object after ( "<a name="line.355"></a>
-<FONT color="green">356</FONT>                        + (System.currentTimeMillis() - addTime) + " millis)",<a name="line.356"></a>
-<FONT color="green">357</FONT>                        false);<a name="line.357"></a>
-<FONT color="green">358</FONT>            }<a name="line.358"></a>
-<FONT color="green">359</FONT>            // See if object will expires (testing every second for 100 seconds. It<a name="line.359"></a>
-<FONT color="green">360</FONT>            // sould not!<a name="line.360"></a>
-<FONT color="green">361</FONT>            for (int i = 0; i &lt; 100; i++)<a name="line.361"></a>
-<FONT color="green">362</FONT>            {<a name="line.362"></a>
-<FONT color="green">363</FONT>                Thread.sleep(1000); // Sleep 0.5 seconds<a name="line.363"></a>
-<FONT color="green">364</FONT>                // Try to get expired object<a name="line.364"></a>
-<FONT color="green">365</FONT>                try<a name="line.365"></a>
-<FONT color="green">366</FONT>                {<a name="line.366"></a>
-<FONT color="green">367</FONT>                    retrievedObject = null;<a name="line.367"></a>
-<FONT color="green">368</FONT>                    retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.368"></a>
-<FONT color="green">369</FONT>                    assertNotNull("Did not retrieve a cached object, after sleep",<a name="line.369"></a>
-<FONT color="green">370</FONT>                            retrievedObject);<a name="line.370"></a>
-<FONT color="green">371</FONT>                    assertNotNull("Cached object has no contents, after sleep.",<a name="line.371"></a>
-<FONT color="green">372</FONT>                            ((RefreshableCachedObject) retrievedObject)<a name="line.372"></a>
-<FONT color="green">373</FONT>                                    .getContents());<a name="line.373"></a>
-<FONT color="green">374</FONT>                    assertTrue(<a name="line.374"></a>
-<FONT color="green">375</FONT>                            "Object did not refresh.",<a name="line.375"></a>
-<FONT color="green">376</FONT>                            (((RefreshableObject) ((RefreshableCachedObject) retrievedObject)<a name="line.376"></a>
-<FONT color="green">377</FONT>                                    .getContents()).getRefreshCount() &gt; 0));<a name="line.377"></a>
-<FONT color="green">378</FONT>                }<a name="line.378"></a>
-<FONT color="green">379</FONT>                catch (ObjectExpiredException e)<a name="line.379"></a>
-<FONT color="green">380</FONT>                {<a name="line.380"></a>
-<FONT color="green">381</FONT>                    assertTrue(<a name="line.381"></a>
-<FONT color="green">382</FONT>                            "Received unexpected ObjectExpiredException exception "<a name="line.382"></a>
-<FONT color="green">383</FONT>                                    + "when retrieving refreshable object after ( "<a name="line.383"></a>
-<FONT color="green">384</FONT>                                    + (System.currentTimeMillis() - addTime)<a name="line.384"></a>
-<FONT color="green">385</FONT>                                    + " millis)", false);<a name="line.385"></a>
-<FONT color="green">386</FONT>                }<a name="line.386"></a>
-<FONT color="green">387</FONT>            }<a name="line.387"></a>
-<FONT color="green">388</FONT>            // Remove objects<a name="line.388"></a>
-<FONT color="green">389</FONT>            this.globalCache.removeObject(cacheKey);<a name="line.389"></a>
-<FONT color="green">390</FONT>        }<a name="line.390"></a>
-<FONT color="green">391</FONT>    <a name="line.391"></a>
-<FONT color="green">392</FONT>        /**<a name="line.392"></a>
-<FONT color="green">393</FONT>         * Verify a cached object will be delete after it has been untouched beyond<a name="line.393"></a>
-<FONT color="green">394</FONT>         * it's TimeToLive.<a name="line.394"></a>
-<FONT color="green">395</FONT>         * <a name="line.395"></a>
-<FONT color="green">396</FONT>         * This test can take serveral minutes.<a name="line.396"></a>
-<FONT color="green">397</FONT>         * <a name="line.397"></a>
-<FONT color="green">398</FONT>         * @throws Exception<a name="line.398"></a>
-<FONT color="green">399</FONT>         */<a name="line.399"></a>
-<FONT color="green">400</FONT>        public void testRefreshableTimeToLive() throws Exception<a name="line.400"></a>
-<FONT color="green">401</FONT>        {<a name="line.401"></a>
-<FONT color="green">402</FONT>            String skipTestsProperty = System.getProperty(SKIP_TESTS_KEY, "false");<a name="line.402"></a>
-<FONT color="green">403</FONT>            LOG.info("What is the value of the skipTestsProperty:"<a name="line.403"></a>
-<FONT color="green">404</FONT>                    + skipTestsProperty);<a name="line.404"></a>
-<FONT color="green">405</FONT>            if (Boolean.valueOf(skipTestsProperty).booleanValue())<a name="line.405"></a>
-<FONT color="green">406</FONT>            {<a name="line.406"></a>
-<FONT color="green">407</FONT>                LOG.warn("Skipping testRefreshableTimeToLive test due to property "<a name="line.407"></a>
-<FONT color="green">408</FONT>                        + SKIP_TESTS_KEY + " being true.");<a name="line.408"></a>
-<FONT color="green">409</FONT>                return;<a name="line.409"></a>
-<FONT color="green">410</FONT>            }<a name="line.410"></a>
-<FONT color="green">411</FONT>            else<a name="line.411"></a>
-<FONT color="green">412</FONT>            {<a name="line.412"></a>
-<FONT color="green">413</FONT>                LOG.warn("Running testRefreshableTimeToLive test due to property "<a name="line.413"></a>
-<FONT color="green">414</FONT>                        + SKIP_TESTS_KEY + " being false.");<a name="line.414"></a>
-<FONT color="green">415</FONT>            }<a name="line.415"></a>
-<FONT color="green">416</FONT>    <a name="line.416"></a>
-<FONT color="green">417</FONT>            Object retrievedObject = null;<a name="line.417"></a>
-<FONT color="green">418</FONT>            RefreshableCachedObject cacheObject = null;<a name="line.418"></a>
-<FONT color="green">419</FONT>            // Create and add Object that expires in TEST_EXPIRETIME millis.<a name="line.419"></a>
-<FONT color="green">420</FONT>            cacheObject = new RefreshableCachedObject(new RefreshableObject(),<a name="line.420"></a>
-<FONT color="green">421</FONT>                    getTestExpireTime());<a name="line.421"></a>
-<FONT color="green">422</FONT>            assertNotNull("Failed to create a cachable object", cacheObject);<a name="line.422"></a>
-<FONT color="green">423</FONT>            cacheObject.setTTL(getTestExpireTime());<a name="line.423"></a>
-<FONT color="green">424</FONT>            // Verify TimeToLive was set<a name="line.424"></a>
-<FONT color="green">425</FONT>            assertEquals("Returned TimeToLive", getTestExpireTime(), cacheObject<a name="line.425"></a>
-<FONT color="green">426</FONT>                    .getTTL());<a name="line.426"></a>
-<FONT color="green">427</FONT>            // Add object to Cache<a name="line.427"></a>
-<FONT color="green">428</FONT>            this.globalCache.addObject(cacheKey, cacheObject);<a name="line.428"></a>
-<FONT color="green">429</FONT>            long addTime = System.currentTimeMillis();<a name="line.429"></a>
-<FONT color="green">430</FONT>            // Try to get un-expired object<a name="line.430"></a>
-<FONT color="green">431</FONT>            try<a name="line.431"></a>
-<FONT color="green">432</FONT>            {<a name="line.432"></a>
-<FONT color="green">433</FONT>                retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.433"></a>
-<FONT color="green">434</FONT>                assertNotNull("Did not retrieve a cached object", retrievedObject);<a name="line.434"></a>
-<FONT color="green">435</FONT>                assertEquals("Did not retrieve correct cached object",<a name="line.435"></a>
-<FONT color="green">436</FONT>                        cacheObject, retrievedObject);<a name="line.436"></a>
-<FONT color="green">437</FONT>            }<a name="line.437"></a>
-<FONT color="green">438</FONT>            catch (ObjectExpiredException e)<a name="line.438"></a>
-<FONT color="green">439</FONT>            {<a name="line.439"></a>
-<FONT color="green">440</FONT>                fail("Object expired early ( "<a name="line.440"></a>
-<FONT color="green">441</FONT>                        + (System.currentTimeMillis() - addTime) + " millis)");<a name="line.441"></a>
-<FONT color="green">442</FONT>            }<a name="line.442"></a>
-<FONT color="green">443</FONT>            // Wait long enough to allow object to expire, but do not exceed TTL<a name="line.443"></a>
-<FONT color="green">444</FONT>            long timeout = getTestExpireTime() - 0000;<a name="line.444"></a>
-<FONT color="green">445</FONT>            Thread.sleep(timeout);<a name="line.445"></a>
-<FONT color="green">446</FONT>            // Try to get expired object<a name="line.446"></a>
-<FONT color="green">447</FONT>            try<a name="line.447"></a>
-<FONT color="green">448</FONT>            {<a name="line.448"></a>
-<FONT color="green">449</FONT>                retrievedObject = null;<a name="line.449"></a>
-<FONT color="green">450</FONT>                retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.450"></a>
-<FONT color="green">451</FONT>                assertNotNull("Did not retrieve a cached object, after sleep",<a name="line.451"></a>
-<FONT color="green">452</FONT>                        retrievedObject);<a name="line.452"></a>
-<FONT color="green">453</FONT>                assertNotNull("Cached object has no contents, after sleep.",<a name="line.453"></a>
-<FONT color="green">454</FONT>                        ((RefreshableCachedObject) retrievedObject).getContents());<a name="line.454"></a>
-<FONT color="green">455</FONT>                /*<a name="line.455"></a>
-<FONT color="green">456</FONT>                 * @todo this is not working for some reason<a name="line.456"></a>
-<FONT color="green">457</FONT>                 * <a name="line.457"></a>
-<FONT color="green">458</FONT>                 * assertTrue( "Object did not refresh.", (((RefreshableObject)<a name="line.458"></a>
-<FONT color="green">459</FONT>                 * ((RefreshableCachedObject)<a name="line.459"></a>
-<FONT color="green">460</FONT>                 * retrievedObject).getContents()).getRefreshCount() &gt; 0));<a name="line.460"></a>
-<FONT color="green">461</FONT>                 */<a name="line.461"></a>
-<FONT color="green">462</FONT>            }<a name="line.462"></a>
-<FONT color="green">463</FONT>            catch (ObjectExpiredException e)<a name="line.463"></a>
-<FONT color="green">464</FONT>            {<a name="line.464"></a>
-<FONT color="green">465</FONT>                assertTrue("Received unexpected ObjectExpiredException exception "<a name="line.465"></a>
-<FONT color="green">466</FONT>                        + "when retrieving refreshable object after ( "<a name="line.466"></a>
-<FONT color="green">467</FONT>                        + (System.currentTimeMillis() - addTime) + " millis)",<a name="line.467"></a>
-<FONT color="green">468</FONT>                        false);<a name="line.468"></a>
-<FONT color="green">469</FONT>            }<a name="line.469"></a>
-<FONT color="green">470</FONT>            // Wait long enough to allow object to expire and exceed TTL<a name="line.470"></a>
-<FONT color="green">471</FONT>            Thread.sleep(getTestExpireTime() + 5000);<a name="line.471"></a>
-<FONT color="green">472</FONT>            // Try to get expired object<a name="line.472"></a>
-<FONT color="green">473</FONT>            try<a name="line.473"></a>
-<FONT color="green">474</FONT>            {<a name="line.474"></a>
-<FONT color="green">475</FONT>                retrievedObject = null;<a name="line.475"></a>
-<FONT color="green">476</FONT>                retrievedObject = this.globalCache.getObject(cacheKey);<a name="line.476"></a>
-<FONT color="green">477</FONT>                assertNull("Retrieved a cached object, after exceeding TimeToLive",<a name="line.477"></a>
-<FONT color="green">478</FONT>                        retrievedObject);<a name="line.478"></a>
-<FONT color="green">479</FONT>            }<a name="line.479"></a>
-<FONT color="green">480</FONT>            catch (ObjectExpiredException e)<a name="line.480"></a>
-<FONT color="green">481</FONT>            {<a name="line.481"></a>
-<FONT color="green">482</FONT>                assertNull(<a name="line.482"></a>
-<FONT color="green">483</FONT>                        "Retrieved the expired cached object, but caught expected ObjectExpiredException exception",<a name="line.483"></a>
-<FONT color="green">484</FONT>                        retrievedObject);<a name="line.484"></a>
-<FONT color="green">485</FONT>            }<a name="line.485"></a>
-<FONT color="green">486</FONT>        }<a name="line.486"></a>
-<FONT color="green">487</FONT>    <a name="line.487"></a>
-<FONT color="green">488</FONT>        /**<a name="line.488"></a>
-<FONT color="green">489</FONT>         * Test that we can get a list of the keys in the cache<a name="line.489"></a>
-<FONT color="green">490</FONT>         * <a name="line.490"></a>
-<FONT color="green">491</FONT>         * @return<a name="line.491"></a>
-<FONT color="green">492</FONT>         */<a name="line.492"></a>
-<FONT color="green">493</FONT>        public void testCacheGetKeyList()<a name="line.493"></a>
-<FONT color="green">494</FONT>        {<a name="line.494"></a>
-<FONT color="green">495</FONT>            this.globalCache.flushCache();<a name="line.495"></a>
-<FONT color="green">496</FONT>            this.globalCache.addObject("date1", new CachedObject(new Date()));<a name="line.496"></a>
-<FONT color="green">497</FONT>            this.globalCache.addObject("date2", new CachedObject(new Date()));<a name="line.497"></a>
-<FONT color="green">498</FONT>            this.globalCache.addObject("date3", new CachedObject(new Date()));<a name="line.498"></a>
-<FONT color="green">499</FONT>            assertTrue("Did not get key list back.",<a name="line.499"></a>
-<FONT color="green">500</FONT>                    (this.globalCache.getKeys() != null));<a name="line.500"></a>
-<FONT color="green">501</FONT>            List keys = this.globalCache.getKeys();<a name="line.501"></a>
-<FONT color="green">502</FONT>            for (Iterator itr = keys.iterator(); itr.hasNext();)<a name="line.502"></a>
-<FONT color="green">503</FONT>            {<a name="line.503"></a>
-<FONT color="green">504</FONT>                Object key = itr.next();<a name="line.504"></a>
-<FONT color="green">505</FONT>                assertTrue("Key was not an instance of String.",<a name="line.505"></a>
-<FONT color="green">506</FONT>                        (key instanceof String));<a name="line.506"></a>
-<FONT color="green">507</FONT>            }<a name="line.507"></a>
-<FONT color="green">508</FONT>    <a name="line.508"></a>
-<FONT color="green">509</FONT>        }<a name="line.509"></a>
-<FONT color="green">510</FONT>    <a name="line.510"></a>
-<FONT color="green">511</FONT>        /**<a name="line.511"></a>
-<FONT color="green">512</FONT>         * Test that we can get a list of the keys in the cache<a name="line.512"></a>
-<FONT color="green">513</FONT>         * <a name="line.513"></a>
-<FONT color="green">514</FONT>         * @return<a name="line.514"></a>
-<FONT color="green">515</FONT>         */<a name="line.515"></a>
-<FONT color="green">516</FONT>        public void testCacheGetCachedObjects()<a name="line.516"></a>
-<FONT color="green">517</FONT>        {<a name="line.517"></a>
-<FONT color="green">518</FONT>            this.globalCache.flushCache();<a name="line.518"></a>
-<FONT color="green">519</FONT>            this.globalCache.addObject("date1", new CachedObject(new Date()));<a name="line.519"></a>
-<FONT color="green">520</FONT>            this.globalCache.addObject("date2", new CachedObject(new Date()));<a name="line.520"></a>
-<FONT color="green">521</FONT>            this.globalCache.addObject("date3", new CachedObject(new Date()));<a name="line.521"></a>
-<FONT color="green">522</FONT>            assertTrue("Did not get object list back.", (this.globalCache<a name="line.522"></a>
-<FONT color="green">523</FONT>                    .getCachedObjects() != null));<a name="line.523"></a>
-<FONT color="green">524</FONT>            List objects = this.globalCache.getCachedObjects();<a name="line.524"></a>
-<FONT color="green">525</FONT>            for (Iterator itr = objects.iterator(); itr.hasNext();)<a name="line.525"></a>
-<FONT color="green">526</FONT>            {<a name="line.526"></a>
-<FONT color="green">527</FONT>                Object obj = itr.next();<a name="line.527"></a>
-<FONT color="green">528</FONT>                assertNotNull("Object was null.", obj);<a name="line.528"></a>
-<FONT color="green">529</FONT>                assertTrue("Object was not an instance of CachedObject",<a name="line.529"></a>
-<FONT color="green">530</FONT>                        (obj instanceof CachedObject));<a name="line.530"></a>
-<FONT color="green">531</FONT>            }<a name="line.531"></a>
-<FONT color="green">532</FONT>    <a name="line.532"></a>
-<FONT color="green">533</FONT>        }<a name="line.533"></a>
-<FONT color="green">534</FONT>    <a name="line.534"></a>
-<FONT color="green">535</FONT>        /**<a name="line.535"></a>
-<FONT color="green">536</FONT>         * Test that the retrieved list is safe from<a name="line.536"></a>
-<FONT color="green">537</FONT>         * ConcurrentModificationException's being thrown if the cache is updated<a name="line.537"></a>
-<FONT color="green">538</FONT>         * while we are iterating over the List.<a name="line.538"></a>
-<FONT color="green">539</FONT>         * <a name="line.539"></a>
-<FONT color="green">540</FONT>         * @return<a name="line.540"></a>
-<FONT color="green">541</FONT>         */<a name="line.541"></a>
-<FONT color="green">542</FONT>        public void testCacheModification()<a name="line.542"></a>
-<FONT color="green">543</FONT>        {<a name="line.543"></a>
-<FONT color="green">544</FONT>            this.globalCache.flushCache();<a name="line.544"></a>
-<FONT color="green">545</FONT>            this.globalCache.addObject("date1", new CachedObject(new Date()));<a name="line.545"></a>
-<FONT color="green">546</FONT>            this.globalCache.addObject("date2", new CachedObject(new Date()));<a name="line.546"></a>
-<FONT color="green">547</FONT>            this.globalCache.addObject("date3", new CachedObject(new Date()));<a name="line.547"></a>
-<FONT color="green">548</FONT>            assertTrue("Did not get key list back.",<a name="line.548"></a>
-<FONT color="green">549</FONT>                    (this.globalCache.getKeys() != null));<a name="line.549"></a>
-<FONT color="green">550</FONT>            List keys = this.globalCache.getKeys();<a name="line.550"></a>
-<FONT color="green">551</FONT>            try<a name="line.551"></a>
-<FONT color="green">552</FONT>            {<a name="line.552"></a>
-<FONT color="green">553</FONT>                for (Iterator itr = keys.iterator(); itr.hasNext();)<a name="line.553"></a>
-<FONT color="green">554</FONT>                {<a name="line.554"></a>
-<FONT color="green">555</FONT>                    Object key = itr.next();<a name="line.555"></a>
-<FONT color="green">556</FONT>                    this.globalCache.addObject("date4",<a name="line.556"></a>
-<FONT color="green">557</FONT>                            new CachedObject(new Date()));<a name="line.557"></a>
-<FONT color="green">558</FONT>                }<a name="line.558"></a>
-<FONT color="green">559</FONT>            }<a name="line.559"></a>
-<FONT color="green">560</FONT>            catch (ConcurrentModificationException cme)<a name="line.560"></a>
-<FONT color="green">561</FONT>            {<a name="line.561"></a>
-<FONT color="green">562</FONT>                fail("Caught ConcurrentModificationException adding to cache.");<a name="line.562"></a>
-<FONT color="green">563</FONT>            }<a name="line.563"></a>
-<FONT color="green">564</FONT>            List objects = this.globalCache.getCachedObjects();<a name="line.564"></a>
-<FONT color="green">565</FONT>            try<a name="line.565"></a>
-<FONT color="green">566</FONT>            {<a name="line.566"></a>
-<FONT color="green">567</FONT>                for (Iterator itr = objects.iterator(); itr.hasNext();)<a name="line.567"></a>
-<FONT color="green">568</FONT>                {<a name="line.568"></a>
-<FONT color="green">569</FONT>                    Object obj = itr.next();<a name="line.569"></a>
-<FONT color="green">570</FONT>                    this.globalCache.addObject("date4",<a name="line.570"></a>
-<FONT color="green">571</FONT>                            new CachedObject(new Date()));<a name="line.571"></a>
-<FONT color="green">572</FONT>                }<a name="line.572"></a>
-<FONT color="green">573</FONT>            }<a name="line.573"></a>
-<FONT color="green">574</FONT>            catch (ConcurrentModificationException cme)<a name="line.574"></a>
-<FONT color="green">575</FONT>            {<a name="line.575"></a>
-<FONT color="green">576</FONT>                fail("Caught ConcurrentModificationException adding to cache.");<a name="line.576"></a>
-<FONT color="green">577</FONT>            }<a name="line.577"></a>
-<FONT color="green">578</FONT>        }<a name="line.578"></a>
-<FONT color="green">579</FONT>    <a name="line.579"></a>
-<FONT color="green">580</FONT>        /**<a name="line.580"></a>
-<FONT color="green">581</FONT>         * Down cast the interface to the concreate object in order to grab the<a name="line.581"></a>
-<FONT color="green">582</FONT>         * cache check frequency.<a name="line.582"></a>
-<FONT color="green">583</FONT>         * <a name="line.583"></a>
-<FONT color="green">584</FONT>         * @return the refresh requency in milliseconds<a name="line.584"></a>
-<FONT color="green">585</FONT>         */<a name="line.585"></a>
-<FONT color="green">586</FONT>        private long getCacheRefresh()<a name="line.586"></a>
-<FONT color="green">587</FONT>        {<a name="line.587"></a>
-<FONT color="green">588</FONT>            try<a name="line.588"></a>
-<FONT color="green">589</FONT>            {<a name="line.589"></a>
-<FONT color="green">590</FONT>                DefaultGlobalCacheService cache = <a name="line.590"></a>
-<FONT color="green">591</FONT>                    (DefaultGlobalCacheService)this.lookup(GlobalCacheService.ROLE);<a name="line.591"></a>
-<FONT color="green">592</FONT>                return cache.getCacheCheckFrequency() * 1000L;<a name="line.592"></a>
-<FONT color="green">593</FONT>            }<a name="line.593"></a>
-<FONT color="green">594</FONT>            catch (ComponentException e)<a name="line.594"></a>
-<FONT color="green">595</FONT>            {<a name="line.595"></a>
-<FONT color="green">596</FONT>                return 5000;<a name="line.596"></a>
-<FONT color="green">597</FONT>            }<a name="line.597"></a>
-<FONT color="green">598</FONT>        }<a name="line.598"></a>
-<FONT color="green">599</FONT>    <a name="line.599"></a>
-<FONT color="green">600</FONT>        /**<a name="line.600"></a>
-<FONT color="green">601</FONT>         * How long until it expires<a name="line.601"></a>
-<FONT color="green">602</FONT>         * <a name="line.602"></a>
-<FONT color="green">603</FONT>         * @return the cache refresh plus 1000.<a name="line.603"></a>
-<FONT color="green">604</FONT>         */<a name="line.604"></a>
-<FONT color="green">605</FONT>        private long getTestExpireTime()<a name="line.605"></a>
-<FONT color="green">606</FONT>        {<a name="line.606"></a>
-<FONT color="green">607</FONT>            return getCacheRefresh() + 1000;<a name="line.607"></a>
-<FONT color="green">608</FONT>        }<a name="line.608"></a>
-<FONT color="green">609</FONT>    <a name="line.609"></a>
-<FONT color="green">610</FONT>        /**<a name="line.610"></a>
-<FONT color="green">611</FONT>         * Simple object that can be refreshed<a name="line.611"></a>
-<FONT color="green">612</FONT>         */<a name="line.612"></a>
-<FONT color="green">613</FONT>        class RefreshableObject implements Refreshable<a name="line.613"></a>
-<FONT color="green">614</FONT>        {<a name="line.614"></a>
-<FONT color="green">615</FONT>            private int refreshCount = 0;<a name="line.615"></a>
-<FONT color="green">616</FONT>    <a name="line.616"></a>
-<FONT color="green">617</FONT>            /**<a name="line.617"></a>
-<FONT color="green">618</FONT>             * Increment the refresh counter<a name="line.618"></a>
-<FONT color="green">619</FONT>             */<a name="line.619"></a>
-<FONT color="green">620</FONT>            public void refresh()<a name="line.620"></a>
-<FONT color="green">621</FONT>            {<a name="line.621"></a>
-<FONT color="green">622</FONT>                this.refreshCount++;<a name="line.622"></a>
-<FONT color="green">623</FONT>            }<a name="line.623"></a>
-<FONT color="green">624</FONT>    <a name="line.624"></a>
-<FONT color="green">625</FONT>            /**<a name="line.625"></a>
-<FONT color="green">626</FONT>             * Reutrn the number of time this object has been refreshed<a name="line.626"></a>
-<FONT color="green">627</FONT>             * <a name="line.627"></a>
-<FONT color="green">628</FONT>             * @return Number of times refresh() has been called<a name="line.628"></a>
-<FONT color="green">629</FONT>             */<a name="line.629"></a>
-<FONT color="green">630</FONT>            public int getRefreshCount()<a name="line.630"></a>
-<FONT color="green">631</FONT>            {<a name="line.631"></a>
-<FONT color="green">632</FONT>                return this.refreshCount;<a name="line.632"></a>
-<FONT color="green">633</FONT>            }<a name="line.633"></a>
-<FONT color="green">634</FONT>        }<a name="line.634"></a>
-<FONT color="green">635</FONT>    }<a name="line.635"></a>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-</PRE>
-</BODY>
-</HTML>
+<!DOCTYPE HTML>
+<html lang="de">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<main role="main">
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span><a id="line.1">/*</a>
+<span class="sourceLineNo">002</span><a id="line.2"> * Licensed to the Apache Software Foundation (ASF) under one</a>
+<span class="sourceLineNo">003</span><a id="line.3"> * or more contributor license agreements.  See the NOTICE file</a>
+<span class="sourceLineNo">004</span><a id="line.4"> * distributed with this work for additional information</a>
+<span class="sourceLineNo">005</span><a id="line.5"> * regarding copyright ownership.  The ASF licenses this file</a>
+<span class="sourceLineNo">006</span><a id="line.6"> * to you under the Apache License, Version 2.0 (the</a>
+<span class="sourceLineNo">007</span><a id="line.7"> * "License"); you may not use this file except in compliance</a>
+<span class="sourceLineNo">008</span><a id="line.8"> * with the License.  You may obtain a copy of the License at</a>
+<span class="sourceLineNo">009</span><a id="line.9"> *</a>
+<span class="sourceLineNo">010</span><a id="line.10"> *   http://www.apache.org/licenses/LICENSE-2.0</a>
+<span class="sourceLineNo">011</span><a id="line.11"> *</a>
+<span class="sourceLineNo">012</span><a id="line.12"> * Unless required by applicable law or agreed to in writing,</a>
+<span class="sourceLineNo">013</span><a id="line.13"> * software distributed under the License is distributed on an</a>
+<span class="sourceLineNo">014</span><a id="line.14"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</a>
+<span class="sourceLineNo">015</span><a id="line.15"> * KIND, either express or implied.  See the License for the</a>
+<span class="sourceLineNo">016</span><a id="line.16"> * specific language governing permissions and limitations</a>
+<span class="sourceLineNo">017</span><a id="line.17"> * under the License.</a>
+<span class="sourceLineNo">018</span><a id="line.18"> */</a>
+<span class="sourceLineNo">019</span><a id="line.19"></a>
+<span class="sourceLineNo">020</span><a id="line.20">package org.apache.fulcrum.cache;</a>
+<span class="sourceLineNo">021</span><a id="line.21"></a>
+<span class="sourceLineNo">022</span><a id="line.22">import static org.junit.jupiter.api.Assertions.assertEquals;</a>
+<span class="sourceLineNo">023</span><a id="line.23">import static org.junit.jupiter.api.Assertions.assertNotNull;</a>
+<span class="sourceLineNo">024</span><a id="line.24">import static org.junit.jupiter.api.Assertions.assertNull;</a>
+<span class="sourceLineNo">025</span><a id="line.25">import static org.junit.jupiter.api.Assertions.assertSame;</a>
+<span class="sourceLineNo">026</span><a id="line.26">import static org.junit.jupiter.api.Assertions.assertTrue;</a>
+<span class="sourceLineNo">027</span><a id="line.27">import static org.junit.jupiter.api.Assertions.fail;</a>
+<span class="sourceLineNo">028</span><a id="line.28"></a>
+<span class="sourceLineNo">029</span><a id="line.29">import java.util.ConcurrentModificationException;</a>
+<span class="sourceLineNo">030</span><a id="line.30">import java.util.Date;</a>
+<span class="sourceLineNo">031</span><a id="line.31">import java.util.List;</a>
+<span class="sourceLineNo">032</span><a id="line.32"></a>
+<span class="sourceLineNo">033</span><a id="line.33">import org.apache.avalon.framework.component.ComponentException;</a>
+<span class="sourceLineNo">034</span><a id="line.34">import org.apache.fulcrum.cache.impl.DefaultGlobalCacheService;</a>
+<span class="sourceLineNo">035</span><a id="line.35">import org.apache.fulcrum.testcontainer.BaseUnit5Test;</a>
+<span class="sourceLineNo">036</span><a id="line.36">import org.apache.logging.log4j.LogManager;</a>
+<span class="sourceLineNo">037</span><a id="line.37">import org.apache.logging.log4j.Logger;</a>
+<span class="sourceLineNo">038</span><a id="line.38">import org.junit.jupiter.api.AfterEach;</a>
+<span class="sourceLineNo">039</span><a id="line.39">import org.junit.jupiter.api.BeforeEach;</a>
+<span class="sourceLineNo">040</span><a id="line.40">import org.junit.jupiter.api.Tag;</a>
+<span class="sourceLineNo">041</span><a id="line.41">import org.junit.jupiter.api.Test;</a>
+<span class="sourceLineNo">042</span><a id="line.42"></a>
+<span class="sourceLineNo">043</span><a id="line.43">/**</a>
+<span class="sourceLineNo">044</span><a id="line.44"> * CacheTest</a>
+<span class="sourceLineNo">045</span><a id="line.45"> *</a>
+<span class="sourceLineNo">046</span><a id="line.46"> * @author &lt;a href="paulsp@apache.org"&gt;Paul Spencer&lt;/a&gt;</a>
+<span class="sourceLineNo">047</span><a id="line.47"> * @author &lt;a href="epugh@upstate.com"&gt;Eric Pugh&lt;/a&gt;</a>
+<span class="sourceLineNo">048</span><a id="line.48"> * @author &lt;a href="mailto:peter@courefreshableCachedObjectux.biz"&gt;Peter CourefreshableCachedObjectux&lt;/a&gt;</a>
+<span class="sourceLineNo">049</span><a id="line.49"> * @version $Id: CacheTest.java 1890338 2021-05-31 10:31:19Z gk $</a>
+<span class="sourceLineNo">050</span><a id="line.50"> */</a>
+<span class="sourceLineNo">051</span><a id="line.51">public class CacheTest extends BaseUnit5Test</a>
+<span class="sourceLineNo">052</span><a id="line.52">{</a>
+<span class="sourceLineNo">053</span><a id="line.53"></a>
+<span class="sourceLineNo">054</span><a id="line.54">    protected GlobalCacheService globalCache = null;</a>
+<span class="sourceLineNo">055</span><a id="line.55"></a>
+<span class="sourceLineNo">056</span><a id="line.56">    protected static final String cacheKey = "CacheKey";</a>
+<span class="sourceLineNo">057</span><a id="line.57"></a>
+<span class="sourceLineNo">058</span><a id="line.58">    protected static final String cacheKey_2 = "CacheKey_2";</a>
+<span class="sourceLineNo">059</span><a id="line.59"></a>
+<span class="sourceLineNo">060</span><a id="line.60">    protected static final Logger log = LogManager.getLogger( CacheTest.class );</a>
+<span class="sourceLineNo">061</span><a id="line.61"></a>
+<span class="sourceLineNo">062</span><a id="line.62">    static {</a>
+<span class="sourceLineNo">063</span><a id="line.63">        String logSystem = System.getProperty("jcs.logSystem", null);</a>
+<span class="sourceLineNo">064</span><a id="line.64">        if (logSystem == null) {</a>
+<span class="sourceLineNo">065</span><a id="line.65">            System.setProperty("jcs.logSystem", "log4j2" );</a>
+<span class="sourceLineNo">066</span><a id="line.66">            log.info( "Setting jcs.logSystem to: log4j2");</a>
+<span class="sourceLineNo">067</span><a id="line.67">            logSystem = System.getProperty("jcs.logSystem", null);</a>
+<span class="sourceLineNo">068</span><a id="line.68">        }</a>
+<span class="sourceLineNo">069</span><a id="line.69">        log.warn( "What is the value of the jcs.logSystem: "+ logSystem);</a>
+<span class="sourceLineNo">070</span><a id="line.70">        </a>
+<span class="sourceLineNo">071</span><a id="line.71">    }</a>
+<span class="sourceLineNo">072</span><a id="line.72"></a>
+<span class="sourceLineNo">073</span><a id="line.73">    /**</a>
+<span class="sourceLineNo">074</span><a id="line.74">     * Method to configure the role name of the service used</a>
+<span class="sourceLineNo">075</span><a id="line.75">     *</a>
+<span class="sourceLineNo">076</span><a id="line.76">     * @return the role name of the service to lookup</a>
+<span class="sourceLineNo">077</span><a id="line.77">     */</a>
+<span class="sourceLineNo">078</span><a id="line.78">    protected String getCacheRoleName()</a>
+<span class="sourceLineNo">079</span><a id="line.79">    {</a>
+<span class="sourceLineNo">080</span><a id="line.80">        return GlobalCacheService.ROLE;</a>
+<span class="sourceLineNo">081</span><a id="line.81">    }</a>
+<span class="sourceLineNo">082</span><a id="line.82"></a>
+<span class="sourceLineNo">083</span><a id="line.83">    @BeforeEach</a>
+<span class="sourceLineNo">084</span><a id="line.84">    protected void setUp() throws Exception</a>
+<span class="sourceLineNo">085</span><a id="line.85">    {</a>
+<span class="sourceLineNo">086</span><a id="line.86">        System.out.println( "Testing service: "+ getClass().getName() + "for "+ getCacheRoleName());</a>
+<span class="sourceLineNo">087</span><a id="line.87">        //if (globalCache == null) {</a>
+<span class="sourceLineNo">088</span><a id="line.88">            try</a>
+<span class="sourceLineNo">089</span><a id="line.89">            {</a>
+<span class="sourceLineNo">090</span><a id="line.90">                globalCache = (GlobalCacheService) this</a>
+<span class="sourceLineNo">091</span><a id="line.91">                        .lookup(getCacheRoleName());</a>
+<span class="sourceLineNo">092</span><a id="line.92">            }</a>
+<span class="sourceLineNo">093</span><a id="line.93">            catch (ComponentException e)</a>
+<span class="sourceLineNo">094</span><a id="line.94">            {</a>
+<span class="sourceLineNo">095</span><a id="line.95">                e.printStackTrace();</a>
+<span class="sourceLineNo">096</span><a id="line.96">                fail(e.getMessage());</a>
+<span class="sourceLineNo">097</span><a id="line.97">            }</a>
+<span class="sourceLineNo">098</span><a id="line.98">        //}</a>
+<span class="sourceLineNo">099</span><a id="line.99">    }</a>
+<span class="sourceLineNo">100</span><a id="line.100">    </a>
+<span class="sourceLineNo">101</span><a id="line.101">    @AfterEach</a>
+<span class="sourceLineNo">102</span><a id="line.102">    protected void cleanup() {</a>
+<span class="sourceLineNo">103</span><a id="line.103">        this.globalCache.removeObject(cacheKey);</a>
+<span class="sourceLineNo">104</span><a id="line.104">    }</a>
+<span class="sourceLineNo">105</span><a id="line.105"></a>
+<span class="sourceLineNo">106</span><a id="line.106">    /**</a>
+<span class="sourceLineNo">107</span><a id="line.107">     * Simple test that verify an object can be created and deleted.</a>
+<span class="sourceLineNo">108</span><a id="line.108">     *</a>
+<span class="sourceLineNo">109</span><a id="line.109">     * @throws Exception if unable to add object</a>
+<span class="sourceLineNo">110</span><a id="line.110">     */</a>
+<span class="sourceLineNo">111</span><a id="line.111">    @Test</a>
+<span class="sourceLineNo">112</span><a id="line.112">    public void testSimpleAddGetCacheObject() throws Exception</a>
+<span class="sourceLineNo">113</span><a id="line.113">    {</a>
+<span class="sourceLineNo">114</span><a id="line.114">        String testString = "This is a test";</a>
+<span class="sourceLineNo">115</span><a id="line.115">        Object retrievedObject = null;</a>
+<span class="sourceLineNo">116</span><a id="line.116">        CachedObject&lt;String&gt; cacheObject1 = null;</a>
+<span class="sourceLineNo">117</span><a id="line.117">        // Create object</a>
+<span class="sourceLineNo">118</span><a id="line.118">        cacheObject1 = new CachedObject&lt;String&gt;(testString);</a>
+<span class="sourceLineNo">119</span><a id="line.119">        assertNotNull(cacheObject1, "Failed to create a cachable object 1" );</a>
+<span class="sourceLineNo">120</span><a id="line.120">        // Add object to cache</a>
+<span class="sourceLineNo">121</span><a id="line.121">        this.globalCache.addObject(cacheKey, cacheObject1);</a>
+<span class="sourceLineNo">122</span><a id="line.122">        // Get object from cache</a>
+<span class="sourceLineNo">123</span><a id="line.123">        retrievedObject = this.globalCache.getObject(cacheKey);</a>
+<span class="sourceLineNo">124</span><a id="line.124">        assertNotNull( retrievedObject, "Did not retrieve a cached object 1");</a>
+<span class="sourceLineNo">125</span><a id="line.125">        assertSame(</a>
+<span class="sourceLineNo">126</span><a id="line.126">                retrievedObject, cacheObject1,</a>
+<span class="sourceLineNo">127</span><a id="line.127">                "Did not retrieve a correct, expected cached object 1");</a>
+<span class="sourceLineNo">128</span><a id="line.128">        // Remove object from cache</a>
+<span class="sourceLineNo">129</span><a id="line.129">        this.globalCache.removeObject(cacheKey);</a>
+<span class="sourceLineNo">130</span><a id="line.130">        // Verify object removed from cache</a>
+<span class="sourceLineNo">131</span><a id="line.131">        retrievedObject = null;</a>
+<span class="sourceLineNo">132</span><a id="line.132">        cacheObject1 = null;</a>
+<span class="sourceLineNo">133</span><a id="line.133">        try</a>
+<span class="sourceLineNo">134</span><a id="line.134">        {</a>
+<span class="sourceLineNo">135</span><a id="line.135">            retrievedObject = this.globalCache.getObject(cacheKey);</a>
+<span class="sourceLineNo">136</span><a id="line.136">            assertNull(</a>
+<span class="sourceLineNo">137</span><a id="line.137">                    retrievedObject,</a>
+<span class="sourceLineNo">138</span><a id="line.138">                    "Retrieved the deleted cached object 1 and did not get expected ObjectExpiredException"</a>
+<span class="sourceLineNo">139</span><a id="line.139">                    );</a>
+<span class="sourceLineNo">140</span><a id="line.140">            assertNotNull(</a>
+<span class="sourceLineNo">141</span><a id="line.141">                    retrievedObject,</a>
+<span class="sourceLineNo">142</span><a id="line.142">                    "Did not get expected ObjectExpiredException retrieving a deleted object"</a>
+<span class="sourceLineNo">143</span><a id="line.143">                    );</a>
+<span class="sourceLineNo">144</span><a id="line.144">        }</a>
+<span class="sourceLineNo">145</span><a id="line.145">        catch (ObjectExpiredException e)</a>
+<span class="sourceLineNo">146</span><a id="line.146">        {</a>
+<span class="sourceLineNo">147</span><a id="line.147">            assertNull(</a>
+<span class="sourceLineNo">148</span><a id="line.148">                    retrievedObject,</a>
+<span class="sourceLineNo">149</span><a id="line.149">                    "Retrieved the deleted cached object 1, but caught expected ObjectExpiredException exception"</a>
+<span class="sourceLineNo">150</span><a id="line.150">                    );</a>
+<span class="sourceLineNo">151</span><a id="line.151">        }</a>
+<span class="sourceLineNo">152</span><a id="line.152">        // Remove object from cache that does NOT exist in the cache</a>
+<span class="sourceLineNo">153</span><a id="line.153">        this.globalCache.removeObject(cacheKey);</a>
+<span class="sourceLineNo">154</span><a id="line.154">    }</a>
+<span class="sourceLineNo">155</span><a id="line.155"></a>
+<span class="sourceLineNo">156</span><a id="line.156">    /**</a>
+<span class="sourceLineNo">157</span><a id="line.157">     * Simple test that adds, retrieves, and deletes 2 object.</a>
+<span class="sourceLineNo">158</span><a id="line.158">     *</a>
+<span class="sourceLineNo">159</span><a id="line.159">     * @throws Exception if unable to add and retrieve objects</a>
+<span class="sourceLineNo">160</span><a id="line.160">     */</a>
+<span class="sourceLineNo">161</span><a id="line.161">    @Test</a>
+<span class="sourceLineNo">162</span><a id="line.162">    public void test2ObjectAddGetCachedObject() throws Exception</a>
+<span class="sourceLineNo">163</span><a id="line.163">    {</a>
+<span class="sourceLineNo">164</span><a id="line.164">        String testString = "This is a test";</a>
+<span class="sourceLineNo">165</span><a id="line.165">        Object retrievedObject = null;</a>
+<span class="sourceLineNo">166</span><a id="line.166">        CachedObject&lt;String&gt; cacheObject1 = null;</a>
+<span class="sourceLineNo">167</span><a id="line.167">        CachedObject&lt;String&gt; cacheObject2 = null;</a>
+<span class="sourceLineNo">168</span><a id="line.168">        // Create and add Object #1</a>
+<span class="sourceLineNo">169</span><a id="line.169">        cacheObject1 = new CachedObject&lt;String&gt;(testString);</a>
+<span class="sourceLineNo">170</span><a id="line.170">        assertNotNull(cacheObject1, "Failed to create a cachable object 1" );</a>
+<span class="sourceLineNo">171</span><a id="line.171">        this.globalCache.addObject(cacheKey, cacheObject1);</a>
+<span class="sourceLineNo">172</span><a id="line.172">        retrievedObject = this.globalCache.getObject(cacheKey);</a>
+<span class="sourceLineNo">173</span><a id="line.173">        assertNotNull( retrievedObject, "Did not retrieve a cached object 1");</a>
+<span class="sourceLineNo">174</span><a id="line.174">        assertEquals(cacheObject1,</a>
+<span class="sourceLineNo">175</span><a id="line.175">                retrievedObject, "Did not retrieve correct cached object");</a>
+<span class="sourceLineNo">176</span><a id="line.176">        // Create and add Object #2</a>
+<span class="sourceLineNo">177</span><a id="line.177">        cacheObject2 = new CachedObject&lt;String&gt;(testString);</a>
+<span class="sourceLineNo">178</span><a id="line.178">        assertNotNull(cacheObject2, "Failed to create a cachable object 2");</a>
+<span class="sourceLineNo">179</span><a id="line.179">        this.globalCache.addObject(cacheKey_2, cacheObject2);</a>
+<span class="sourceLineNo">180</span><a id="line.180">        retrievedObject = this.globalCache.getObject(cacheKey_2);</a>
+<span class="sourceLineNo">181</span><a id="line.181">        assertNotNull(retrievedObject, "Did not retrieve a cached object 2");</a>
+<span class="sourceLineNo">182</span><a id="line.182">        assertEquals( cacheObject2,</a>
+<span class="sourceLineNo">183</span><a id="line.183">                retrievedObject,</a>
+<span class="sourceLineNo">184</span><a id="line.184">                "Did not retrieve correct cached object 2");</a>
+<span class="sourceLineNo">185</span><a id="line.185">        // Get object #1</a>
+<span class="sourceLineNo">186</span><a id="line.186">        retrievedObject = this.globalCache.getObject(cacheKey);</a>
+<span class="sourceLineNo">187</span><a id="line.187">        assertNotNull(</a>
+<span class="sourceLineNo">188</span><a id="line.188">                retrievedObject,</a>
+<span class="sourceLineNo">189</span><a id="line.189">                "Did not retrieve a cached object 1. Attempt #2");</a>
+<span class="sourceLineNo">190</span><a id="line.190">        assertEquals(</a>
+<span class="sourceLineNo">191</span><a id="line.191">                cacheObject1, retrievedObject,</a>
+<span class="sourceLineNo">192</span><a id="line.192">                "Did not retrieve correct cached object 1. Attempt #2");</a>
+<span class="sourceLineNo">193</span><a id="line.193">        // Get object #1</a>
+<span class="sourceLineNo">194</span><a id="line.194">        retrievedObject = this.globalCache.getObject(cacheKey);</a>
+<span class="sourceLineNo">195</span><a id="line.195">        assertNotNull(</a>
+<span class="sourceLineNo">196</span><a id="line.196">                retrievedObject,</a>
+<span class="sourceLineNo">197</span><a id="line.197">                "Did not retrieve a cached object 1. Attempt #3");</a>
+<span class="sourceLineNo">198</span><a id="line.198">        assertEquals(</a>
+<span class="sourceLineNo">199</span><a id="line.199">                cacheObject1, retrievedObject,</a>
+<span class="sourceLineNo">200</span><a id="line.200">                "Did not retrieve correct cached object 1. Attempt #3");</a>
+<span class="sourceLineNo">201</span><a id="line.201">        // Get object #2</a>
+<span class="sourceLineNo">202</span><a id="line.202">        retrievedObject = this.globalCache.getObject(cacheKey_2);</a>
+<span class="sourceLineNo">203</span><a id="line.203">        assertNotNull(</a>
+<span class="sourceLineNo">204</span><a id="line.204">                retrievedObject,</a>
+<span class="sourceLineNo">205</span><a id="line.205">                "Did not retrieve a cached object 2. Attempt #2");</a>
+<span class="sourceLineNo">206</span><a id="line.206">        assertEquals(</a>
+<span class="sourceLineNo">207</span><a id="line.207">                cacheObject2, retrievedObject,</a>
+<span class="sourceLineNo">208</span><a id="line.208">                "Did not retrieve correct cached object 2 Attempt #2");</a>
+<span class="sourceLineNo">209</span><a id="line.209">        // Remove objects</a>
+<span class="sourceLineNo">210</span><a id="line.210">        this.globalCache.removeObject(cacheKey);</a>
+<span class="sourceLineNo">211</span><a id="line.211">        this.globalCache.removeObject(cacheKey_2);</a>
+<span class="sourceLineNo">212</span><a id="line.212">    }</a>
+<span class="sourceLineNo">213</span><a id="line.213"></a>
+<span class="sourceLineNo">214</span><a id="line.214">    /**</a>
+<span class="sourceLineNo">215</span><a id="line.215">     * Verify that an object will throw the ObjectExpiredException when it now</a>
+<span class="sourceLineNo">216</span><a id="line.216">     * longer exists in cache.</a>
+<span class="sourceLineNo">217</span><a id="line.217">     *</a>
+<span class="sourceLineNo">218</span><a id="line.218">     * @throws Exception if object is not expired</a>
+<span class="sourceLineNo">219</span><a id="line.219">     */</a>
+<span class="sourceLineNo">220</span><a id="line.220">    @Test</a>
+<span class="sourceLineNo">221</span><a id="line.221">    public void testObjectExpiration() throws Exception</a>
+<span class="sourceLineNo">222</span><a id="line.222">    {</a>
+<span class="sourceLineNo">223</span><a id="line.223">        String testString = "This is a test";</a>
+<span class="sourceLineNo">224</span><a id="line.224">        Object retrievedObject = null;</a>
+<span class="sourceLineNo">225</span><a id="line.225">        CachedObject&lt;String&gt; cacheObject = null;</a>
+<span class="sourceLineNo">226</span><a id="line.226">        // Create and add Object that expires in 1000 millis (1 second)</a>
+<span class="sourceLineNo">227</span><a id="line.227">        cacheObject = new CachedObject&lt;String&gt;(testString, 1000);</a>
+<span class="sourceLineNo">228</span><a id="line.228">        assertNotNull(cacheObject, "Failed to create a cachable object");</a>
+<span class="sourceLineNo">229</span><a id="line.229">        long addTime = System.currentTimeMillis();</a>
+<span class="sourceLineNo">230</span><a id="line.230">        this.globalCache.addObject(cacheKey, cacheObject);</a>
+<span class="sourceLineNo">231</span><a id="line.231">        // Try to get un-expired object</a>
+<span class="sourceLineNo">232</span><a id="line.232">        try</a>
+<span class="sourceLineNo">233</span><a id="line.233">        {</a>
+<span class="sourceLineNo">234</span><a id="line.234">            retrievedObject = this.globalCache.getObject(cacheKey);</a>
+<span class="sourceLineNo">235</span><a id="line.235">            assertNotNull( retrievedObject, "Did not retrieve a cached object");</a>
+<span class="sourceLineNo">236</span><a id="line.236">            assertEquals(</a>
+<span class="sourceLineNo">237</span><a id="line.237">                    cacheObject, retrievedObject,</a>
+<span class="sourceLineNo">238</span><a id="line.238">                    "Did not retrieve correct cached object");</a>
+<span class="sourceLineNo">239</span><a id="line.239">        }</a>
+<span class="sourceLineNo">240</span><a id="line.240">        catch (ObjectExpiredException e)</a>
+<span class="sourceLineNo">241</span><a id="line.241">        {</a>
+<span class="sourceLineNo">242</span><a id="line.242">            assertTrue(false, "Object expired early ( "</a>
+<span class="sourceLineNo">243</span><a id="line.243">                    + (System.currentTimeMillis() - addTime) + " millis)");</a>
+<span class="sourceLineNo">244</span><a id="line.244">        }</a>
+<span class="sourceLineNo">245</span><a id="line.245">        // Sleep 1500 Millis (1.5 seconds)</a>
+<span class="sourceLineNo">246</span><a id="line.246">        Thread.sleep(1500);</a>
+<span class="sourceLineNo">247</span><a id="line.247">        // Try to get expired object</a>
+<span class="sourceLineNo">248</span><a id="line.248">        try</a>
+<span class="sourceLineNo">249</span><a id="line.249">        {</a>
+<span class="sourceLineNo">250</span><a id="line.250">            retrievedObject = null;</a>
+<span class="sourceLineNo">251</span><a id="line.251">            retrievedObject = this.globalCache.getObject(cacheKey);</a>
+<span class="sourceLineNo">252</span><a id="line.252">            assertNull(retrievedObject,</a>
+<span class="sourceLineNo">253</span><a id="line.253">                    "Retrieved the expired cached object  and did not get expected ObjectExpiredException"</a>
+<span class="sourceLineNo">254</span><a id="line.254">                    );</a>
+<span class="sourceLineNo">255</span><a id="line.255">            assertNotNull(retrievedObject,</a>
+<span class="sourceLineNo">256</span><a id="line.256">                    "Did not get expected ObjectExpiredException retrieving an expired object"</a>
+<span class="sourceLineNo">257</span><a id="line.257">                    );</a>
+<span class="sourceLineNo">258</span><a id="line.258">        }</a>
+<span class="sourceLineNo">259</span><a id="line.259">        catch (ObjectExpiredException e)</a>
+<span class="sourceLineNo">260</span><a id="line.260">        {</a>
+<span class="sourceLineNo">261</span><a id="line.261">            assertNull(retrievedObject,</a>
+<span class="sourceLineNo">262</span><a id="line.262">                    "Retrieved the expired cached object, but caught expected ObjectExpiredException exception"</a>
+<span class="sourceLineNo">263</span><a id="line.263">                    );</a>
+<span class="sourceLineNo">264</span><a id="line.264">        }</a>
+<span class="sourceLineNo">265</span><a id="line.265">        // Remove objects</a>
+<span class="sourceLineNo">266</span><a id="line.266">        this.globalCache.removeObject(cacheKey);</a>
+<span class="sourceLineNo">267</span><a id="line.267">    }</a>
+<span class="sourceLineNo">268</span><a id="line.268"></a>
+<span class="sourceLineNo">269</span><a id="line.269">    /**</a>
+<span class="sourceLineNo">270</span><a id="line.270">     * Verify the all object will be flushed from the cache.</a>
+<span class="sourceLineNo">271</span><a id="line.271">     *</a>
+<span class="sourceLineNo">272</span><a id="line.272">     * This test can take server minutes.</a>
+<span class="sourceLineNo">273</span><a id="line.273">     *</a>
+<span class="sourceLineNo">274</span><a id="line.274">     * @throws Exception if flushing the cache fails</a>
+<span class="sourceLineNo">275</span><a id="line.275">     */</a>
+<span class="sourceLineNo">276</span><a id="line.276">    @Test</a>
+<span class="sourceLineNo">277</span><a id="line.277">    public void testCacheFlush() throws Exception</a>
+<span class="sourceLineNo">278</span><a id="line.278">    {</a>
+<span class="sourceLineNo">279</span><a id="line.279">        String testString = "This is a test";</a>
+<span class="sourceLineNo">280</span><a id="line.280">        CachedObject&lt;String&gt; cacheObject = null;</a>
+<span class="sourceLineNo">281</span><a id="line.281">        // Create and add Object that expires in 1 turbine Refresh + 1 millis</a>
+<span class="sourceLineNo">282</span><a id="line.282">        cacheObject = new CachedObject&lt;String&gt;(testString, (getCacheRefresh() * 5) + 1);</a>
+<span class="sourceLineNo">283</span><a id="line.283">        assertNotNull( cacheObject, "Failed to create a cachable object");</a>
+<span class="sourceLineNo">284</span><a id="line.284">        this.globalCache.addObject(cacheKey, cacheObject);</a>
+<span class="sourceLineNo">285</span><a id="line.285">        // 1 Refresh</a>
+<span class="sourceLineNo">286</span><a id="line.286">        Thread.sleep(getCacheRefresh() + 1);</a>
+<span class="sourceLineNo">287</span><a id="line.287">        assertTrue( (0 &lt; this.globalCache</a>
+<span class="sourceLineNo">288</span><a id="line.288">                .getNumberOfObjects()),</a>
+<span class="sourceLineNo">289</span><a id="line.289">                "No object in cache before flush");</a>

[... 450 lines stripped ...]