XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport implements HandlerAdapter, InitializingBean { @Override public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (HttpTransportConstants.METHOD_GET.equals(request.getMethod())) { Transformer transformer = createTransformer(); Source schemaSource = getSchemaSource((XsdSchema) handler); if (transformSchemaLocations) { DOMResult domResult = new DOMResult(); transformer.transform(schemaSource, domResult); Document schemaDocument = (Document) domResult.getNode(); transformSchemaLocations(schemaDocument, request); schemaSource = new DOMSource(schemaDocument); } response.setContentType(CONTENT_TYPE); StreamResult responseResult = new StreamResult(response.getOutputStream()); transformer.transform(schemaSource, responseResult); } else { response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } return null; }  void setSchemaLocationExpression(String schemaLocationExpression); void setTransformSchemaLocations(boolean transformSchemaLocations); @Override long getLastModified(HttpServletRequest request, Object handler); @Override ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler); @Override boolean supports(Object handler); @Override void afterPropertiesSet(); static final String DEFAULT_SCHEMA_LOCATION_EXPRESSION; }
@Test public void handleNonGet() throws Exception { request.setMethod(HttpTransportConstants.METHOD_POST); adapter.handle(request, response, null); assertEquals("METHOD_NOT_ALLOWED expected", HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getStatus()); }