You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/11/01 08:12:36 UTC
svn commit: r1404480 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/util/ test/java/org/apache/camel/component/
test/java/org/apache/camel/processor/
Author: ningjiang
Date: Thu Nov 1 07:12:35 2012
New Revision: 1404480
URL: http://svn.apache.org/viewvc?rev=1404480&view=rev
Log:
Fixed the CS errors of camel-core
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopWithAggregatorTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
camel/trunk/camel-core/src/main/java/org/apache/camel/util/LoadPropertiesException.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/ComponentDiscoveryTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java?rev=1404480&r1=1404479&r2=1404480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java Thu Nov 1 07:12:35 2012
@@ -353,7 +353,7 @@ public final class CamelContextHelper {
* Finds all possible Components on the classpath and Registry
*/
public static SortedMap<String, Properties> findComponents(CamelContext camelContext) throws LoadPropertiesException {
- SortedMap<String,Properties> map = new TreeMap<String, Properties>();
+ SortedMap<String, Properties> map = new TreeMap<String, Properties>();
Enumeration<URL> iter = camelContext.getClassResolver().loadResourcesAsURL(COMPONENT_DESCRIPTOR);
while (iter.hasMoreElements()) {
URL url = iter.nextElement();
@@ -374,8 +374,8 @@ public final class CamelContextHelper {
}
// lets see what other components are in the registry
- Map<String,Component> beanMap = camelContext.getRegistry().lookupByType(Component.class);
- Set<Map.Entry<String,Component>> entries = beanMap.entrySet();
+ Map<String, Component> beanMap = camelContext.getRegistry().lookupByType(Component.class);
+ Set<Map.Entry<String, Component>> entries = beanMap.entrySet();
for (Map.Entry<String, Component> entry : entries) {
String name = entry.getKey();
if (!map.containsKey(name)) {
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/LoadPropertiesException.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LoadPropertiesException.java?rev=1404480&r1=1404479&r2=1404480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/LoadPropertiesException.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/LoadPropertiesException.java Thu Nov 1 07:12:35 2012
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,14 +16,15 @@
*/
package org.apache.camel.util;
-import org.apache.camel.CamelException;
-
import java.net.URL;
+import org.apache.camel.CamelException;
+
/**
* Represents a failure to open a Properties file at a given URL
*/
public class LoadPropertiesException extends CamelException {
+ private static final long serialVersionUID = 3684303677685065529L;
private final URL url;
public LoadPropertiesException(URL url, Exception cause) {
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/ComponentDiscoveryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/ComponentDiscoveryTest.java?rev=1404480&r1=1404479&r2=1404480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/ComponentDiscoveryTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/ComponentDiscoveryTest.java Thu Nov 1 07:12:35 2012
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,6 +16,11 @@
*/
package org.apache.camel.component;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedMap;
+
import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.util.CamelContextHelper;
@@ -24,11 +28,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.SortedMap;
-
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -42,7 +41,7 @@ public class ComponentDiscoveryTest {
public void testComponentDiscovery() throws Exception {
CamelContext context = new DefaultCamelContext();
- SortedMap<String,Properties> map = CamelContextHelper.findComponents(context);
+ SortedMap<String, Properties> map = CamelContextHelper.findComponents(context);
assertNotNull("Should never return null", map);
assertTrue("Component map should never be empty", !map.isEmpty());
@@ -52,7 +51,7 @@ public class ComponentDiscoveryTest {
assertTrue("Component map contain component: " + expectedName, properties != null);
}
- Set<Map.Entry<String,Properties>> entries = map.entrySet();
+ Set<Map.Entry<String, Properties>> entries = map.entrySet();
for (Map.Entry<String, Properties> entry : entries) {
LOG.info("Found component " + entry.getKey() + " with properties: " + entry.getValue());
}
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopWithAggregatorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopWithAggregatorTest.java?rev=1404480&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopWithAggregatorTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopWithAggregatorTest.java Thu Nov 1 07:12:35 2012
@@ -0,0 +1,87 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+
+public class LoopWithAggregatorTest extends ContextTestSupport {
+ public void testLoopCopy() throws Exception {
+ getMockEndpoint("mock:loop").expectedBodiesReceived("AB", "AB", "AB");
+ getMockEndpoint("mock:result").expectedBodiesReceived("AB");
+
+ template.requestBody("direct:start", "A");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // START SNIPPET: e1
+ from("direct:start")
+ // instruct loop to use copy mode, which mean it will use a copy of the input exchange
+ // for each loop iteration, instead of keep using the same exchange all over
+ .loop(3).copy()
+ .enrich("direct:getTimeStamp", new ExampleAggregationStrategy())
+ .inOnly("mock:loop")
+ .end()
+ .to("mock:result");
+ // END SNIPPET: e1
+
+ from("direct:getTimeStamp").process(new Processor() {
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ // set the response directly
+ exchange.getIn().setBody("B");
+
+ }
+
+ });
+ }
+ };
+ }
+
+ public static class ExampleAggregationStrategy implements AggregationStrategy {
+
+ public Exchange aggregate(Exchange original, Exchange resource) {
+ String originalBody = original.getIn().getBody(String.class);
+ if (original.getOut().getBody() != null) {
+ System.out.println("get the out message ");
+ originalBody = original.getOut().getBody(String.class);
+ }
+ String resourceResponse = resource.getIn().getBody(String.class);
+ String mergeResult = originalBody + resourceResponse;
+ System.out.println("The original MEP is " + original.getPattern());
+ if (original.getPattern().isOutCapable()) {
+ System.out.println("set the out message ");
+ original.getOut().setBody(mergeResult);
+ } else {
+ original.getIn().setBody(mergeResult);
+ }
+ return original;
+ }
+
+ }
+
+}