XsltExceptionSerializer implements ExceptionsSerializer { @Override public void serializeException( HttpResponseBuffer response, OWSException ex, XMLExceptionSerializer exceptionSerializer, Map<String, String> map ) throws SerializingException { try { response.setContentType( contenType ); ByteArrayOutputStream stream = writeToStream( ex, exceptionSerializer ); transform( new ByteArrayInputStream( stream.toByteArray() ), response ); } catch ( XMLStreamException e ) { throw new SerializingException( e ); } catch ( FactoryConfigurationError e ) { throw new SerializingException( e ); } } XsltExceptionSerializer( String contentType, URL xsltUrl, Workspace workspace ); @Override void serializeException( HttpResponseBuffer response, OWSException ex,
                                    XMLExceptionSerializer exceptionSerializer, Map<String, String> map );  }
@Test public void testSerializeException() throws Exception { XsltExceptionSerializer xsltExceptionSerializer = createXsltExceptionSerializer(); ByteArrayOutputStream os = new ByteArrayOutputStream(); OWSException ex = new OWSException( EXCEPTION, NO_APPLICABLE_CODE ); serialize( xsltExceptionSerializer, os, ex ); String htmlException = os.toString(); assertThat( htmlException, containsString( EXCEPTION ) ); assertThat( htmlException, containsString( NO_APPLICABLE_CODE ) ); }
@Test public void testSerializeException_ContentType() throws Exception { XsltExceptionSerializer xsltExceptionSerializer = createXsltExceptionSerializer(); ByteArrayOutputStream os = new ByteArrayOutputStream(); OWSException ex = new OWSException( EXCEPTION, NO_APPLICABLE_CODE ); XMLExceptionSerializer exceptionSerializer = exceptionSerializer(); HttpResponseBuffer response = responseBuffer( os ); xsltExceptionSerializer.serializeException( response, ex, exceptionSerializer, null ); serialize( xsltExceptionSerializer, os, ex ); verify( response ).setContentType( eq( CONTENT_TYPE ) ); }