camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r1296215 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/component/stub/ main/resources/META-INF/services/org/apache/camel/component/ test/java/org/apache/camel/component/stub/
Date Fri, 02 Mar 2012 14:10:04 GMT
Author: jstrachan
Date: Fri Mar  2 14:10:03 2012
New Revision: 1296215

URL: http://svn.apache.org/viewvc?rev=1296215&view=rev
Log:
added a first spike of a stub component for CAMEL-5057

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/stub/
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java
  (with props)
    camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/stub
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java
  (with props)

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java?rev=1296215&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java
(added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java
Fri Mar  2 14:10:03 2012
@@ -0,0 +1,46 @@
+/**
+ * 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.stub;
+
+import java.util.Map;
+
+import org.apache.camel.component.vm.VmComponent;
+
+/** 
+ * Allows you to easily stub out a middleware transport by prefixing the URI with "stub:"
which is 
+ * handy for testing out routes, or isolating bits of middleware.
+ *
+ */
+public class StubComponent extends VmComponent {
+
+	public StubComponent() {
+	}
+
+	@Override
+	protected void validateURI(String uri, String path,
+			Map<String, Object> parameters) {
+        // Don't validate so we can stub any URI
+	}
+
+	@Override
+	protected void validateParameters(String uri,
+			Map<String, Object> parameters, String optionPrefix) {
+        // Don't validate so we can stub any URI
+	}
+
+
+}

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/stub
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/stub?rev=1296215&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/stub
(added)
+++ camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/stub
Fri Mar  2 14:10:03 2012
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.stub.StubComponent
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java?rev=1296215&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java
Fri Mar  2 14:10:03 2012
@@ -0,0 +1,52 @@
+/**
+ * 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.stub;
+
+import org.apache.camel.builder.RouteBuilder;
+
+import org.apache.camel.component.vm.AbstractVmTestSupport;
+
+public class StubInOnlyTest extends AbstractVmTestSupport {
+
+    public void testInOnly() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template2.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("stub:smtp://some.server.com?something=bar&whatnot=cheese").to("mock:result");
+            }
+        };
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("stub:smtp://some.server.com?something=bar&whatnot=cheese");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message