1 17 package org.apache.geronimo.connector.outbound; 18 19 import junit.framework.TestCase; 20 21 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 { 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 { 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 { 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 { 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 |