Esempio n. 1
0
  @Test
  @WrapInMockProbeExecution
  public void testCombination() throws ServletException, IOException {

    Filter filter = new MockFilterWithServlet();
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test");
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockFilterChain chain = new MockFilterChain();
    filter.doFilter(request, response, chain);

    // perform assertions
    OperationSafeImpl operation = Agent.getInstance().getCurrentOperation();
    Iterator<TraceEventSafeImpl> iterator = operation.getTrace().getEvents().iterator();
    assertTrue(iterator.hasNext());
    ProbeExecution mockProbeExecution = iterator.next().getProbeExecution();
    assertNotNull(mockProbeExecution);
    assertTrue(mockProbeExecution instanceof MockProbeExecution);
    assertTrue(iterator.hasNext());
    ProbeExecution probeExecution = iterator.next().getProbeExecution();
    assertTrue(probeExecution instanceof ServletProbeExecution);
    ServletProbeExecution filterProbeExecution = (ServletProbeExecution) probeExecution;
    assertTrue(filterProbeExecution.getClazz().equals(MockFilterWithServlet.class));
    assertNotNull(filterProbeExecution.getRequestURI());
    assertTrue(iterator.hasNext());
    ProbeExecution nestedProbeExecution = iterator.next().getProbeExecution();
    assertTrue(nestedProbeExecution instanceof ServletProbeExecution);
    ServletProbeExecution servletProbeExecution = (ServletProbeExecution) nestedProbeExecution;
    assertEquals(MockServlet.class, servletProbeExecution.getClazz());
  }
Esempio n. 2
0
  private ServletProbeExecution getRootServletProbeExecution() {

    OperationSafeImpl operation = Agent.getInstance().getCurrentOperation();
    Iterator<TraceEventSafeImpl> iterator = operation.getTrace().getEvents().iterator();
    assertTrue(iterator.hasNext());
    ProbeExecution mockProbeExecution = iterator.next().getProbeExecution();
    assertNotNull(mockProbeExecution);
    assertTrue(mockProbeExecution instanceof MockProbeExecution);
    assertTrue(iterator.hasNext());
    ProbeExecution probeExecution = iterator.next().getProbeExecution();
    assertTrue(probeExecution instanceof ServletProbeExecution);
    return (ServletProbeExecution) probeExecution;
  }