use of org.springframework.test.web.servlet.MockMvc in project spring-boot by spring-projects.
the class MetricFilterAutoConfigurationTests method records302HttpInteractionsAsSingleMetric.
@Test
public void records302HttpInteractionsAsSingleMetric() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class, MetricFilterAutoConfiguration.class, RedirectFilter.class);
MetricsFilter filter = context.getBean(MetricsFilter.class);
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController()).addFilter(filter).addFilter(context.getBean(RedirectFilter.class)).build();
mvc.perform(get("/unknownPath/1")).andExpect(status().is3xxRedirection());
mvc.perform(get("/unknownPath/2")).andExpect(status().is3xxRedirection());
verify(context.getBean(CounterService.class), times(2)).increment("status.302.unmapped");
verify(context.getBean(GaugeService.class), times(2)).submit(eq("response.unmapped"), anyDouble());
context.close();
}
use of org.springframework.test.web.servlet.MockMvc in project spring-boot by spring-projects.
the class MetricFilterAutoConfigurationTests method recordsKnown404HttpInteractionsAsSingleMetricWithPathAndTemplateVariable.
@Test
public void recordsKnown404HttpInteractionsAsSingleMetricWithPathAndTemplateVariable() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class, MetricFilterAutoConfiguration.class);
Filter filter = context.getBean(Filter.class);
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController()).addFilter(filter).build();
mvc.perform(get("/knownPath/foo")).andExpect(status().isNotFound());
verify(context.getBean(CounterService.class)).increment("status.404.knownPath.someVariable");
verify(context.getBean(GaugeService.class)).submit(eq("response.knownPath.someVariable"), anyDouble());
context.close();
}
use of org.springframework.test.web.servlet.MockMvc in project spring-boot by spring-projects.
the class MetricFilterAutoConfigurationTests method recordsHttpInteractionsWithTemplateVariable.
@Test
public void recordsHttpInteractionsWithTemplateVariable() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class, MetricFilterAutoConfiguration.class);
Filter filter = context.getBean(Filter.class);
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController()).addFilter(filter).build();
mvc.perform(get("/templateVarTest/foo")).andExpect(status().isOk());
verify(context.getBean(CounterService.class)).increment("status.200.templateVarTest.someVariable");
verify(context.getBean(GaugeService.class)).submit(eq("response.templateVarTest.someVariable"), anyDouble());
context.close();
}
use of org.springframework.test.web.servlet.MockMvc in project spring-boot by spring-projects.
the class MetricFilterAutoConfigurationTests method recordsHttpInteractionsWithWildcardMapping.
@Test
public void recordsHttpInteractionsWithWildcardMapping() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class, MetricFilterAutoConfiguration.class);
Filter filter = context.getBean(Filter.class);
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController()).addFilter(filter).build();
mvc.perform(get("/wildcardMapping/foo")).andExpect(status().isOk());
verify(context.getBean(CounterService.class)).increment("status.200.wildcardMapping.star");
verify(context.getBean(GaugeService.class)).submit(eq("response.wildcardMapping.star"), anyDouble());
context.close();
}
use of org.springframework.test.web.servlet.MockMvc in project spring-boot by spring-projects.
the class MetricFilterAutoConfigurationTests method records404HttpInteractionsAsSingleMetric.
@Test
public void records404HttpInteractionsAsSingleMetric() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class, MetricFilterAutoConfiguration.class);
Filter filter = context.getBean(Filter.class);
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController()).addFilter(filter).build();
mvc.perform(get("/unknownPath/1")).andExpect(status().isNotFound());
mvc.perform(get("/unknownPath/2")).andExpect(status().isNotFound());
verify(context.getBean(CounterService.class), times(2)).increment("status.404.unmapped");
verify(context.getBean(GaugeService.class), times(2)).submit(eq("response.unmapped"), anyDouble());
context.close();
}
Aggregations