### Question:
ExceptionContentHandler extends ContentHandler { public ServiceExceptionReport getContent(InputStream stream, URL url, String contentType) { ServiceExceptionReport ser = getReport(stream, url, contentType); if (ser != null) { for (ServiceException se : ser.getServiceException()) { LOGGER.warn("Service exception received for url [" + url + "]: code [" + se.getCode() + "] value [" + se.getvalue() + "]"); } } return ser; }  static String formatServiceException(ServiceExceptionReport ser, int lineLength); ServiceExceptionReport getContent(InputStream stream, URL url, String contentType); @Override ServiceExceptionReport getContent(URLConnection urlc); static final String MIME_TYPE; static final String MIME_TYPE_1_3; }### Answer:
@Test public void testGetContentv1dot1() throws MalformedURLException { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<!DOCTYPE WMT_MS_Capabilities SYSTEM \"ogc/schemas/wms/1.1.1/exception_1_1_1.dtd\">" + "<ServiceExceptionReport version=\"1.1.1\"><ServiceException>" + "The value for parameter HEIGHT \"0\" is invalid: The height must be at least 1.</ServiceException></ServiceExceptionReport>"; ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes(StringUtilities.DEFAULT_CHARSET)); ExceptionContentHandler handler = new ExceptionContentHandler(); ServiceExceptionReport report = handler.getContent(stream, new URL("http: assertEquals(1, report.getServiceException().size()); ServiceException exception = report.getServiceException().get(0); assertEquals("The value for parameter HEIGHT \"0\" is invalid: The height must be at least 1.", exception.getvalue()); }
@Test public void testGetContentv1dot3() throws MalformedURLException { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ogc:ServiceExceptionReport version=\"1.3.0\"" + " xsi:schemaLocation=\"http: + " xmlns:ogc=\"http: + "<ogc:ServiceException locator=\"Parameter HEIGHT\">" + "The value for parameter HEIGHT \"0\" is invalid: The height must be at least 1.</ogc:ServiceException></ogc:ServiceExceptionReport>"; ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes(StringUtilities.DEFAULT_CHARSET)); ExceptionContentHandler handler = new ExceptionContentHandler(); ServiceExceptionReport report = handler.getContent(stream, new URL("http: ExceptionContentHandler.MIME_TYPE_1_3); assertEquals(1, report.getServiceException().size()); ServiceException exception = report.getServiceException().get(0); assertEquals("The value for parameter HEIGHT \"0\" is invalid: The height must be at least 1.", exception.getvalue()); }