This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 39abde2caa0d0f8b41014abfff906c7fd3bd94b3 Author: Claus Ibsen <[email protected]> AuthorDate: Mon Nov 6 11:14:19 2017 +0100 CAMEL-11959: Polished. --- .../camel-yql/src/main/docs/yql-component.adoc | 72 ++++++++++------------ .../camel/component/yql/YqlComponentTest.java | 5 +- .../camel-yql/src/test/resources/log4j2.properties | 2 +- 3 files changed, 35 insertions(+), 44 deletions(-) diff --git a/components/camel-yql/src/main/docs/yql-component.adoc b/components/camel-yql/src/main/docs/yql-component.adoc index 8319a89..43780f8 100644 --- a/components/camel-yql/src/main/docs/yql-component.adoc +++ b/components/camel-yql/src/main/docs/yql-component.adoc @@ -17,16 +17,15 @@ for this component: </dependency> ------------------------------------------------------------ -### URI format +=== URI format -[source,java] --------------------------------------------- +---- yql://query[?options] --------------------------------------------- +---- Where *query* represents the YQL query. -### Options +=== Options // component options: START The Yahoo Query Language component supports 2 options which are listed below. @@ -69,43 +68,43 @@ with the following path and query parameters: | *diagnostics* (producer) | If true diagnostic information is returned with the response. | false | boolean | *env* (producer) | Allows you to use multiple Open Data Tables through a YQL environment file. More information https://developer.yahoo.com/yql/guide/yql_storage.htmlusing-records-env-files= | | String | *format* (producer) | The expected format. Allowed values: xml or json. | json | String -| *https* (producer) | Option to use HTTPS to communicate with YQL. | true | boolean | *jsonCompat* (producer) | Enables lossless JSON processing. The only allowed value is new. More information https://developer.yahoo.com/yql/guide/response.htmljson-to-json= | | String | *throwExceptionOnFailure* (producer) | Option to disable throwing the YqlHttpException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code. | true | boolean | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean +| *https* (security) | Option to use HTTPS to communicate with YQL. | true | boolean |=== // endpoint options: END -### Exchange data format +=== Exchange data format Camel will deliver the body as a JSON or XML formatted java.lang.String (see the `format` option above). -### Message Headers +=== Message Headers [width="100%",cols="10%,90%",options="header",] -|======================================================================= +|=== |Header |Description |`CamelYqlHttpRequest` | Original HTTP request sent to YQL. |`CamelYqlHttpStatus` | Status code from the response. -|======================================================================= +|=== -### Samples +=== Samples -# Sample 1 +==== Sample 1 In this example we query YQL to obtain the current wind and atmosphere data in Chicago: [source,java] --------------------------------------------------------- +---- from("direct:start") .to("yql://select wind, atmosphere from weather.forecast where woeid in (select woeid from geo.places(1) where text='chicago, il'"); --------------------------------------------------------- +---- Which will setup the body as: [source,json] --------------------------------------------------------- +---- { "query":{ "count":1, @@ -128,31 +127,31 @@ Which will setup the body as: } } } --------------------------------------------------------- +---- and the headers: [width="100%",cols="30%,70%",options="header",] -|======================================================================= +|=== |Header |Value |`CamelYqlHttpRequest` |https://query.yahooapis.com/v1/public/yql?q=select+wind%2C+atmosphere+from+weather.forecast+where+woeid+in+%28select+woeid+from+geo.places%281%29+where+text%3D%22chicago%2C+il%22%29&format=json&callback=&diagnostics=false&debug=false |`CamelYqlHttpStatus` |200 -|======================================================================= +|=== -# Sample 2 +==== Sample 2 In this example we query YQL to obtain the Google quote. [source,java] --------------------------------------------------------- +---- from("direct:start") .to("yql://select symbol, Ask, Bid, AverageDailyVolume from yahoo.finance.quotes where symbol in ('GOOG')?env=store://datatables.org/alltableswithkeys&https=false&callback=yqlCallback"); --------------------------------------------------------- +---- Which will setup the body as: [source,json] --------------------------------------------------------- +---- /**/yqlCallback({ "query":{ "count":1, @@ -168,31 +167,31 @@ Which will setup the body as: } } }); --------------------------------------------------------- +---- and the headers: [width="100%",cols="30%,70%",options="header",] -|======================================================================= +|=== |Header |Value |`CamelYqlHttpRequest` |http://query.yahooapis.com/v1/public/yql?q=select+symbol%2C+Ask%2C+Bid%2C+AverageDailyVolume+from+yahoo.finance.quotes+where+symbol+in+%28%27GOOG%27%29&format=json&callback=yqlCallback&diagnostics=false&debug=false&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys |`CamelYqlHttpStatus` |200 -|======================================================================= +|=== -# Sample 3 +==== Sample 3 In this example we query YQL to obtain one book written by Barack Obama [source,java] --------------------------------------------------------- +---- from("direct:start") .to("yql://select * from google.books where q='barack obama' and maxResults=1?format=xml&crossProduct=optimized&env=store://datatables.org/alltableswithkeys"); --------------------------------------------------------- +---- Which will setup the body as: [source,xml] --------------------------------------------------------- +---- <?xml version="1.0" encoding="UTF-8"?> <query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1" yahoo:created="2017-11-01T20:32:22Z" yahoo:lang="en-US"> <results> @@ -217,22 +216,17 @@ Which will setup the body as: </results> </query> <!-- total: 646 --> --------------------------------------------------------- +---- and the headers: [width="100%",cols="30%,70%",options="header",] -|======================================================================= +|=== |Header |Value |`CamelYqlHttpRequest` |https://query.yahooapis.com/v1/public/yql?q=select+*+from+google.books+where+q%3D%27barack+obama%27+and+maxResults%3D1&format=xml&callback=&crossProduct=optimized&diagnostics=false&debug=false&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys |`CamelYqlHttpStatus` |200 -|======================================================================= - -### See Also +|=== -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] +=== See Also -* https://developer.yahoo.com/yql/guide/[YQL Official Guide] \ No newline at end of file +* https://developer.yahoo.com/yql/guide/[YQL Official Guide] diff --git a/components/camel-yql/src/test/java/org/apache/camel/component/yql/YqlComponentTest.java b/components/camel-yql/src/test/java/org/apache/camel/component/yql/YqlComponentTest.java index 5c959ab..8328aff 100644 --- a/components/camel-yql/src/test/java/org/apache/camel/component/yql/YqlComponentTest.java +++ b/components/camel-yql/src/test/java/org/apache/camel/component/yql/YqlComponentTest.java @@ -25,9 +25,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.text.IsEmptyString.emptyString; - public class YqlComponentTest extends CamelTestSupport { @Rule @@ -89,7 +86,7 @@ public class YqlComponentTest extends CamelTestSupport { assertNotNull(yqlConfiguration); assertEquals("query", yqlConfiguration.getQuery()); assertEquals("json", yqlConfiguration.getFormat()); - assertThat(yqlConfiguration.getCallback(), is(emptyString())); + assertNull(yqlConfiguration.getCallback()); assertNull(yqlConfiguration.getCrossProduct()); assertFalse(yqlConfiguration.isDiagnostics()); assertFalse(yqlConfiguration.isDebug()); diff --git a/components/camel-yql/src/test/resources/log4j2.properties b/components/camel-yql/src/test/resources/log4j2.properties index 25d964b..21c4b43 100644 --- a/components/camel-yql/src/test/resources/log4j2.properties +++ b/components/camel-yql/src/test/resources/log4j2.properties @@ -30,4 +30,4 @@ appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n #logger.camel.level =DEBUG rootLogger.level = INFO -rootLogger.appenderRef.out.ref = out +rootLogger.appenderRef.out.ref = file -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
