XsltCapabilitiesSerializer implements CapabilitiesSerializer { @Override public void serialize( InputStream capabilitiesXmlStream, OutputStream responseStream ) throws IOException { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( workspace.getModuleClassLoader() ); try { XsltUtils.transform( capabilitiesXmlStream, this.xslt, responseStream ); } catch ( Exception e ) { LOG.warn( "Unable to transform Capabilities: {}.", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } finally { Thread.currentThread().setContextClassLoader( loader ); } } XsltCapabilitiesSerializer( URL xslt, Workspace workspace ); @Override void serialize( InputStream capabilitiesXmlStream, OutputStream responseStream );  }
@Test public void testSerialize() throws Exception { URL xslt = XsltCapabilitiesSerializerTest.class.getResource( "capabilities2html.xsl" ); Workspace workspace = mockWorkspace(); XsltCapabilitiesSerializer xsltCapabilitiesSerializer = new XsltCapabilitiesSerializer( xslt, workspace ); ByteArrayOutputStream responseStream = new ByteArrayOutputStream(); xsltCapabilitiesSerializer.serialize( capabilitiesXmlStream(), responseStream ); String html = responseStream.toString(); assertThat( html, containsString( "WMS" ) ); assertThat( html, containsString( "deegree 3 Utah Demo WMS" ) ); }