You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/05/25 06:56:11 UTC

[camel] branch master updated: CAMEL-13557: Fixed test to use property binding support as the old has removed the legacy JDK PropertyEditor in CAMEL-13566

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


The following commit(s) were added to refs/heads/master by this push:
     new 63e94e6  CAMEL-13557: Fixed test to use property binding support as the old has removed the legacy JDK PropertyEditor in CAMEL-13566
63e94e6 is described below

commit 63e94e660cc681a8631808819838a256f31d13fd
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat May 25 08:55:48 2019 +0200

    CAMEL-13557: Fixed test to use property binding support as the old has removed the legacy JDK PropertyEditor in CAMEL-13566
---
 .../component/as2/AbstractAS2TestSupport.java      |  4 +-
 .../component/box/AbstractBoxTestSupport.java      |  4 +-
 .../BoxConnectionHelperIntegrationTest.java        | 64 ----------------------
 .../braintree/AbstractBraintreeTestSupport.java    |  8 +--
 .../component/docker/it/DockerITTestSupport.java   |  4 +-
 .../camel/component/elsql/ElsqlComponent.java      |  4 +-
 .../component/facebook/FacebookComponent.java      |  3 +-
 .../component/fhir/AbstractFhirTestSupport.java    |  4 +-
 .../apache/camel/component/fop/FopProducer.java    |  5 +-
 .../AbstractGoogleCalendarTestSupport.java         |  4 +-
 .../AbstractGoogleCalendarStreamTestSupport.java   |  4 +-
 .../apache/camel/component/jdbc/JdbcProducer.java  |  6 +-
 .../apache/camel/component/sql/SqlComponent.java   |  3 +-
 13 files changed, 29 insertions(+), 88 deletions(-)

diff --git a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AbstractAS2TestSupport.java b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AbstractAS2TestSupport.java
index 508a42a..939b7bb 100644
--- a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AbstractAS2TestSupport.java
+++ b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AbstractAS2TestSupport.java
@@ -23,7 +23,7 @@ import java.util.Properties;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.test.junit4.CamelTestSupport;
 
 /**
@@ -53,7 +53,7 @@ public class AbstractAS2TestSupport extends CamelTestSupport {
         }
 
         final AS2Configuration configuration = new AS2Configuration();
-        IntrospectionSupport.setProperties(configuration, options);
+        PropertyBindingSupport.bindProperties(context, configuration, options);
 
         // add AS2Component to Camel context
         final AS2Component component = new AS2Component(context);
diff --git a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/AbstractBoxTestSupport.java b/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/AbstractBoxTestSupport.java
index 44a2c4a..74f3760 100644
--- a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/AbstractBoxTestSupport.java
+++ b/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/AbstractBoxTestSupport.java
@@ -25,7 +25,7 @@ import com.box.sdk.BoxFile;
 import com.box.sdk.BoxFolder;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.test.junit4.CamelTestSupport;
 
 /**
@@ -60,7 +60,7 @@ public class AbstractBoxTestSupport extends CamelTestSupport {
         }
 
         final BoxConfiguration configuration = new BoxConfiguration();
-        IntrospectionSupport.setProperties(configuration, options);
+        PropertyBindingSupport.bindProperties(context, configuration, options);
 
         // add BoxComponent to Camel context
         final BoxComponent component = new BoxComponent(context);
diff --git a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/internal/BoxConnectionHelperIntegrationTest.java b/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/internal/BoxConnectionHelperIntegrationTest.java
deleted file mode 100644
index 1134a22..0000000
--- a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/internal/BoxConnectionHelperIntegrationTest.java
+++ /dev/null
@@ -1,64 +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.
- */
-package org.apache.camel.component.box.internal;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Properties;
-import java.util.stream.Collectors;
-
-import com.box.sdk.BoxAPIConnection;
-import com.box.sdk.BoxUser;
-import org.apache.camel.component.box.BoxConfiguration;
-import org.apache.camel.support.IntrospectionSupport;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Test class for {@link BoxConnectionHelper}.
- */
-public class BoxConnectionHelperIntegrationTest {
-
-    private static final String TEST_OPTIONS_PROPERTIES = "/test-options.properties";
-
-    private BoxConfiguration configuration = new BoxConfiguration();
-
-    @Before
-    public void loadConfiguration() throws Exception {
-        Properties properties = new Properties();
-        try {
-            properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
-        } catch (Exception e) {
-            throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()),
-                    e);
-        }
-
-        Map<String, Object> options = properties.entrySet().stream().collect(
-                Collectors.<Map.Entry, String, Object>toMap(e -> (String) e.getKey(), Map.Entry::getValue));
-
-        IntrospectionSupport.setProperties(configuration, options);
-    }
-
-    @Test
-    public void testCreateConnection() {
-        BoxAPIConnection connection = BoxConnectionHelper.createConnection(configuration);
-        BoxUser user = BoxUser.getCurrentUser(connection);
-        assertNotNull(user);
-    }
-}
diff --git a/components/camel-braintree/src/test/java/org/apache/camel/component/braintree/AbstractBraintreeTestSupport.java b/components/camel-braintree/src/test/java/org/apache/camel/component/braintree/AbstractBraintreeTestSupport.java
index 0fdcbb4..91f3600 100644
--- a/components/camel-braintree/src/test/java/org/apache/camel/component/braintree/AbstractBraintreeTestSupport.java
+++ b/components/camel-braintree/src/test/java/org/apache/camel/component/braintree/AbstractBraintreeTestSupport.java
@@ -29,7 +29,7 @@ import org.apache.camel.component.braintree.internal.BraintreeApiCollection;
 import org.apache.camel.component.braintree.internal.BraintreeApiName;
 import org.apache.camel.component.braintree.internal.BraintreeConstants;
 import org.apache.camel.component.braintree.internal.BraintreeLogHandler;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.support.component.ApiMethod;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.ObjectHelper;
