You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2010/09/27 18:06:10 UTC

svn commit: r1001791 - in /camel/trunk/components/camel-spring/src/test: java/org/apache/camel/spring/placeholder/ resources/org/apache/camel/spring/placeholder/

Author: cmueller
Date: Mon Sep 27 16:06:10 2010
New Revision: 1001791

URL: http://svn.apache.org/viewvc?rev=1001791&view=rev
Log:
CAMEL-3162: added unit test

Added:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRoute.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest-context.xml   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/bundle-context.cfg

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRoute.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRoute.java?rev=1001791&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRoute.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRoute.java Mon Sep 27 16:06:10 2010
@@ -0,0 +1,38 @@
+/**
+ * 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.spring.placeholder;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class SimpleLanguageWithSprinPropertyPlaceholderRoute extends RouteBuilder {
+
+    private String fromEndpoint;
+    private String toEndpoint;
+
+    public void configure() throws Exception {
+        from(fromEndpoint)
+        .to(toEndpoint);
+    }
+
+    public void setFromEndpoint(String fromEndpoint) {
+        this.fromEndpoint = fromEndpoint;
+    }
+
+    public void setToEndpoint(String toEndpoint) {
+        this.toEndpoint = toEndpoint;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRoute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRoute.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java?rev=1001791&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java Mon Sep 27 16:06:10 2010
@@ -0,0 +1,76 @@
+/**
+ * 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.spring.placeholder;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.Calendar;
+
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.util.FileUtil;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+@ContextConfiguration
+public class SimpleLanguageWithSprinPropertyPlaceholderRouteTest extends AbstractJUnit4SpringContextTests {
+    
+    @Produce(uri = "direct:startSimple")
+    protected ProducerTemplate template;
+
+    @Before
+    public void setUp() throws Exception {
+        FileUtil.deleteFile(new File("target/outBox"));
+        FileUtil.deleteFile(new File("target/outBoxSimple"));
+    }
+
+    @Test
+    @DirtiesContext
+    public void replaceSimpleExpression() throws Exception {
+        template.sendBody("Test");
+
+        Thread.sleep(500);
+        
+        assertFileExists("target/outBoxSimple/");
+    }
+    
+    @Ignore(value = "dissabled because of https://jira.springsource.org/browse/SPR-7593")
+    @Test
+    @DirtiesContext
+    public void replaceExpression() throws Exception {
+        template.sendBody("direct:start", "Test");
+
+        Thread.sleep(500);
+        
+        assertFileExists("target/outBox/");
+    }
+
+    private void assertFileExists(String directory) {
+        Calendar today = Calendar.getInstance();
+        String day = String.valueOf(today.get(Calendar.DAY_OF_MONTH));
+        String month = String.valueOf(today.get(Calendar.MONTH) + 1);
+        month = month.length() == 1 ? "0" + month : month;
+        String year = String.valueOf(today.get(Calendar.YEAR));
+
+        assertTrue(new File(directory + "test-" + year + month + day + ".txt").exists());
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest-context.xml?rev=1001791&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest-context.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest-context.xml Mon Sep 27 16:06:10 2010
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:camel="http://camel.apache.org/schema/spring"
+	xmlns:ctx="http://www.springframework.org/schema/context"
+	xsi:schemaLocation="
+        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+        ">
+        
+	<ctx:property-placeholder ignore-unresolvable="true" location="classpath:org/apache/camel/spring/placeholder/bundle-context.cfg" />
+	
+	<bean id="testRoute1" class="org.apache.camel.spring.placeholder.SimpleLanguageWithSprinPropertyPlaceholderRoute">
+		<property name="fromEndpoint" value="${fromEndpoint}" />
+		<property name="toEndpoint" value="${toEndpoint}" />
+	</bean>
+ 
+    <bean id="testRoute2" class="org.apache.camel.spring.placeholder.SimpleLanguageWithSprinPropertyPlaceholderRoute">
+        <property name="fromEndpoint" value="${fromEndpointSimple}" />
+        <property name="toEndpoint" value="${toEndpointSimple}" />
+    </bean>
+
+	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+		<camel:routeBuilder ref="testRoute1"/>
+        <camel:routeBuilder ref="testRoute2"/>
+	</camelContext>
+</beans>
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/bundle-context.cfg
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/bundle-context.cfg?rev=1001791&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/bundle-context.cfg (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/placeholder/bundle-context.cfg Mon Sep 27 16:06:10 2010
@@ -0,0 +1,25 @@
+#
+#
+#    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.
+#
+#
+fromEndpoint=direct:start
+toEndpoint=file://target/outBox?fileName=test-${date:now:yyyyMMdd}.txt
+
+fromEndpointSimple=direct:startSimple
+toEndpointSimple=file://target/outBoxSimple?fileName=test-$simple{date:now:yyyyMMdd}.txt
\ No newline at end of file