camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1225077 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityFileLetterWithPropertyTest.java
Date Wed, 28 Dec 2011 03:04:13 GMT
Author: ningjiang
Date: Wed Dec 28 03:04:12 2011
New Revision: 1225077

URL: http://svn.apache.org/viewvc?rev=1225077&view=rev
Log:
 CAMEL-4834 camel properties component should support not specifying the file location

Added:
    camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityFileLetterWithPropertyTest.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java?rev=1225077&r1=1225076&r2=1225077&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
Wed Dec 28 03:04:12 2011
@@ -107,19 +107,20 @@ public class PropertiesComponent extends
     }
 
     public String parseUri(String uri, String... paths) throws Exception {
-        ObjectHelper.notNull(paths, "paths");
-
-        // location may contain JVM system property or OS environment variables
-        // so we need to parse those
-        String[] locations = parseLocations(paths);
-
-        // check cache first
-        CacheKey key = new CacheKey(locations);
-        Properties prop = cache ? cacheMap.get(key) : null;
-        if (prop == null) {
-            prop = propertiesResolver.resolveProperties(getCamelContext(), locations);
-            if (cache) {
-                cacheMap.put(key, prop);
+        Properties prop = null;
+        if (paths != null) {
+            // location may contain JVM system property or OS environment variables
+            // so we need to parse those
+            String[] locations = parseLocations(paths);
+    
+            // check cache first
+            CacheKey key = new CacheKey(locations);
+            prop = cache ? cacheMap.get(key) : null;
+            if (prop == null) {
+                prop = propertiesResolver.resolveProperties(getCamelContext(), locations);
+                if (cache) {
+                    cacheMap.put(key, prop);
+                }
             }
         }
 

Added: camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityFileLetterWithPropertyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityFileLetterWithPropertyTest.java?rev=1225077&view=auto
==============================================================================
--- camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityFileLetterWithPropertyTest.java
(added)
+++ camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityFileLetterWithPropertyTest.java
Wed Dec 28 03:04:12 2011
@@ -0,0 +1,42 @@
+/**
+ * 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.velocity;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.impl.JndiRegistry;
+
+public class VelocityFileLetterWithPropertyTest extends VelocityLetterTest {
+    
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry =  new JndiRegistry(createJndiContext());
+        registry.bind("properties", new PropertiesComponent());
+        return registry;
+    }
+    
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                
+                System.setProperty("ENV", "src/test/resources/");
+                
+                from("direct:a").to("velocity:file:{{ENV}}org/apache/camel/component/velocity/letter.vm").to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityFileLetterWithPropertyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityFileLetterWithPropertyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message