You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/08/21 07:58:05 UTC

[camel] 10/20: Improve configurability

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 17ebeaabefea872cf2330038793af4c1b3a72d1f
Author: Roberto Flores <be...@gmail.com>
AuthorDate: Mon Jul 15 06:55:41 2019 -0500

    Improve configurability
---
 components/camel-any23/pom.xml                     |   5 +
 .../src/main/docs/any23-dataformat.adoc            |  15 ++-
 .../camel/dataformat/any23/Any23DataFormat.java    | 129 ++++++++-------------
 .../camel/dataformat/any23/Any23OutputFormat.java  |   2 +-
 .../camel/dataformat/any23/Any23Parameters.java    |  36 ------
 .../camel/dataformat/any23/utils/Any23Utils.java   |  58 +++++++++
 ...java => Any23DataFormatConfigurationsTest.java} |  17 ++-
 ...icTest.java => Any23DataFormatDefaultTest.java} |  10 +-
 ...est.java => Any23DataFormatExtractorsTest.java} |  21 +++-
 ...t.java => Any23DataFormatOutputFormatTest.java} |  11 +-
 .../camel/dataformat/any23/Any23TestSupport.java   |  15 ++-
 .../src/test/resources/log4j2.properties           |   2 +-
 .../camel/dataformat/any23/microformat/vcard.html  |  14 +++
 .../apache/camel/dataformat/any23/testfile1.html   |  38 ------
 .../camel/dataformat/any23/testfile2-evilHtml.html |  77 ------------
 15 files changed, 180 insertions(+), 270 deletions(-)

diff --git a/components/camel-any23/pom.xml b/components/camel-any23/pom.xml
index 14f7b4c..0330ca0 100644
--- a/components/camel-any23/pom.xml
+++ b/components/camel-any23/pom.xml
@@ -79,5 +79,10 @@
       <artifactId>rdf4j-rio-rdfxml</artifactId>
       <version>3.0.0-M1</version>
     </dependency>
+    <dependency>
+      <groupId>org.eclipse.rdf4j</groupId>
+      <artifactId>rdf4j-rio-turtle</artifactId>
+      <version>3.0.0-M1</version>
+    </dependency>
   </dependencies>
 </project>
diff --git a/components/camel-any23/src/main/docs/any23-dataformat.adoc b/components/camel-any23/src/main/docs/any23-dataformat.adoc
index 962f3a4..3155e14 100644
--- a/components/camel-any23/src/main/docs/any23-dataformat.adoc
+++ b/components/camel-any23/src/main/docs/any23-dataformat.adoc
@@ -32,10 +32,10 @@ The Any23 dataformat supports 5 options, which are listed below.
 [width="100%",cols="2s,1m,1m,6",options="header"]
 |===
 | Name | Default | Java Type | Description
-| outputFormat | MODEL | String | 
-| configurations |  | String | 
-| extractors |  | String | 
-| baseuri |  | String | 
+| outputFormat | MODEL | Any23Type | 
+| configurations |  | Map | 
+| extractors |  | List | 
+| baseURI |  | String | 
 | contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSon etc.
 |===
 // dataformat options: END
@@ -55,19 +55,18 @@ When using Spring Boot make sure to use the following Maven dependency to have s
 ----
 
 
-The component supports 6 options, which are listed below.
+The component supports 5 options, which are listed below.
 
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *camel.dataformat.any23.baseuri* |  |  | String
+| *camel.dataformat.any23.base-u-r-i* |  |  | String
 | *camel.dataformat.any23.configurations* |  |  | String
 | *camel.dataformat.any23.content-type-header* | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSon etc. | false | Boolean
 | *camel.dataformat.any23.enabled* | Whether to enable auto configuration of the any23 data format. This is enabled by default. |  | Boolean
-| *camel.dataformat.any23.extractors* |  |  | String
-| *camel.dataformat.any23.output-format* |  | MODEL | String
+| *camel.dataformat.any23.extractors* |  |  | List
 |===
 // spring-boot-auto-configure options: END
 
