You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2017/03/13 09:42:08 UTC

[1/2] camel git commit: CAMEL-10966 Salesforce Maven Plugin doesn't escape strings when doing the camel-salesforce:generate phase

Repository: camel
Updated Branches:
  refs/heads/master efbccd439 -> cccf6726b


CAMEL-10966 Salesforce Maven Plugin doesn't escape strings when doing the camel-salesforce:generate phase


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/91424b88
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/91424b88
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/91424b88

Branch: refs/heads/master
Commit: 91424b883a91eafbfae55ffdd97d45b07623abb2
Parents: efbccd4
Author: Nicolas Cisco <nc...@gmail.com>
Authored: Fri Mar 10 13:17:10 2017 -0300
Committer: Zoran Regvart <zr...@apache.org>
Committed: Mon Mar 13 10:40:38 2017 +0100

----------------------------------------------------------------------
 .../camel-salesforce-maven-plugin/pom.xml       |  11 +-
 .../apache/camel/maven/CamelSalesforceMojo.java |   5 +-
 .../src/main/resources/sobject-picklist.vm      |   2 +-
 .../src/main/resources/sobject-pojo.vm          |   2 +-
 .../maven/CamelSalesforceMojoOutputTest.java    | 147 +++++++++++
 .../src/test/resources/case.json                | 195 ++++++++++++++
 .../resources/complex_calculated_formula.json   |  84 ++++++
 .../src/test/resources/generated/Case.java      | 256 +++++++++++++++++++
 .../generated/Case_PickListAccentMarkEnum.java  |  39 +++
 .../Case_PickListQuotationMarkEnum.java         |  39 +++
 .../generated/Case_PickListSlashEnum.java       |  39 +++
 .../generated/ComplexCalculatedFormula.java     | 141 ++++++++++
 .../resources/generated/QueryRecordsCase.java   |  27 ++
 .../QueryRecordsComplexCalculatedFormula.java   |  27 ++
 14 files changed, 1007 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/pom.xml b/components/camel-salesforce/camel-salesforce-maven-plugin/pom.xml
index 6c10bc4..bf07f3e 100644
--- a/components/camel-salesforce/camel-salesforce-maven-plugin/pom.xml
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/pom.xml
@@ -119,9 +119,9 @@
       <version>${velocity-version}</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity-tools</artifactId>
-      <version>${velocity-tools-version}</version>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>${commons-lang3-version}</version>
     </dependency>
 
     <!-- logging -->
@@ -177,6 +177,11 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
index ee7e1ab..f557a56 100644
--- a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
@@ -63,6 +63,7 @@ import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.jsse.SSLContextParameters;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.log4j.Logger;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -72,7 +73,6 @@ import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.tools.generic.EscapeTool;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.log.Log4JLogChute;
 import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
