CatEnvironmentTest.java
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.dianping.cat;
import java.io.File;
import junit.framework.Assert;
import org.junit.Test;
import com.dianping.cat.message.MessageProducer;
import com.dianping.cat.message.Transaction;
public class CatEnvironmentTest {
@Test
public void testWithoutInitialize() throws InterruptedException {
MessageProducer cat = Cat.getProducer();
Transaction t = cat.newTransaction("TestType", "TestName");
t.addData("data here");
t.setStatus("TestStatus");
t.complete();
Thread.sleep(100);
Assert.assertEquals(true, Cat.isInitialized());
Cat.destroy();
}
@Test
public void testWithInitialize() throws InterruptedException {
Cat.initialize(new File("/data/appdatas/cat/client.xml"));
MessageProducer cat = Cat.getProducer();
Transaction t = cat.newTransaction("TestType", "TestName");
t.addData("data here");
t.setStatus("TestStatus");
t.complete();
Thread.sleep(100);
Assert.assertEquals(true, Cat.isInitialized());
Cat.destroy();
}
@Test
public void testWithNoExistGlobalConfigInitialize() throws InterruptedException {
Cat.initialize(new File("/data/appdatas/cat/clientNoExist.xml"));
MessageProducer cat = Cat.getProducer();
Transaction t = cat.newTransaction("TestType", "TestName");
t.addData("data here");
t.setStatus("TestStatus");
t.complete();
Thread.sleep(100);
Assert.assertEquals(true, Cat.isInitialized());
Cat.destroy();
}
@Test
public void testJobTest() throws Exception{
Cat.initialize("192.168.7.70","192.168.7.71");
Transaction t = Cat.newTransaction("TestType", "TestName");
t.addData("data here");
t.setStatus("TestStatus");
t.complete();
Thread.sleep(10000);
}
}