diff --git a/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23DataFormat.java b/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23DataFormat.java
index 0d2122c..2400b0a 100644
--- a/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23DataFormat.java
+++ b/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23DataFormat.java
@@ -18,19 +18,18 @@ package org.apache.camel.dataformat.any23;
 
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 import org.apache.any23.Any23;
 import org.apache.any23.configuration.DefaultConfiguration;
 import org.apache.any23.configuration.ModifiableConfiguration;
 import org.apache.any23.source.DocumentSource;
 import org.apache.any23.source.StringDocumentSource;
-import org.apache.any23.writer.JSONLDWriter;
-import org.apache.any23.writer.NQuadsWriter;
-import org.apache.any23.writer.NTriplesWriter;
-import org.apache.any23.writer.RDFXMLWriter;
 import org.apache.any23.writer.TripleHandler;
-import org.apache.any23.writer.TurtleWriter;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.dataformat.any23.utils.Any23Utils;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.DataFormatName;
 import org.apache.camel.spi.annotations.Dataformat;
@@ -52,14 +51,11 @@ public class Any23DataFormat extends ServiceSupport implements DataFormat, DataF
   private static final Logger LOG = LoggerFactory.getLogger(Any23DataFormat.class);
 
   private Any23 any23;
-  private Any23OutputFormat format = Any23OutputFormat.RDFXML;
-  private ModifiableConfiguration conf;
-  private String[] extractorsList;
 
