You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@commons.apache.org by gg...@apache.org on 2020/09/29 15:33:20 UTC

svn commit: r1066218 [22/31] - in /websites/production/commons/content/proper/commons-pool: ./ apidocs/ apidocs/org/apache/commons/pool2/ apidocs/org/apache/commons/pool2/class-use/ apidocs/org/apache/commons/pool2/impl/ apidocs/org/apache/commons/pool...

Modified: websites/production/commons/content/proper/commons-pool/xref-test/org/apache/commons/pool2/TestBasePoolableObjectFactory.html
==============================================================================
--- websites/production/commons/content/proper/commons-pool/xref-test/org/apache/commons/pool2/TestBasePoolableObjectFactory.html (original)
+++ websites/production/commons/content/proper/commons-pool/xref-test/org/apache/commons/pool2/TestBasePoolableObjectFactory.html Tue Sep 29 15:33:18 2020
@@ -24,36 +24,63 @@
 <a class="jxr_linenumber" name="L16" href="#L16">16</a>  <em class="jxr_comment"> */</em>
 <a class="jxr_linenumber" name="L17" href="#L17">17</a>  <strong class="jxr_keyword">package</strong> org.apache.commons.pool2;
 <a class="jxr_linenumber" name="L18" href="#L18">18</a>  
-<a class="jxr_linenumber" name="L19" href="#L19">19</a>  <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.junit.Assert.assertTrue;
-<a class="jxr_linenumber" name="L20" href="#L20">20</a>  
-<a class="jxr_linenumber" name="L21" href="#L21">21</a>  <strong class="jxr_keyword">import</strong> org.apache.commons.pool2.impl.DefaultPooledObject;
-<a class="jxr_linenumber" name="L22" href="#L22">22</a>  <strong class="jxr_keyword">import</strong> org.junit.Test;
+<a class="jxr_linenumber" name="L19" href="#L19">19</a>  <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.junit.Assert.assertEquals;
+<a class="jxr_linenumber" name="L20" href="#L20">20</a>  <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.junit.Assert.assertTrue;
+<a class="jxr_linenumber" name="L21" href="#L21">21</a>  
+<a class="jxr_linenumber" name="L22" href="#L22">22</a>  <strong class="jxr_keyword">import</strong> java.util.concurrent.atomic.AtomicInteger;
 <a class="jxr_linenumber" name="L23" href="#L23">23</a>  
