title: Spring boot test not recognizing servlet
body: <p>I have got Spring Boot Application and I want to test it. I do not use Spring Controllers, but I use Servlet with service method. Also I have got my configuration class that provides ServletRegistrationBean.
  But every time when I try to perform mock request I get 404 error. There is no call to servlet at all. I think that Spring does not find this servlet. How could I fix it? While I am launching app at localhost everything works fine.</p>
  
  <p>Test:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringBootTest
  @AutoConfigureMockMvc
  public class SpringDataProcessorTest {
  
      @Autowired
      private MockMvc mockMvc;
  
      @Test
      public void retrieveByRequest() throws Exception{
          mockMvc.perform(buildRetrieveCustomerByIdRequest("1")).andExpect(status().isOk());
  
      }
  
      private MockHttpServletRequestBuilder buildRetrieveCustomerByIdRequest(String id) throws Exception {
          return get(String.format("/path/get('%s')", id)).contentType(APPLICATION_JSON_UTF8);
      }
  }
  </code></pre>
  
  <p>Configuration:</p>
  
  <pre><code>@Configuration
  public class ODataConfiguration extends WebMvcConfigurerAdapter {
      public String urlPath = "/path/*";
  
  
      @Bean
      public ServletRegistrationBean odataServlet(MyServlet servlet) {
          return new ServletRegistrationBean(servlet, new String[] {odataUrlPath});
      }
  }
  </code></pre>
  
  <p>MyServlet:</p>
  
  <pre><code>@Component
  public class MyServlet extends HttpServlet {
  
      @Autowired
      private ODataHttpHandler handler;
  
  
      @Override
      @Transactional
      protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
          try {
              handler.process(req, resp);
          } catch (Exception e) {
              log.error("Server Error occurred", e);
              throw new ServletException(e);
          }
      }
  }
  </code></pre>