+ /**
+ * Enter variable amount in this order
+ *
+ * count, used, max_range, max_objects
+ * @param intPool
+ * @param ints
+ */
+ private void check(Pool<Integer> intPool, int ... ints) {
+ String rpt = intPool.toString();
+ // Fallthrough on purpose, to process only the ints entered, but in the right order.
+ switch(ints.length) {
+ case 4:
+ assertTrue(rpt.contains(String.format("max_objects(%d)", ints[3])));
+ case 3:
+ assertTrue(rpt.contains(String.format("max_range(%d)", ints[2])));
+ case 2:
+ assertTrue(rpt.contains(String.format("used(%d)", ints[1])));
+ case 1:
+ assertTrue(rpt.contains(String.format("count(%d)", ints[0])));
+ }
+ }
+
+ @Test
+ public void settings() throws CadiException {
+ Pool<Integer> intPool = new Pool<Integer>(new IntegerCreator());
+ check(intPool,0,0,Pool.MAX_RANGE,Pool.MAX_OBJECTS);
+
+ // Check MaxObjects, min is 0
+ intPool.setMaxObjects(-10);
+ check(intPool,0,0,Pool.MAX_RANGE,0);
+
+ intPool.setMaxObjects(10);
+ check(intPool,0,0,Pool.MAX_RANGE,10);
+
+ // Check MaxRange, min is 0
+ intPool.setMaxRange(-10);
+ check(intPool,0,0,0,10);
+
+ intPool.setMaxRange(2);
+ check(intPool,0,0,2,10);
+
+ // Validate Priming
+ intPool.prime(3);
+ check(intPool,3,3,2,10);
+
+ // Drain
+ intPool.drain();
+ check(intPool,0,0,2,10);
+ }
+