提交 c0e4c3fd 编写于 作者: V vongosling

Remove and Polish unstable UT

上级 38d70bd5
......@@ -17,11 +17,12 @@
package org.apache.rocketmq.common.filter;
import java.util.HashSet;
import java.util.Set;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
public class FilterAPITest {
......@@ -32,7 +33,7 @@ public class FilterAPITest {
@Test
public void testBuildSubscriptionData() throws Exception {
SubscriptionData subscriptionData =
FilterAPI.buildSubscriptionData(group, topic, subString);
FilterAPI.buildSubscriptionData(group, topic, subString);
assertThat(subscriptionData.getTopic()).isEqualTo(topic);
assertThat(subscriptionData.getSubString()).isEqualTo(subString);
String[] tags = subString.split("\\|\\|");
......@@ -47,7 +48,7 @@ public class FilterAPITest {
public void testBuildTagSome() {
try {
SubscriptionData subscriptionData = FilterAPI.build(
"TOPIC", "A || B", ExpressionType.TAG
"TOPIC", "A || B", ExpressionType.TAG
);
assertThat(subscriptionData).isNotNull();
......@@ -67,7 +68,7 @@ public class FilterAPITest {
public void testBuildSQL() {
try {
SubscriptionData subscriptionData = FilterAPI.build(
"TOPIC", "a is not null", ExpressionType.SQL92
"TOPIC", "a is not null", ExpressionType.SQL92
);
assertThat(subscriptionData).isNotNull();
......@@ -79,16 +80,8 @@ public class FilterAPITest {
}
}
@Test
public void testBuildSQLWithNullSubString() {
try {
FilterAPI.build(
"TOPIC", null, ExpressionType.SQL92
);
assertThat(Boolean.FALSE).isTrue();
} catch (Exception e) {
e.printStackTrace();
}
@Test(expected = IllegalArgumentException.class)
public void testBuildSQLWithNullSubString() throws Exception {
FilterAPI.build("TOPIC", null, ExpressionType.SQL92);
}
}
/*
* 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.rocketmq.common.protocol.route;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* BrokerData tests.
*/
public class BrokerDataTest {
private static BrokerData brokerData;
@BeforeClass
public static void prepare() {
brokerData = new BrokerData("testCluster", "testBroker",
new HashMap<Long, String>() {{
put(1L, "addr1");
put(2L, "addr2");
put(3L, "addr3");
}});
}
@Test
public void selectBrokerAddr() throws Exception {
List<String> selectedAddr = new ArrayList<String>();
for (int i = 0; i < 5; i++)
selectedAddr.add(brokerData.selectBrokerAddr());
List<String> firstElemList = new ArrayList<String>();
for (int i = 0; i < 5; i++)
firstElemList.add(selectedAddr.get(0));
Assert.assertFalse("Contains same addresses", selectedAddr.equals(firstElemList));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册