提交 3c0b7521 编写于 作者: Y yong.you

modify the test case error

上级 01a01fa2
......@@ -263,4 +263,9 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
m_remoteRole = remoteRole;
}
}
public void setServerConfigManager(ServerConfigManager serverConfigManager) {
m_serverConfigManager = serverConfigManager;
}
}
......@@ -3,7 +3,9 @@ package com.dianping.cat.consumer.advanced;
import junit.framework.Assert;
import org.junit.Test;
import org.unidal.lookup.ComponentTestCase;
import com.dianping.cat.ServerConfigManager;
import com.dianping.cat.consumer.cross.CrossAnalyzer;
import com.dianping.cat.consumer.cross.CrossAnalyzer.CrossInfo;
import com.dianping.cat.message.Message;
......@@ -12,11 +14,32 @@ import com.dianping.cat.message.internal.DefaultTransaction;
import com.dianping.cat.message.spi.MessageTree;
import com.dianping.cat.message.spi.internal.DefaultMessageTree;
public class CrossInfoTest {
public class CrossInfoTest extends ComponentTestCase{
public MessageTree buildMockMessageTree() {
MessageTree tree = new DefaultMessageTree();
tree.setMessageId("Cat-c0a80746-373452-6");// 192.168.7.70 machine logview
tree.setIpAddress("192.168.0.1");
return tree;
}
@Test
public void testParsePigeonClientTransaction() {
CrossAnalyzer analyzer = new CrossAnalyzer();
public void testParseOtherTransaction() throws Exception {
CrossAnalyzer analyzer =new CrossAnalyzer();
analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
DefaultTransaction t = new DefaultTransaction("Other", "method1", null);
MessageTree tree = buildMockMessageTree();
CrossInfo info = analyzer.parseCorssTransaction(t, tree);
Assert.assertEquals(true, info == null);
}
@Test
public void testParsePigeonClientTransaction() throws Exception {
CrossAnalyzer analyzer =new CrossAnalyzer();
analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
DefaultTransaction t = new DefaultTransaction("Call", "method1", null);
MessageTree tree = buildMockMessageTree();
CrossInfo info = analyzer.parseCorssTransaction(t, tree);
......@@ -36,8 +59,9 @@ public class CrossInfoTest {
}
@Test
public void testParsePigeonServerTransaction() {
CrossAnalyzer analyzer = new CrossAnalyzer();
public void testParsePigeonServerTransaction() throws Exception {
CrossAnalyzer analyzer =new CrossAnalyzer();
analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
DefaultTransaction t = new DefaultTransaction("Service", "method1", null);
MessageTree tree = buildMockMessageTree();
......@@ -58,9 +82,10 @@ public class CrossInfoTest {
}
@Test
public void testParsePigeonServerTransactionWithPort() {
CrossAnalyzer analyzer = new CrossAnalyzer();
public void testParsePigeonServerTransactionWithPort() throws Exception {
CrossAnalyzer analyzer =new CrossAnalyzer();
analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
DefaultTransaction t = new DefaultTransaction("Service", "method1", null);
MessageTree tree = buildMockMessageTree();
CrossInfo info = analyzer.parseCorssTransaction(t, tree);
......@@ -75,22 +100,4 @@ public class CrossInfoTest {
Assert.assertEquals(info.getDetailType(), "PigeonService");
Assert.assertEquals(info.getRemoteRole(), "Pigeon.Client");
}
@Test
public void testParseOtherTransaction() {
CrossAnalyzer analyzer = new CrossAnalyzer();
DefaultTransaction t = new DefaultTransaction("Other", "method1", null);
MessageTree tree = buildMockMessageTree();
CrossInfo info = analyzer.parseCorssTransaction(t, tree);
Assert.assertEquals(true, info == null);
}
public MessageTree buildMockMessageTree() {
MessageTree tree = new DefaultMessageTree();
tree.setMessageId("Cat-c0a80746-373452-6");// 192.168.7.70 machine logview
tree.setIpAddress("192.168.0.1");
return tree;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册