@@ -59,7 +59,7 @@ public class AbstractBraintreeTestSupport extends CamelTestSupport {
 
         // add BraintreeComponent to Camel context
         final BraintreeComponent component = new BraintreeComponent(context);
-        component.setConfiguration(buildBraintreeConfiguration());
+        component.setConfiguration(buildBraintreeConfiguration(context));
         context.addComponent("braintree", component);
 
         return context;
@@ -74,7 +74,7 @@ public class AbstractBraintreeTestSupport extends CamelTestSupport {
         }
     }
 
-    protected BraintreeConfiguration buildBraintreeConfiguration() throws Exception {
+    protected BraintreeConfiguration buildBraintreeConfiguration(CamelContext context) throws Exception {
 
         final Properties properties = new Properties();
         try {
@@ -113,7 +113,7 @@ public class AbstractBraintreeTestSupport extends CamelTestSupport {
         final BraintreeConfiguration configuration = new BraintreeConfiguration();
         configuration.setHttpLogLevel(BraintreeLogHandler.DEFAULT_LOGGER_VERSION);
         configuration.setHttpLogName(BraintreeLogHandler.DEFAULT_LOGGER_NAME);
-        IntrospectionSupport.setProperties(configuration, options);
+        PropertyBindingSupport.bindProperties(context, configuration, options);
 
         return configuration;
     }
diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/it/DockerITTestSupport.java b/components/camel-docker/src/test/java/org/apache/camel/component/docker/it/DockerITTestSupport.java
index 93d396e..6e03d43 100644
--- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/it/DockerITTestSupport.java
+++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/it/DockerITTestSupport.java
@@ -23,7 +23,7 @@ import java.util.Properties;
 import org.apache.camel.CamelContext;
 import org.apache.camel.component.docker.DockerComponent;
 import org.apache.camel.component.docker.DockerConfiguration;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.test.junit4.CamelTestSupport;
 
 public class DockerITTestSupport extends CamelTestSupport {
@@ -42,7 +42,7 @@ public class DockerITTestSupport extends CamelTestSupport {
         properties.entrySet().forEach((e) -> options.put(e.getKey().toString(), e.getValue()));
 
         DockerConfiguration configuration = new DockerConfiguration();
-        IntrospectionSupport.setProperties(configuration, options);
+        PropertyBindingSupport.bindProperties(context, configuration, options);
 
         DockerComponent component = new DockerComponent();
         component.setConfiguration(configuration);
diff --git a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlComponent.java b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlComponent.java
index 50a13d5..7dcc368 100644
--- a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlComponent.java
+++ b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlComponent.java
@@ -26,6 +26,7 @@ import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.support.DefaultComponent;
 import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
 
 @Component("elsql")
@@ -62,7 +63,8 @@ public class ElsqlComponent extends DefaultComponent {
         }
 
         NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(target);
-        IntrospectionSupport.setProperties(jdbcTemplate, parameters, "template.");
+        Map<String, Object> params = IntrospectionSupport.extractProperties(parameters, "template.");
+        PropertyBindingSupport.bindProperties(getCamelContext(), jdbcTemplate, params);
 
         String elsqlName = remaining;
         String resUri = resourceUri;
diff --git a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookComponent.java b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookComponent.java
index 836b593..383bcab 100644
--- a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookComponent.java
+++ b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookComponent.java
@@ -27,6 +27,7 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
 import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 
 /**
  * Represents the component that manages {@link FacebookEndpoint}.
@@ -76,7 +77,7 @@ public class FacebookComponent extends DefaultComponent {
 
         // create endpoint configuration with component properties
         FacebookEndpointConfiguration config = new FacebookEndpointConfiguration();
-        IntrospectionSupport.setProperties(config, componentProperties);
+        PropertyBindingSupport.bindProperties(getCamelContext(), config, componentProperties);
         return config;
     }
 
diff --git a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java
index 03e0eca..fe4efff 100644
--- a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java
+++ b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java
@@ -26,7 +26,7 @@ import ca.uhn.fhir.rest.client.api.IGenericClient;
 import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.hl7.fhir.dstu3.model.Bundle;
 import org.hl7.fhir.dstu3.model.HumanName;
@@ -97,7 +97,7 @@ public abstract class AbstractFhirTestSupport extends CamelTestSupport {
         this.fhirClient = this.fhirContext.newRestfulGenericClient((String) options.get("serverUrl"));
         GENERIC_CLIENT_THREAD_LOCAL.set(this.fhirClient);
         final FhirConfiguration configuration = new FhirConfiguration();
-        IntrospectionSupport.setProperties(configuration, options);
+        PropertyBindingSupport.bindProperties(context, configuration, options);
         configuration.setFhirContext(this.fhirContext);
 
         // add FhirComponent to Camel context
diff --git a/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java b/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java
index 99d6200..19abf79 100644
--- a/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java
+++ b/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java
@@ -32,6 +32,7 @@ import javax.xml.transform.stream.StreamSource;
 import org.apache.camel.Exchange;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.Fop;
@@ -103,7 +104,7 @@ public class FopProducer extends DefaultProducer {
             .extractProperties(headers, FopConstants.CAMEL_FOP_ENCRYPT);
         if (!encryptionParameters.isEmpty()) {
             PDFEncryptionParams encryptionParams = new PDFEncryptionParams();
-            IntrospectionSupport.setProperties(encryptionParams, encryptionParameters);
+            PropertyBindingSupport.bindProperties(getEndpoint().getCamelContext(), encryptionParams, encryptionParameters);
             userAgent.getRendererOptions().put("encryption-params", encryptionParams);
         }
     }
@@ -118,7 +119,7 @@ public class FopProducer extends DefaultProducer {
     private void setRenderParameters(FOUserAgent userAgent, Map<String, Object> headers) throws Exception {
         Map<String, Object> parameters = IntrospectionSupport.extractProperties(headers, FopConstants.CAMEL_FOP_RENDER);
         if (!parameters.isEmpty()) {
-            IntrospectionSupport.setProperties(userAgent, parameters);
+            PropertyBindingSupport.bindProperties(getEndpoint().getCamelContext(), userAgent, parameters);
         }
     }
     
diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/AbstractGoogleCalendarTestSupport.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/AbstractGoogleCalendarTestSupport.java
index 58bc1c9..c01e2c0 100644
--- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/AbstractGoogleCalendarTestSupport.java
+++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/AbstractGoogleCalendarTestSupport.java
@@ -26,7 +26,7 @@ import com.google.api.services.calendar.model.Calendar;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.After;
 import org.junit.Before;
@@ -82,7 +82,7 @@ public class AbstractGoogleCalendarTestSupport extends CamelTestSupport {
         }
 
         final GoogleCalendarConfiguration configuration = new GoogleCalendarConfiguration();
-        IntrospectionSupport.setProperties(configuration, options);
+        PropertyBindingSupport.bindProperties(context, configuration, options);
 
         // add GoogleCalendarComponent to Camel context
         final GoogleCalendarComponent component = new GoogleCalendarComponent(context);
diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java
index 80fe0ac..e0e2fb9 100644
--- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java
+++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java
@@ -22,7 +22,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.test.junit4.CamelTestSupport;
 
 /**
@@ -54,7 +54,7 @@ public class AbstractGoogleCalendarStreamTestSupport extends CamelTestSupport {
         }
 
         final GoogleCalendarStreamConfiguration configuration = new GoogleCalendarStreamConfiguration();
-        IntrospectionSupport.setProperties(configuration, options);
+        PropertyBindingSupport.bindProperties(context, configuration, options);
 
         // add GoogleCalendarComponent to Camel context
         final GoogleCalendarStreamComponent component = new GoogleCalendarStreamComponent(context);
diff --git a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
index 51493b7..f7dd84f 100644
--- a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
+++ b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
@@ -34,7 +34,7 @@ import javax.sql.DataSource;
 import org.apache.camel.Exchange;
 import org.apache.camel.spi.Synchronization;
 import org.apache.camel.support.DefaultProducer;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 
 import org.springframework.jdbc.datasource.DataSourceUtils;
 
@@ -193,7 +193,7 @@ public class JdbcProducer extends DefaultProducer {
 
             if (parameters != null && !parameters.isEmpty()) {
                 Map<String, Object> copy = new HashMap<>(parameters);
-                IntrospectionSupport.setProperties(stmt, copy);
+                PropertyBindingSupport.bindProperties(exchange.getContext(), stmt, copy);
             }
 
             log.debug("Executing JDBC Statement: {}", sql);
@@ -383,7 +383,7 @@ public class JdbcProducer extends DefaultProducer {
             properties.put(name, value);
         }
         try {
-            IntrospectionSupport.setProperties(answer, properties);
+            PropertyBindingSupport.bindProperties(getEndpoint().getCamelContext(), answer, properties);
         } catch (Exception e) {
             throw new SQLException("Error setting properties on output class " + outputClass, e);
         }
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
index 1b79a56..24f3d42 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
@@ -27,6 +27,7 @@ import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.support.DefaultComponent;
 import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
@@ -89,7 +90,7 @@ public class SqlComponent extends DefaultComponent {
 
         JdbcTemplate jdbcTemplate = new JdbcTemplate(target);
         Map<String, Object> templateOptions = IntrospectionSupport.extractProperties(parameters, "template.");
-        IntrospectionSupport.setProperties(jdbcTemplate, templateOptions);
+        PropertyBindingSupport.bindProperties(getCamelContext(), jdbcTemplate, templateOptions);
 
         String query = remaining;
         if (usePlaceholder) {