@@ -585,6 +585,7 @@ public class CamelSalesforceMojo extends AbstractMojo {
             VelocityContext context = new VelocityContext();
             context.put("packageName", packageName);
             context.put("utility", utility);
+            context.put("esc", StringEscapeUtils.class);
             context.put("desc", description);
             context.put("generatedDate", generatedDate);
             context.put("useStringsForPicklists", useStringsForPicklists);
@@ -615,7 +616,7 @@ public class CamelSalesforceMojo extends AbstractMojo {
                     context = new VelocityContext();
                     context.put("packageName", packageName);
                     context.put("utility", utility);
-                    context.put("esc", new EscapeTool());
+                    context.put("esc", StringEscapeUtils.class);
                     context.put("field", field);
                     context.put("enumName", enumName);
                     context.put("generatedDate", generatedDate);

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-picklist.vm
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-picklist.vm b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-picklist.vm
index 22dda10..58bf3e6 100644
--- a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-picklist.vm
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-picklist.vm
@@ -37,7 +37,7 @@ public enum $enumName {
 #foreach ( $entry in $values)
 #set ( $value = $entry.Value )
     // $value
-    $utility.getEnumConstant($value)("$esc.java($value)")#if ( $foreach.hasNext ),#else;#end
+    $utility.getEnumConstant($value)("$esc.escapeJava($value)")#if ( $foreach.hasNext ),#else;#end
 
 #end
 #end

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-pojo.vm
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-pojo.vm b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-pojo.vm
index fd5f133..35b6f4a 100644
--- a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-pojo.vm
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-pojo.vm
@@ -135,7 +135,7 @@ public class $desc.Name extends AbstractDescribedSObjectBase {
 #foreach ( $p in $utility.propertiesOf($obj) )## PROPERTY LOOP
 #if ( $utility.notNull(${p.value}) )## VALUE DEFINED CONDITION
 #if ( ${p.value.class.name} == "java.lang.String" )## STRING CONDITION
-        ${utility.current()}.set${p.key}("${p.value}");
+        ${utility.current()}.set${p.key}("$esc.escapeJava(${p.value})");
 #elseif ( ${utility.isPrimitiveOrBoxed(${p.value})} )## PRIMITIVE OR BOXED CONDITION
         ${utility.current()}.set${p.key}(${p.value});
 #elseif ( ${p.value.class.name} == "java.util.ArrayList" )## LIST CONDITION

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoOutputTest.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoOutputTest.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoOutputTest.java
new file mode 100644
index 0000000..f4d9851
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoOutputTest.java
@@ -0,0 +1,147 @@
+/**
+ * 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.maven;
+
+import java.io.File;
+import java.io.InputStream;
+import java.lang.Exception;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.Before;
+
+import org.apache.maven.plugin.logging.SystemStreamLog;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.camel.component.salesforce.api.utils.JsonUtils;
+import org.apache.camel.component.salesforce.api.dto.SObjectDescription;
+
+import org.apache.log4j.Logger;
+
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.apache.velocity.runtime.log.Log4JLogChute;
+
+import org.apache.commons.io.FileUtils;
+
+//import java.util.Scanner;
+
+public class CamelSalesforceMojoOutputTest {
+    private static final String TEST_CASE_FILE = "case.json";
+    private static final String TEST_CALCULATED_FORMULA_FILE = "complex_calculated_formula.json";
+    private static final String OUTPUT_FOLDER = "target/test-generated-sources";
+    private static final String generatedDate = "Thu Mar 09 16:15:49 ART 2017";
+
+    private CamelSalesforceMojoAccessor mojo;
+    private CamelSalesforceMojo.GeneratorUtility utility;
+    private File pkgDir;
+
+    private static class CamelSalesforceMojoAccessor extends CamelSalesforceMojo {
+        private static final Logger LOG = Logger.getLogger(CamelSalesforceMojoAccessor.class.getName());
+
+        public CamelSalesforceMojoAccessor() throws Exception {
+            // initialize velocity to load resources from class loader and use Log4J
+            Properties velocityProperties = new Properties();
+            velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
+            velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
+            velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
+            velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.logger", LOG.getName());
+
+            VelocityEngine engine = new VelocityEngine(velocityProperties);
+            engine.init();
+
+            Field field = CamelSalesforceMojo.class.getDeclaredField("engine");
+            field.setAccessible(true);
+            field.set(this, engine);
+        }
+
+        // Expose processDescription in order to test it
+        public void processDescription(File pkgDir, SObjectDescription description, GeneratorUtility utility, String generatedDate) throws Exception {
+            Method method = CamelSalesforceMojo.class.getDeclaredMethod("processDescription", File.class, SObjectDescription.class, CamelSalesforceMojo.GeneratorUtility.class, String.class);
+            method.setAccessible(true);
+            method.invoke(this, pkgDir, description, utility, generatedDate);
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        mojo = createMojo();
+
+        pkgDir = new File(OUTPUT_FOLDER);
+        if (!pkgDir.exists()) {
+            if (!pkgDir.mkdirs()) {
+                throw new Exception("Unable to create " + pkgDir);
+            }
+        }
+
+        utility = createGeneratorUtility();
+    }
+
+    @Test
+    public void testProcessDescriptionPickLists() throws Exception {
+        SObjectDescription description = createSObjectDescription(TEST_CASE_FILE);
+
+        mojo.processDescription(pkgDir, description, utility, generatedDate);
+
+        assertClassFile("Case.java");
+        assertClassFile("Case_PickListAccentMarkEnum.java");
+        assertClassFile("Case_PickListQuotationMarkEnum.java");
+        assertClassFile("Case_PickListSlashEnum.java");
+        assertClassFile("QueryRecordsCase.java");
+    }
+
+    @Test
+    public void testProcessDescriptionCalculatedFormula() throws Exception {
+        SObjectDescription description = createSObjectDescription(TEST_CALCULATED_FORMULA_FILE);
+
+        mojo.processDescription(pkgDir, description, utility, generatedDate);
+
+        assertClassFile("ComplexCalculatedFormula.java");
+        assertClassFile("QueryRecordsComplexCalculatedFormula.java");
+    }
+
+    public void assertClassFile(String name) throws Exception {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        Assert.assertTrue("Class "+name+" must be equal to the target one", FileUtils.contentEquals(new File(OUTPUT_FOLDER, name), FileUtils.toFile(classLoader.getResource("generated/"+name))));
+    }
+
+    protected CamelSalesforceMojo.GeneratorUtility createGeneratorUtility() {
+        return new CamelSalesforceMojo.GeneratorUtility(false);
+    }
+
+    protected SObjectDescription createSObjectDescription(String name) throws Exception {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        InputStream inputStream = classLoader.getResourceAsStream(name);
+        ObjectMapper mapper = JsonUtils.createObjectMapper();
+        SObjectDescription description = mapper.readValue(inputStream, SObjectDescription.class);
+        if (description == null)
+            throw new Exception("Couldn't Read description from file");
+
+        return description;
+    }
+
+    protected CamelSalesforceMojoAccessor createMojo() throws Exception {
+        CamelSalesforceMojoAccessor mojo = new CamelSalesforceMojoAccessor();
+        mojo.setLog(new SystemStreamLog());
+        return mojo;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/case.json
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/case.json b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/case.json
new file mode 100644
index 0000000..938744f
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/case.json
@@ -0,0 +1,195 @@
+{
+    "name": "Case",
+    "label": "Caso",
+    "updatable": true,
+    "keyPrefix": "500",
+    "custom": false,
+    "urls": {
+        "sobject": "/services/data/v34.0/sobjects/Case",
+        "describe": "/services/data/v34.0/sobjects/Case/describe",
+        "rowTemplate": "/services/data/v34.0/sobjects/Case/{ID}",
+        "approvalLayouts": "/services/data/v34.0/sobjects/Case/describe/approvalLayouts",
+        "quickActions": "/services/data/v34.0/sobjects/Case/quickActions",
+        "caseArticleSuggestions": "/services/data/v34.0/sobjects/Case/suggestedArticles",
+        "listviews": "/services/data/v34.0/sobjects/Case/listviews",
+        "layouts": "/services/data/v34.0/sobjects/Case/describe/layouts",
+        "compactLayouts": "/services/data/v34.0/sobjects/Case/describe/compactLayouts",
+        "caseRowArticleSuggestions": "/services/data/v34.0/sobjects/Case/{ID}/suggestedArticles",
+        "uiEditTemplate": "https://salesforce-host/{ID}/e",
+        "uiDetailTemplate": "https://salesforce-host/{ID}",
+        "uiNewRecord":"https://salesforce-host/500/e"
+    },
+    "searchable": true,
+    "labelPlural": "Casos",
+    "layoutable": true,
+    "activateable": false,
+    "createable": true,
+    "deprecatedAndHidden": false,
+    "deletable": true,
+    "customSetting": false,
+    "feedEnabled": true,
+    "mergeable": false,
+    "queryable": true,
+    "replicateable": true,
+    "retrieveable": true,
+    "searchLayoutable": "true",
+    "undeletable": true,
+    "triggerable": true,
+    "compactLayoutable": true,
+    "actionOverrides": [],
+    "fields": [
+        {
+            "length": 40,
+            "name": "PickListAccentMark",
+            "type": "picklist",
+            "label": "Accent Mark",
+            "updateable": true,
+            "calculated": false,
+            "caseSensitive": false,
+            "unique": false,
+            "nillable": true,
+            "precision": 0,
+            "scale": 0,
+            "byteLength": 120,
+            "nameField": false,
+            "sortable": true,
+            "filterable": true,
+            "writeRequiresMasterRead": false,
+            "externalId": false,
+            "idLookup": false,
+            "inlineHelpText": "This is a picklist accent mark test \u00f3",
+            "createable": true,
+            "soapType": "xsd:string",
+            "autoNumber": false,
+            "restrictedPicklist": false,
+            "namePointing": false,
+            "custom": false,
+            "defaultedOnCreate": false,
+            "deprecatedAndHidden": false,
+            "htmlFormatted": false,
+            "picklistValues": [
+                {
+                    "value": "Audiencia de Conciliaci\u00f3n",
+                    "label": "Audiencia de Conciliaci\u00f3n",
+                    "active": true,
+                    "defaultValue": false
+                }
+            ],
+            "dependentPicklist": false,
+            "referenceTo": [
+
+            ],
+            "cascadeDelete": false,
+            "restrictedDelete": false,
+            "digits": "0",
+            "groupable": true,
+            "permissionable": true,
+            "displayLocationInDecimal": false,
+            "highScaleNumber": false,
+            "queryByDistance": false,
+            "encrypted": false
+        },
+        {
+            "length": 255,
+            "name": "PickListSlash",
+            "type": "picklist",
+            "label": "Slash",
+            "updateable": true,
+            "calculated": false,
+            "caseSensitive": false,
+            "unique": false,
+            "nillable": true,
+            "precision": 0,
+            "scale": 0,
+            "byteLength": 765,
+            "nameField": false,
+            "sortable": true,
+            "filterable": true,
+            "writeRequiresMasterRead": false,
+            "externalId": false,
+            "idLookup": false,
+            "inlineHelpText": "This is a picklist slash test /",
+            "createable": true,
+            "soapType": "xsd:string",
+            "autoNumber": false,
+            "restrictedPicklist": false,
+            "namePointing": false,
+            "custom": true,
+            "defaultedOnCreate": false,
+            "deprecatedAndHidden": false,
+            "htmlFormatted": false,
+            "picklistValues": [
+                {
+                    "value": "Acciones relacionadas con cotizaciones y\/o avisos de entrega",
+                    "label": "Acciones relacionadas con cotizaciones y\/o avisos de entrega",
+                    "active": true,
+                    "defaultValue": false
+                }
+            ],
+            "dependentPicklist": false,
+            "referenceTo": [
+
+            ],
+            "cascadeDelete": false,
+            "restrictedDelete": false,
+            "digits": "0",
+            "groupable": true,
+            "permissionable": true,
+            "displayLocationInDecimal": false,
+            "highScaleNumber": false,
+            "queryByDistance": false,
+            "encrypted": false
+        },
+        {
+            "length": 255,
+            "name": "PickListQuotationMark",
+            "type": "picklist",
+            "label": "QuotationMark",
+            "updateable": true,
+            "calculated": false,
+            "caseSensitive": false,
+            "unique": false,
+            "nillable": true,
+            "precision": 0,
+            "scale": 0,
+            "byteLength": 765,
+            "nameField": false,
+            "sortable": true,
+            "filterable": true,
+            "writeRequiresMasterRead": false,
+            "externalId": false,
+            "idLookup": false,
+            "inlineHelpText": "This is a picklist quotation mark test \"",
+            "createable": true,
+            "soapType": "xsd:string",
+            "autoNumber": false,
+            "restrictedPicklist": false,
+            "namePointing": false,
+            "custom": true,
+            "defaultedOnCreate": false,
+            "deprecatedAndHidden": false,
+            "htmlFormatted": false,
+            "picklistValues": [
+                {
+                    "value": "No apretar \"miralo\"",
+                    "label": "No apretar \"miralo\"",
+                    "active": true,
+                    "defaultValue": false
+                }
+            ],
+            "dependentPicklist": false,
+            "referenceTo": [
+
+            ],
+            "cascadeDelete": false,
+            "restrictedDelete": false,
+            "digits": "0",
+            "groupable": true,
+            "permissionable": true,
+            "displayLocationInDecimal": false,
+            "highScaleNumber": false,
+            "queryByDistance": false,
+            "encrypted": false
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/complex_calculated_formula.json
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/complex_calculated_formula.json b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/complex_calculated_formula.json
new file mode 100644
index 0000000..36c645e
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/complex_calculated_formula.json
@@ -0,0 +1,84 @@
+{
+    "name": "ComplexCalculatedFormula",
+    "label": "Complex Calculated Formula",
+    "updatable": true,
+    "keyPrefix": "500",
+    "custom": false,
+    "urls": {
+        "sobject": "/services/data/v34.0/sobjects/Case",
+        "describe": "/services/data/v34.0/sobjects/Case/describe",
+        "rowTemplate": "/services/data/v34.0/sobjects/Case/{ID}",
+        "approvalLayouts": "/services/data/v34.0/sobjects/Case/describe/approvalLayouts",
+        "quickActions": "/services/data/v34.0/sobjects/Case/quickActions",
+        "caseArticleSuggestions": "/services/data/v34.0/sobjects/Case/suggestedArticles",
+        "listviews": "/services/data/v34.0/sobjects/Case/listviews",
+        "layouts": "/services/data/v34.0/sobjects/Case/describe/layouts",
+        "compactLayouts": "/services/data/v34.0/sobjects/Case/describe/compactLayouts",
+        "caseRowArticleSuggestions": "/services/data/v34.0/sobjects/Case/{ID}/suggestedArticles",
+        "uiEditTemplate": "https://salesforce-host/{ID}/e",
+        "uiDetailTemplate": "https://salesforce-host/{ID}",
+        "uiNewRecord":"https://salesforce-host/500/e"
+    },
+    "searchable": true,
+    "labelPlural": "ComplexCalculatedFormulas",
+    "layoutable": true,
+    "activateable": false,
+    "createable": true,
+    "deprecatedAndHidden": false,
+    "deletable": true,
+    "customSetting": false,
+    "feedEnabled": true,
+    "mergeable": false,
+    "queryable": true,
+    "replicateable": true,
+    "retrieveable": true,
+    "searchLayoutable": "true",
+    "undeletable": true,
+    "triggerable": true,
+    "compactLayoutable": true,
+    "actionOverrides": [],
+    "fields": [
+        {
+            "length": 1300,
+            "name": "ComplexCalculatedFormula",
+            "type": "string",
+            "label": "A complex calculated formula",
+            "updateable": false,
+            "calculated": true,
+            "caseSensitive": false,
+            "unique": false,
+            "nillable": true,
+            "precision": 0,
+            "scale": 0,
+            "byteLength": 3900,
+            "nameField": false,
+            "sortable": true,
+            "filterable": true,
+            "writeRequiresMasterRead": false,
+            "externalId": false,
+            "idLookup": false,
+            "createable": false,
+            "soapType": "xsd:string",
+            "autoNumber": false,
+            "restrictedPicklist": false,
+            "namePointing": false,
+            "custom": true,
+            "defaultedOnCreate": false,
+            "deprecatedAndHidden": false,
+            "htmlFormatted": true,
+            "calculatedFormula":"IF( RecordType.Id  = \"012F0000000rmbC\", \r\n\r\nIF(Case_Age__c > 30, \r\nIMAGE(\"/img/samples/color_red.gif\", \"red\", 30, 30),\r\nIF( Case_Age__c > 15,\r\nIMAGE(\"/img/samples/color_yellow.gif\", \"yellow\", 30, 30),\r\nIMAGE(\"/img/samples/color_green.gif\", \"green\", 30, 30)\r\n)),\r\n\r\n\r\nIF(Case_Age__c > 10, \r\nIMAGE(\"/img/samples/color_red.gif\", \"red\", 30, 30),\r\nIF( Case_Age__c > 5,\r\nIMAGE(\"/img/samples/color_yellow.gif\", \"yellow\", 30, 30),\r\nIMAGE(\"/img/samples/color_green.gif\", \"green\", 30, 30)\r\n))\r\n)",
+            "picklistValues": [],
+            "dependentPicklist":false,
+            "referenceTo": [],
+            "cascadeDelete": false,
+            "restrictedDelete": false,
+            "digits": "0",
+            "groupable": false,
+            "permissionable": true,
+            "displayLocationInDecimal": false,
+            "highScaleNumber": false,
+            "queryByDistance": false,
+            "encrypted": false
+         }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case.java
new file mode 100644
index 0000000..df282c3
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case.java
@@ -0,0 +1,256 @@
+/*
+ * Salesforce DTO generated by camel-salesforce-maven-plugin
+ * Generated on: Thu Mar 09 16:15:49 ART 2017
+ */
+package $packageName;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.thoughtworks.xstream.annotations.XStreamAlias;
+import com.thoughtworks.xstream.annotations.XStreamConverter;
+
+import org.apache.camel.component.salesforce.api.PicklistEnumConverter;
+import org.apache.camel.component.salesforce.api.dto.AbstractDescribedSObjectBase;
+import org.apache.camel.component.salesforce.api.dto.ChildRelationShip;
+import org.apache.camel.component.salesforce.api.dto.InfoUrls;
+import org.apache.camel.component.salesforce.api.dto.NamedLayoutInfo;
+import org.apache.camel.component.salesforce.api.dto.RecordTypeInfo;
+import org.apache.camel.component.salesforce.api.dto.SObjectDescription;
+import org.apache.camel.component.salesforce.api.dto.SObjectDescriptionUrls;
+import org.apache.camel.component.salesforce.api.dto.SObjectField;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Salesforce DTO for SObject Case
+ */
+@XStreamAlias("Case")
+public class Case extends AbstractDescribedSObjectBase {
+
+    private static final SObjectDescription DESCRIPTION = createSObjectDescription();
+
+    // PickListAccentMark
+    @XStreamConverter(PicklistEnumConverter.class)
+    private Case_PickListAccentMarkEnum PickListAccentMark;
+
+    @JsonProperty("PickListAccentMark")
+    public Case_PickListAccentMarkEnum getPickListAccentMark() {
+        return this.PickListAccentMark;
+    }
+
+    @JsonProperty("PickListAccentMark")
+    public void setPickListAccentMark(Case_PickListAccentMarkEnum PickListAccentMark) {
+        this.PickListAccentMark = PickListAccentMark;
+    }
+
+    // PickListSlash
+    @XStreamConverter(PicklistEnumConverter.class)
+    private Case_PickListSlashEnum PickListSlash;
+
+    @JsonProperty("PickListSlash")
+    public Case_PickListSlashEnum getPickListSlash() {
+        return this.PickListSlash;
+    }
+
+    @JsonProperty("PickListSlash")
+    public void setPickListSlash(Case_PickListSlashEnum PickListSlash) {
+        this.PickListSlash = PickListSlash;
+    }
+
+    // PickListQuotationMark
+    @XStreamConverter(PicklistEnumConverter.class)
+    private Case_PickListQuotationMarkEnum PickListQuotationMark;
+
+    @JsonProperty("PickListQuotationMark")
+    public Case_PickListQuotationMarkEnum getPickListQuotationMark() {
+        return this.PickListQuotationMark;
+    }
+
+    @JsonProperty("PickListQuotationMark")
+    public void setPickListQuotationMark(Case_PickListQuotationMarkEnum PickListQuotationMark) {
+        this.PickListQuotationMark = PickListQuotationMark;
+    }
+
+
+    @Override
+    public final SObjectDescription description() {
+        return DESCRIPTION;
+    }
+
+    private static SObjectDescription createSObjectDescription() {
+        final SObjectDescription description = new SObjectDescription();
+
+
+        description.setMergeable(false);
+        description.setUndeletable(true);
+        description.setCreateable(true);
+        description.setSearchLayoutable("true");
+        description.setQueryable(true);
+        description.setLabel("Caso");
+        description.setTriggerable(true);
+        description.setReplicateable(true);
+        description.setCustom(false);
+
+        final SObjectDescriptionUrls sObjectDescriptionUrls1 = new SObjectDescriptionUrls();
+        sObjectDescriptionUrls1.setDescribe("/services/data/v34.0/sobjects/Case/describe");
+        sObjectDescriptionUrls1.setCaseArticleSuggestions("/services/data/v34.0/sobjects/Case/suggestedArticles");
+        sObjectDescriptionUrls1.setLayouts("/services/data/v34.0/sobjects/Case/describe/layouts");
+        sObjectDescriptionUrls1.setSobject("/services/data/v34.0/sobjects/Case");
+        sObjectDescriptionUrls1.setUiEditTemplate("https://salesforce-host/{ID}/e");
+        sObjectDescriptionUrls1.setQuickActions("/services/data/v34.0/sobjects/Case/quickActions");
+        sObjectDescriptionUrls1.setCaseRowArticleSuggestions("/services/data/v34.0/sobjects/Case/{ID}/suggestedArticles");
+        sObjectDescriptionUrls1.setRowTemplate("/services/data/v34.0/sobjects/Case/{ID}");
+        sObjectDescriptionUrls1.setListviews("/services/data/v34.0/sobjects/Case/listviews");
+        sObjectDescriptionUrls1.setCompactLayouts("/services/data/v34.0/sobjects/Case/describe/compactLayouts");
+        sObjectDescriptionUrls1.setApprovalLayouts("/services/data/v34.0/sobjects/Case/describe/approvalLayouts");
+        sObjectDescriptionUrls1.setUiNewRecord("https://salesforce-host/500/e");
+        sObjectDescriptionUrls1.setUiDetailTemplate("https://salesforce-host/{ID}");
+        description.setUrls(sObjectDescriptionUrls1);
+        description.setName("Case");
+        description.setLayoutable(true);
+        description.setCompactLayoutable(true);
+        description.setDeprecatedAndHidden(false);
+
+        final List<SObjectField> fields1 = new ArrayList<>();
+        description.setFields(fields1);
+
+        final SObjectField sObjectField1 = new SObjectField();
+        fields1.add(sObjectField1);
+
+        sObjectField1.setWriteRequiresMasterRead(false);
+        sObjectField1.setNillable(true);
+        sObjectField1.setCreateable(true);
+        sObjectField1.setEncrypted(false);
+        sObjectField1.setDigits("0");
+        sObjectField1.setDependentPicklist(false);
+        sObjectField1.setInlineHelpText("This is a picklist accent mark test \u00F3");
+        sObjectField1.setLabel("Accent Mark");
+        sObjectField1.setHighScaleNumber(false);
+        sObjectField1.setDisplayLocationInDecimal(false);
+        sObjectField1.setName("PickListAccentMark");
+        sObjectField1.setHtmlFormatted(false);
+        sObjectField1.setDeprecatedAndHidden(false);
+        sObjectField1.setRestrictedPicklist(false);
+        sObjectField1.setNameField(false);
+        sObjectField1.setCaseSensitive(false);
+        sObjectField1.setPermissionable(true);
+        sObjectField1.setCascadeDelete(false);
+        sObjectField1.setDefaultedOnCreate(false);
+        sObjectField1.setExternalId(false);
+        sObjectField1.setSoapType("xsd:string");
+        sObjectField1.setGroupable(true);
+        sObjectField1.setCustom(false);
+        sObjectField1.setScale(0);
+        sObjectField1.setCalculated(false);
+        sObjectField1.setRestrictedDelete(false);
+        sObjectField1.setNamePointing(false);
+        sObjectField1.setIdLookup(false);
+        sObjectField1.setType("picklist");
+        sObjectField1.setSortable(true);
+        sObjectField1.setLength(40);
+        sObjectField1.setPrecision(0);
+        sObjectField1.setByteLength(120);
+        sObjectField1.setQueryByDistance(false);
+        sObjectField1.setFilterable(true);
+        sObjectField1.setUpdateable(true);
+        sObjectField1.setUnique(false);
+        sObjectField1.setAutoNumber(false);
+
+        final SObjectField sObjectField2 = new SObjectField();
+        fields1.add(sObjectField2);
+
+        sObjectField2.setWriteRequiresMasterRead(false);
+        sObjectField2.setNillable(true);
+        sObjectField2.setCreateable(true);
+        sObjectField2.setEncrypted(false);
+        sObjectField2.setDigits("0");
+        sObjectField2.setDependentPicklist(false);
+        sObjectField2.setInlineHelpText("This is a picklist slash test /");
+        sObjectField2.setLabel("Slash");
+        sObjectField2.setHighScaleNumber(false);
+        sObjectField2.setDisplayLocationInDecimal(false);
+        sObjectField2.setName("PickListSlash");
+        sObjectField2.setHtmlFormatted(false);
+        sObjectField2.setDeprecatedAndHidden(false);
+        sObjectField2.setRestrictedPicklist(false);
+        sObjectField2.setNameField(false);
+        sObjectField2.setCaseSensitive(false);
+        sObjectField2.setPermissionable(true);
+        sObjectField2.setCascadeDelete(false);
+        sObjectField2.setDefaultedOnCreate(false);
+        sObjectField2.setExternalId(false);
+        sObjectField2.setSoapType("xsd:string");
+        sObjectField2.setGroupable(true);
+        sObjectField2.setCustom(true);
+        sObjectField2.setScale(0);
+        sObjectField2.setCalculated(false);
+        sObjectField2.setRestrictedDelete(false);
+        sObjectField2.setNamePointing(false);
+        sObjectField2.setIdLookup(false);
+        sObjectField2.setType("picklist");
+        sObjectField2.setSortable(true);
+        sObjectField2.setLength(255);
+        sObjectField2.setPrecision(0);
+        sObjectField2.setByteLength(765);
+        sObjectField2.setQueryByDistance(false);
+        sObjectField2.setFilterable(true);
+        sObjectField2.setUpdateable(true);
+        sObjectField2.setUnique(false);
+        sObjectField2.setAutoNumber(false);
+
+        final SObjectField sObjectField3 = new SObjectField();
+        fields1.add(sObjectField3);
+
+        sObjectField3.setWriteRequiresMasterRead(false);
+        sObjectField3.setNillable(true);
+        sObjectField3.setCreateable(true);
+        sObjectField3.setEncrypted(false);
+        sObjectField3.setDigits("0");
+        sObjectField3.setDependentPicklist(false);
+        sObjectField3.setInlineHelpText("This is a picklist quotation mark test \"");
+        sObjectField3.setLabel("QuotationMark");
+        sObjectField3.setHighScaleNumber(false);
+        sObjectField3.setDisplayLocationInDecimal(false);
+        sObjectField3.setName("PickListQuotationMark");
+        sObjectField3.setHtmlFormatted(false);
+        sObjectField3.setDeprecatedAndHidden(false);
+        sObjectField3.setRestrictedPicklist(false);
+        sObjectField3.setNameField(false);
+        sObjectField3.setCaseSensitive(false);
+        sObjectField3.setPermissionable(true);
+        sObjectField3.setCascadeDelete(false);
+        sObjectField3.setDefaultedOnCreate(false);
+        sObjectField3.setExternalId(false);
+        sObjectField3.setSoapType("xsd:string");
+        sObjectField3.setGroupable(true);
+        sObjectField3.setCustom(true);
+        sObjectField3.setScale(0);
+        sObjectField3.setCalculated(false);
+        sObjectField3.setRestrictedDelete(false);
+        sObjectField3.setNamePointing(false);
+        sObjectField3.setIdLookup(false);
+        sObjectField3.setType("picklist");
+        sObjectField3.setSortable(true);
+        sObjectField3.setLength(255);
+        sObjectField3.setPrecision(0);
+        sObjectField3.setByteLength(765);
+        sObjectField3.setQueryByDistance(false);
+        sObjectField3.setFilterable(true);
+        sObjectField3.setUpdateable(true);
+        sObjectField3.setUnique(false);
+        sObjectField3.setAutoNumber(false);
+
+
+        description.setActivateable(false);
+        description.setLabelPlural("Casos");
+        description.setDeletable(true);
+        description.setFeedEnabled(true);
+        description.setSearchable(true);
+        description.setCustomSetting(false);
+        description.setRetrieveable(true);
+        description.setKeyPrefix("500");
+
+        return description;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListAccentMarkEnum.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListAccentMarkEnum.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListAccentMarkEnum.java
new file mode 100644
index 0000000..915d143
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListAccentMarkEnum.java
@@ -0,0 +1,39 @@
+/*
+ * Salesforce DTO generated by camel-salesforce-maven-plugin
+ * Generated on: Thu Mar 09 16:15:49 ART 2017
+ */
+package $packageName;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Salesforce Enumeration DTO for picklist PickListAccentMark
+ */
+public enum Case_PickListAccentMarkEnum {
+
+    // Audiencia de Conciliaci�n
+    AUDIENCIA_DE_CONCILIACI�N("Audiencia de Conciliaci\u00F3n");
+
+    final String value;
+
+    private Case_PickListAccentMarkEnum(String value) {
+        this.value = value;
+    }
+
+    @JsonValue
+    public String value() {
+        return this.value;
+    }
+
+    @JsonCreator
+    public static Case_PickListAccentMarkEnum fromValue(String value) {
+        for (Case_PickListAccentMarkEnum e : Case_PickListAccentMarkEnum.values()) {
+            if (e.value.equals(value)) {
+                return e;
+            }
+        }
+        throw new IllegalArgumentException(value);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListQuotationMarkEnum.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListQuotationMarkEnum.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListQuotationMarkEnum.java
new file mode 100644
index 0000000..3f55dd2
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListQuotationMarkEnum.java
@@ -0,0 +1,39 @@
+/*
+ * Salesforce DTO generated by camel-salesforce-maven-plugin
+ * Generated on: Thu Mar 09 16:15:49 ART 2017
+ */
+package $packageName;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Salesforce Enumeration DTO for picklist PickListQuotationMark
+ */
+public enum Case_PickListQuotationMarkEnum {
+
+    // No apretar "miralo"
+    NO_APRETAR__MIRALO_("No apretar \"miralo\"");
+
+    final String value;
+
+    private Case_PickListQuotationMarkEnum(String value) {
+        this.value = value;
+    }
+
+    @JsonValue
+    public String value() {
+        return this.value;
+    }
+
+    @JsonCreator
+    public static Case_PickListQuotationMarkEnum fromValue(String value) {
+        for (Case_PickListQuotationMarkEnum e : Case_PickListQuotationMarkEnum.values()) {
+            if (e.value.equals(value)) {
+                return e;
+            }
+        }
+        throw new IllegalArgumentException(value);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListSlashEnum.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListSlashEnum.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListSlashEnum.java
new file mode 100644
index 0000000..fca520a
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/Case_PickListSlashEnum.java
@@ -0,0 +1,39 @@
+/*
+ * Salesforce DTO generated by camel-salesforce-maven-plugin
+ * Generated on: Thu Mar 09 16:15:49 ART 2017
+ */
+package $packageName;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Salesforce Enumeration DTO for picklist PickListSlash
+ */
+public enum Case_PickListSlashEnum {
+
+    // Acciones relacionadas con cotizaciones y/o avisos de entrega
+    ACCIONES_RELACIONADAS_CON_COTIZACIONES_Y_O_AVISOS_DE_ENTREGA("Acciones relacionadas con cotizaciones y/o avisos de entrega");
+
+    final String value;
+
+    private Case_PickListSlashEnum(String value) {
+        this.value = value;
+    }
+
+    @JsonValue
+    public String value() {
+        return this.value;
+    }
+
+    @JsonCreator
+    public static Case_PickListSlashEnum fromValue(String value) {
+        for (Case_PickListSlashEnum e : Case_PickListSlashEnum.values()) {
+            if (e.value.equals(value)) {
+                return e;
+            }
+        }
+        throw new IllegalArgumentException(value);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/ComplexCalculatedFormula.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/ComplexCalculatedFormula.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/ComplexCalculatedFormula.java
new file mode 100644
index 0000000..3eeaef1
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/ComplexCalculatedFormula.java
@@ -0,0 +1,141 @@
+/*
+ * Salesforce DTO generated by camel-salesforce-maven-plugin
+ * Generated on: Thu Mar 09 16:15:49 ART 2017
+ */
+package $packageName;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.thoughtworks.xstream.annotations.XStreamAlias;
+
+import org.apache.camel.component.salesforce.api.dto.AbstractDescribedSObjectBase;
+import org.apache.camel.component.salesforce.api.dto.ChildRelationShip;
+import org.apache.camel.component.salesforce.api.dto.InfoUrls;
+import org.apache.camel.component.salesforce.api.dto.NamedLayoutInfo;
+import org.apache.camel.component.salesforce.api.dto.RecordTypeInfo;
+import org.apache.camel.component.salesforce.api.dto.SObjectDescription;
+import org.apache.camel.component.salesforce.api.dto.SObjectDescriptionUrls;
+import org.apache.camel.component.salesforce.api.dto.SObjectField;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Salesforce DTO for SObject ComplexCalculatedFormula
+ */
+@XStreamAlias("ComplexCalculatedFormula")
+public class ComplexCalculatedFormula extends AbstractDescribedSObjectBase {
+
+    private static final SObjectDescription DESCRIPTION = createSObjectDescription();
+
+    // ComplexCalculatedFormula
+    private String ComplexCalculatedFormula;
+
+    @JsonProperty("ComplexCalculatedFormula")
+    public String getComplexCalculatedFormula() {
+        return this.ComplexCalculatedFormula;
+    }
+
+    @JsonProperty("ComplexCalculatedFormula")
+    public void setComplexCalculatedFormula(String ComplexCalculatedFormula) {
+        this.ComplexCalculatedFormula = ComplexCalculatedFormula;
+    }
+
+
+    @Override
+    public final SObjectDescription description() {
+        return DESCRIPTION;
+    }
+
+    private static SObjectDescription createSObjectDescription() {
+        final SObjectDescription description = new SObjectDescription();
+
+
+        description.setMergeable(false);
+        description.setUndeletable(true);
+        description.setCreateable(true);
+        description.setSearchLayoutable("true");
+        description.setQueryable(true);
+        description.setLabel("Complex Calculated Formula");
+        description.setTriggerable(true);
+        description.setReplicateable(true);
+        description.setCustom(false);
+
+        final SObjectDescriptionUrls sObjectDescriptionUrls1 = new SObjectDescriptionUrls();
+        sObjectDescriptionUrls1.setDescribe("/services/data/v34.0/sobjects/Case/describe");
+        sObjectDescriptionUrls1.setCaseArticleSuggestions("/services/data/v34.0/sobjects/Case/suggestedArticles");
+        sObjectDescriptionUrls1.setLayouts("/services/data/v34.0/sobjects/Case/describe/layouts");
+        sObjectDescriptionUrls1.setSobject("/services/data/v34.0/sobjects/Case");
+        sObjectDescriptionUrls1.setUiEditTemplate("https://salesforce-host/{ID}/e");
+        sObjectDescriptionUrls1.setQuickActions("/services/data/v34.0/sobjects/Case/quickActions");
+        sObjectDescriptionUrls1.setCaseRowArticleSuggestions("/services/data/v34.0/sobjects/Case/{ID}/suggestedArticles");
+        sObjectDescriptionUrls1.setRowTemplate("/services/data/v34.0/sobjects/Case/{ID}");
+        sObjectDescriptionUrls1.setListviews("/services/data/v34.0/sobjects/Case/listviews");
+        sObjectDescriptionUrls1.setCompactLayouts("/services/data/v34.0/sobjects/Case/describe/compactLayouts");
+        sObjectDescriptionUrls1.setApprovalLayouts("/services/data/v34.0/sobjects/Case/describe/approvalLayouts");
+        sObjectDescriptionUrls1.setUiNewRecord("https://salesforce-host/500/e");
+        sObjectDescriptionUrls1.setUiDetailTemplate("https://salesforce-host/{ID}");
+        description.setUrls(sObjectDescriptionUrls1);
+        description.setName("ComplexCalculatedFormula");
+        description.setLayoutable(true);
+        description.setCompactLayoutable(true);
+        description.setDeprecatedAndHidden(false);
+
+        final List<SObjectField> fields1 = new ArrayList<>();
+        description.setFields(fields1);
+
+        final SObjectField sObjectField1 = new SObjectField();
+        fields1.add(sObjectField1);
+
+        sObjectField1.setWriteRequiresMasterRead(false);
+        sObjectField1.setNillable(true);
+        sObjectField1.setCreateable(false);
+        sObjectField1.setEncrypted(false);
+        sObjectField1.setDigits("0");
+        sObjectField1.setDependentPicklist(false);
+        sObjectField1.setLabel("A complex calculated formula");
+        sObjectField1.setHighScaleNumber(false);
+        sObjectField1.setDisplayLocationInDecimal(false);
+        sObjectField1.setName("ComplexCalculatedFormula");
+        sObjectField1.setHtmlFormatted(true);
+        sObjectField1.setDeprecatedAndHidden(false);
+        sObjectField1.setRestrictedPicklist(false);
+        sObjectField1.setNameField(false);
+        sObjectField1.setCaseSensitive(false);
+        sObjectField1.setPermissionable(true);
+        sObjectField1.setCascadeDelete(false);
+        sObjectField1.setDefaultedOnCreate(false);
+        sObjectField1.setExternalId(false);
+        sObjectField1.setSoapType("xsd:string");
+        sObjectField1.setGroupable(false);
+        sObjectField1.setCustom(true);
+        sObjectField1.setScale(0);
+        sObjectField1.setCalculated(true);
+        sObjectField1.setRestrictedDelete(false);
+        sObjectField1.setNamePointing(false);
+        sObjectField1.setIdLookup(false);
+        sObjectField1.setType("string");
+        sObjectField1.setSortable(true);
+        sObjectField1.setLength(1300);
+        sObjectField1.setPrecision(0);
+        sObjectField1.setByteLength(3900);
+        sObjectField1.setQueryByDistance(false);
+        sObjectField1.setFilterable(true);
+        sObjectField1.setCalculatedFormula("IF( RecordType.Id  = \"012F0000000rmbC\", \r\n\r\nIF(Case_Age__c > 30, \r\nIMAGE(\"/img/samples/color_red.gif\", \"red\", 30, 30),\r\nIF( Case_Age__c > 15,\r\nIMAGE(\"/img/samples/color_yellow.gif\", \"yellow\", 30, 30),\r\nIMAGE(\"/img/samples/color_green.gif\", \"green\", 30, 30)\r\n)),\r\n\r\n\r\nIF(Case_Age__c > 10, \r\nIMAGE(\"/img/samples/color_red.gif\", \"red\", 30, 30),\r\nIF( Case_Age__c > 5,\r\nIMAGE(\"/img/samples/color_yellow.gif\", \"yellow\", 30, 30),\r\nIMAGE(\"/img/samples/color_green.gif\", \"green\", 30, 30)\r\n))\r\n)");
+        sObjectField1.setUpdateable(false);
+        sObjectField1.setUnique(false);
+        sObjectField1.setAutoNumber(false);
+
+
+        description.setActivateable(false);
+        description.setLabelPlural("ComplexCalculatedFormulas");
+        description.setDeletable(true);
+        description.setFeedEnabled(true);
+        description.setSearchable(true);
+        description.setCustomSetting(false);
+        description.setRetrieveable(true);
+        description.setKeyPrefix("500");
+
+        return description;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/QueryRecordsCase.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/QueryRecordsCase.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/QueryRecordsCase.java
new file mode 100644
index 0000000..a644a31
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/QueryRecordsCase.java
@@ -0,0 +1,27 @@
+/*
+ * Salesforce Query DTO generated by camel-salesforce-maven-plugin
+ * Generated on: Thu Mar 09 16:15:49 ART 2017
+ */
+package $packageName;
+
+import com.thoughtworks.xstream.annotations.XStreamImplicit;
+import org.apache.camel.component.salesforce.api.dto.AbstractQueryRecordsBase;
+
+import java.util.List;
+
+/**
+ * Salesforce QueryRecords DTO for type Case
+ */
+public class QueryRecordsCase extends AbstractQueryRecordsBase {
+
+    @XStreamImplicit
+    private List<Case> records;
+
+    public List<Case> getRecords() {
+        return records;
+    }
+
+    public void setRecords(List<Case> records) {
+        this.records = records;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91424b88/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/QueryRecordsComplexCalculatedFormula.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/QueryRecordsComplexCalculatedFormula.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/QueryRecordsComplexCalculatedFormula.java
new file mode 100644
index 0000000..279373b
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/resources/generated/QueryRecordsComplexCalculatedFormula.java
@@ -0,0 +1,27 @@
+/*
+ * Salesforce Query DTO generated by camel-salesforce-maven-plugin
+ * Generated on: Thu Mar 09 16:15:49 ART 2017
+ */
+package $packageName;
+
+import com.thoughtworks.xstream.annotations.XStreamImplicit;
+import org.apache.camel.component.salesforce.api.dto.AbstractQueryRecordsBase;
+
+import java.util.List;
+
+/**
+ * Salesforce QueryRecords DTO for type ComplexCalculatedFormula
+ */
+public class QueryRecordsComplexCalculatedFormula extends AbstractQueryRecordsBase {
+
+    @XStreamImplicit
+    private List<ComplexCalculatedFormula> records;
+
+    public List<ComplexCalculatedFormula> getRecords() {
+        return records;
+    }
+
+    public void setRecords(List<ComplexCalculatedFormula> records) {
+        this.records = records;
+    }
+}


[2/2] camel git commit: CAMEL-10966 Salesforce Maven Plugin doesn't esc...

Posted by zr...@apache.org.
CAMEL-10966 Salesforce Maven Plugin doesn't esc...

...ape strings when doing the camel-salesforce:generate phase

This changes the test a bit, let me explain how: there is no need to use
reflection to make a method in the object under test accessible, we can
simply change the visibility of the target method and refactor where
needed. This makes the object under test easier to test and in the end
better in quality.

So I changed the visibility of the `engine` field to package private to
make it accessible from the test, and refactored the initialization of
`VelocityEngine` into `createVelocityEngine` method so that it can be
used in the test. Now this can be used in the `setUp` method of the
test.

To clean up the test a bit I used `Parameterized` runner which is nice
for tests that repeat the same checks over a number of inputs --
parameters, there is a unused field `json` but that's the way the
`Parameterized` runner works: every parameter needs to be used. I've
added `@Parameters(name = "json = {0}, source = {2}")` to make the tests
cases for different parameters more distinct from each other, with IDE
support it is possible to run all or only single test case (set of
parameters)[1].

I also added a JUnit rule that will create and cleanup the temporary
directory, that way the test can be run via different runners in
parallel -- for instance I use Infinitest that runs tests in the IDE in
the background, now I'm sure that those won't interfere with the tests I
run manually. So this makes the test run less prone to outside
influences and less _flaky_.

[1] http://blog.moritz.eysholdt.de/2014/11/new-eclipse-junit-feature-run-subtrees.html


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cccf6726
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cccf6726
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cccf6726

Branch: refs/heads/master
Commit: cccf6726b1fb59d592453e32909c0c3fa39dad2c
Parents: 91424b8
Author: Zoran Regvart <zr...@apache.org>
Authored: Sat Mar 11 14:45:59 2017 +0100
Committer: Zoran Regvart <zr...@apache.org>
Committed: Mon Mar 13 10:40:44 2017 +0100

----------------------------------------------------------------------
 .../apache/camel/maven/CamelSalesforceMojo.java |  27 ++--
 .../maven/CamelSalesforceMojoOutputTest.java    | 151 +++++++------------
 2 files changed, 69 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cccf6726/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
index f557a56..33aceba 100644
--- a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
@@ -266,7 +266,8 @@ public class CamelSalesforceMojo extends AbstractMojo {
     @Parameter(property = "camelSalesforce.useStringsForPicklists", defaultValue = "false")
     protected Boolean useStringsForPicklists;
 
-    private VelocityEngine engine;
+    VelocityEngine engine;
+
     private long responseTimeout;
 
     /**
@@ -275,14 +276,7 @@ public class CamelSalesforceMojo extends AbstractMojo {
      * @throws MojoExecutionException
      */
     public void execute() throws MojoExecutionException {
-        // initialize velocity to load resources from class loader and use Log4J
-        Properties velocityProperties = new Properties();
-        velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
-        velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
-        velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
-        velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.logger", LOG.getName());
-        engine = new VelocityEngine(velocityProperties);
-        engine.init();
+        engine = createVelocityEngine();
 
         // make sure we can load both templates
         if (!engine.resourceExists(SOBJECT_POJO_VM)
@@ -426,6 +420,19 @@ public class CamelSalesforceMojo extends AbstractMojo {
         }
     }
 
+    static VelocityEngine createVelocityEngine() {
+        // initialize velocity to load resources from class loader and use Log4J
+        final Properties velocityProperties = new Properties();
+        velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
+        velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
+        velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
+        velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.logger", LOG.getName());
+
+        final VelocityEngine engine = new VelocityEngine(velocityProperties);
+
+        return engine;
+    }
+
     protected void filterObjectNames(Set<String> objectNames) throws MojoExecutionException {
         getLog().info("Looking for matching Object names...");
         // create a list of accepted names
@@ -574,7 +581,7 @@ public class CamelSalesforceMojo extends AbstractMojo {
         return httpClient;
     }
 
-    private void processDescription(File pkgDir, SObjectDescription description, GeneratorUtility utility, String generatedDate) throws MojoExecutionException {
+    void processDescription(File pkgDir, SObjectDescription description, GeneratorUtility utility, String generatedDate) throws MojoExecutionException {
         // generate a source file for SObject
         String fileName = description.getName() + JAVA_EXT;
         BufferedWriter writer = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/cccf6726/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoOutputTest.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoOutputTest.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoOutputTest.java
index f4d9851..4ddf2d2 100644
--- a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoOutputTest.java
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoOutputTest.java
@@ -17,131 +17,84 @@
 package org.apache.camel.maven;
 
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
-import java.lang.Exception;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Properties;
-
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.Before;
-
-import org.apache.maven.plugin.logging.SystemStreamLog;
+import java.util.Arrays;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 
-import org.apache.camel.component.salesforce.api.utils.JsonUtils;
 import org.apache.camel.component.salesforce.api.dto.SObjectDescription;
-
-import org.apache.log4j.Logger;
-
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
-import org.apache.velocity.runtime.log.Log4JLogChute;
-
+import org.apache.camel.component.salesforce.api.utils.JsonUtils;
 import org.apache.commons.io.FileUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
 
-//import java.util.Scanner;
-
+@RunWith(Parameterized.class)
 public class CamelSalesforceMojoOutputTest {
     private static final String TEST_CASE_FILE = "case.json";
     private static final String TEST_CALCULATED_FORMULA_FILE = "complex_calculated_formula.json";
-    private static final String OUTPUT_FOLDER = "target/test-generated-sources";
-    private static final String generatedDate = "Thu Mar 09 16:15:49 ART 2017";
-
-    private CamelSalesforceMojoAccessor mojo;
-    private CamelSalesforceMojo.GeneratorUtility utility;
-    private File pkgDir;
-
-    private static class CamelSalesforceMojoAccessor extends CamelSalesforceMojo {
-        private static final Logger LOG = Logger.getLogger(CamelSalesforceMojoAccessor.class.getName());
-
-        public CamelSalesforceMojoAccessor() throws Exception {
-            // initialize velocity to load resources from class loader and use Log4J
-            Properties velocityProperties = new Properties();
-            velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
-            velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
-            velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
-            velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.logger", LOG.getName());
-
-            VelocityEngine engine = new VelocityEngine(velocityProperties);
-            engine.init();
-
-            Field field = CamelSalesforceMojo.class.getDeclaredField("engine");
-            field.setAccessible(true);
-            field.set(this, engine);
-        }
-
-        // Expose processDescription in order to test it
-        public void processDescription(File pkgDir, SObjectDescription description, GeneratorUtility utility, String generatedDate) throws Exception {
-            Method method = CamelSalesforceMojo.class.getDeclaredMethod("processDescription", File.class, SObjectDescription.class, CamelSalesforceMojo.GeneratorUtility.class, String.class);
-            method.setAccessible(true);
-            method.invoke(this, pkgDir, description, utility, generatedDate);
-        }
+    private static final String FIXED_DATE = "Thu Mar 09 16:15:49 ART 2017";
+
+    private CamelSalesforceMojo mojo;
+    private CamelSalesforceMojo.GeneratorUtility utility = new CamelSalesforceMojo.GeneratorUtility(false);
+
+    @Rule
+    public TemporaryFolder temp = new TemporaryFolder();
+
+    @Parameters(name = "json = {0}, source = {2}")
+    public static Iterable<Object[]> parameters() throws IOException {
+        return Arrays.asList(pair(TEST_CASE_FILE, "Case.java"),
+            pair(TEST_CASE_FILE, "Case_PickListAccentMarkEnum.java"),
+            pair(TEST_CASE_FILE, "Case_PickListQuotationMarkEnum.java"),
+            pair(TEST_CASE_FILE, "Case_PickListSlashEnum.java"), pair(TEST_CASE_FILE, "QueryRecordsCase.java"),
+            pair(TEST_CALCULATED_FORMULA_FILE, "ComplexCalculatedFormula.java"),
+            pair(TEST_CALCULATED_FORMULA_FILE, "QueryRecordsComplexCalculatedFormula.java"));
     }
 
-    @Before
-    public void setUp() throws Exception {
-        mojo = createMojo();
-
-        pkgDir = new File(OUTPUT_FOLDER);
-        if (!pkgDir.exists()) {
-            if (!pkgDir.mkdirs()) {
-                throw new Exception("Unable to create " + pkgDir);
-            }
-        }
-
-        utility = createGeneratorUtility();
+    static Object[] pair(String json, String source) throws IOException {
+        return new Object[] {json, createSObjectDescription(json), source};
     }
 
-    @Test
-    public void testProcessDescriptionPickLists() throws Exception {
-        SObjectDescription description = createSObjectDescription(TEST_CASE_FILE);
+    @Parameter(0)
+    public String json;
+
+    @Parameter(1)
+    public SObjectDescription description;
 
-        mojo.processDescription(pkgDir, description, utility, generatedDate);
+    @Parameter(2)
+    public String source;
 
-        assertClassFile("Case.java");
-        assertClassFile("Case_PickListAccentMarkEnum.java");
-        assertClassFile("Case_PickListQuotationMarkEnum.java");
-        assertClassFile("Case_PickListSlashEnum.java");
-        assertClassFile("QueryRecordsCase.java");
+    @Before
+    public void setUp() throws Exception {
+        mojo = new CamelSalesforceMojo();
+        mojo.engine = CamelSalesforceMojo.createVelocityEngine();
     }
 
     @Test
-    public void testProcessDescriptionCalculatedFormula() throws Exception {
-        SObjectDescription description = createSObjectDescription(TEST_CALCULATED_FORMULA_FILE);
+    public void testProcessDescriptionPickLists() throws Exception {
+        final File pkgDir = temp.newFolder();
 
-        mojo.processDescription(pkgDir, description, utility, generatedDate);
+        mojo.processDescription(pkgDir, description, utility, FIXED_DATE);
 
-        assertClassFile("ComplexCalculatedFormula.java");
-        assertClassFile("QueryRecordsComplexCalculatedFormula.java");
-    }
+        File generatedFile = new File(pkgDir, source);
+        File expectedFile = FileUtils.toFile(CamelSalesforceMojoOutputTest.class.getResource("/generated/" + source));
 
-    public void assertClassFile(String name) throws Exception {
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        Assert.assertTrue("Class "+name+" must be equal to the target one", FileUtils.contentEquals(new File(OUTPUT_FOLDER, name), FileUtils.toFile(classLoader.getResource("generated/"+name))));
+        Assert.assertTrue("Geberated source file in " + source + " must be equal to the one present in test/resources",
+            FileUtils.contentEquals(generatedFile, expectedFile));
     }
 
-    protected CamelSalesforceMojo.GeneratorUtility createGeneratorUtility() {
-        return new CamelSalesforceMojo.GeneratorUtility(false);
-    }
-
-    protected SObjectDescription createSObjectDescription(String name) throws Exception {
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        InputStream inputStream = classLoader.getResourceAsStream(name);
+    static SObjectDescription createSObjectDescription(String name) throws IOException {
+        InputStream inputStream = CamelSalesforceMojoOutputTest.class.getResourceAsStream("/" + name);
         ObjectMapper mapper = JsonUtils.createObjectMapper();
-        SObjectDescription description = mapper.readValue(inputStream, SObjectDescription.class);
-        if (description == null)
-            throw new Exception("Couldn't Read description from file");
 
-        return description;
+        return mapper.readValue(inputStream, SObjectDescription.class);
     }
 
-    protected CamelSalesforceMojoAccessor createMojo() throws Exception {
-        CamelSalesforceMojoAccessor mojo = new CamelSalesforceMojoAccessor();
-        mojo.setLog(new SystemStreamLog());
-        return mojo;
-    }
 }