예제 #1
0
 @Test
 public void testBasic() throws InterruptedException, TException {
   startServer();
   scribe.Client client1 = makeNiftyClient();
   Assert.assertEquals(client1.Log(Arrays.asList(new LogEntry("client1", "aaa"))), ResultCode.OK);
   Assert.assertEquals(client1.Log(Arrays.asList(new LogEntry("client1", "bbb"))), ResultCode.OK);
   scribe.Client client2 = makeNiftyClient();
   Assert.assertEquals(client2.Log(Arrays.asList(new LogEntry("client2", "ccc"))), ResultCode.OK);
 }
예제 #2
0
 @Test
 public void testMaxConnections() throws InterruptedException, TException {
   startServer(getThriftServerDefBuilder().limitConnectionsTo(1));
   scribe.Client client1 = makeNiftyClient();
   Assert.assertEquals(client1.Log(Arrays.asList(new LogEntry("client1", "aaa"))), ResultCode.OK);
   Assert.assertEquals(client1.Log(Arrays.asList(new LogEntry("client1", "bbb"))), ResultCode.OK);
   scribe.Client client2 = makeNiftyClient();
   try {
     client2.Log(Arrays.asList(new LogEntry("client2", "ccc")));
   } catch (TTransportException e) {
     // expected
   }
 }
예제 #3
0
 @Test
 public void testMaxConnections2() throws InterruptedException, TException {
   startServer(getThriftServerDefBuilder().limitConnectionsTo(1));
   scribe.Client client1 = makeNiftyClient();
   Assert.assertEquals(client1.Log(Arrays.asList(new LogEntry("client1", "aaa"))), ResultCode.OK);
   Assert.assertEquals(client1.Log(Arrays.asList(new LogEntry("client1", "bbb"))), ResultCode.OK);
   scribe.Client client2 = makeNiftyClient();
   try {
     client2.Log(Arrays.asList(new LogEntry("client2", "ccc")));
   } catch (TTransportException e) {
     // expected
   }
   // now need to make sure we didn't double-decrement the number of connections, so try again
   scribe.Client client3 = makeNiftyClient();
   try {
     client3.Log(Arrays.asList(new LogEntry("client3", "ddd")));
     Assert.fail();
   } catch (TTransportException e) {
     // expected
   }
 }