Пример #1
0
  @Test
  public void testNetty2978Concurrent() throws Exception {
    final CamelClient client = new CamelClient();
    try {
      final List<Callable<String>> callables = new ArrayList<Callable<String>>();
      for (int count = 0; count < 1000; count++) {
        final int i = count;
        callables.add(
            new Callable<String>() {
              public String call() {
                return client.lookup(i);
              }
            });
      }

      final ExecutorService executorService = Executors.newFixedThreadPool(10);
      final List<Future<String>> results = executorService.invokeAll(callables);
      final Set<String> replies = new HashSet<String>();
      for (Future<String> future : results) {
        // wait at most 60 sec to not hang test
        String reply = future.get(60, TimeUnit.SECONDS);
        assertTrue(reply.startsWith("Bye "));
        replies.add(reply);
      }

      // should be 1000 unique replies
      assertEquals(1000, replies.size());
      executorService.shutdownNow();
    } finally {
      client.close();
    }
  }
Пример #2
0
 @Test
 public void testNetty2978() throws Exception {
   CamelClient client = new CamelClient();
   try {
     for (int i = 0; i < 1000; i++) {
       Object reply = client.lookup(i);
       assertEquals("Bye " + i, reply);
     }
   } finally {
     client.close();
   }
 }