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 2011/03/25 09:36:24 UTC
svn commit: r1085284 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/builder/ProxyBuilder.java
test/java/org/apache/camel/impl/CamelProduceInterfaceTest.java
test/java/org/apache/camel/impl/Echo.java
Author: davsclaus
Date: Fri Mar 25 08:36:23 2011
New Revision: 1085284
URL: http://svn.apache.org/viewvc?rev=1085284&view=rev
Log:
Added check for NPE
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelProduceInterfaceTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/Echo.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ProxyBuilder.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ProxyBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ProxyBuilder.java?rev=1085284&r1=1085283&r2=1085284&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ProxyBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ProxyBuilder.java Fri Mar 25 08:36:23 2011
@@ -19,6 +19,7 @@ package org.apache.camel.builder;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.component.bean.ProxyHelper;
+import org.apache.camel.util.ObjectHelper;
/**
* A build to create Camel proxies.
@@ -64,6 +65,7 @@ public final class ProxyBuilder {
* @throws Exception is thrown if error creating the proxy
*/
public <T> T build(Class<T>... interfaceClasses) throws Exception {
+ ObjectHelper.notNull(endpoint, "endpoint");
return ProxyHelper.createProxy(endpoint, interfaceClasses);
}
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelProduceInterfaceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelProduceInterfaceTest.java?rev=1085284&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelProduceInterfaceTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelProduceInterfaceTest.java Fri Mar 25 08:36:23 2011
@@ -0,0 +1,48 @@
+/**
+ * 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.impl;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.ProxyBuilder;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ *
+ */
+public class CamelProduceInterfaceTest extends ContextTestSupport {
+
+ private Echo echo;
+
+ public void testCamelProduceInterface() throws Exception {
+ String reply = echo.hello("Camel");
+ assertEquals("Hello Camel", reply);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // we gotta cheat and use proxy builder as ContextTestSupport doesnt do
+ // all the IoC wiring we need when using @Produce on an interface
+ echo = new ProxyBuilder(context).endpoint("direct:hello").build(Echo.class);
+
+ from("direct:hello").transform(body().prepend("Hello "));
+ }
+ };
+ }
+}
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/Echo.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/Echo.java?rev=1085284&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/Echo.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/Echo.java Fri Mar 25 08:36:23 2011
@@ -0,0 +1,29 @@
+/**
+ * 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.impl;
+
+import org.apache.camel.Produce;
+
+/**
+ *
+ */
+public interface Echo {
+
+ @Produce(uri = "direct:hello")
+ String hello(String name);
+
+}