}
@Test
public void testProfileNestedSteps()
{
Profile result = null;
MiniProfiler.start();
try
{
Step s1 = MiniProfiler.step("Step 1");
Step s11 = MiniProfiler.step("Step 1.1");
s11.close();
s1.close();
Step s2 = MiniProfiler.step("Step 2");
Step s21 = MiniProfiler.step("Step 2.1");
s21.close();
Step s22 = MiniProfiler.step("Step 2.2");
s22.close();
s2.close();
} finally
{
result = MiniProfiler.stop();
}
assertNotNull("Profile should be generated");
assertEquals("Request", result.getName());
assertEquals(0, result.getDepth());
List<Profile> children = result.getChildren();
assertEquals(2, children.size());
Profile child = children.get(0);
assertEquals("Step 1", child.getName());
assertEquals(1, child.getDepth());
List<Profile> children2 = child.getChildren();
assertEquals(1, children2.size());
Profile child2 = children2.get(0);
assertEquals("Step 1.1", child2.getName());
assertEquals(2, child2.getDepth());
child = children.get(1);
assertEquals("Step 2", child.getName());
assertEquals(1, child.getDepth());
children2 = child.getChildren();
assertEquals(2, children2.size());
child2 = children2.get(0);
assertEquals("Step 2.1", child2.getName());
assertEquals(2, child2.getDepth());
child2 = children2.get(1);
assertEquals("Step 2.2", child2.getName());
assertEquals(2, child2.getDepth());
}