Signed-off-by: Daemonxiao <735462752@qq.com>
Co-authored-by: iosmanthus <myosmanthustree@gmail.com>
This commit is contained in:
Daemonxiao 2022-06-21 18:03:00 +08:00
parent 8849f35d29
commit 7742a6d377
1 changed files with 11 additions and 9 deletions

View File

@ -55,7 +55,8 @@ public class ChannelFactoryTest {
File a = new File(caPath);
File b = new File(clientCertPath);
File c = new File(clientKeyPath);
try(CertWatcher certWatcher = new CertWatcher(2, ImmutableList.of(a, b, c), () -> changed.set(true))){
try (CertWatcher certWatcher =
new CertWatcher(2, ImmutableList.of(a, b, c), () -> changed.set(true))) {
Thread.sleep(5000);
assertTrue(changed.get());
}
@ -64,14 +65,15 @@ public class ChannelFactoryTest {
@Test
public void testCertWatcherWithExceptionTask() throws InterruptedException {
AtomicInteger timesOfReloadTask = new AtomicInteger(0);
CertWatcher certWatcher = new CertWatcher(
1,
ImmutableList.of(new File(caPath), new File(clientCertPath), new File(clientKeyPath)),
() -> {
timesOfReloadTask.getAndIncrement();
touchCert();
throw new RuntimeException("Mock exception in reload task");
});
CertWatcher certWatcher =
new CertWatcher(
1,
ImmutableList.of(new File(caPath), new File(clientCertPath), new File(clientKeyPath)),
() -> {
timesOfReloadTask.getAndIncrement();
touchCert();
throw new RuntimeException("Mock exception in reload task");
});
Thread.sleep(5000);
certWatcher.close();