Skip to content

Commit

Permalink
Add a basic test for pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Oct 23, 2024
1 parent a847c8b commit e56bd90
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 3 deletions.
17 changes: 17 additions & 0 deletions integration-tests/kamelet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-xml-io-dsl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-yaml-dsl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-seda</artifactId>
Expand Down Expand Up @@ -210,6 +214,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-yaml-dsl-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,11 @@ public String kameletLocationAtRuntime(@PathParam("name") String name) {
public String greeting() {
return consumerTemplate.receiveBody("seda:greeting", 10000, String.class);
}

@Path("/pipe")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String pipe() {
return consumerTemplate.receiveBody("seda:greetingFromProperty", 10000, String.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
## limitations under the License.
## ---------------------------------------------------------------------------
camel.kamelet.setBodyFromProperties.bodyValueFromProperty=Camel Quarkus Kamelet Property
camel.main.routes-include-pattern=pipes/greeting-pipe.yaml

quarkus.camel.kamelet.identifiers = injector,logger,greeting
quarkus.camel.kamelet.identifiers = injector,logger,greeting,greeting-from-property

# this is needed to actually test that kamelet are preloaded at build time:
camel.component.kamelet.location = file:/invalid

quarkus.native.resources.includes=kamelets-runtime/*.xml
quarkus.native.resources.includes=kamelets-runtime/*.xml,pipes/*.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# 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.
#

apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: greeting-from-property
labels:
camel.apache.org/kamelet.type: "source"
camel.apache.org/kamelet.name: "greeting"
camel.apache.org/kamelet.version: "v1"
camel.apache.org/kamelet.revision: "1"
spec:
definition:
title: "Greeting"
description: "Send a greeting"
properties:
greeting:
title: Greeting
description: The greeting to send.
type: string
example: Hello World
dependencies:
- "camel:timer"
template:
from:
uri: timer:greetFromProperty?repeatCount=1&delay=-1
steps:
- setBody:
constant: "{{greeting}}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# 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.
#

apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: greeting-pipe
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: greeting-from-property
properties:
greeting: "Hello Pipe"
sink:
uri: "seda:greetingFromProperty"
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,12 @@ public void testKameletWithBean() {
.statusCode(200)
.body(is("Hello World"));
}

@Test
public void pipe() {
RestAssured.get("/kamelet/pipe")
.then()
.statusCode(200)
.body(is("Hello Pipe"));
}
}

0 comments on commit e56bd90

Please sign in to comment.