/** @throws java.lang.Exception */ @Before public void setUp() throws Exception { pool = new TestPool(mutableOne); FieldUtil.setValue(pool, "isWorking", true); ArrayList<RpcStub> empty = new ArrayList<RpcStub>(); FieldUtil.setValue(pool, "poolHandler", new MultiplexPoolHandler(empty, 2, 2)); readySet = FieldUtil.getValue(pool, "readySet"); }
@Test public void testBuildClients() throws Exception { FieldUtil.setValue(pool, "isWorking", false); FieldUtil.setValue(pool, "poolSize", 0); mutableOne.updateData(makeAddress()); pool.build(); pool.build(); // Already true }
@Test public void testSimplePool() throws Exception { FieldUtil.setValue(pool, "isWorking", false); mutableOne.updateData(makeAddress()); pool.build(); pool.build(); // Already true }
@Test public void testMarkDeleted() throws Exception { List<String> data = makeAddress(); FieldUtil.setValue(pool, "isWorking", false); mutableOne.updateData(data); FieldUtil.setValue(pool, "isWorking", true); mutableOne.updateData(makeAddress()); mutableOne.updateData(data); assertEquals(2, readySet.size()); // Check the backed queue LinkedBlockingQueue<RpcStub> readyQueue = FieldUtil.getValue(pool.poolHandler, "readyQueue"); int delc = 0, addc = 0; for (RpcStub cli : readyQueue) { if (RpcUtil.isInUse(cli)) ++addc; else ++delc; } assertEquals(5, addc); assertEquals(5, delc); }
@Test public void testReallyBuildError() throws Exception { NodeInfo info = new NodeInfo(); info.setProtocol("network/json"); InetSocketAddress address = new InetSocketAddress("localhost", 8809); info.setAddress(address); info.setWeight(1); FieldUtil.setValue(pool, "weightShare", 0.6); pool.buildSuperClients(info); Set<RpcStub> clientSet = RpcStubPool.getPool().getClients(info.getAddress()); assertEquals(0, clientSet.size()); }