KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > outbound > PoolResizeTest


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.connector.outbound;
18
19 import junit.framework.TestCase;
20
21 /**
22  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
23  */

24 public class PoolResizeTest extends TestCase {
25
26     private final int oldCheckedOut = 20;
27     private final int oldConnectionCount = 40;
28     private final int oldPermitsAvailable = oldConnectionCount - oldCheckedOut;
29     private final int oldMaxSize = 60;
30
31     public void testOne() throws Exception JavaDoc {
32         int oldMinSize = 5;
33         int newMaxSize = 10;
34         AbstractSinglePoolConnectionInterceptor.ResizeInfo resizeInfo = new AbstractSinglePoolConnectionInterceptor.ResizeInfo(oldMinSize, oldPermitsAvailable, oldConnectionCount, newMaxSize);
35         assertEquals("wrong shrinkLater", 10, resizeInfo.getShrinkLater());
36         assertEquals("wrong shrinkNow", 20, resizeInfo.getShrinkNow());
37         assertEquals("wrong newMinSize", 5, resizeInfo.getNewMinSize());
38         assertEquals("wrong transferCheckedOut", 10, resizeInfo.getTransferCheckedOut());
39     }
40
41     public void testTwo() throws Exception JavaDoc {
42         int oldMinSize = 5;
43         int newMaxSize = 30;
44         AbstractSinglePoolConnectionInterceptor.ResizeInfo resizeInfo = new AbstractSinglePoolConnectionInterceptor.ResizeInfo(oldMinSize, oldPermitsAvailable, oldConnectionCount, newMaxSize);
45         assertEquals("wrong shrinkLater", 0, resizeInfo.getShrinkLater());
46         assertEquals("wrong shrinkNow", 10, resizeInfo.getShrinkNow());
47         assertEquals("wrong newMinSize", 5, resizeInfo.getNewMinSize());
48         assertEquals("wrong transferCheckedOut", 20, resizeInfo.getTransferCheckedOut());
49     }
50
51     public void testThree() throws Exception JavaDoc {
52         int oldMinSize = 5;
53         int newMaxSize = 50;
54         AbstractSinglePoolConnectionInterceptor.ResizeInfo resizeInfo = new AbstractSinglePoolConnectionInterceptor.ResizeInfo(oldMinSize, oldPermitsAvailable, oldConnectionCount, newMaxSize);
55         assertEquals("wrong shrinkLater", 00, resizeInfo.getShrinkLater());
56         assertEquals("wrong shrinkNow", 0, resizeInfo.getShrinkNow());
57         assertEquals("wrong newMinSize", 5, resizeInfo.getNewMinSize());
58         assertEquals("wrong transferCheckedOut", 20, resizeInfo.getTransferCheckedOut());
59     }
60
61     public void testFour() throws Exception JavaDoc {
62         int oldMinSize = 5;
63         int newMaxSize = 70;
64         AbstractSinglePoolConnectionInterceptor.ResizeInfo resizeInfo = new AbstractSinglePoolConnectionInterceptor.ResizeInfo(oldMinSize, oldPermitsAvailable, oldConnectionCount, newMaxSize);
65         assertEquals("wrong shrinkLater", 0, resizeInfo.getShrinkLater());
66         assertEquals("wrong shrinkNow", 0, resizeInfo.getShrinkNow());
67         assertEquals("wrong newMinSize", 5, resizeInfo.getNewMinSize());
68         assertEquals("wrong transferCheckedOut", 20, resizeInfo.getTransferCheckedOut());
69     }
70
71
72 }
73
Popular Tags