Updated Branches: refs/heads/master 0682e8dd4 -> 171639f49
CAMEL-6236: Added dataformat component Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/171639f4 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/171639f4 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/171639f4 Branch: refs/heads/master Commit: 171639f49acdf81bfc4cc986ed50da5710dc3457 Parents: 0682e8d Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Aug 13 08:24:36 2013 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Aug 13 08:56:35 2013 +0200 ---------------------------------------------------------------------- camel-core/pom.xml | 4 + .../dataformat/DataFormatComponent.java | 51 +++++++++ .../dataformat/DataFormatEndpoint.java | 112 +++++++++++++++++++ .../org/apache/camel/impl/StringDataFormat.java | 13 ++- .../org/apache/camel/impl/ZipDataFormat.java | 10 +- .../dataformat/SerializationDataFormat.java | 5 + .../org/apache/camel/component/dataformat | 18 +++ .../org/apache/camel/dataformat/serialization | 18 +++ .../services/org/apache/camel/dataformat/string | 18 +++ .../services/org/apache/camel/dataformat/zip | 18 +++ .../DataFormatEndpointSerializationTest.java | 55 +++++++++ .../DataFormatEndpointStringTest.java | 54 +++++++++ .../management/ManagedCamelContextTest.java | 2 +- .../camel/example/DataFormatComponentTest.java | 44 ++++++++ 14 files changed, 419 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/pom.xml ---------------------------------------------------------------------- diff --git a/camel-core/pom.xml b/camel-core/pom.xml index cd2f201..d7e8aa8 100755 --- a/camel-core/pom.xml +++ b/camel-core/pom.xml @@ -65,6 +65,7 @@ org.apache.camel.spi.ComponentResolver;component=ref, org.apache.camel.spi.ComponentResolver;component=xslt, org.apache.camel.spi.ComponentResolver;component=browse, + org.apache.camel.spi.ComponentResolver;component=dataformat, org.apache.camel.spi.ComponentResolver;component=dataset, org.apache.camel.spi.ComponentResolver;component=timer, org.apache.camel.spi.ComponentResolver;component=file, @@ -72,6 +73,9 @@ org.apache.camel.spi.ComponentResolver;component=binding, org.apache.camel.spi.ComponentResolver;component=seda, org.apache.camel.spi.ComponentResolver;component=language, + org.apache.camel.spi.DataFormatResolver;dataformat=serialization, + org.apache.camel.spi.DataFormatResolver;dataformat=string, + org.apache.camel.spi.DataFormatResolver;dataformat=zip, org.apache.camel.spi.LanguageResolver;language=ref, org.apache.camel.spi.LanguageResolver;language=constant, org.apache.camel.spi.LanguageResolver;language=bean, http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/main/java/org/apache/camel/component/dataformat/DataFormatComponent.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/dataformat/DataFormatComponent.java b/camel-core/src/main/java/org/apache/camel/component/dataformat/DataFormatComponent.java new file mode 100644 index 0000000..f692ab8 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/dataformat/DataFormatComponent.java @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.dataformat; + +import java.util.Map; + +import org.apache.camel.Endpoint; +import org.apache.camel.impl.DefaultComponent; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.util.EndpointHelper; +import org.apache.camel.util.ObjectHelper; + +public class DataFormatComponent extends DefaultComponent { + + @Override + protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { + String name = ObjectHelper.before(remaining, ":"); + DataFormat df = getCamelContext().resolveDataFormat(name); + if (df == null) { + throw new IllegalArgumentException("Cannot find data format with name: " + name); + } + + String operation = ObjectHelper.after(remaining, ":"); + if (!"marshal".equals(operation) && !"unmarshal".equals(operation)) { + throw new IllegalArgumentException("Operation must be either marshal or unmarshal, was: " + operation); + } + + // set reference properties first as they use # syntax that fools the regular properties setter + EndpointHelper.setReferenceProperties(getCamelContext(), df, parameters); + EndpointHelper.setProperties(getCamelContext(), df, parameters); + + DataFormatEndpoint endpoint = new DataFormatEndpoint(uri, this, df); + endpoint.setOperation(operation); + setProperties(endpoint, parameters); + return endpoint; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/main/java/org/apache/camel/component/dataformat/DataFormatEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/dataformat/DataFormatEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/dataformat/DataFormatEndpoint.java new file mode 100644 index 0000000..7304990 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/dataformat/DataFormatEndpoint.java @@ -0,0 +1,112 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.dataformat; + +import org.apache.camel.AsyncCallback; +import org.apache.camel.AsyncProcessor; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.impl.DefaultAsyncProducer; +import org.apache.camel.impl.DefaultEndpoint; +import org.apache.camel.processor.MarshalProcessor; +import org.apache.camel.processor.UnmarshalProcessor; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.util.ServiceHelper; + +public class DataFormatEndpoint extends DefaultEndpoint { + + private DataFormat dataFormat; + private MarshalProcessor marshal; + private UnmarshalProcessor unmarshal; + private String operation; + + public DataFormatEndpoint() { + } + + public DataFormatEndpoint(String endpointUri, Component component, DataFormat dataFormat) { + super(endpointUri, component); + this.dataFormat = dataFormat; + } + + public DataFormat getDataFormat() { + return dataFormat; + } + + public void setDataFormat(DataFormat dataFormat) { + this.dataFormat = dataFormat; + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + @Override + public Producer createProducer() throws Exception { + return new DefaultAsyncProducer(this) { + @Override + public boolean process(Exchange exchange, AsyncCallback callback) { + if (marshal != null) { + return marshal.process(exchange, callback); + } else { + return unmarshal.process(exchange, callback); + } + } + + @Override + public String toString() { + return "DataFormatProducer[" + dataFormat + "]"; + } + }; + } + + @Override + public Consumer createConsumer(Processor processor) throws Exception { + throw new UnsupportedOperationException("Cannot consume from data format"); + } + + @Override + public boolean isSingleton() { + return true; + } + + @Override + protected void doStart() throws Exception { + if (operation.equals("marshal")) { + marshal = new MarshalProcessor(dataFormat); + marshal.setCamelContext(getCamelContext()); + } else { + unmarshal = new UnmarshalProcessor(dataFormat); + unmarshal.setCamelContext(getCamelContext()); + } + + ServiceHelper.startServices(dataFormat, marshal, unmarshal); + super.doStart(); + } + + @Override + protected void doStop() throws Exception { + ServiceHelper.stopServices(marshal, unmarshal, dataFormat); + super.doStop(); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/main/java/org/apache/camel/impl/StringDataFormat.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/StringDataFormat.java b/camel-core/src/main/java/org/apache/camel/impl/StringDataFormat.java index 6a11116..7b115ac 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/StringDataFormat.java +++ b/camel-core/src/main/java/org/apache/camel/impl/StringDataFormat.java @@ -32,12 +32,23 @@ import org.apache.camel.util.ExchangeHelper; */ public class StringDataFormat implements DataFormat { - private final String charset; + private String charset; + + public StringDataFormat() { + } public StringDataFormat(String charset) { this.charset = charset; } + public String getCharset() { + return charset; + } + + public void setCharset(String charset) { + this.charset = charset; + } + public void marshal(Exchange exchange, Object graph, OutputStream stream) throws IOException { String text = ExchangeHelper.convertToType(exchange, String.class, graph); http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java b/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java index 051e0f3..c496714 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java +++ b/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java @@ -33,7 +33,7 @@ import org.apache.camel.util.IOHelper; */ public class ZipDataFormat implements DataFormat { - private final int compressionLevel; + private int compressionLevel; public ZipDataFormat() { this.compressionLevel = Deflater.BEST_SPEED; @@ -43,6 +43,14 @@ public class ZipDataFormat implements DataFormat { this.compressionLevel = compressionLevel; } + public int getCompressionLevel() { + return compressionLevel; + } + + public void setCompressionLevel(int compressionLevel) { + this.compressionLevel = compressionLevel; + } + public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception { // ask for a mandatory type conversion to avoid a possible NPE beforehand as we do copy from the InputStream InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, exchange, graph); http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/main/java/org/apache/camel/model/dataformat/SerializationDataFormat.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/SerializationDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/SerializationDataFormat.java index d3309d1..b30b331 100644 --- a/camel-core/src/main/java/org/apache/camel/model/dataformat/SerializationDataFormat.java +++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/SerializationDataFormat.java @@ -31,6 +31,11 @@ import org.apache.camel.spi.RouteContext; public class SerializationDataFormat extends DataFormatDefinition { @Override + public String getDataFormatName() { + return "serialization"; + } + + @Override protected DataFormat createDataFormat(RouteContext routeContext) { return new org.apache.camel.impl.SerializationDataFormat(); } http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/dataformat ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/dataformat b/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/dataformat new file mode 100644 index 0000000..4f29da3 --- /dev/null +++ b/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/dataformat @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +class=org.apache.camel.component.dataformat.DataFormatComponent \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/serialization ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/serialization b/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/serialization new file mode 100644 index 0000000..fb6899a --- /dev/null +++ b/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/serialization @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +class=org.apache.camel.impl.SerializationDataFormat http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/string ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/string b/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/string new file mode 100644 index 0000000..757b501 --- /dev/null +++ b/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/string @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +class=org.apache.camel.impl.StringDataFormat http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/zip ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/zip b/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/zip new file mode 100644 index 0000000..526007c --- /dev/null +++ b/camel-core/src/main/resources/META-INF/services/org/apache/camel/dataformat/zip @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +class=org.apache.camel.impl.ZipDataFormat http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatEndpointSerializationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatEndpointSerializationTest.java b/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatEndpointSerializationTest.java new file mode 100644 index 0000000..3d7e84e --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatEndpointSerializationTest.java @@ -0,0 +1,55 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.dataformat; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.impl.MySerialBean; + +public class DataFormatEndpointSerializationTest extends ContextTestSupport { + + public void testSerialization() throws Exception { + MySerialBean bean = new MySerialBean(); + bean.setId(123); + bean.setName("Donald"); + + Object data = template.requestBody("direct:marshal", bean); + assertNotNull(data); + + Object out = template.requestBody("direct:unmarshal", data); + assertNotNull(out); + + MySerialBean outBean = context.getTypeConverter().convertTo(MySerialBean.class, out); + assertNotNull(outBean); + assertEquals(123, outBean.getId()); + assertEquals("Donald", outBean.getName()); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:unmarshal") + .to("dataformat:serialization:unmarshal"); + + from("direct:marshal") + .to("dataformat:serialization:marshal"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatEndpointStringTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatEndpointStringTest.java b/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatEndpointStringTest.java new file mode 100644 index 0000000..cbe5dc7 --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatEndpointStringTest.java @@ -0,0 +1,54 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.dataformat; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; + +public class DataFormatEndpointStringTest extends ContextTestSupport { + + public void testUnmarshalUTF8() throws Exception { + // NOTE: Here we can use a MockEndpoint as we unmarshal the inputstream to String + + // include a UTF-8 char in the text \u0E08 is a Thai elephant + final String title = "Hello Thai Elephant \u0E08"; + byte[] bytes = title.getBytes("UTF-8"); + InputStream in = new ByteArrayInputStream(bytes); + + template.sendBody("direct:start", in); + + MockEndpoint mock = context.getEndpoint("mock:unmarshal", MockEndpoint.class); + mock.setExpectedMessageCount(1); + mock.expectedBodiesReceived(title); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .to("dataformat:string:unmarshal?charset=UTF-8") + .to("mock:unmarshal"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java b/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java index 7f1aa9c..b43c723 100644 --- a/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java +++ b/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java @@ -168,7 +168,7 @@ public class ManagedCamelContextTest extends ManagementTestSupport { Map<String, Properties> info = (Map<String, Properties>) mbeanServer.invoke(on, "findComponents", null, null); assertNotNull(info); - assertEquals(21, info.size()); + assertEquals(22, info.size()); Properties prop = info.get("seda"); assertNotNull(prop); assertEquals("org.apache.camel", prop.get("groupId")); http://git-wip-us.apache.org/repos/asf/camel/blob/171639f4/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatComponentTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatComponentTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatComponentTest.java new file mode 100644 index 0000000..facf9a1 --- /dev/null +++ b/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatComponentTest.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.example; + +import org.apache.camel.builder.RouteBuilder; + +/** + * @version + */ +public class DataFormatComponentTest extends DataFormatTest { + + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:start"). + to("dataformat:jaxb:marshal?contextPath=org.apache.camel.example"). + to("direct:marshalled"); + + from("direct:marshalled"). + to("dataformat:jaxb:unmarshal?contextPath=org.apache.camel.example"). + to("mock:result"); + + from("direct:prettyPrint"). + to("dataformat:jaxb:marshal?contextPath=org.apache.camel.foo.bar&prettyPrint=true"). + to("mock:result"); + } + }; + } + +} \ No newline at end of file