Skip to content

Commit

Permalink
chore: prepare release (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmamo authored Oct 20, 2024
1 parent d8d5a2d commit de753ea
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 54 deletions.
67 changes: 40 additions & 27 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ Then the Smooks code for executing this:
[source,java]
----
Smooks smooks = new Smooks(configStream);
JavaResult javaResult = new JavaResult();
JavaSink javaSink = new JavaSink();
smooks.filterSource(new StreamSource(soapMessageStream), javaResult);
smooks.filterSource(new StreamSource(soapMessageStream), javaSink);
String bodyContent = javaResult.getBean("soapBody").toString().trim();
String bodyContent = javaSink.getBean("soapBody").toString().trim();
----

And of course, you can do all of this programmatically too (i.e., no need for the XML config):
Expand All @@ -77,10 +77,10 @@ Smooks smooks = new Smooks();
smooks.addVisitor(new FragmentSerializer().setBindTo("soapBody"), "Envelope/Body");
JavaResult javaResult = new JavaResult();
smooks.filterSource(new StreamSource(soapMessageStream), javaResult);
JavaSink javaSink = new JavaSink();
smooks.filterSource(new StreamSource(soapMessageStream), javaSink);
String bodyContent = javaResult.getBean("soapBody").toString().trim();
String bodyContent = javaSink.getBean("soapBody").toString().trim();
----

The code snippets above only show how to create the split messages and bind them into the bean context, from where they can be accessed. How about routing these split messages to another endpoint for processing?Well it's easy, just use one of the routing components as outlined in the following sections.
Expand Down Expand Up @@ -159,15 +159,21 @@ To achieve this with Smooks, we assemble the following Smooks configuration:
<!--
Every time we hit the end of an <order-item> element, apply this freemarker template,
outputting the result to the "orderItemSplitStream" OutputStream, which is the file
output stream configured above.
-->
(4) <ftl:freemarker applyOnElement="order-item">
<ftl:template>target/classes/orderitem-split.ftl</ftl:template>
<ftl:use>
output stream configured below.
-->
(4) <core:smooks filterSourceOn="order-item">
<core:action>
<!-- Output the templating result to the "orderItemSplitStream" file output stream... -->
<ftl:outputTo outputStreamResource="orderItemSplitStream"/>
</ftl:use>
</ftl:freemarker>
<core:outputTo outputStreamResource="orderItemSplitStream"/>
</core:action>
<core:config>
<smooks-resource-list>
<ftl:freemarker applyOnElement="order-item">
<ftl:template>target/classes/orderitem-split.ftl</ftl:template>
</ftl:freemarker>
</smooks-resource-list>
</core:config>
</core:smooks>
</smooks-resource-list>
----
Expand Down Expand Up @@ -220,18 +226,25 @@ The following is an example `+<jms:router>+` configuration that routes an `+orde
<jms:highWaterMark mark="3"/>
</jms:router>
(3) <ftl:freemarker applyOnElement="order-item">
<!--
Note in the template that we need to use the special FreeMarker variable ".vars"
because of the hyphenated variable names ("order-item"). See http://freemarker.org/docs/ref_specvar.html.
-->
<ftl:template>/orderitem-split.ftl</ftl:template>
<ftl:use>
<!-- Bind the templating result into the bean context, from where
it can be accessed by the JMSRouter (configured above). -->
<ftl:bindTo id="orderItem_xml"/>
</ftl:use>
</ftl:freemarker>
(3) <core:smooks filterSourceOn="order-item">
<!-- Bind the templating result into the bean context, from where
it can be accessed by the JMSRouter (configured above). -->
<core:action>
<core:bindTo id="orderItem_xml"/>
</core:action>
<core:config>
<smooks-resource-list>
<!-- At each "order-item", apply a template to the "order" and "order-item" DOM model... -->
<ftl:freemarker applyOnElement="#document">
<!--
Note in the template that we need to use the special FreeMarker variable ".vars"
because of the hyphenated variable names ("order-item"). See http://freemarker.org/docs/ref_specvar.html.
-->
<ftl:template>/orderitem-split.ftl</ftl:template>
</ftl:freemarker>
</smooks-resource-list>
</core:config>
</core:smooks>
</smooks-resource-list>
----
Expand All @@ -247,7 +260,7 @@ In this case, we route the result of a FreeMarker templating operation to the JM
<dependency>
<groupId>org.smooks.cartridges</groupId>
<artifactId>smooks-routing-cartridge</artifactId>
<version>2.0.0-RC4</version>
<version>2.0.0</version>
</dependency>
----

Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>org.smooks.cartridges</groupId>
<artifactId>smooks-routing-cartridge</artifactId>
<version>2.0.0-RC4</version>
<version>2.0.0</version>

<name>Smooks Routing Cartridge</name>
<url>https://www.smooks.org</url>
Expand Down Expand Up @@ -41,7 +41,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gpg.skip>true</gpg.skip>
<smooks.version>2.0.0-RC4</smooks.version>
<smooks.version>2.0.0</smooks.version>
</properties>

<build>
Expand Down Expand Up @@ -250,7 +250,7 @@
<dependency>
<groupId>org.smooks.cartridges</groupId>
<artifactId>smooks-templating-cartridge</artifactId>
<version>2.0.0-RC4</version>
<version>2.0.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -262,7 +262,7 @@
<dependency>
<groupId>org.smooks.cartridges</groupId>
<artifactId>smooks-javabean-cartridge</artifactId>
<version>2.0.0-RC4</version>
<version>2.0.0</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Test;
import org.smooks.Smooks;
import org.smooks.io.payload.JavaResult;
import org.smooks.io.sink.JavaSink;
import org.smooks.io.source.StreamSource;
import org.xml.sax.SAXException;

import javax.xml.transform.stream.StreamSource;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;

Expand All @@ -62,24 +63,24 @@ public class FragmentSerializerNSConfigTest {
@Test
public void test_children_only() throws IOException, SAXException {
Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01-ext.xml"));
StreamSource source = new StreamSource(getClass().getResourceAsStream("input-message-01.xml"));
JavaResult result = new JavaResult();
StreamSource<InputStream> source = new StreamSource<>(getClass().getResourceAsStream("input-message-01.xml"));
JavaSink sink = new JavaSink();

smooks.filterSource(source, result);
smooks.filterSource(source, sink);

XMLUnit.setIgnoreWhitespace( true );
XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("children-only.xml")), new StringReader(result.getBean("soapBody").toString().trim()));
XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("children-only.xml")), new StringReader(sink.getBean("soapBody").toString().trim()));
}

@Test
public void test_all() throws IOException, SAXException {
Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-02-ext.xml"));
StreamSource source = new StreamSource(getClass().getResourceAsStream("input-message-01.xml"));
JavaResult result = new JavaResult();
JavaSink sink = new JavaSink();

smooks.filterSource(source, result);
smooks.filterSource(source, sink);

XMLUnit.setIgnoreWhitespace( true );
XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("all.xml")), new StringReader(result.getBean("soapBody").toString().trim()));
XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("all.xml")), new StringReader(sink.getBean("soapBody").toString().trim()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
import org.smooks.api.ExecutionContext;
import org.smooks.api.SmooksException;
import org.smooks.api.resource.visitor.sax.ng.AfterVisitor;
import org.smooks.io.payload.JavaResult;
import org.smooks.io.sink.JavaSink;
import org.smooks.io.source.StreamSource;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

import javax.xml.transform.stream.StreamSource;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand All @@ -71,27 +71,27 @@ public class FragmentSerializerTest {
@Test
public void test_children_only() throws IOException, SAXException {
Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
StreamSource source = new StreamSource(getClass().getResourceAsStream("input-message-01.xml"));
JavaResult result = new JavaResult();
StreamSource<InputStream> source = new StreamSource<>(getClass().getResourceAsStream("input-message-01.xml"));
JavaSink sink = new JavaSink();

smooks.filterSource(source, result);
smooks.filterSource(source, sink);

XMLUnit.setIgnoreWhitespace( true );
InputStream stream = getClass().getResourceAsStream("children-only.xml");
Object bean = result.getBean("soapBody");
Object bean = sink.getBean("soapBody");
XMLAssert.assertXMLEqual(new InputStreamReader(stream), new StringReader(bean.toString().trim()));
}

@Test
public void test_all() throws IOException, SAXException {
Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-02.xml"));
StreamSource source = new StreamSource(getClass().getResourceAsStream("input-message-01.xml"));
JavaResult result = new JavaResult();
StreamSource<InputStream> source = new StreamSource(getClass().getResourceAsStream("input-message-01.xml"));
JavaSink sink = new JavaSink();

smooks.filterSource(source, result);
smooks.filterSource(source, sink);

XMLUnit.setIgnoreWhitespace( true );
XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("all.xml")), new StringReader(result.getBean("soapBody").toString().trim()));
XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("all.xml")), new StringReader(sink.getBean("soapBody").toString().trim()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.smooks.engine.resource.config.DefaultResourceConfig;
import org.smooks.engine.resource.visitor.smooks.NestedSmooksVisitor;
import org.smooks.io.ResourceOutputStream;
import org.smooks.io.payload.StringSource;
import org.smooks.io.source.StringSource;
import org.smooks.support.FileUtils;
import org.smooks.testkit.MockApplicationContext;
import org.smooks.testkit.MockExecutionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@
import org.junit.Before;
import org.junit.Test;
import org.smooks.Smooks;
import org.smooks.support.StreamUtils;
import org.smooks.io.source.StreamSource;
import org.xml.sax.SAXException;

import javax.xml.transform.stream.StreamSource;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import org.smooks.cartridges.templating.freemarker.FreeMarkerTemplateProcessor;
import org.smooks.engine.DefaultApplicationContextBuilder;
import org.smooks.engine.resource.visitor.smooks.NestedSmooksVisitor;
import org.smooks.io.payload.StringSource;
import org.smooks.io.source.StringSource;
import org.xml.sax.SAXException;

import javax.jms.JMSException;
Expand Down

0 comments on commit de753ea

Please sign in to comment.