Ejemplo n.º 1
0
 /** @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");
 }
Ejemplo n.º 2
0
 @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
 }
Ejemplo n.º 3
0
 @Test
 public void testSimplePool() throws Exception {
   FieldUtil.setValue(pool, "isWorking", false);
   mutableOne.updateData(makeAddress());
   pool.build();
   pool.build(); // Already true
 }
Ejemplo n.º 4
0
 @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);
 }
Ejemplo n.º 5
0
 @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());
 }