Author: davsclaus Date: Wed Jan 21 07:41:29 2009 New Revision: 736324 URL: http://svn.apache.org/viewvc?rev=736324&view=rev Log: CAMEL-505: Endpoints in camel-core is nowe easier to create using spring beans in the spring xml files. There is a defualt no args constructor and then you can set all properties on the endpoint using spring.
Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/log/ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/log/SpringLogTest.java (with props) camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml (with props) Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java?rev=736324&r1=736323&r2=736324&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java Wed Jan 21 07:41:29 2009 @@ -257,4 +257,8 @@ public void setFormatter(ExchangeFormatter formatter) { this.formatter = formatter; } + + public void setLogName(String logName) { + this.log = LogFactory.getLog(logName); + } } Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/log/SpringLogTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/log/SpringLogTest.java?rev=736324&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/log/SpringLogTest.java (added) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/log/SpringLogTest.java Wed Jan 21 07:41:29 2009 @@ -0,0 +1,43 @@ +/** + * 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.log; + +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.spring.SpringTestSupport; +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @version $Revision$ + */ +public class SpringLogTest extends SpringTestSupport { + protected Object expectedBody = "Hello there!"; + protected String uri = "direct:start"; + + public void testSendingCamelExchangeToEndpointResultsInValidApplicationEventAfterTheRefreshEvent() throws Exception { + MockEndpoint result = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); + result.expectedMessageCount(1); + + template.sendBody(uri, expectedBody); + + result.assertIsSatisfied(); + } + + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/component/log/SpringLogTest-context.xml"); + } +} \ No newline at end of file Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/log/SpringLogTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/log/SpringLogTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml?rev=736324&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml (added) +++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml Wed Jan 21 07:41:29 2009 @@ -0,0 +1,42 @@ +<?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" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd + "> + + <bean id="log" class="org.apache.camel.component.log.LogEndpoint"> + <property name="logger" ref="myLogger"/> + </bean> + + <bean id="myLogger" class="org.apache.camel.processor.Logger"> + <property name="level" value="WARN"/> + <property name="logName" value="cool"/> + </bean> + + <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> + <route> + <from uri="direct:start"/> + <to uri="log"/> + <to uri="mock:result"/> + </route> + </camelContext> + +</beans> Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml