@@ -0,0 +1,2196 @@
+package com.dianping.cat.demo;%0A%0Aimport com.dianping.cat.Cat;%0Aimport com.dianping.cat.message.ForkedTransaction;%0Aimport com.dianping.cat.message.Message;%0Aimport com.dianping.cat.message.Transaction;%0Aimport org.junit.Test;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created by yj.huang on 15-2-2.%0A */%0Apublic class TestTruncateForkedTransaction %7B%0A    @Test%0A    public void testTruncateForkedTransaction() throws Exception %7B%0A        final String ID = %2217%22;%0A        Transaction t = Cat.newTransaction(%22Test truncate forkedTransaction %22 + ID, %22Root%22);%0A%0A        final int N_FORKED = 1200;%0A        List%3CThread%3E threadList = new ArrayList%3CThread%3E(N_FORKED);%0A        for (int i = 0; i %3C N_FORKED; i++)%0A        %7B%0A            ForkedTransaction t1 = Cat.newForkedTransaction(%22ForkedChild%22, %22Child%22 + i);%0A            Thread thread = new Thread(new TimedRunnable(t1, 100));%0A            threadList.add(thread);%0A        %7D%0A%0A        for (Thread thread : threadList)%0A        %7B%0A            thread.start();%0A        %7D%0A%0A        Thread.sleep(1000);%0A        t.setStatus(Message.SUCCESS);%0A        t.complete();%0A%0A        for (Thread thread : threadList)%0A        %7B%0A            thread.join();%0A        %7D%0A        Thread.sleep(1000);%0A    %7D%0A%0A    static class TimedRunnable implements Runnable %7B%0A        private ForkedTransaction m_transaction;%0A%0A        private int m_timeout;%0A%0A        public TimedRunnable(ForkedTransaction t, int timeout) %7B%0A            m_transaction = t;%0A            m_timeout = timeout;%0A        %7D%0A%0A        @Override%0A        public void run() %7B%0A            try %7B%0A                m_transaction.fork();%0A                Thread.sleep(m_timeout);%0A                Cat.logEvent(%22TimedRunnable%22, %22Timeout.%22 + m_timeout + %22 forked transaction: %22 + m_transaction.getName());%0A                m_transaction.setStatus(Message.SUCCESS);%0A            %7D catch (Exception e) %7B%0A                System.out.println(%22Interrupted. forked transaction: %22 + m_transaction.getName() );%0A                Cat.logError(%22Exception. forked transaction: %22 + m_transaction.getName(), e);%0A                m_transaction.setStatus(e);%0A            %7D finally %7B%0A                m_transaction.complete();%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add TestTruncateForkedTransaction.java