TransactionTest.java 568 B

1234567891011121314151617181920212223242526272829
  1. package com.dianping.cat.message;
  2. import org.junit.Test;
  3. import org.junit.runner.RunWith;
  4. import org.junit.runners.JUnit4;
  5. import com.dianping.cat.Cat;
  6. @RunWith(JUnit4.class)
  7. public class TransactionTest {
  8. @Test
  9. public void testNormal() {
  10. Transaction t = Cat.getProducer().newTransaction("URL", "MyPage");
  11. try {
  12. // do your business here
  13. t.addData("k1", "v1");
  14. t.addData("k2", "v2");
  15. t.addData("k3", "v3");
  16. Thread.sleep(30);
  17. t.setStatus(Message.SUCCESS);
  18. } catch (Exception e) {
  19. t.setStatus(e);
  20. } finally {
  21. t.complete();
  22. }
  23. }
  24. }