-// * There is no embedded server. so it works depend on etcd local server.
-// */
-//@Disabled
-//public class EtcdServiceDiscoveryTest {
-//
-// static EtcdServiceDiscovery etcdServiceDiscovery;
-//
-// @BeforeAll
-// public static void setUp() throws Exception {
-// URL url = URL.valueOf("etcd3://127.0.0.1:2379/org.apache.dubbo.registry.RegistryService");
-// etcdServiceDiscovery = new EtcdServiceDiscovery();
-// Assertions.assertNull(etcdServiceDiscovery.etcdClient);
-// etcdServiceDiscovery.initialize(url);
-// }
-//
-// @AfterAll
-// public static void destroy() throws Exception {
-//// etcdServiceDiscovery.destroy();
-// }
-//
-//
-// @Test
-// public void testLifecycle() throws Exception {
-// URL url = URL.valueOf("etcd3://127.0.0.1:2233/org.apache.dubbo.registry.RegistryService");
-// EtcdServiceDiscovery etcdServiceDiscoveryTmp = new EtcdServiceDiscovery();
-// Assertions.assertNull(etcdServiceDiscoveryTmp.etcdClient);
-// etcdServiceDiscoveryTmp.initialize(url);
-// Assertions.assertNotNull(etcdServiceDiscoveryTmp.etcdClient);
-// Assertions.assertTrue(etcdServiceDiscoveryTmp.etcdClient.isConnected());
-// etcdServiceDiscoveryTmp.destroy();
-// Assertions.assertFalse(etcdServiceDiscoveryTmp.etcdClient.isConnected());
-// }
-//
-// @Test
-// public void testRegistry() throws Exception {
-// ServiceInstance serviceInstance = new DefaultServiceInstance(valueOf(System.nanoTime()), "EtcdTestService", "127.0.0.1", 8080);
-// Assertions.assertNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
-// etcdServiceDiscovery.register(serviceInstance);
-// Assertions.assertNotNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
-// }
-//
-// @Test
-// public void testUnRegistry() throws Exception {
-// ServiceInstance serviceInstance = new DefaultServiceInstance(valueOf(System.nanoTime()), "EtcdTest2Service", "127.0.0.1", 8080);
-// Assertions.assertNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
-// etcdServiceDiscovery.register(serviceInstance);
-// Assertions.assertNotNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
-// etcdServiceDiscovery.unregister(serviceInstance);
-// Assertions.assertNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
-// }
-//
-// @Test
-// public void testUpdate() throws Exception {
-// DefaultServiceInstance serviceInstance = new DefaultServiceInstance(valueOf(System.nanoTime()), "EtcdTest34Service", "127.0.0.1", 8080);
-// Assertions.assertNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
-// etcdServiceDiscovery.register(serviceInstance);
-// Assertions.assertNotNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
-// Assertions.assertEquals(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)),
-// new Gson().toJson(serviceInstance));
-// serviceInstance.setPort(9999);
-// etcdServiceDiscovery.update(serviceInstance);
-// Assertions.assertNotNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
-// Assertions.assertEquals(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)),
-// new Gson().toJson(serviceInstance));
-// }
-//
-// @Test
-// public void testGetInstances() throws Exception {
-// String serviceName = "EtcdTest77Service";
-// Assertions.assertTrue(etcdServiceDiscovery.getInstances(serviceName).isEmpty());
-// etcdServiceDiscovery.register(new DefaultServiceInstance(valueOf(System.nanoTime()), serviceName, "127.0.0.1", 8080));
-// etcdServiceDiscovery.register(new DefaultServiceInstance(valueOf(System.nanoTime()), serviceName, "127.0.0.1", 9809));
-// Assertions.assertFalse(etcdServiceDiscovery.getInstances(serviceName).isEmpty());
-// List
+ * There is no embedded server. so it works depend on etcd local server.
+ */
+@Disabled
+public class EtcdServiceDiscoveryTest {
+
+ private EtcdServiceDiscovery etcdServiceDiscovery;
+
+ private ApplicationModel applicationModel;
+
+ @BeforeEach
+ public void setUp() {
+ URL url = URL.valueOf("etcd3://127.0.0.1:2379/org.apache.dubbo.registry.RegistryService");
+ FrameworkModel frameworkModel = FrameworkModel.defaultModel();
+ applicationModel = frameworkModel.newApplication();
+ ApplicationConfig config = new ApplicationConfig();
+ config.setName("MockMetrics");
+ applicationModel.getApplicationConfigManager().setApplication(config);
+ etcdServiceDiscovery = new EtcdServiceDiscovery(applicationModel,url);
+ }
+
+ @AfterEach
+ public void destroy() throws Exception {
+ etcdServiceDiscovery.destroy();
+ }
+
+
+ @Test
+ public void testLifecycle() throws Exception {
+ Assertions.assertNotNull(etcdServiceDiscovery.etcdClient);
+ Assertions.assertTrue(etcdServiceDiscovery.etcdClient.isConnected());
+ etcdServiceDiscovery.destroy();
+ Assertions.assertFalse(etcdServiceDiscovery.etcdClient.isConnected());
+ }
+
+ @Test
+ public void testRegistry(){
+ ServiceInstance serviceInstance = new DefaultServiceInstance("EtcdTestService", "127.0.0.1", 8080,applicationModel);
+ Assertions.assertNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
+ etcdServiceDiscovery.doRegister(serviceInstance);
+ Assertions.assertNotNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
+ }
+
+ @Test
+ public void testUnRegistry() {
+ ServiceInstance serviceInstance = new DefaultServiceInstance("EtcdTest2Service", "127.0.0.1", 8080,applicationModel);
+ Assertions.assertNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
+ etcdServiceDiscovery.doRegister(serviceInstance);
+ Assertions.assertNotNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
+ etcdServiceDiscovery.doUnregister(serviceInstance);
+ Assertions.assertNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
+ }
+
+ @Test
+ public void testUpdate() {
+ DefaultServiceInstance serviceInstance = new DefaultServiceInstance( "EtcdTest34Service", "127.0.0.1", 8080,applicationModel);
+ Assertions.assertNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
+ etcdServiceDiscovery.doRegister(serviceInstance);
+
+ Assertions.assertNotNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
+
+ Assertions.assertEquals(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)), new Gson().toJson(serviceInstance));
+ serviceInstance.setPort(9999);
+
+ etcdServiceDiscovery.doRegister(serviceInstance);
+ Assertions.assertNotNull(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)));
+ Assertions.assertEquals(etcdServiceDiscovery.etcdClient.getKVValue(etcdServiceDiscovery.toPath(serviceInstance)), new Gson().toJson(serviceInstance));
+ }
+
+ @Test
+ public void testGetInstances() {
+ String serviceName = "EtcdTest77Service";
+ Assertions.assertTrue(etcdServiceDiscovery.getInstances(serviceName).isEmpty());
+ etcdServiceDiscovery.doRegister(new DefaultServiceInstance(serviceName, "127.0.0.1", 8080,applicationModel));
+ etcdServiceDiscovery.doRegister(new DefaultServiceInstance(serviceName, "127.0.0.1", 9809,applicationModel));
+ Assertions.assertFalse(etcdServiceDiscovery.getInstances(serviceName).isEmpty());
+ List