-  private String configurations;
-  private String extractors;
-  private String outputFormat;
-  private String documentIRI = "http://mock.foo/bar";
+  private Map<String, String> configurations;
+  private List<String> extractors;
+  private Any23OutputFormat outputFormat;
+  private String baseURI;
 
   @Override
   public String getDataFormatName() {
@@ -71,30 +67,8 @@ public class Any23DataFormat extends ServiceSupport implements DataFormat, DataF
    */
   public void marshal(Exchange exchange, Object object, OutputStream outputStream) throws Exception {
     final String payload = ExchangeHelper.convertToMandatoryType(exchange, String.class, object);
-    DocumentSource source = new StringDocumentSource(payload, documentIRI);
-    TripleHandler handler;
-    switch (format) {
-      case NTRIPLES:
-        handler = new NTriplesWriter(outputStream);
-        break;
-      case TURTLE:
-        handler = new TurtleWriter(outputStream);
-        break;
-      case NQUADS:
-        handler = new NQuadsWriter(outputStream);
-        break;
-      case RDFXML:
-        handler = new RDFXMLWriter(outputStream);
-        break;
-      case JSONLD:
-        handler = new JSONLDWriter(outputStream);
-        break;
-      case MODEL:
-        handler = new NTriplesWriter(outputStream);
-        break;
-      default:
-        handler = new NTriplesWriter(outputStream);
-    }
+    DocumentSource source = new StringDocumentSource(payload, baseURI);
+    TripleHandler handler = Any23Utils.obtainHandler(outputFormat, outputStream);
     any23.extract(source, handler);
     handler.close();
   }
@@ -104,33 +78,38 @@ public class Any23DataFormat extends ServiceSupport implements DataFormat, DataF
    */
   public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
     //TODO
+    //Under construction
+    //Looking for libraries which could perform RDF -> HTML 
+    //Candidate: https://github.com/rhizomik/redefer-rdf2html
     return null;
   }
 
   @Override
   protected void doStart() throws Exception {
-    conf = DefaultConfiguration.copy();
-    if (configurations != null) {
-      String[] newConfigs = configurations.split(";");
-      for (String con : newConfigs) {
-        String[] vals = con.split("=");
-        conf.setProperty(vals[0], vals[0]);
+    ModifiableConfiguration conf = null;
+    String[] extrArray = null;
+    if (extractors != null && !extractors.isEmpty()) {
+      extrArray = new String[extractors.size()];
+      extrArray = extractors.toArray(extrArray);
+    }
+    if (configurations != null && !configurations.isEmpty()) {
+      conf = DefaultConfiguration.copy();
+      for (Entry<String, String> entry : configurations.entrySet()) {
+        conf.setProperty(entry.getKey(), entry.getValue());
       }
     }
-    if (extractors != null) {
-      extractorsList = extractors.split(";");
+    if (outputFormat == null) {
+      //Default output format
+      outputFormat = Any23OutputFormat.RDFXML;
     }
-    if (configurations == null && extractors == null) {
+    if (conf == null && extrArray == null) {
       any23 = new Any23();
-    } else if (configurations != null && extractors == null) {
+    } else if (conf != null && extrArray == null) {
       any23 = new Any23(conf);
-    } else if (configurations == null && extractors != null) {
-      any23 = new Any23(extractors);
-    } else if (configurations != null && extractors != null) {
-      any23 = new Any23(conf, extractors);
-    }
-    if (outputFormat != null) {
-      format = Any23OutputFormat.valueOf(outputFormat);
+    } else if (conf == null && extrArray != null) {
+      any23 = new Any23(extrArray);
+    } else if (conf != null && extrArray != null) {
+      any23 = new Any23(conf, extrArray);
     }
   }
 
@@ -147,52 +126,36 @@ public class Any23DataFormat extends ServiceSupport implements DataFormat, DataF
     this.any23 = any23;
   }
 
-  public Any23OutputFormat getFormat() {
-    return format;
-  }
-
-  public void setFormat(Any23OutputFormat format) {
-    this.format = format;
-  }
-
-  public ModifiableConfiguration getConf() {
-    return conf;
-  }
-
-  public void setConf(ModifiableConfiguration conf) {
-    this.conf = conf;
-  }
-
-  public String[] getExtractorsList() {
-    return extractorsList;
-  }
-
-  public void setExtractorsList(String[] extractorsList) {
-    this.extractorsList = extractorsList;
-  }
-
-  public String getConfigurations() {
+  public Map<String, String> getConfigurations() {
     return configurations;
   }
 
-  public void setConfigurations(String configurations) {
+  public void setConfigurations(Map<String, String> configurations) {
     this.configurations = configurations;
   }
 
-  public String getExtractors() {
+  public List<String> getExtractors() {
     return extractors;
   }
 
-  public void setExtractors(String extractors) {
+  public void setExtractors(List<String> extractors) {
     this.extractors = extractors;
   }
 
-  public String getOutputFormat() {
+  public Any23OutputFormat getOutputFormat() {
     return outputFormat;
   }
 
-  public void setOutputFormat(String outputFormat) {
+  public void setOutputFormat(Any23OutputFormat outputFormat) {
     this.outputFormat = outputFormat;
   }
 
+  public String getBaseURI() {
+    return baseURI;
+  }
+
+  public void setBaseURI(String baseURI) {
+    this.baseURI = baseURI;
+  }
+
 }
diff --git a/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23OutputFormat.java b/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23OutputFormat.java
index 0ceddc5..3d4d12a 100644
--- a/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23OutputFormat.java
+++ b/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23OutputFormat.java
@@ -17,5 +17,5 @@
 package org.apache.camel.dataformat.any23;
 
 public enum Any23OutputFormat {
-  NTRIPLES, TURTLE, NQUADS, RDFXML, JSONLD, RDFJSON, MODEL
+  NTRIPLES, TURTLE, NQUADS, RDFXML, JSONLD, RDFJSON
 }
diff --git a/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23Parameters.java b/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23Parameters.java
deleted file mode 100644
index cb9536c..0000000
--- a/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/Any23Parameters.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.apache.camel.dataformat.any23;
-
-import java.io.ByteArrayOutputStream;
-import org.apache.any23.writer.NTriplesWriter;
-import org.apache.any23.writer.TripleHandler;
-
-/**
- *
- * @author joe
- */
-public class Any23Parameters {
-
-  private ByteArrayOutputStream OUT;
-//public static  final TripleHandler TRIPLEHANDLER ;
-
-  private TripleHandler triplehandler;
-
-  public TripleHandler getTripleHandlerOutput() {
-    return triplehandler;
-  }
-
-  public void setTripleHandlerOutput(TripleHandler triplehandler) {
-    this.triplehandler = triplehandler;
-  }
-
-  public Any23Parameters(ByteArrayOutputStream out) {
-    this.OUT = out;
-    this.triplehandler = new NTriplesWriter(out);
-  }
-
-}
diff --git a/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/utils/Any23Utils.java b/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/utils/Any23Utils.java
new file mode 100644
index 0000000..6c97a5e
--- /dev/null
+++ b/components/camel-any23/src/main/java/org/apache/camel/dataformat/any23/utils/Any23Utils.java
@@ -0,0 +1,58 @@
+/*
+ * 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.dataformat.any23.utils;
+
+import java.io.OutputStream;
+import org.apache.any23.writer.JSONLDWriter;
+import org.apache.any23.writer.JSONWriter;
+import org.apache.any23.writer.NQuadsWriter;
+import org.apache.any23.writer.NTriplesWriter;
+import org.apache.any23.writer.RDFXMLWriter;
+import org.apache.any23.writer.TripleHandler;
+import org.apache.any23.writer.TurtleWriter;
+import org.apache.camel.dataformat.any23.Any23OutputFormat;
+
+public class Any23Utils {
+
+  public static TripleHandler obtainHandler(Any23OutputFormat format, OutputStream outputStream) {
+    TripleHandler handler;
+    switch (format) {
+      case NTRIPLES:
+        handler = new NTriplesWriter(outputStream);
+        break;
+      case TURTLE:
+        handler = new TurtleWriter(outputStream);
+        break;
+      case NQUADS:
+        handler = new NQuadsWriter(outputStream);
+        break;
+      case RDFXML:
+        handler = new RDFXMLWriter(outputStream);
+        break;
+      case JSONLD:
+        handler = new JSONLDWriter(outputStream);
+        break;
+      case RDFJSON:
+        handler = new JSONWriter(outputStream);
+        break;
+      default:
+        throw new AssertionError(format.name());
+    }
+    return handler;
+  }
+
+}
diff --git a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatConfigurationsTest.java
similarity index 77%
copy from components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java
copy to components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatConfigurationsTest.java
index 9f7a465..d7c34dd 100644
--- a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java
+++ b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatConfigurationsTest.java
@@ -18,11 +18,14 @@ package org.apache.camel.dataformat.any23;
 
 import java.io.File;
 import java.io.InputStream;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.dataformat.Any23Type;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.commons.io.IOUtils;
 import org.eclipse.rdf4j.model.Model;
@@ -30,10 +33,12 @@ import org.eclipse.rdf4j.rio.RDFFormat;
 import org.eclipse.rdf4j.rio.Rio;
 import org.junit.Test;
 
-public class Any23DataFormatBasicTest extends CamelTestSupport {
+public class Any23DataFormatConfigurationsTest extends CamelTestSupport {
+
+  private final String BASEURI = "http://mock.foo/bar";
 
   @Test
-  public void testMarshalToRDFXMLFromHTML() throws Exception {
+  public void test() throws Exception {
     MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
     String contenhtml = Any23TestSupport.loadFileAsString(new File("src/test/resources/org/apache/camel/dataformat/any23/microformat/vcard.html"));
     template.sendBody("direct:start", contenhtml);
@@ -42,8 +47,8 @@ public class Any23DataFormatBasicTest extends CamelTestSupport {
       Message in = exchange.getIn();
       String resultingRDF = in.getBody(String.class);
       InputStream toInputStream = IOUtils.toInputStream(resultingRDF);
-      Model parse = Rio.parse(toInputStream, "http://mock.foo/bar", RDFFormat.RDFXML);
-      assertEquals(parse.size(), 28);
+      Model parse = Rio.parse(toInputStream, BASEURI, RDFFormat.TURTLE);
+      assertEquals(parse.size(), 25);
     }
   }
 
@@ -51,7 +56,9 @@ public class Any23DataFormatBasicTest extends CamelTestSupport {
   protected RouteBuilder createRouteBuilder() {
     return new RouteBuilder() {
       public void configure() {
-        from("direct:start").marshal().any23("http://mock.foo/bar").to("mock:result");
+        Map<String, String> conf = new HashMap();
+        conf.put("any23.extraction.metadata.nesting", "off");
+        from("direct:start").marshal().any23(BASEURI, Any23Type.TURTLE, conf).to("mock:result");
       }
     };
   }
diff --git a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatDefaultTest.java
similarity index 87%
copy from components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java
copy to components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatDefaultTest.java
index 9f7a465..244dedd 100644
--- a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java
+++ b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatDefaultTest.java
@@ -30,10 +30,12 @@ import org.eclipse.rdf4j.rio.RDFFormat;
 import org.eclipse.rdf4j.rio.Rio;
 import org.junit.Test;
 
-public class Any23DataFormatBasicTest extends CamelTestSupport {
+public class Any23DataFormatDefaultTest extends CamelTestSupport {
+
+  private final String BASEURI = "http://mock.foo/bar";
 
   @Test
-  public void testMarshalToRDFXMLFromHTML() throws Exception {
+  public void test() throws Exception {
     MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
     String contenhtml = Any23TestSupport.loadFileAsString(new File("src/test/resources/org/apache/camel/dataformat/any23/microformat/vcard.html"));
     template.sendBody("direct:start", contenhtml);
@@ -42,7 +44,7 @@ public class Any23DataFormatBasicTest extends CamelTestSupport {
       Message in = exchange.getIn();
       String resultingRDF = in.getBody(String.class);
       InputStream toInputStream = IOUtils.toInputStream(resultingRDF);
-      Model parse = Rio.parse(toInputStream, "http://mock.foo/bar", RDFFormat.RDFXML);
+      Model parse = Rio.parse(toInputStream, BASEURI, RDFFormat.RDFXML);
       assertEquals(parse.size(), 28);
     }
   }
@@ -51,7 +53,7 @@ public class Any23DataFormatBasicTest extends CamelTestSupport {
   protected RouteBuilder createRouteBuilder() {
     return new RouteBuilder() {
       public void configure() {
-        from("direct:start").marshal().any23("http://mock.foo/bar").to("mock:result");
+        from("direct:start").marshal().any23(BASEURI).to("mock:result");
       }
     };
   }
diff --git a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatExtractorsTest.java
similarity index 73%
copy from components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java
copy to components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatExtractorsTest.java
index 9f7a465..1cf88e6 100644
--- a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java
+++ b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatExtractorsTest.java
@@ -18,11 +18,15 @@ package org.apache.camel.dataformat.any23;
 
 import java.io.File;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.dataformat.Any23Type;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.commons.io.IOUtils;
 import org.eclipse.rdf4j.model.Model;
@@ -30,10 +34,12 @@ import org.eclipse.rdf4j.rio.RDFFormat;
 import org.eclipse.rdf4j.rio.Rio;
 import org.junit.Test;
 
-public class Any23DataFormatBasicTest extends CamelTestSupport {
+public class Any23DataFormatExtractorsTest extends CamelTestSupport {
+
+  private final String BASEURI = "http://mock.foo/bar";
 
   @Test
-  public void testMarshalToRDFXMLFromHTML() throws Exception {
+  public void test() throws Exception {
     MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
     String contenhtml = Any23TestSupport.loadFileAsString(new File("src/test/resources/org/apache/camel/dataformat/any23/microformat/vcard.html"));
     template.sendBody("direct:start", contenhtml);
@@ -41,9 +47,10 @@ public class Any23DataFormatBasicTest extends CamelTestSupport {
     for (Exchange exchange : list) {
       Message in = exchange.getIn();
       String resultingRDF = in.getBody(String.class);
+      System.out.println(resultingRDF);
       InputStream toInputStream = IOUtils.toInputStream(resultingRDF);
-      Model parse = Rio.parse(toInputStream, "http://mock.foo/bar", RDFFormat.RDFXML);
-      assertEquals(parse.size(), 28);
+      Model parse = Rio.parse(toInputStream, BASEURI, RDFFormat.TURTLE);
+      assertEquals(parse.size(), 1);
     }
   }
 
@@ -51,7 +58,11 @@ public class Any23DataFormatBasicTest extends CamelTestSupport {
   protected RouteBuilder createRouteBuilder() {
     return new RouteBuilder() {
       public void configure() {
-        from("direct:start").marshal().any23("http://mock.foo/bar").to("mock:result");
+        Map<String, String> conf = new HashMap();
+        conf.put("any23.extraction.metadata.nesting", "off");
+        List<String> extc = new ArrayList();
+        extc.add("html-head-title");
+        from("direct:start").marshal().any23(BASEURI, Any23Type.TURTLE, conf, extc).to("mock:result");
       }
     };
   }
diff --git a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatOutputFormatTest.java
similarity index 84%
rename from components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java
rename to components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatOutputFormatTest.java
index 9f7a465..d00c196 100644
--- a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatBasicTest.java
+++ b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23DataFormatOutputFormatTest.java
@@ -23,6 +23,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.dataformat.Any23Type;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.commons.io.IOUtils;
 import org.eclipse.rdf4j.model.Model;
@@ -30,10 +31,12 @@ import org.eclipse.rdf4j.rio.RDFFormat;
 import org.eclipse.rdf4j.rio.Rio;
 import org.junit.Test;
 
-public class Any23DataFormatBasicTest extends CamelTestSupport {
+public class Any23DataFormatOutputFormatTest extends CamelTestSupport {
+
+  private final String BASEURI = "http://mock.foo/bar";
 
   @Test
-  public void testMarshalToRDFXMLFromHTML() throws Exception {
+  public void test() throws Exception {
     MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
     String contenhtml = Any23TestSupport.loadFileAsString(new File("src/test/resources/org/apache/camel/dataformat/any23/microformat/vcard.html"));
     template.sendBody("direct:start", contenhtml);
@@ -42,7 +45,7 @@ public class Any23DataFormatBasicTest extends CamelTestSupport {
       Message in = exchange.getIn();
       String resultingRDF = in.getBody(String.class);
       InputStream toInputStream = IOUtils.toInputStream(resultingRDF);
-      Model parse = Rio.parse(toInputStream, "http://mock.foo/bar", RDFFormat.RDFXML);
+      Model parse = Rio.parse(toInputStream, BASEURI, RDFFormat.TURTLE);
       assertEquals(parse.size(), 28);
     }
   }
@@ -51,7 +54,7 @@ public class Any23DataFormatBasicTest extends CamelTestSupport {
   protected RouteBuilder createRouteBuilder() {
     return new RouteBuilder() {
       public void configure() {
-        from("direct:start").marshal().any23("http://mock.foo/bar").to("mock:result");
+        from("direct:start").marshal().any23(BASEURI, Any23Type.TURTLE).to("mock:result");
       }
     };
   }
diff --git a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23TestSupport.java b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23TestSupport.java
index 04d4f6a..9f34d74 100644
--- a/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23TestSupport.java
+++ b/components/camel-any23/src/test/java/org/apache/camel/dataformat/any23/Any23TestSupport.java
@@ -1,11 +1,3 @@
-package org.apache.camel.dataformat.any23;
-
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import org.apache.camel.util.IOHelper;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -22,6 +14,13 @@ import org.apache.camel.util.IOHelper;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.camel.dataformat.any23;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import org.apache.camel.util.IOHelper;
+
 public final class Any23TestSupport {
 
   private Any23TestSupport() {
diff --git a/components/camel-any23/src/test/resources/log4j2.properties b/components/camel-any23/src/test/resources/log4j2.properties
index 57bb91f..b919809 100644
--- a/components/camel-any23/src/test/resources/log4j2.properties
+++ b/components/camel-any23/src/test/resources/log4j2.properties
@@ -17,7 +17,7 @@
 
 appender.file.type = File
 appender.file.name = file
-appender.file.fileName = target/camel-atom-test.log
+appender.file.fileName = target/camel-any23-test.log
 appender.file.layout.type = PatternLayout
 appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
 appender.out.type = Console
diff --git a/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/microformat/vcard.html b/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/microformat/vcard.html
index c09a89b..2b79fb1 100644
--- a/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/microformat/vcard.html
+++ b/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/microformat/vcard.html
@@ -1,3 +1,17 @@
+<!--
+    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.
+-->
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
diff --git a/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/testfile1.html b/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/testfile1.html
deleted file mode 100644
index b6f4707..0000000
--- a/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/testfile1.html
+++ /dev/null
@@ -1,38 +0,0 @@
-<!--
-
-    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.
-
--->
-<html>
-     <head>
-      <title>FooBar</title>
-      <meta name=metatag value=foo>
-     </head>
-     
-     <body onload="foo()"  >
-         <p>
-            Some text
-            
-         <p>
-             Some more Text
-     <p>TidyMarkupNode
-          <img src=filename.jpg>
-          
-          <font color="red">Some red text
-          
-     </body>
-    
-</HTML>
\ No newline at end of file
diff --git a/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/testfile2-evilHtml.html b/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/testfile2-evilHtml.html
deleted file mode 100644
index 35ec6da..0000000
--- a/components/camel-any23/src/test/resources/org/apache/camel/dataformat/any23/testfile2-evilHtml.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!--
-
-    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.
-
--->
-<html>
-<META-START>
-John Cowan
-<TABLE>
-<ROW>
-<CELL>SOUPE</CELL>
-<CELL>BE EVIL!</CELL></ROW>
-DE BALISES</TABLE>
-<CORR NEW="U" LOC="PI"/>
-<G ID="P1">
-Ecritez une balise ouvrante (sans attributs)
-</G>
-ou fermante HTML ici, s.v.p.</META-START>
-<FONT>X Y <p> ABC </FONT> xyz
-QRS<sup>TUV<sub>WXY</sup>Z</sub>
-
-<p>TidyMarkupNode
-<script language="javascript"><p></script>
-<table><tbody><tr><th>ABC
-</table><nr/>
-<meta><meta><meta><meta>
-<pre xml:space="default">test</pre>
-<test xmlns:xml="http://www.example.org/>
-</test><hr/>
-(add a random HTML tag above)
-<r:r:r:test/>
-
-<b><i></B></I>
-<b>
-  <p>bbb</b></p>
-  <p>bbb</b></p>
-  <p>bbb</b></p>
-<blink>&grec;
-<p xmlns:xqp="http://www.w3.org/1998/XML">
- <span xqp:space="preserve">~~~</span>
-</p></blink>
-<html:p xmlns:html="http://...."></p>
-<@/><!--Apple logo in PUA-->
-<!--comment--comment-->
-<!--comment--comment>
-
-<P>]]>
-<P id="7" id="8">M</p>
-<p xmlns:a="urn" xmlns:b="urn"
-   a:id="7" b:id="9">~~~</p>
-<p id="a" idref="a"/>  BE EVIL!
-<extreme sID="a" mood="happy"/>
-<extreme eID="a" mood="sad"/>
-<math><mi>2</mi><msup>3
-  </msup></math>  <title>
-<verse><seg>When,</seg><seg>in</line>
-<line>the beginning</line><line>God created
-the heaven and the earth.</line></verse>
-
-<How/><To/><Markup/><Legibly/>
-<Name Name="Name">Name</Name>
-<list 4 text </p>
-<marquee>foo!</marquee>
-		
\ No newline at end of file