### Question:
MvcServlet extends SlingAllMethodsServlet { public void enableMvc(ConfigurableListableBeanFactory factory, BundleContext context) { if (factory == null) { throw new IllegalArgumentException("Method argument factory must not be null."); } if (context == null) { throw new IllegalArgumentException("Method argument context must not be null."); } BundleAwareServletConfig servletConfig = new BundleAwareServletConfig(context); factory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext, servletConfig)); factory.ignoreDependencyInterface(ServletContextAware.class); factory.ignoreDependencyInterface(ServletConfigAware.class); final BundleSpecificDispatcherServlet dispatcherServlet = createBundleSpecificDispatcherServlet(factory, servletConfig); factory.registerSingleton(generateNameFor(BundleSpecificDispatcherServlet.class), dispatcherServlet); this.mvcCapableBundles.put(context.getBundle(), dispatcherServlet); }  void enableMvc(ConfigurableListableBeanFactory factory, BundleContext context); void disableMvc(Bundle bundle);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testEnableMvcRequiresNonNullFactory() { this.testee.enableMvc(null, this.context); }
@Test(expected = IllegalArgumentException.class) public void testEnableMvcRequiresNonNullContext() { this.testee.enableMvc(this.factory, null); }
@Test public void testEnableMvc() { enableMvc(); verifyMvcContextIsInjectedIntoFactory(); assertInjectMvcContextIsNotNull(); }
@Test public void testOnlyResponsibleContextsServiceRequests() throws Exception { enableMvc(); serviceRequest(); verifyMvcContextDoesNotServiceRequest(); withMvcContextResponsible(); serviceRequest(); verifyMvcContextServicedRequestOnce(); }
@Test public void testServletConfigurationProvidedToBundleSpecificDispatcherServletHasSensibleServletName() { withRealDispatcherServletCreated(); enableMvc(); assertServletNameOfBundleSpecificDispatcherServletIs("BundleSpecificDispatcherServlet for bundle symbolic-name"); }
@Test public void testPatchMethodIsSupported() throws Exception { enableMvc(); withMvcContextResponsible(); withPatchRequest(); serviceRequest(); verifyMvcContextServicedRequestOnce(); }