---
apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ConfigMap
  metadata:
    labels:
      funktion.fabric8.io/kind: Connector
      provider: fabric8
      project: connector-test
      version: 1.1.9
      group: io.fabric8.funktion.connector
    name: test
  data:
    deployment.yml: |
      ---
      apiVersion: extensions/v1beta1
      kind: Deployment
      metadata:
        labels:
          funktion.fabric8.io/kind: Subscription
          connector: test
      spec:
        replicas: 1
        template:
          metadata:
            labels:
              funktion.fabric8.io/kind: Subscription
              connector: test
          spec:
            containers:
            - image: fabric8/connector-test:1.1.9
              name: connector
    schema.yml: |
      ---
      component:
        kind: component
        scheme: test
        syntax: test:name
        title: Test
        description: The test component extends the mock component by on startup to pull messages from another endpoint to set the expected message bodies.
        label: core,testing
        deprecated: false
        async: false
        producerOnly: true
        lenientProperties: true
        javaType: org.apache.camel.component.test.TestComponent
        groupId: org.apache.camel
        artifactId: camel-core
        version: 2.18.1
      componentProperties: {}
      properties:
        name:
          kind: path
          group: producer
          required: true
          type: string
          javaType: java.lang.String
          deprecated: false
          secret: false
          description: Name of endpoint to lookup in the registry to use for polling messages used for testing
        anyOrder:
          kind: parameter
          group: producer
          type: boolean
          javaType: boolean
          deprecated: false
          secret: false
          defaultValue: false
          description: Whether the expected messages should arrive in the same order or can be in any order.
        assertPeriod:
          kind: parameter
          group: producer
          label: producer
          type: integer
          javaType: long
          deprecated: false
          secret: false
          defaultValue: "0"
          description: Sets a grace period after which the mock endpoint will re-assert to ensure the preliminary assertion is still valid. This is used for example to assert that exactly a number of messages arrives. For example if link expectedMessageCount(int) was set to 5 then the assertion is satisfied when 5 or more message arrives. To ensure that exactly 5 messages arrives then you would need to wait a little period to ensure no further message arrives. This is what you can use this link setAssertPeriod(long) method for. By default this period is disabled.
        delimiter:
          kind: parameter
          group: producer
          type: string
          javaType: java.lang.String
          deprecated: false
          secret: false
          description: The split delimiter to use when split is enabled. By default the delimiter is new line based. The delimiter can be a regular expression.
        expectedCount:
          kind: parameter
          group: producer
          label: producer
          type: integer
          javaType: int
          deprecated: false
          secret: false
          defaultValue: -1
          description: 'Specifies the expected number of message exchanges that should be
            received by this endpoint. Beware: If you want to expect that 0 messages then
            take extra care as 0 matches when the tests starts so you need to set a assert
            period time to let the test run for a while to make sure there are still no
            messages arrived; for that use link setAssertPeriod(long). An alternative is
            to use NotifyBuilder and use the notifier to know when Camel is done routing
            some messages before you call the link assertIsSatisfied() method on the mocks.
            This allows you to not use a fixed assert period to speedup testing times. If
            you want to assert that exactly n''th message arrives to this mock endpoint
            then see also the link setAssertPeriod(long) method for further details.'
        reportGroup:
          kind: parameter
          group: producer
          label: producer
          type: integer
          javaType: int
          deprecated: false
          secret: false
          description: A number that is used to turn on throughput logging based on groups of the size.
        resultMinimumWaitTime:
          kind: parameter
          group: producer
          label: producer
          type: integer
          javaType: long
          deprecated: false
          secret: false
          defaultValue: "0"
          description: Sets the minimum expected amount of time (in millis) the link assertIsSatisfied() will wait on a latch until it is satisfied
        resultWaitTime:
          kind: parameter
          group: producer
          label: producer
          type: integer
          javaType: long
          deprecated: false
          secret: false
          defaultValue: "0"
          description: Sets the maximum amount of time (in millis) the link assertIsSatisfied() will wait on a latch until it is satisfied
        retainFirst:
          kind: parameter
          group: producer
          label: producer
          type: integer
          javaType: int
          deprecated: false
          secret: false
          defaultValue: -1
          description: 'Specifies to only retain the first n''th number of received Exchanges.
            This is used when testing with big data to reduce memory consumption by not
            storing copies of every Exchange this mock endpoint receives. Important: When
            using this limitation then the link getReceivedCounter() will still return the
            actual number of received Exchanges. For example if we have received 5000 Exchanges
            and have configured to only retain the first 10 Exchanges then the link getReceivedCounter()
            will still return 5000 but there is only the first 10 Exchanges in the link
            getExchanges() and link getReceivedExchanges() methods. When using this method
            then some of the other expectation methods is not supported for example the
            link expectedBodiesReceived(Object...) sets a expectation on the first number
            of bodies received. You can configure both link setRetainFirst(int) and link
            setRetainLast(int) methods to limit both the first and last received.'
        retainLast:
          kind: parameter
          group: producer
          label: producer
          type: integer
          javaType: int
          deprecated: false
          secret: false
          defaultValue: -1
          description: 'Specifies to only retain the last n''th number of received Exchanges.
            This is used when testing with big data to reduce memory consumption by not
            storing copies of every Exchange this mock endpoint receives. Important: When
            using this limitation then the link getReceivedCounter() will still return the
            actual number of received Exchanges. For example if we have received 5000 Exchanges
            and have configured to only retain the last 20 Exchanges then the link getReceivedCounter()
            will still return 5000 but there is only the last 20 Exchanges in the link getExchanges()
            and link getReceivedExchanges() methods. When using this method then some of
            the other expectation methods is not supported for example the link expectedBodiesReceived(Object...)
            sets a expectation on the first number of bodies received. You can configure
            both link setRetainFirst(int) and link setRetainLast(int) methods to limit both
            the first and last received.'
        sleepForEmptyTest:
          kind: parameter
          group: producer
          label: producer
          type: integer
          javaType: long
          deprecated: false
          secret: false
          defaultValue: "0"
          description: Allows a sleep to be specified to wait to check that this endpoint really is empty when link expectedMessageCount(int) is called with zero
        split:
          kind: parameter
          group: producer
          type: boolean
          javaType: boolean
          deprecated: false
          secret: false
          defaultValue: false
          description: "If enabled the the messages loaded from the test endpoint will be\
            \ split using \n\r delimiters (new lines) 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."
        timeout:
          kind: parameter
          group: producer
          type: integer
          javaType: long
          deprecated: false
          secret: false
          defaultValue: "2000"
          description: The timeout to use when polling for message bodies from the URI
        copyOnExchange:
          kind: parameter
          group: producer (advanced)
          label: producer,advanced
          type: boolean
          javaType: boolean
          deprecated: false
          secret: false
          defaultValue: true
          description: Sets whether to make a deep copy of the incoming Exchange when received at this mock endpoint. Is by default true.
        synchronous:
          kind: parameter
          group: advanced
          label: advanced
          type: boolean
          javaType: boolean
          deprecated: false
          secret: false
          defaultValue: false
          description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
    documentation.adoc: |+
      [[Test-TestComponent]]
      Test Component
      ~~~~~~~~~~~~~~

      link:testing.html[Testing] of distributed and asynchronous processing is
      notoriously difficult. The link:mock.html[Mock], link:test.html[Test]
      and link:dataset.html[DataSet] endpoints work great with the
      link:testing.html[Camel Testing Framework] to simplify your unit and
      integration testing using
      link:enterprise-integration-patterns.html[Enterprise Integration
      Patterns] and Camel's large range of link:components.html[Components]
      together with the powerful link:bean-integration.html[Bean Integration].

      The *test* component extends the link:mock.html[Mock] component to
      support pulling messages from another endpoint on startup to set the
      expected message bodies on the underlying link:mock.html[Mock] endpoint.
      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 link:mock.html[Mock]
      endpoint, which is only valid if the received messages match the number
      of expected messages and their message payloads are equal.

      Maven users will need to add the following dependency to their `pom.xml`
      for this component when using *Camel 2.8* or older:

      [source,xml]
      ------------------------------------------------------------
      <dependency>
          <groupId>org.apache.camel</groupId>
          <artifactId>camel-spring</artifactId>
          <version>x.x.x</version>
          <!-- use the same version as your Camel core version -->
      </dependency>
      ------------------------------------------------------------

      From Camel 2.9 onwards the link:test.html[Test] component is provided
      directly in the camel-core.

      [[Test-URIformat]]
      URI format
      ^^^^^^^^^^

      [source,java]
      --------------------------------
      test:expectedMessagesEndpointUri
      --------------------------------

      Where *expectedMessagesEndpointUri* refers to some other
      link:component.html[Component] URI that the expected message bodies are
      pulled from before starting the test.

      [[Test-URIOptions]]
      URI Options
      ^^^^^^^^^^^

      // component options: START
      The Test component has no options.
      // component options: END


      // endpoint options: START
      The Test component supports 15 endpoint options which are listed below:

      {% raw %}
      [width="100%",cols="2,1,1m,1m,5",options="header"]
      |=======================================================================
      | Name | Group | Default | Java Type | Description
      | name | producer |  | String | *Required* Name of endpoint to lookup in the registry to use for polling messages used for testing
      | anyOrder | producer | false | boolean | Whether the expected messages should arrive in the same order or can be in any order.
      | assertPeriod | producer | 0 | long | Sets a grace period after which the mock endpoint will re-assert to ensure the preliminary assertion is still valid. This is used for example to assert that exactly a number of messages arrives. For example if link expectedMessageCount(int) was set to 5 then the assertion is satisfied when 5 or more message arrives. To ensure that exactly 5 messages arrives then you would need to wait a little period to ensure no further message arrives. This is what you can use this link setAssertPeriod(long) method for. By default this period is disabled.
      | delimiter | producer |  | String | The split delimiter to use when split is enabled. By default the delimiter is new line based. The delimiter can be a regular expression.
      | expectedCount | producer | -1 | int | Specifies the expected number of message exchanges that should be received by this endpoint. Beware: If you want to expect that 0 messages then take extra care as 0 matches when the tests starts so you need to set a assert period time to let the test run for a while to make sure there are still no messages arrived; for that use link setAssertPeriod(long). An alternative is to use NotifyBuilder and use the notifier to know when Camel is done routing some messages before you call the link assertIsSatisfied() method on the mocks. This allows you to not use a fixed assert period to speedup testing times. If you want to assert that exactly n'th message arrives to this mock endpoint then see also the link setAssertPeriod(long) method for further details.
      | reportGroup | producer |  | int | A number that is used to turn on throughput logging based on groups of the size.
      | resultMinimumWaitTime | producer | 0 | long | Sets the minimum expected amount of time (in millis) the link assertIsSatisfied() will wait on a latch until it is satisfied
      | resultWaitTime | producer | 0 | long | Sets the maximum amount of time (in millis) the link assertIsSatisfied() will wait on a latch until it is satisfied
      | retainFirst | producer | -1 | int | Specifies to only retain the first n'th number of received Exchanges. This is used when testing with big data to reduce memory consumption by not storing copies of every Exchange this mock endpoint receives. Important: When using this limitation then the link getReceivedCounter() will still return the actual number of received Exchanges. For example if we have received 5000 Exchanges and have configured to only retain the first 10 Exchanges then the link getReceivedCounter() will still return 5000 but there is only the first 10 Exchanges in the link getExchanges() and link getReceivedExchanges() methods. When using this method then some of the other expectation methods is not supported for example the link expectedBodiesReceived(Object...) sets a expectation on the first number of bodies received. You can configure both link setRetainFirst(int) and link setRetainLast(int) methods to limit both the first and last received.
      | retainLast | producer | -1 | int | Specifies to only retain the last n'th number of received Exchanges. This is used when testing with big data to reduce memory consumption by not storing copies of every Exchange this mock endpoint receives. Important: When using this limitation then the link getReceivedCounter() will still return the actual number of received Exchanges. For example if we have received 5000 Exchanges and have configured to only retain the last 20 Exchanges then the link getReceivedCounter() will still return 5000 but there is only the last 20 Exchanges in the link getExchanges() and link getReceivedExchanges() methods. When using this method then some of the other expectation methods is not supported for example the link expectedBodiesReceived(Object...) sets a expectation on the first number of bodies received. You can configure both link setRetainFirst(int) and link setRetainLast(int) methods to limit both the first and last received.
      | sleepForEmptyTest | producer | 0 | long | Allows a sleep to be specified to wait to check that this endpoint really is empty when link expectedMessageCount(int) is called with zero
      | split | producer | false | boolean | If enabled the the messages loaded from the test endpoint will be split using \n\r delimiters (new lines) 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.
      | timeout | producer | 2000 | long | The timeout to use when polling for message bodies from the URI
      | copyOnExchange | producer (advanced) | true | boolean | Sets whether to make a deep copy of the incoming Exchange when received at this mock endpoint. Is by default true.
      | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
      |=======================================================================
      {% endraw %}
      // endpoint options: END


      [[Test-Example]]
      Example
      ^^^^^^^

      For example, you could write a test case as follows:

      [source,java]
      --------------------------------------------------
      from("seda:someEndpoint").
        to("test:file://data/expectedOutput?noop=true");
      --------------------------------------------------

      If your test then invokes the
      http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#assertIsSatisfied(org.apache.camel.CamelContext)[MockEndpoint.assertIsSatisfied(camelContext)
      method], your test case will perform the necessary assertions.

      To see how you can set other expectations on the test endpoint, see the
      link:mock.html[Mock] component.

      [[Test-SeeAlso]]
      See Also
      ^^^^^^^^

      * link:configuring-camel.html[Configuring Camel]
      * link:component.html[Component]
      * link:endpoint.html[Endpoint]
      * link:getting-started.html[Getting Started]

      * link:spring-testing.html[Spring Testing]

