Search in sources :

Example 1 with WebMvc25

use of brave.spring.webmvc.WebMvcRuntime.WebMvc25 in project brave by openzipkin.

the class WebMvcRuntimeTest method WebMvc25_httpTracing_whenDoesntExist.

@Test(expected = NoSuchBeanDefinitionException.class)
public void WebMvc25_httpTracing_whenDoesntExist() {
    ApplicationContext context = mock(ApplicationContext.class);
    when(context.containsBean("httpTracing")).thenReturn(false);
    new WebMvc25().httpTracing(context);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) WebMvc25(brave.spring.webmvc.WebMvcRuntime.WebMvc25) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with WebMvc25

use of brave.spring.webmvc.WebMvcRuntime.WebMvc25 in project brave by openzipkin.

the class WebMvcRuntimeTest method WebMvc25_httpTracing_whenWrongType.

@Test(expected = NoSuchBeanDefinitionException.class)
public void WebMvc25_httpTracing_whenWrongType() {
    ApplicationContext context = mock(ApplicationContext.class);
    when(context.containsBean("httpTracing")).thenReturn(true);
    when(context.getBean("httpTracing")).thenReturn("foo");
    new WebMvc25().httpTracing(context);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) WebMvc25(brave.spring.webmvc.WebMvcRuntime.WebMvc25) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with WebMvc25

use of brave.spring.webmvc.WebMvcRuntime.WebMvc25 in project brave by openzipkin.

the class WebMvcRuntimeTest method WebMvc25_isHandlerMethod_isFalse.

/**
 * Due to HandlerMethod being only present after 3.1, we can't look up the class in 2.5
 */
@Test
public void WebMvc25_isHandlerMethod_isFalse() {
    HandlerMethod handlerMethod = mock(HandlerMethod.class);
    assertThat(new WebMvc25().isHandlerMethod(handlerMethod)).isFalse();
}
Also used : WebMvc25(brave.spring.webmvc.WebMvcRuntime.WebMvc25) HandlerMethod(org.springframework.web.method.HandlerMethod) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with WebMvc25

use of brave.spring.webmvc.WebMvcRuntime.WebMvc25 in project brave by openzipkin.

the class WebMvcRuntimeTest method WebMvc25_httpTracing_byName.

/**
 * Spring 2.5 cannot get beans by type, so fallback to name
 */
@Test
public void WebMvc25_httpTracing_byName() {
    ApplicationContext context = mock(ApplicationContext.class);
    when(context.containsBean("httpTracing")).thenReturn(true);
    when(context.getBean("httpTracing")).thenReturn(mock(HttpTracing.class));
    new WebMvc25().httpTracing(context);
    verify(context).containsBean("httpTracing");
    verify(context).getBean("httpTracing");
    verifyNoMoreInteractions(context);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) HttpTracing(brave.http.HttpTracing) WebMvc25(brave.spring.webmvc.WebMvcRuntime.WebMvc25) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

WebMvc25 (brave.spring.webmvc.WebMvcRuntime.WebMvc25)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 ApplicationContext (org.springframework.context.ApplicationContext)3 HttpTracing (brave.http.HttpTracing)1 HandlerMethod (org.springframework.web.method.HandlerMethod)1