Skip to content
Permalink
Browse files
integration test for dubbo-samples-simplified-registry-xml
  • Loading branch information
beiwei30 committed Jul 1, 2019
1 parent 2c8360b commit c8ff189f29f5a545db1145bf5e3202516727924f
Show file tree
Hide file tree
Showing 17 changed files with 433 additions and 542 deletions.
File renamed without changes.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.samples.simplified.registry.nosimple;
package org.apache.dubbo.samples.simplified.registry.xml;

import org.apache.zookeeper.server.ServerConfig;
import org.apache.zookeeper.server.ZooKeeperServerMain;
@@ -0,0 +1,58 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.dubbo.samples.simplified.registry.xml;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.samples.simplified.registry.xml.api.DemoService;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;

public class SimpleRegistryXmlConsumer {

public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/simplified-consumer.xml");
context.start();

DemoService demoService = context.getBean("demoService", DemoService.class);
printServiceData();

String hello = demoService.sayHello("world");
System.out.println(hello);
}

private static void printServiceData() {
List<String> urls = ZkUtil.getChildren(ZkUtil.toUrlPath("consumers"));
System.out.println("*********************************************************");
urls.stream().map(URL::decode).forEach(System.out::println);
System.out.println("not contains 'retries':" + !urls.get(0).contains("retries"));
System.out.println("not contains 'owner':" + !urls.get(0).contains("owner"));
System.out.println("not contains 'actives':" + !urls.get(0).contains("actives"));
System.out.println("not contains 'timeout':" + !urls.get(0).contains("timeout"));
System.out.println("contains 'application':" + urls.get(0).contains("application"));
System.out.println("contains 'version':" + urls.get(0).contains("version"));
System.out.println("contains 'group':" + urls.get(0).contains("group"));
System.out.println("contains 'specVersion(default)':" + urls.get(0).contains(RELEASE_KEY));
System.out.println("*********************************************************");
}
}
@@ -0,0 +1,60 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.dubbo.samples.simplified.registry.xml;

import org.apache.dubbo.common.URL;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;
import java.util.concurrent.CountDownLatch;

import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;

public class SimpleRegistryXmlProvider {

public static void main(String[] args) throws Exception {
new EmbeddedZooKeeper(2181, false).start();

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/simplified-provider.xml");
context.start();

printServiceData();

System.out.println("dubbo service started");
new CountDownLatch(1).await();
}

private static void printServiceData() {
List<String> urls = ZkUtil.getChildren(ZkUtil.toUrlPath("providers"));
System.out.println("*********************************************************");
urls.stream().map(URL::decode).forEach(System.out::println);
System.out.println("not contains 'executes':" + !urls.get(0).contains("executes"));
System.out.println("contains 'retries':" + urls.get(0).contains("retries"));
System.out.println("contains 'owner':" + urls.get(0).contains("owner"));
System.out.println("contains 'timeout(default)':" + urls.get(0).contains("timeout"));
System.out.println("contains 'version(default)':" + urls.get(0).contains("version"));
System.out.println("contains 'group(default)':" + urls.get(0).contains("group"));
System.out.println("contains 'specVersion(default)':" + urls.get(0).contains(RELEASE_KEY));
System.out.println("*********************************************************");
}


}
@@ -16,32 +16,59 @@
* limitations under the License.
*
*/
package org.apache.dubbo.samples.simplified.registry.nosimple;
package org.apache.dubbo.samples.simplified.registry.xml;

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.samples.simplified.registry.nosimple.api.DemoService;
import org.apache.dubbo.samples.simplified.registry.xml.api.DemoService;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

import java.util.Collections;
import java.util.List;

import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;


/**
* 2018/11/8
*/
public class ZkUtil {
private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1");
private static CuratorFramework client;

static {
initClient();
}

private static void initClient() {
client = CuratorFrameworkFactory.newClient(zookeeperHost + ":2181", 60 * 1000, 60 * 1000,
new ExponentialBackoffRetry(1000, 3));
client.start();
}

private static String toRootDir() {
return "/dubbo";
}

private static String toServicePath() {
String name = DemoService.class.getName();
return toRootDir() + Constants.PATH_SEPARATOR + URL.encode(name);
return toRootDir() + PATH_SEPARATOR + URL.encode(name);
}

private static String toCategoryPath(String side) {
return toServicePath() + Constants.PATH_SEPARATOR + side;
return toServicePath() + PATH_SEPARATOR + side;
}

public static String toUrlPath(String side) {
return toCategoryPath(side);
}

public static List<String> getChildren(String path) {
try {
return client.getChildren().forPath(path);
} catch (Exception e) {
e.printStackTrace();
return Collections.emptyList();
}
}

}
@@ -17,7 +17,7 @@
*
*/

package org.apache.dubbo.samples.simplified.registry.nosimple.api;
package org.apache.dubbo.samples.simplified.registry.xml.api;

public interface DemoService {

0 comments on commit c8ff189

Please sign in to comment.