Skip to content

Commit

Permalink
Merge pull request #334 from sunnights/zookeeper-test
Browse files Browse the repository at this point in the history
fix: fix zookeeper ut bug
  • Loading branch information
rayzhang0603 authored Jul 11, 2017
2 parents 1801fc6 + 909a4a5 commit 2eb87e3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ classname=com.weibo.motan.benchmark.TestStringRunnable
params=1

# 10kString
# classname=com.weibo.motan.test.benchmark.TestStringRunnable
# classname=com.weibo.motan.benchmark.TestStringRunnable
# params=10

# Empty
# classname=com.weibo.motan.test.benchmark.TestEmptyRunnable
# classname=com.weibo.motan.benchmark.TestEmptyRunnable
# params=1

# Pojo
# classname=com.weibo.motan.test.benchmark.TestPojoRunnable
# classname=com.weibo.motan.benchmark.TestPojoRunnable
# params=1
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@
import java.util.*;

/**
*
* <pre>
* Interface config,
*
*
* 配置约定
* 1 service 和 referer 端相同的参数的含义一定相同;
* 2 service端参数的覆盖策略:protocol--basicConfig--service,前面的配置会被后面的config参数覆盖;
* 3 registry 参数不进入service、referer端的参数列表;
* 4 referer端从注册中心拿到参数后,先用referer端的参数覆盖,然后再使用该service
* </pre>
*
*
* @author fishermen
* @version V1.0 created at: 2013-5-27
*/
Expand Down Expand Up @@ -116,13 +115,12 @@ public class AbstractInterfaceConfig extends AbstractConfig {
protected Integer mingzSize;

protected String codec;
protected String localServiceAddress;

public Integer getRetries() {
return retries;
}

protected String localServiceAddress;

public void setRetries(Integer retries) {
this.retries = retries;
}
Expand Down Expand Up @@ -231,15 +229,15 @@ public String getCheck() {
return check;
}

public void setCheck(String check) {
this.check = check;
}

@Deprecated
public void setCheck(Boolean check) {
this.check = String.valueOf(check);
}

public void setCheck(String check) {
this.check = check;
}

public Boolean getShareChannel() {
return shareChannel;
}
Expand Down Expand Up @@ -339,8 +337,9 @@ protected List<URL> loadRegistryUrls() {
if (!map.containsKey(URLParamType.protocol.getName())) {
if (address.contains("://")) {
map.put(URLParamType.protocol.getName(), address.substring(0, address.indexOf("://")));
} else {
map.put(URLParamType.protocol.getName(), MotanConstants.REGISTRY_PROTOCOL_LOCAL);
}
map.put(URLParamType.protocol.getName(), MotanConstants.REGISTRY_PROTOCOL_LOCAL);
}
// address内部可能包含多个注册中心地址
List<URL> urls = UrlUtils.parseURLs(address, map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
import junit.framework.Assert;
import org.I0Itec.zkclient.ZkClient;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.InputStream;
import java.util.List;
import java.util.Properties;

public class ZookeeperRegistryTest {
private ZookeeperRegistry registry;
private URL serviceUrl, clientUrl;
private EmbeddedZookeeper zookeeper;
private ZkClient zkClient;
private String service = "com.weibo.motan.demoService";

@Before
public void setUp() throws Exception {
private static ZookeeperRegistry registry;
private static URL serviceUrl, clientUrl;
private static EmbeddedZookeeper zookeeper;
private static ZkClient zkClient;
private static String service = "com.weibo.motan.demoService";

@BeforeClass
public static void setUp() throws Exception {
Properties properties = new Properties();
InputStream in = EmbeddedZookeeper.class.getResourceAsStream("/zoo.cfg");
properties.load(in);
Expand All @@ -38,15 +38,15 @@ public void setUp() throws Exception {

zookeeper = new EmbeddedZookeeper();
zookeeper.start();
Thread.sleep(300);

zkClient = new ZkClient("127.0.0.1:" + port, 5000);
registry = new ZookeeperRegistry(zkUrl, zkClient);
}

@After
public void tearDown() throws Exception {
public void tearDown() {
zkClient.deleteRecursive(MotanConstants.ZOOKEEPER_REGISTRY_NAMESPACE);
zookeeper = null;
}

@Test
Expand Down

0 comments on commit 2eb87e3

Please sign in to comment.