1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718package org .apache .commons .pool3 .impl ;
1819
1920import static org .junit .jupiter .api .Assertions .assertEquals ;
@@ -31,100 +32,69 @@ class TestDefaultPooledObjectInfo {
3132 @ Test
3233 void testGetLastBorrowTrace () throws Exception {
3334 final AbandonedConfig abandonedConfig = new AbandonedConfig ();
34-
3535 abandonedConfig .setRemoveAbandonedOnBorrow (true );
3636 abandonedConfig .setRemoveAbandonedTimeout (TestConstants .ONE_SECOND_DURATION );
3737 abandonedConfig .setLogAbandoned (true );
38- try (GenericObjectPool <String , TestException > pool = new GenericObjectPool <>(new SimpleFactory (),
39- new GenericObjectPoolConfig <>(), abandonedConfig )) {
40-
38+ try (GenericObjectPool <String , TestException > pool = new GenericObjectPool <>(new SimpleFactory (), new GenericObjectPoolConfig <>(), abandonedConfig )) {
4139 pool .borrowObject ();
4240 // pool.returnObject(s1); // Object not returned, causes abandoned object created exception
43-
4441 final Set <DefaultPooledObjectInfo > strings = pool .listAllObjects ();
4542 final DefaultPooledObjectInfo s1Info = strings .iterator ().next ();
4643 final String lastBorrowTrace = s1Info .getLastBorrowTrace ();
47-
4844 assertTrue (lastBorrowTrace .startsWith ("Pooled object created" ));
4945 }
5046 }
5147
5248 @ Test
5349 void testGetPooledObjectToString () throws Exception {
5450 try (GenericObjectPool <String , TestException > pool = new GenericObjectPool <>(new SimpleFactory ())) {
55-
5651 final String s1 = pool .borrowObject ();
57-
5852 final Set <DefaultPooledObjectInfo > strings = pool .listAllObjects ();
59-
6053 assertEquals (1 , strings .size ());
61-
6254 final DefaultPooledObjectInfo s1Info = strings .iterator ().next ();
63-
6455 assertEquals (s1 , s1Info .getPooledObjectToString ());
6556 }
6657 }
6758
6859 @ Test
6960 void testGetPooledObjectType () throws Exception {
7061 try (GenericObjectPool <String , TestException > pool = new GenericObjectPool <>(new SimpleFactory ())) {
71-
7262 pool .borrowObject ();
73-
7463 final Set <DefaultPooledObjectInfo > strings = pool .listAllObjects ();
75-
7664 assertEquals (1 , strings .size ());
77-
7865 final DefaultPooledObjectInfo s1Info = strings .iterator ().next ();
79-
8066 assertEquals (String .class .getName (), s1Info .getPooledObjectType ());
8167 }
8268 }
8369
8470 @ Test
8571 void testTiming () throws Exception {
8672 try (GenericObjectPool <String , TestException > pool = new GenericObjectPool <>(new SimpleFactory ())) {
87-
8873 final long t1Millis = System .currentTimeMillis ();
89-
9074 Thread .sleep (50 );
9175 final String s1 = pool .borrowObject ();
9276 Thread .sleep (50 );
93-
9477 final long t2Millis = System .currentTimeMillis ();
95-
9678 Thread .sleep (50 );
9779 pool .returnObject (s1 );
9880 Thread .sleep (50 );
99-
10081 final long t3Millis = System .currentTimeMillis ();
101-
10282 Thread .sleep (50 );
10383 pool .borrowObject ();
10484 Thread .sleep (50 );
105-
10685 final long t4Millis = System .currentTimeMillis ();
107-
10886 final Set <DefaultPooledObjectInfo > strings = pool .listAllObjects ();
109-
11087 assertEquals (1 , strings .size ());
111-
11288 final DefaultPooledObjectInfo s1Info = strings .iterator ().next ();
113-
11489 final SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss Z" );
115-
11690 assertTrue (s1Info .getCreateTime () > t1Millis );
11791 assertEquals (sdf .format (Long .valueOf (s1Info .getCreateTime ())), s1Info .getCreateTimeFormatted ());
11892 assertTrue (s1Info .getCreateTime () < t2Millis );
119-
12093 assertTrue (s1Info .getLastReturnTime () > t2Millis );
121- assertEquals (sdf .format (Long .valueOf (s1Info .getLastReturnTime ())),
122- s1Info .getLastReturnTimeFormatted ());
94+ assertEquals (sdf .format (Long .valueOf (s1Info .getLastReturnTime ())), s1Info .getLastReturnTimeFormatted ());
12395 assertTrue (s1Info .getLastReturnTime () < t3Millis );
124-
12596 assertTrue (s1Info .getLastBorrowTime () > t3Millis );
126- assertEquals (sdf .format (Long .valueOf (s1Info .getLastBorrowTime ())),
127- s1Info .getLastBorrowTimeFormatted ());
97+ assertEquals (sdf .format (Long .valueOf (s1Info .getLastBorrowTime ())), s1Info .getLastBorrowTimeFormatted ());
12898 assertTrue (s1Info .getLastBorrowTime () < t4Millis );
12999 }
130100 }
0 commit comments