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/11/24 08:44:43 UTC
svn commit: r883614 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/builder/xml/
camel-core/src/main/java/org/apache/camel/model/
camel-core/src/main/java/org/apache/camel/processor/
camel-core/src/main/resources/org/apache/camel/model/ ca...
Author: davsclaus
Date: Tue Nov 24 07:44:42 2009
New Revision: 883614
URL: http://svn.apache.org/viewvc?rev=883614&view=rev
Log:
CAMEL-2206: Added new Sampler EIP. Thanks to Stephen Gargan for the contribution.
Added:
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/TimeUnitAdapter.java (with props)
camel/trunk/camel-core/src/main/java/org/apache/camel/model/SamplingDefinition.java (with props)
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java (with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java (with props)
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerTest.java (with props)
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerWithDefaultTest.java (with props)
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottler.xml (with props)
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottlerWithDefault.xml (with props)
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
Added: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/TimeUnitAdapter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/TimeUnitAdapter.java?rev=883614&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/TimeUnitAdapter.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/TimeUnitAdapter.java Tue Nov 24 07:44:42 2009
@@ -0,0 +1,47 @@
+/**
+ * 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.builder.xml;
+
+import java.util.concurrent.TimeUnit;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * <code>TimeUnitAdapter</code> is a simple adapter to convert between Strings
+ * and instances of the {@link TimeUnit} enumeration
+ */
+public class TimeUnitAdapter extends XmlAdapter<String, TimeUnit> {
+
+ @Override
+ public String marshal(TimeUnit v) throws Exception {
+ String result = null;
+ if (v != null) {
+ result = v.toString();
+ }
+ return result;
+ }
+
+ @Override
+ public TimeUnit unmarshal(String v) throws Exception {
+ TimeUnit result = null;
+ if (v != null) {
+ result = TimeUnit.valueOf(v.toUpperCase());
+ }
+ return result;
+ }
+
+}
Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/TimeUnitAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/TimeUnitAdapter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=883614&r1=883613&r2=883614&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Tue Nov 24 07:44:42 2009
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -1137,6 +1138,39 @@
}
/**
+ * <a href="http://camel.apache.org/sampling.html">Sampling Throttler</a>
+ * Creates a sampling throttler allowing you to extract a sample of
+ * exchanges from the traffic on a route. It is configured with a sampling
+ * period, during which only a single exchange is allowed to pass through.
+ * All other exchanges will be stopped.
+ * <p/>
+ * Default period is one second.
+ *
+ * @return the builder
+ */
+ public SamplingDefinition sample() {
+ return sample(1, TimeUnit.SECONDS);
+ }
+
+ /**
+ * <a href="http://camel.apache.org/sampling.html">Sampling Throttler</a>
+ * Creates a sampling throttler allowing you to extract a sample of exchanges
+ * from the traffic through a route. It is configured with a sampling period
+ * during which only a single exchange is allowed to pass through.
+ * All other exchanges will be stopped.
+ *
+ * @param samplePeriod this is the sample interval, only one exchange is
+ * allowed through in this interval
+ * @param unit this is the units for the samplePeriod e.g. Seconds
+ * @return the builder
+ */
+ public SamplingDefinition sample(long samplePeriod, TimeUnit unit) {
+ SamplingDefinition answer = new SamplingDefinition(samplePeriod, unit);
+ addOutput(answer);
+ return answer;
+ }
+
+ /**
* <a href="http://camel.apache.org/splitter.html">Splitter EIP:</a>
* Creates a splitter allowing you split a message into a number of pieces and process them individually.
* <p>
Added: camel/trunk/camel-core/src/main/java/org/apache/camel/model/SamplingDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SamplingDefinition.java?rev=883614&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/SamplingDefinition.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/SamplingDefinition.java Tue Nov 24 07:44:42 2009
@@ -0,0 +1,138 @@
+/**
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.camel.Processor;
+import org.apache.camel.builder.xml.TimeUnitAdapter;
+import org.apache.camel.processor.SamplingThrottler;
+import org.apache.camel.spi.RouteContext;
+
+/**
+ * Represents an XML <sample/> element
+ *
+ * @version $Revision$
+ */
+@XmlRootElement(name = "sample")
+@XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unchecked")
+public class SamplingDefinition extends ProcessorDefinition<ProcessorDefinition> {
+
+ // use Long to let it be optional in JAXB so when using XML the default is 1 second
+
+ @XmlAttribute()
+ private Long samplePeriod = 1L;
+
+ @XmlAttribute()
+ @XmlJavaTypeAdapter(TimeUnitAdapter.class)
+ private TimeUnit units = TimeUnit.SECONDS;
+
+ @XmlElementRef
+ private List<ProcessorDefinition> outputs = new ArrayList<ProcessorDefinition>();
+
+ public SamplingDefinition() {
+ }
+
+ public SamplingDefinition(long samplePeriod, TimeUnit units) {
+ this.samplePeriod = samplePeriod;
+ this.units = units;
+ }
+
+ @Override
+ public String toString() {
+ return "Sample[1 Exchange per " + samplePeriod + " " + units.toString().toLowerCase() + " -> " + getOutputs() + "]";
+ }
+
+ @Override
+ public String getShortName() {
+ return "sample";
+ }
+
+ @Override
+ public String getLabel() {
+ return "sample[1 Exchange per " + samplePeriod + " " + units.toString().toLowerCase() + "]";
+ }
+
+ @Override
+ public Processor createProcessor(RouteContext routeContext) throws Exception {
+ Processor childProcessor = routeContext.createProcessor(this);
+ return new SamplingThrottler(childProcessor, samplePeriod, units);
+ }
+
+ // Fluent API
+ // -------------------------------------------------------------------------
+
+ /**
+ * Sets the sample period during which only a single {@link org.apache.camel.Exchange} will pass through.
+ *
+ * @param samplePeriod the period
+ * @return the builder
+ */
+ public SamplingDefinition samplePeriod(long samplePeriod) {
+ setSamplePeriod(samplePeriod);
+ return this;
+ }
+
+ /**
+ * Sets the time units for the sample period, defaulting to seconds.
+ *
+ * @param units the time unit of the sample period.
+ * @return the builder
+ */
+ public SamplingDefinition timeUnits(TimeUnit units) {
+ setUnits(units);
+ return this;
+ }
+
+ // Properties
+ // -------------------------------------------------------------------------
+
+ public List<ProcessorDefinition> getOutputs() {
+ return outputs;
+ }
+
+ public void setOutputs(List<ProcessorDefinition> outputs) {
+ this.outputs = outputs;
+ }
+
+ public long getSamplePeriod() {
+ return samplePeriod;
+ }
+
+ public void setSamplePeriod(long samplePeriod) {
+ this.samplePeriod = samplePeriod;
+ }
+
+ public void setUnits(String units) {
+ this.units = TimeUnit.valueOf(units);
+ }
+
+ public void setUnits(TimeUnit units) {
+ this.units = units;
+ }
+
+}
Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/model/SamplingDefinition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/model/SamplingDefinition.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java?rev=883614&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java Tue Nov 24 07:44:42 2009
@@ -0,0 +1,129 @@
+/**
+ * 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 static java.lang.String.format;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A <code>SamplingThrottler</code> is a special kind of throttler. It also
+ * limits the number of exchanges sent to a downstream endpoint. It differs from
+ * a normal throttler in that it will not queue exchanges above the threshold
+ * for a given period. Instead these exchanges will be stopped, precluding them
+ * from being processed at all by downstream consumers.
+ * <p/>
+ * This kind of throttling can be useful for taking a sample from
+ * an exchange stream, rough consolidation of noisy and bursty exchange traffic
+ * or where queuing of throttled exchanges is undesirable.
+ *
+ * @version $Revision$
+ */
+public class SamplingThrottler extends DelegateProcessor {
+ protected final transient Log log = LogFactory.getLog(getClass());
+ private long samplePeriod;
+ private long periodInNanos;
+ private TimeUnit units;
+ private long timeOfLastExchange;
+ private StopProcessor stopper = new StopProcessor();
+ private Object calculationLock = new Object();
+ private SampleStats sampled = new SampleStats();
+
+ public SamplingThrottler(Processor processor, long samplePeriod, TimeUnit units) {
+ super(processor);
+
+ if (samplePeriod <= 0) {
+ throw new IllegalArgumentException("A positive value is required for the sampling period");
+ }
+ if (units == null) {
+ throw new IllegalArgumentException("A invalid null value was supplied for the units of the sampling period");
+ }
+ this.samplePeriod = samplePeriod;
+ this.units = units;
+ periodInNanos = units.toNanos(samplePeriod);
+ }
+
+ @Override
+ public String toString() {
+ return "SamplingThrottler[1 exchange per: " + samplePeriod + " " + units.toString().toLowerCase() + " -> " + getProcessor() + "]";
+ }
+
+ public String getTraceLabel() {
+ return "samplingThrottler[1 exchange per: " + samplePeriod + " " + units.toString().toLowerCase() + "]";
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ boolean doSend = false;
+
+ synchronized (calculationLock) {
+ long now = System.nanoTime();
+ if (now >= timeOfLastExchange + periodInNanos) {
+ doSend = true;
+ if (log.isTraceEnabled()) {
+ log.trace(sampled.sample());
+ }
+ timeOfLastExchange = now;
+ } else {
+ if (log.isTraceEnabled()) {
+ log.trace(sampled.drop());
+ }
+ }
+ }
+
+ if (doSend) {
+ super.process(exchange);
+ } else {
+ stopper.process(exchange);
+ }
+ }
+
+ private static class SampleStats {
+ private long droppedThisPeriod;
+ private long totalDropped;
+ private long totalSampled;
+ private long totalThisPeriod;
+
+ String drop() {
+ droppedThisPeriod++;
+ totalThisPeriod++;
+ totalDropped++;
+ return getDroppedLog();
+ }
+
+ String sample() {
+ totalThisPeriod = 1; // a new period, reset to 1
+ totalSampled++;
+ droppedThisPeriod = 0;
+ return getSampledLog();
+ }
+
+ String getSampledLog() {
+ return format("Sampled %d of %d total exchanges", totalSampled, totalSampled + totalDropped);
+ }
+
+ String getDroppedLog() {
+ return format("Dropped %d of %d exchanges in this period, totalling %d dropped of %d exchanges overall.",
+ droppedThisPeriod, totalThisPeriod, totalDropped, totalSampled + totalDropped);
+ }
+ }
+
+}
Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index?rev=883614&r1=883613&r2=883614&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index (original)
+++ camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index Tue Nov 24 07:44:42 2009
@@ -58,6 +58,7 @@
RouteDefinition
RoutesDefinition
RoutingSlipDefinition
+SamplingDefinition
SetBodyDefinition
SetExchangePatternDefinition
SetHeaderDefinition
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java?rev=883614&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java Tue Nov 24 07:44:42 2009
@@ -0,0 +1,123 @@
+/**
+ * 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.direct.DirectEndpoint;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class SamplingThrottlerTest extends ContextTestSupport {
+
+ public void testSamplingFromExchangeStream() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(2);
+ mock.setResultWaitTime(3000);
+
+ List<Exchange> sentExchanges = new ArrayList<Exchange>();
+ sendExchangesThroughDroppingThrottler(sentExchanges, 15);
+
+ mock.assertIsSatisfied();
+ validateDroppedExchanges(sentExchanges, 2);
+ }
+
+ public void testBurstySampling() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(2);
+ mock.setResultWaitTime(3000);
+
+ List<Exchange> sentExchanges = new ArrayList<Exchange>();
+
+ // send a burst of 5 exchanges, expecting only one to get through
+ sendExchangesThroughDroppingThrottler(sentExchanges, 5);
+ // sleep through a complete period
+ Thread.sleep(1100);
+ // send another 5 now
+ sendExchangesThroughDroppingThrottler(sentExchanges, 5);
+
+ mock.assertIsSatisfied();
+ validateDroppedExchanges(sentExchanges, 2);
+ }
+
+ public void testSendLotsOfMessagesSimultaneouslyButOnly3GetThrough() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(3);
+ mock.setResultWaitTime(4000);
+
+ final List<Exchange> sentExchanges = Collections.synchronizedList(new ArrayList<Exchange>());
+ ExecutorService executor = Executors.newFixedThreadPool(5);
+ for (int i = 0; i < 5; i++) {
+ executor.execute(new Runnable() {
+ public void run() {
+ try {
+ sendExchangesThroughDroppingThrottler(sentExchanges, 35);
+ } catch (InterruptedException e) {}
+ }
+ });
+ }
+
+ mock.assertIsSatisfied();
+ }
+
+ private void sendExchangesThroughDroppingThrottler(List<Exchange> sentExchanges, int messages) throws InterruptedException {
+ DirectEndpoint targetEndpoint = resolveMandatoryEndpoint("direct:sample", DirectEndpoint.class);
+ for (int i = 0; i < messages; i++) {
+ Exchange e = targetEndpoint.createExchange();
+ e.getIn().setBody("<message>" + i + "</message>");
+ template.send(targetEndpoint, e);
+ sentExchanges.add(e);
+ Thread.sleep(100);
+ }
+ }
+
+ private void validateDroppedExchanges(List<Exchange> sentExchanges, int expectedNotDroppedCount) {
+ int notDropped = 0;
+ for (Exchange e : sentExchanges) {
+ Boolean stopped = e.getProperty(Exchange.ROUTE_STOP, Boolean.class);
+ if (stopped == null) {
+ notDropped++;
+ }
+ }
+ assertEquals(expectedNotDroppedCount, notDropped);
+ }
+
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ // START SNIPPET: e1
+ from("direct:sample").sample().to("mock:result");
+
+ from("direct:sample-configured").sample(1, TimeUnit.SECONDS).to("mock:result");
+
+ from("direct:sample-configured-via-dsl").sample().samplePeriod(1).timeUnits(TimeUnit.SECONDS).to("mock:result");
+ // END SNIPPET: e1
+ }
+ };
+ }
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerTest.java?rev=883614&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerTest.java Tue Nov 24 07:44:42 2009
@@ -0,0 +1,30 @@
+/**
+ * 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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.SamplingThrottlerTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringSamplingThrottlerTest extends SamplingThrottlerTest {
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this, "org/apache/camel/spring/processor/samplingThrottler.xml");
+ }
+
+}
Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerWithDefaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerWithDefaultTest.java?rev=883614&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerWithDefaultTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerWithDefaultTest.java Tue Nov 24 07:44:42 2009
@@ -0,0 +1,30 @@
+/**
+ * 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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.SamplingThrottlerTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringSamplingThrottlerWithDefaultTest extends SamplingThrottlerTest {
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this, "org/apache/camel/spring/processor/samplingThrottler.xml");
+ }
+
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerWithDefaultTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSamplingThrottlerWithDefaultTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottler.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottler.xml?rev=883614&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottler.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottler.xml Tue Nov 24 07:44:42 2009
@@ -0,0 +1,37 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <!-- START SNIPPET: e1 -->
+ <route>
+ <from uri="direct:sample"/>
+ <sample samplePeriod="1" units="seconds">
+ <to uri="mock:result"/>
+ </sample>
+ </route>
+ <!-- END SNIPPET: e1 -->
+
+ </camelContext>
+
+</beans>
Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottler.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottler.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottler.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottlerWithDefault.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottlerWithDefault.xml?rev=883614&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottlerWithDefault.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottlerWithDefault.xml Tue Nov 24 07:44:42 2009
@@ -0,0 +1,38 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <!-- START SNIPPET: e1 -->
+ <route>
+ <from uri="direct:sample"/>
+ <!-- will by default use 1 second period -->
+ <sample>
+ <to uri="mock:result"/>
+ </sample>
+ </route>
+ <!-- END SNIPPET: e1 -->
+
+ </camelContext>
+
+</beans>
Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottlerWithDefault.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottlerWithDefault.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottlerWithDefault.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml