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 2009/09/17 14:44:26 UTC
svn commit: r816171 - in /camel/trunk/camel-core/src/test:
java/org/apache/camel/model/ resources/org/apache/camel/model/
Author: davsclaus
Date: Thu Sep 17 12:44:25 2009
New Revision: 816171
URL: http://svn.apache.org/viewvc?rev=816171&view=rev
Log:
MR-187: Added unit tests
Added:
camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithFailoverLoadBalance.xml
- copied, changed from r816135, camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithStickyLoadBalance.xml
camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithRandomLoadBalance.xml (with props)
camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithTopicLoadBalance.xml (with props)
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java?rev=816171&r1=816170&r2=816171&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java Thu Sep 17 12:44:25 2009
@@ -20,8 +20,11 @@
import javax.xml.bind.JAXBException;
import org.apache.camel.model.language.ExpressionDefinition;
+import org.apache.camel.model.loadbalancer.FailoverLoadBalancerDefinition;
+import org.apache.camel.model.loadbalancer.RandomLoadBalancerDefinition;
import org.apache.camel.model.loadbalancer.RoundRobinLoadBalancerDefinition;
import org.apache.camel.model.loadbalancer.StickyLoadBalancerDefinition;
+import org.apache.camel.model.loadbalancer.TopicLoadBalancerDefinition;
/**
* @version $Revision$
@@ -206,6 +209,32 @@
assertNotNull("the expression should not be null ", strategy.getCorrelationExpression());
}
+ public void testParseFailoverLoadBalance() throws Exception {
+ RouteDefinition route = assertOneRoute("routeWithFailoverLoadBalance.xml");
+ assertFrom(route, "seda:a");
+ LoadBalanceDefinition loadBalance = assertOneProcessorInstanceOf(LoadBalanceDefinition.class, route);
+ assertEquals("Here should have 3 output here", 3, loadBalance.getOutputs().size());
+ assertTrue("The loadBalancer shoud be FailoverLoadBalancerDefinition", loadBalance.getLoadBalancerType() instanceof FailoverLoadBalancerDefinition);
+ FailoverLoadBalancerDefinition strategy = (FailoverLoadBalancerDefinition)loadBalance.getLoadBalancerType();
+ assertEquals("there should be 2 exceptions", 2, strategy.getExceptions().size());
+ }
+
+ public void testParseRandomLoadBalance() throws Exception {
+ RouteDefinition route = assertOneRoute("routeWithRandomLoadBalance.xml");
+ assertFrom(route, "seda:a");
+ LoadBalanceDefinition loadBalance = assertOneProcessorInstanceOf(LoadBalanceDefinition.class, route);
+ assertEquals("Here should have 3 output here", 3, loadBalance.getOutputs().size());
+ assertTrue("The loadBalancer shoud be RandomLoadBalancerDefinition", loadBalance.getLoadBalancerType() instanceof RandomLoadBalancerDefinition);
+ }
+
+ public void testParseTopicLoadBalance() throws Exception {
+ RouteDefinition route = assertOneRoute("routeWithTopicLoadBalance.xml");
+ assertFrom(route, "seda:a");
+ LoadBalanceDefinition loadBalance = assertOneProcessorInstanceOf(LoadBalanceDefinition.class, route);
+ assertEquals("Here should have 3 output here", 3, loadBalance.getOutputs().size());
+ assertTrue("The loadBalancer shoud be TopicLoadBalancerDefinition", loadBalance.getLoadBalancerType() instanceof TopicLoadBalancerDefinition);
+ }
+
public void testParseBatchResequencerXml() throws Exception {
RouteDefinition route = assertOneRoute("resequencerBatch.xml");
ResequenceDefinition resequencer = assertOneProcessorInstanceOf(ResequenceDefinition.class, route);
Copied: camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithFailoverLoadBalance.xml (from r816135, camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithStickyLoadBalance.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithFailoverLoadBalance.xml?p2=camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithFailoverLoadBalance.xml&p1=camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithStickyLoadBalance.xml&r1=816135&r2=816171&rev=816171&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithStickyLoadBalance.xml (original)
+++ camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithFailoverLoadBalance.xml Thu Sep 17 12:44:25 2009
@@ -16,17 +16,16 @@
limitations under the License.
-->
<routes id="camel" xmlns="http://camel.apache.org/schema/spring">
- <route>
- <from uri="seda:a"/>
- <loadBalance>
- <sticky>
- <correlationExpression>
- <language language="juel">in.header.foo == 'bar'</language>
- </correlationExpression>
- </sticky>
- <to uri="seda:b"/>
- <to uri="seda:c"/>
- <to uri="seda:d"/>
- </loadBalance>
- </route>
+ <route>
+ <from uri="seda:a"/>
+ <loadBalance>
+ <failover>
+ <exception>java.io.IOException</exception>
+ <exception>java.text.ParseException</exception>
+ </failover>
+ <to uri="seda:b"/>
+ <to uri="seda:c"/>
+ <to uri="seda:d"/>
+ </loadBalance>
+ </route>
</routes>
Added: camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithRandomLoadBalance.xml
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithRandomLoadBalance.xml?rev=816171&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithRandomLoadBalance.xml (added)
+++ camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithRandomLoadBalance.xml Thu Sep 17 12:44:25 2009
@@ -0,0 +1,28 @@
+<?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.
+-->
+<routes id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <loadBalance>
+ <random/>
+ <to uri="seda:b"/>
+ <to uri="seda:c"/>
+ <to uri="seda:d"/>
+ </loadBalance>
+ </route>
+</routes>
Propchange: camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithRandomLoadBalance.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithRandomLoadBalance.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithRandomLoadBalance.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithTopicLoadBalance.xml
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithTopicLoadBalance.xml?rev=816171&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithTopicLoadBalance.xml (added)
+++ camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithTopicLoadBalance.xml Thu Sep 17 12:44:25 2009
@@ -0,0 +1,28 @@
+<?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.
+-->
+<routes id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <loadBalance>
+ <topic/>
+ <to uri="seda:b"/>
+ <to uri="seda:c"/>
+ <to uri="seda:d"/>
+ </loadBalance>
+ </route>
+</routes>
Propchange: camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithTopicLoadBalance.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithTopicLoadBalance.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/camel-core/src/test/resources/org/apache/camel/model/routeWithTopicLoadBalance.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml