View Javadoc

1   package org.e2etrace.formatter;
2   
3   /*
4    * Copyright 2006 Gunther Popp
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.e2etrace.trace.DefaultTraceSession;
20  import org.e2etrace.trace.DefaultTraceStepFactory;
21  import org.e2etrace.trace.ITraceSession;
22  import org.e2etrace.trace.MockTimerFactory;
23  
24  
25  /**
26   * Generates a tree of trace steps for testing purposes.
27   * <p>
28   *
29   * @author Gunther Popp
30   *
31   */
32  public class GenerateTestSession {
33  
34    /**
35     * Generate the tree of test steps.
36     * <p>
37     *
38     * @return root step of the tree
39     */
40    public static ITraceSession generate() {
41      DefaultTraceSession sts;
42  
43      sts = new DefaultTraceSession("TestSession", new DefaultTraceStepFactory(
44          new MockTimerFactory(new long[] { 110, 70, 80, 80, 20, 10, 5 })));
45  
46      sts.enterStep("Root_1");
47      sts.enterStep("Child_1_1");
48      sts.leaveStep("Child_1_1");
49      sts.leaveStep("Root_1");
50  
51      sts.enterStep("Root_2");
52      sts.enterStep("Child_2_1");
53      sts.enterStep("Child_2_2");
54      sts.leaveStep("Child_2_2");
55      sts.enterStep("Child_2_3");
56      sts.leaveStep("Child_2_3");
57      sts.leaveStep("Child_2_1");
58      sts.leaveStep("Root_2");
59  
60      sts.enterStep("Root_3");
61      sts.leaveStep("Root_3");
62  
63      return sts;
64  
65    }
66  
67  }