提交 a0de8e05 编写于 作者: C chao.liuc

DUBBO-22

补充testcase

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@162 1a56cb94-b969-4eaa-88fa-be21384802f2
上级 eda6a558
......@@ -349,8 +349,8 @@ public class RegistryDirectoryTest {
registryDirectory.destroy();
Assert.assertEquals(false, registryDirectory.isAvailable());
Assert.assertEquals(false, invokers.get(0).isAvailable());
registryDirectory.destroy();
Map<String, List<Invoker<RegistryDirectoryTest>>> methodInvokerMap = registryDirectory.getMethodInvokerMap();
Map<String, Invoker<RegistryDirectoryTest>> urlInvokerMap = registryDirectory.getUrlInvokerMap();
......@@ -366,7 +366,22 @@ public class RegistryDirectoryTest {
} catch (RpcException e) {
Assert.assertTrue(e.getMessage().contains("already destroyed"));
}
}
@Test
public void testDestroy_WithDestroyRegistry(){
RegistryDirectory registryDirectory = getRegistryDirectory();
CountDownLatch latch = new CountDownLatch(1);
registryDirectory.setRegistry(new MockRegistry(latch));
registryDirectory.destroy();
Assert.assertEquals(0, latch.getCount());
}
@Test
public void testDestroy_WithDestroyRegistry_WithError(){
RegistryDirectory registryDirectory = getRegistryDirectory();
registryDirectory.setRegistry(new MockRegistry(true));
registryDirectory.destroy();
}
@Test
......@@ -490,9 +505,13 @@ public class RegistryDirectoryTest {
private static interface DemoService {}
private static class MockRegistry implements Registry{
CountDownLatch latch ;
boolean destroyWithError ;
public MockRegistry(CountDownLatch latch) {
this.latch = latch;
}
public MockRegistry(boolean destroyWithError) {
this.destroyWithError = destroyWithError;
}
public void register(URL url) {
}
......@@ -512,10 +531,12 @@ public class RegistryDirectoryTest {
return null;
}
public boolean isAvailable() {
return false;
return true;
}
public void destroy() {
if (destroyWithError){
throw new RpcException("test exception ignore.");
}
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册