Class DataSetTestEndpoint

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultEndpoint
org.apache.camel.component.mock.MockEndpoint
org.apache.camel.component.dataset.DataSetTestEndpoint
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.ComponentAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.BrowsableEndpoint, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.HasId, org.apache.camel.spi.NotifyBuilderMatcher, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@UriEndpoint(firstVersion="1.3.0", scheme="dataset-test", title="DataSet Test", syntax="dataset-test:name", producerOnly=true, category={CORE,TESTING}, lenientProperties=true) public class DataSetTestEndpoint extends org.apache.camel.component.mock.MockEndpoint
Extends the mock component by pulling messages from another endpoint on startup to set the expected message bodies. That is, you use the test endpoint in a route and messages arriving on it will be implicitly compared to some expected messages extracted from some other location. So you can use, for example, an expected set of message bodies as files. This will then set up a properly configured Mock endpoint, which is only valid if the received messages match the number of expected messages and their message payloads are equal.
  • Field Summary

    Fields inherited from class org.apache.camel.component.mock.MockEndpoint

    reporter

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
    DataSetTestEndpoint(String endpointUri, org.apache.camel.Component component)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
     
    protected Object
    getInBody(org.apache.camel.Exchange exchange)
    This method allows us to convert or coerce the expected message body into some other type
    long
     
    boolean
     
    boolean
     
    void
    setAnyOrder(boolean anyOrder)
    Whether the expected messages should arrive in the same order or can be in any order.
    void
    setDelimiter(String delimiter)
    The split delimiter to use when split is enabled.
    void
    setExpectedMessageEndpoint(org.apache.camel.Endpoint expectedMessageEndpoint)
     
    void
    setSplit(boolean split)
    If enabled the messages loaded from the test endpoint will be split using new line delimiters so each line is an expected message.
    void
    setTimeout(long timeout)
    The timeout to use when polling for message bodies from the URI

    Methods inherited from class org.apache.camel.component.mock.MockEndpoint

    addReceivedExchange, allMessages, assertEquals, assertEquals, assertExchangeReceived, assertFalse, assertIsNotSatisfied, assertIsNotSatisfied, assertIsSatisfied, assertIsSatisfied, assertIsSatisfied, assertIsSatisfied, assertIsSatisfied, assertIsSatisfied, assertMessagesAscending, assertMessagesDescending, assertMessagesSorted, assertMessagesSorted, assertNoDuplicates, assertTrue, assertWait, await, await, createConsumer, createProducer, doAssertIsSatisfied, expectedBodiesReceived, expectedBodiesReceived, expectedBodiesReceivedInAnyOrder, expectedBodiesReceivedInAnyOrder, expectedBodyReceived, expectedExchangePattern, expectedFileExists, expectedFileExists, expectedFileExists, expectedFileExists, expectedHeaderReceived, expectedHeaderValuesReceivedInAnyOrder, expectedHeaderValuesReceivedInAnyOrder, expectedMessageCount, expectedMessagesMatches, expectedMinimumMessageCount, expectedNoHeaderReceived, expectedPropertyReceived, expectedPropertyValuesReceivedInAnyOrder, expectedPropertyValuesReceivedInAnyOrder, expects, expectsAscending, expectsAscending, expectsDescending, expectsDescending, expectsMessageCount, expectsNoDuplicates, expectsNoDuplicates, fail, getAssertPeriod, getComponent, getExchanges, getExpectedCount, getExpectedMinimumCount, getFailures, getName, getReceivedCounter, getReceivedExchanges, getReporter, getReportGroup, getResultMinimumWaitTime, getResultWaitTime, getRetainFirst, getRetainLast, getSleepForEmptyTest, handle, isCopyOnExchange, isFailFast, isLenientProperties, isLog, message, notifyBuilderMatches, notifyBuilderOnExchange, notifyBuilderReset, onExchange, performAssertions, reset, resetMocks, resolve, returnReplyBody, returnReplyHeader, setAssertPeriod, setAssertPeriod, setCopyOnExchange, setExpectedCount, setExpectedMessageCount, setFailFast, setLog, setMinimumExpectedMessageCount, setName, setReporter, setReportGroup, setResultMinimumWaitTime, setResultWaitTime, setRetainFirst, setRetainLast, setSleepForEmptyTest, waitForCompleteLatch, waitForCompleteLatch, whenAnyExchangeReceived, whenExchangeReceived

    Methods inherited from class org.apache.camel.support.DefaultEndpoint

    configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, equals, getCamelContext, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doStop, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.camel.ComponentAware

    getComponent, setComponent

    Methods inherited from interface org.apache.camel.Endpoint

    configureExchange, configureProperties, createAsyncProducer, createExchange, createExchange, createPollingConsumer, getCamelContext, getEndpointBaseUri, getEndpointKey, getEndpointUri, getExchangePattern, isSingletonProducer, setCamelContext

    Methods inherited from interface org.apache.camel.IsSingleton

    isSingleton

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Constructor Details

    • DataSetTestEndpoint

      public DataSetTestEndpoint(String endpointUri, org.apache.camel.Component component)
  • Method Details

    • setExpectedMessageEndpoint

      public void setExpectedMessageEndpoint(org.apache.camel.Endpoint expectedMessageEndpoint)
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • getInBody

      protected Object getInBody(org.apache.camel.Exchange exchange)
      This method allows us to convert or coerce the expected message body into some other type
    • getTimeout

      public long getTimeout()
    • setTimeout

      public void setTimeout(long timeout)
      The timeout to use when polling for message bodies from the URI
    • isAnyOrder

      public boolean isAnyOrder()
    • setAnyOrder

      public void setAnyOrder(boolean anyOrder)
      Whether the expected messages should arrive in the same order or can be in any order.
    • isSplit

      public boolean isSplit()
    • setSplit

      public void setSplit(boolean split)
      If enabled the messages loaded from the test endpoint will be split using new line delimiters so each line is an expected message.
      For example to use a file endpoint to load a file where each line is an expected message.
    • getDelimiter

      public String getDelimiter()
    • setDelimiter

      public void setDelimiter(String delimiter)
      The split delimiter to use when split is enabled. By default the delimiter is new line based. The delimiter can be a regular expression.