Copia collegamentoCollegamento copiato negli appunti!
To undertake unit testing with Smooks, follow the example below:
public class MyMessageTransformTest
{
@Test
public void test_transform() throws IOException, SAXException
{
Smooks smooks = new Smooks(
getClass().getResourceAsStream("smooks-config.xml") );
try {
Source source = new StreamSource(
getClass().getResourceAsStream("input-message.xml" ) );
StringResult result = new StringResult();
smooks.filterSource(source, result);
// compare the expected xml with the transformation result.
XMLUnit.setIgnoreWhitespace( true );
XMLAssert.assertXMLEqual(
new InputStreamReader(
getClass().getResourceAsStream("expected.xml")),
new StringReader(result.getResult()));
} finally {
smooks.close();
}
}
}
public class MyMessageTransformTest
{
@Test
public void test_transform() throws IOException, SAXException
{
Smooks smooks = new Smooks(
getClass().getResourceAsStream("smooks-config.xml") );
try {
Source source = new StreamSource(
getClass().getResourceAsStream("input-message.xml" ) );
StringResult result = new StringResult();
smooks.filterSource(source, result);
// compare the expected xml with the transformation result.
XMLUnit.setIgnoreWhitespace( true );
XMLAssert.assertXMLEqual(
new InputStreamReader(
getClass().getResourceAsStream("expected.xml")),
new StringReader(result.getResult()));
} finally {
smooks.close();
}
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.
Rendiamo l’open source più inclusivo
Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.
Informazioni su Red Hat
Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.