예제 #1
0
  public void testConcurrentResolve() throws Exception {
    // we use different settings because Ivy do not support multi thread resolve with the same
    // settings yet and this is not what this test is about: the focus of this test is running
    // concurrent resolves in separate vms but using the same cache. We don't span the test on
    // multiple vms, but using separate settings we should only run into shared cache related
    // issues, and not multi thread related issues.
    IvySettings settings1 = new IvySettings();
    IvySettings settings2 = new IvySettings();
    IvySettings settings3 = new IvySettings();

    // run 3 concurrent resolves, one taking 100ms to download files, one 20ms and one 5ms
    // the first one do 10 resolves, the second one 20 and the third 50
    // note that the download time is useful only at the very beginning, then the cached file is
    // used
    ResolveThread t1 =
        asyncResolve(settings1, createSlowResolver(settings1, 100), "org6#mod6.4;3", 10);
    ResolveThread t2 =
        asyncResolve(settings2, createSlowResolver(settings2, 20), "org6#mod6.4;3", 20);
    ResolveThread t3 =
        asyncResolve(settings3, createSlowResolver(settings3, 5), "org6#mod6.4;3", 50);
    t1.join(100000);
    t2.join(20000);
    t3.join(20000);
    assertEquals(10, t1.getCount());
    assertFound("org6#mod6.4;3", t1.getFinalResult());
    assertEquals(20, t2.getCount());
    assertFound("org6#mod6.4;3", t2.getFinalResult());
    assertEquals(50, t3.getCount());
    assertFound("org6#mod6.4;3", t3.getFinalResult());
  }
예제 #2
0
 private ResolveThread asyncResolve(
     IvySettings settings, FileSystemResolver resolver, String module, int loop) {
   ResolveThread thread = new ResolveThread(settings, resolver, module, loop);
   thread.start();
   return thread;
 }