-<a class="jxr_linenumber" name="L24" href="#L24">24</a>  <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L25" href="#L25">25</a>  <em class="jxr_javadoccomment"> */</em>
-<a class="jxr_linenumber" name="L26" href="#L26">26</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a name="TestBasePoolableObjectFactory" href="../../../../org/apache/commons/pool2/TestBasePoolableObjectFactory.html#TestBasePoolableObjectFactory">TestBasePoolableObjectFactory</a> {
-<a class="jxr_linenumber" name="L27" href="#L27">27</a>  
-<a class="jxr_linenumber" name="L28" href="#L28">28</a>      @Test
-<a class="jxr_linenumber" name="L29" href="#L29">29</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testDefaultMethods() <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="L30" href="#L30">30</a>          <strong class="jxr_keyword">final</strong> PooledObjectFactory&lt;Object&gt; factory = <strong class="jxr_keyword">new</strong> TestFactory();
-<a class="jxr_linenumber" name="L31" href="#L31">31</a>  
-<a class="jxr_linenumber" name="L32" href="#L32">32</a>          factory.activateObject(<strong class="jxr_keyword">null</strong>); <em class="jxr_comment">// a no-op</em>
-<a class="jxr_linenumber" name="L33" href="#L33">33</a>          factory.passivateObject(<strong class="jxr_keyword">null</strong>); <em class="jxr_comment">// a no-op</em>
-<a class="jxr_linenumber" name="L34" href="#L34">34</a>          factory.destroyObject(<strong class="jxr_keyword">null</strong>); <em class="jxr_comment">// a no-op</em>
-<a class="jxr_linenumber" name="L35" href="#L35">35</a>          assertTrue(factory.validateObject(<strong class="jxr_keyword">null</strong>)); <em class="jxr_comment">// constant true</em>
-<a class="jxr_linenumber" name="L36" href="#L36">36</a>      }
-<a class="jxr_linenumber" name="L37" href="#L37">37</a>  
-<a class="jxr_linenumber" name="L38" href="#L38">38</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> TestFactory <strong class="jxr_keyword">extends</strong> BasePooledObjectFactory&lt;Object&gt; {
-<a class="jxr_linenumber" name="L39" href="#L39">39</a>          @Override
-<a class="jxr_linenumber" name="L40" href="#L40">40</a>          <strong class="jxr_keyword">public</strong> Object create() <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="L41" href="#L41">41</a>              <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="L42" href="#L42">42</a>          }
-<a class="jxr_linenumber" name="L43" href="#L43">43</a>          @Override
-<a class="jxr_linenumber" name="L44" href="#L44">44</a>          <strong class="jxr_keyword">public</strong> PooledObject&lt;Object&gt; wrap(<strong class="jxr_keyword">final</strong> Object value) {
-<a class="jxr_linenumber" name="L45" href="#L45">45</a>              <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> DefaultPooledObject&lt;&gt;(value);
-<a class="jxr_linenumber" name="L46" href="#L46">46</a>          }
-<a class="jxr_linenumber" name="L47" href="#L47">47</a>      }
-<a class="jxr_linenumber" name="L48" href="#L48">48</a>  }
+<a class="jxr_linenumber" name="L24" href="#L24">24</a>  <strong class="jxr_keyword">import</strong> org.apache.commons.pool2.impl.DefaultPooledObject;
+<a class="jxr_linenumber" name="L25" href="#L25">25</a>  <strong class="jxr_keyword">import</strong> org.junit.Test;
+<a class="jxr_linenumber" name="L26" href="#L26">26</a>  
+<a class="jxr_linenumber" name="L27" href="#L27">27</a>  <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L28" href="#L28">28</a>  <em class="jxr_javadoccomment"> */</em>
+<a class="jxr_linenumber" name="L29" href="#L29">29</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a name="TestBasePoolableObjectFactory" href="../../../../org/apache/commons/pool2/TestBasePoolableObjectFactory.html#TestBasePoolableObjectFactory">TestBasePoolableObjectFactory</a> {
+<a class="jxr_linenumber" name="L30" href="#L30">30</a>  
+<a class="jxr_linenumber" name="L31" href="#L31">31</a>      @Test
+<a class="jxr_linenumber" name="L32" href="#L32">32</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testDefaultMethods() <strong class="jxr_keyword">throws</strong> Exception {
+<a class="jxr_linenumber" name="L33" href="#L33">33</a>          <strong class="jxr_keyword">final</strong> PooledObjectFactory&lt;AtomicInteger&gt; factory = <strong class="jxr_keyword">new</strong> TestFactory();
+<a class="jxr_linenumber" name="L34" href="#L34">34</a>  
+<a class="jxr_linenumber" name="L35" href="#L35">35</a>          factory.activateObject(<strong class="jxr_keyword">null</strong>); <em class="jxr_comment">// a no-op</em>
+<a class="jxr_linenumber" name="L36" href="#L36">36</a>          factory.passivateObject(<strong class="jxr_keyword">null</strong>); <em class="jxr_comment">// a no-op</em>
+<a class="jxr_linenumber" name="L37" href="#L37">37</a>          factory.destroyObject(<strong class="jxr_keyword">null</strong>); <em class="jxr_comment">// a no-op</em>
+<a class="jxr_linenumber" name="L38" href="#L38">38</a>          assertTrue(factory.validateObject(<strong class="jxr_keyword">null</strong>)); <em class="jxr_comment">// constant true</em>
+<a class="jxr_linenumber" name="L39" href="#L39">39</a>      }
+<a class="jxr_linenumber" name="L40" href="#L40">40</a>  
+<a class="jxr_linenumber" name="L41" href="#L41">41</a>      <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L42" href="#L42">42</a>  <em class="jxr_javadoccomment">     * Default destroy does nothing to underlying AtomicInt, ABANDONED mode</em>
+<a class="jxr_linenumber" name="L43" href="#L43">43</a>  <em class="jxr_javadoccomment">     * increments the value.  Verify that destroy with no mode does default,</em>
+<a class="jxr_linenumber" name="L44" href="#L44">44</a>  <em class="jxr_javadoccomment">     * destroy with ABANDONED mode increments.</em>
+<a class="jxr_linenumber" name="L45" href="#L45">45</a>  <em class="jxr_javadoccomment">     *</em>
+<a class="jxr_linenumber" name="L46" href="#L46">46</a>  <em class="jxr_javadoccomment">     * @throws Exception</em>
+<a class="jxr_linenumber" name="L47" href="#L47">47</a>  <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L48" href="#L48">48</a>      @Test
+<a class="jxr_linenumber" name="L49" href="#L49">49</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testDestroyModes() <strong class="jxr_keyword">throws</strong> Exception {
+<a class="jxr_linenumber" name="L50" href="#L50">50</a>          <strong class="jxr_keyword">final</strong> PooledObjectFactory&lt;AtomicInteger&gt; factory = <strong class="jxr_keyword">new</strong> TestFactory();
+<a class="jxr_linenumber" name="L51" href="#L51">51</a>          <strong class="jxr_keyword">final</strong> PooledObject&lt;AtomicInteger&gt; pooledObj = factory.makeObject();
+<a class="jxr_linenumber" name="L52" href="#L52">52</a>          <strong class="jxr_keyword">final</strong> AtomicInteger obj = pooledObj.getObject();
+<a class="jxr_linenumber" name="L53" href="#L53">53</a>          factory.destroyObject(pooledObj);
+<a class="jxr_linenumber" name="L54" href="#L54">54</a>          assertEquals(0, obj.get());
+<a class="jxr_linenumber" name="L55" href="#L55">55</a>          factory.destroyObject(pooledObj, DestroyMode.ABANDONED);
+<a class="jxr_linenumber" name="L56" href="#L56">56</a>          assertEquals(1, obj.get());
+<a class="jxr_linenumber" name="L57" href="#L57">57</a>      }
+<a class="jxr_linenumber" name="L58" href="#L58">58</a>  
+<a class="jxr_linenumber" name="L59" href="#L59">59</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> TestFactory <strong class="jxr_keyword">extends</strong> BasePooledObjectFactory&lt;AtomicInteger&gt; {
+<a class="jxr_linenumber" name="L60" href="#L60">60</a>          @Override
+<a class="jxr_linenumber" name="L61" href="#L61">61</a>          <strong class="jxr_keyword">public</strong> AtomicInteger create() <strong class="jxr_keyword">throws</strong> Exception {
+<a class="jxr_linenumber" name="L62" href="#L62">62</a>              <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> AtomicInteger(0);
+<a class="jxr_linenumber" name="L63" href="#L63">63</a>          }
+<a class="jxr_linenumber" name="L64" href="#L64">64</a>          @Override
+<a class="jxr_linenumber" name="L65" href="#L65">65</a>          <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> destroyObject(<strong class="jxr_keyword">final</strong> PooledObject&lt;AtomicInteger&gt; p, <strong class="jxr_keyword">final</strong> DestroyMode mode){
+<a class="jxr_linenumber" name="L66" href="#L66">66</a>              <strong class="jxr_keyword">if</strong> (mode.equals(DestroyMode.ABANDONED)) {
+<a class="jxr_linenumber" name="L67" href="#L67">67</a>                  p.getObject().incrementAndGet();
+<a class="jxr_linenumber" name="L68" href="#L68">68</a>              }
+<a class="jxr_linenumber" name="L69" href="#L69">69</a>          }
+<a class="jxr_linenumber" name="L70" href="#L70">70</a>          @Override
+<a class="jxr_linenumber" name="L71" href="#L71">71</a>          <strong class="jxr_keyword">public</strong> PooledObject&lt;AtomicInteger&gt; wrap(<strong class="jxr_keyword">final</strong> AtomicInteger value) {
+<a class="jxr_linenumber" name="L72" href="#L72">72</a>              <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> DefaultPooledObject&lt;&gt;(value);
+<a class="jxr_linenumber" name="L73" href="#L73">73</a>          }
+<a class="jxr_linenumber" name="L74" href="#L74">74</a>      }
+<a class="jxr_linenumber" name="L75" href="#L75">75</a>  }
 </pre>
 <hr/>
 <div id="footer">Copyright &#169; 2001&#x2013;2020 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</div>