commit
94f034bccf
@ -25,6 +25,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ -45,11 +47,11 @@ public class AggrWhitelistTest {
|
||||
list.add("com.taobao.tae.AppListOnGrid-*");
|
||||
service.compile(list);
|
||||
|
||||
assertEquals(false, service.isAggrDataId("com.abc"));
|
||||
assertEquals(false, service.isAggrDataId("com.taobao.jiuren"));
|
||||
assertEquals(false, service.isAggrDataId("com.taobao.jiurenABC"));
|
||||
assertEquals(true, service.isAggrDataId("com.taobao.jiuren.abc"));
|
||||
assertEquals(true, service.isAggrDataId("NS_NACOS_SUBSCRIPTION_TOPIC_abc"));
|
||||
assertEquals(true, service.isAggrDataId("com.taobao.tae.AppListOnGrid-abc"));
|
||||
assertFalse(service.isAggrDataId("com.abc"));
|
||||
assertFalse(service.isAggrDataId("com.taobao.jiuren"));
|
||||
assertFalse(service.isAggrDataId("com.taobao.jiurenABC"));
|
||||
assertTrue(service.isAggrDataId("com.taobao.jiuren.abc"));
|
||||
assertTrue(service.isAggrDataId("NS_NACOS_SUBSCRIPTION_TOPIC_abc"));
|
||||
assertTrue(service.isAggrDataId("com.taobao.tae.AppListOnGrid-abc"));
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
package com.alibaba.nacos.config.server.utils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -31,19 +33,19 @@ public class SimpleReadWriteLockTest {
|
||||
@Test
|
||||
public void test_双重读锁_全部释放_加写锁() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
|
||||
lock.releaseReadLock();
|
||||
lock.releaseReadLock();
|
||||
|
||||
assertEquals(true, lock.tryWriteLock());
|
||||
assertTrue(lock.tryWriteLock());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_加写锁() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
assertEquals(true, lock.tryWriteLock());
|
||||
assertTrue(lock.tryWriteLock());
|
||||
lock.releaseWriteLock();
|
||||
}
|
||||
|
||||
@ -51,26 +53,26 @@ public class SimpleReadWriteLockTest {
|
||||
public void test_双重写锁() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
|
||||
assertEquals(true, lock.tryWriteLock());
|
||||
assertEquals(false, lock.tryWriteLock());
|
||||
assertTrue(lock.tryWriteLock());
|
||||
assertFalse(lock.tryWriteLock());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_先读锁后写锁() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertEquals(false, lock.tryWriteLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
assertFalse(lock.tryWriteLock());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_双重读锁_释放一个_加写锁失败() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
|
||||
lock.releaseReadLock();
|
||||
|
||||
assertEquals(false, lock.tryWriteLock());
|
||||
assertFalse(lock.tryWriteLock());
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
Assert.assertEquals(true, JSON.parseObject(result.content).getBoolean("data"));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(result);
|
||||
value = iconfig.getConfig(dataId, group, TIME_OUT);
|
||||
System.out.println(value);
|
||||
Assert.assertEquals(null, value);
|
||||
Assert.assertNull(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,7 +133,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(true);
|
||||
return;
|
||||
}
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,7 +218,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(true);
|
||||
return;
|
||||
}
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,7 +251,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(true);
|
||||
return;
|
||||
}
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,7 +283,7 @@ public class ConfigAPI_ITCase {
|
||||
Thread.sleep(TIME_OUT);
|
||||
Assert.assertTrue(result);
|
||||
String value = iconfig.getConfig(dataId, group, TIME_OUT);
|
||||
Assert.assertEquals(null, value);
|
||||
Assert.assertNull(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,7 +310,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(true);
|
||||
return;
|
||||
}
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,7 +366,7 @@ public class ConfigAPI_ITCase {
|
||||
public void nacos_addListener_2() {
|
||||
try {
|
||||
iconfig.addListener(dataId, group, null);
|
||||
Assert.assertFalse(true);
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
Assert.assertFalse(false);
|
||||
}
|
||||
@ -537,7 +537,7 @@ public class ConfigAPI_ITCase {
|
||||
iconfig.addListener(dataId, group, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
});
|
||||
Thread.sleep(TIME_OUT);
|
||||
@ -571,7 +571,7 @@ public class ConfigAPI_ITCase {
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,7 +653,7 @@ public class ConfigAPI_ITCase {
|
||||
|
||||
Assert.assertEquals(content, JSON.parseObject(result.content).getString("content"));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,7 +682,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertNotNull(JSON.parseObject(result.content).getString("data"));
|
||||
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -713,7 +713,7 @@ public class ConfigAPI_ITCase {
|
||||
result = agent.httpDelete(CONFIG_CONTROLLER_PATH + "/", null, params, agent.getEncode(), TIME_OUT);
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -744,7 +744,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
Assert.assertEquals(true, JSON.parseObject(result.content).getBoolean("data"));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -773,7 +773,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(JSON.parseObject(result.content).getIntValue("totalCount") >= 1);
|
||||
Assert.assertTrue(JSON.parseObject(result.content).getJSONArray("pageItems").getJSONObject(0).getString("content").startsWith(content));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -803,7 +803,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertEquals(content, JSON.parseObject(result.content).getJSONArray("pageItems").getJSONObject(0).getString("content"));
|
||||
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -829,11 +829,11 @@ public class ConfigAPI_ITCase {
|
||||
result = agent.httpGet(CONFIG_CONTROLLER_PATH + "/", null, params, agent.getEncode(), TIME_OUT);
|
||||
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
Assert.assertTrue(JSON.parseObject(result.content).getIntValue("totalCount") == 1);
|
||||
Assert.assertEquals(1, JSON.parseObject(result.content).getIntValue("totalCount"));
|
||||
Assert.assertEquals(content, JSON.parseObject(result.content).getJSONArray("pageItems").getJSONObject(0).getString("content"));
|
||||
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -858,10 +858,10 @@ public class ConfigAPI_ITCase {
|
||||
List<String> params = Arrays.asList("dataId", dataId, "group", group, "pageNo","1", "pageSize","10", "search", "accurate");
|
||||
result = agent.httpGet(CONFIG_CONTROLLER_PATH + "/", null, params, "utf-8", TIME_OUT);
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
Assert.assertTrue(JSON.parseObject(result.content).getIntValue("totalCount") == 1);
|
||||
Assert.assertEquals(1, JSON.parseObject(result.content).getIntValue("totalCount"));
|
||||
Assert.assertEquals(content, JSON.parseObject(result.content).getJSONArray("pageItems").getJSONObject(0).getString("content"));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,7 +107,7 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
TimeUnit.SECONDS.sleep(2);
|
||||
Instance instance = naming.selectOneHealthyInstance(serviceName, Arrays.asList("c1"));
|
||||
|
||||
Assert.assertTrue(instance.getIp() != "1.1.1.1");
|
||||
Assert.assertNotSame("1.1.1.1", instance.getIp());
|
||||
Assert.assertTrue(instance.getPort() != 60002);
|
||||
|
||||
List<Instance> instancesGet = naming.getAllInstances(serviceName);
|
||||
@ -121,7 +121,7 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +138,7 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
|
||||
TimeUnit.SECONDS.sleep(2);
|
||||
Instance instance = naming.selectOneHealthyInstance(serviceName, Arrays.asList("c1", "c2"));
|
||||
Assert.assertTrue(instance.getIp() != "1.1.1.1");
|
||||
Assert.assertNotSame("1.1.1.1", instance.getIp());
|
||||
|
||||
List<Instance> instancesGet = naming.getAllInstances(serviceName);
|
||||
|
||||
@ -151,6 +151,6 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +196,6 @@ public class SubscribeCluster_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class Unsubscribe_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,7 +153,7 @@ public class Unsubscribe_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user