Author: davsclaus
Date: Sat Aug 8 15:06:19 2009
New Revision: 802388
URL: http://svn.apache.org/viewvc?rev=802388&view=rev
Log:
A bit more tuning unit tests
Added:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest.java
(with props)
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/RoutePojo.java
(with props)
camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tuning/
camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest-context.xml
- copied, changed from r802305,
camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpring.xml
Modified:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRouteTest.java
Added:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest.java?rev=802388&view=auto
==============================================================================
---
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest.java
(added)
+++
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest.java
Sat Aug 8 15:06:19 2009
@@ -0,0 +1,73 @@
+/**
+ * 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.jms.tuning;
+
+import org.apache.camel.test.CamelSpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class PerformanceRoutePojoTest extends CamelSpringTestSupport {
+
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new
ClassPathXmlApplicationContext("org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest-context.xml");
+ }
+
+ private int size = 200;
+
+ @Test
+ public void testPojoPerformance() throws Exception {
+ if (!canRunOnThisPlatform()) {
+ return;
+ }
+
+ long start = System.currentTimeMillis();
+
+ getMockEndpoint("mock:audit").expectedMessageCount(size);
+ getMockEndpoint("mock:audit").expectsNoDuplicates().body();
+
+ getMockEndpoint("mock:gold").expectedMessageCount((size / 2) - (size /
10));
+ getMockEndpoint("mock:silver").expectedMessageCount(size / 10);
+
+ for (int i = 0; i < size; i++) {
+ String type;
+ if (i % 10 == 0) {
+ type = "silver";
+ } else if (i % 2 == 0) {
+ type = "gold";
+ } else {
+ type = "bronze";
+ }
+ template.sendBodyAndHeader("activemq:queue:inbox", "Message " + i,
"type", type);
+ }
+
+ assertMockEndpointsSatisfied();
+
+ long delta = System.currentTimeMillis() - start;
+ System.out.println("RoutePerformancePojoTest: Sent: " + size + " Took:
" + delta + " ms");
+ }
+
+ private boolean canRunOnThisPlatform() {
+ String os = System.getProperty("os.name");
+ // HP-UX is just to slow to run this test
+ return !os.toLowerCase().contains("hp-ux");
+ }
+
+}
Propchange:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRouteTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRouteTest.java?rev=802388&r1=802387&r2=802388&view=diff
==============================================================================
---
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRouteTest.java
(original)
+++
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRouteTest.java
Sat Aug 8 15:06:19 2009
@@ -21,16 +21,16 @@
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
+import static
org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-import static
org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
/**
* @version $Revision$
*/
public class PerformanceRouteTest extends CamelTestSupport {
- private int size = 1000;
+ private int size = 200;
@Test
public void testPerformance() throws Exception {
@@ -46,7 +46,6 @@
getMockEndpoint("mock:gold").expectedMessageCount((size / 2) - (size /
10));
getMockEndpoint("mock:silver").expectedMessageCount(size / 10);
-
for (int i = 0; i < size; i++) {
String type;
if (i % 10 == 0) {
@@ -59,10 +58,10 @@
template.sendBodyAndHeader("activemq:queue:inbox", "Message " + i,
"type", type);
}
+ assertMockEndpointsSatisfied();
+
long delta = System.currentTimeMillis() - start;
System.out.println("RoutePerformanceTest: Sent: " + size + " Took: " +
delta + " ms");
-
- assertMockEndpointsSatisfied();
}
private boolean canRunOnThisPlatform() {
@@ -86,7 +85,7 @@
@Override
public void configure() throws Exception {
from("activemq:queue:inbox?concurrentConsumers=10")
- .wireTap("activemq:topic:audit")
+ .to("activemq:topic:audit")
.choice()
.when(header("type").isEqualTo("gold"))
.to("direct:gold")
@@ -100,11 +99,9 @@
.to("mock:gold");
from("direct:silver")
- .delay(5)
.to("mock:silver");
from("direct:bronze")
- .delay(10)
.to("mock:bronze");
from("activemq:topic:audit").to("mock:audit");
Added:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/RoutePojo.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/RoutePojo.java?rev=802388&view=auto
==============================================================================
---
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/RoutePojo.java
(added)
+++
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/RoutePojo.java
Sat Aug 8 15:06:19 2009
@@ -0,0 +1,41 @@
+/**
+ * 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.jms.tuning;
+
+import org.apache.camel.Consume;
+import org.apache.camel.Exchange;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.RecipientList;
+
+/**
+ * @version $Revision$
+ */
+public class RoutePojo {
+
+ @Produce(uri = "activemq:topic:audit")
+ private ProducerTemplate topic;
+
+ @Consume(uri = "activemq:queue:inbox?concurrentConsumers=10")
+ @RecipientList
+ public String listen(Exchange exchange) {
+ topic.send(exchange);
+
+ String type = exchange.getIn().getHeader("type", String.class);
+ return "direct:" + type;
+ }
+}
Propchange:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/RoutePojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/RoutePojo.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied:
camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest-context.xml
(from r802305,
camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpring.xml)
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest-context.xml?p2=camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest-context.xml&p1=camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpring.xml&r1=802305&r2=802388&rev=802388&view=diff
==============================================================================
---
camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpring.xml
(original)
+++
camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tuning/PerformanceRoutePojoTest-context.xml
Sat Aug 8 15:06:19 2009
@@ -22,17 +22,34 @@
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
">
- <!-- START SNIPPET: example -->
- <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
- </camelContext>
+ <bean id="pojo" class="org.apache.camel.component.jms.tuning.RoutePojo"/>
- <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
- <property name="connectionFactory">
- <bean class="org.apache.activemq.ActiveMQConnectionFactory">
- <property name="brokerURL"
value="vm://localhost?broker.persistent=false"/>
- </bean>
- </property>
- </bean>
- <!-- END SNIPPET: example -->
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="direct:gold"/>
+ <to uri="mock:gold"/>
+ </route>
+ <route>
+ <from uri="direct:silver"/>
+ <to uri="mock:silver"/>
+ </route>
+ <route>
+ <from uri="direct:bronze"/>
+ <to uri="mock:bronze"/>
+ </route>
+
+ <route>
+ <from uri="activemq:topic:audit"/>
+ <to uri="mock:audit"/>
+ </route>
+ </camelContext>
+
+ <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
+ <property name="connectionFactory">
+ <bean class="org.apache.activemq.ActiveMQConnectionFactory">
+ <property name="brokerURL"
value="vm://localhost?broker.persistent=false"/>
+ </bean>
+ </property>
+ </bean>
</beans>