Skip to content

Commit 0df2cd7

Browse files
Add integration tests for aws2-translate #2403
1 parent 4dbcf34 commit 0df2cd7

9 files changed

Lines changed: 350 additions & 1 deletion

File tree

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>org.apache.camel.quarkus</groupId>
24+
<artifactId>camel-quarkus-build-parent-it</artifactId>
25+
<version>3.32.0-SNAPSHOT</version>
26+
<relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
27+
</parent>
28+
29+
<artifactId>camel-quarkus-integration-test-aws2-translate</artifactId>
30+
<name>Camel Quarkus :: Integration Tests :: AWS2 Translate</name>
31+
<description>The camel integration tests</description>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.apache.camel.quarkus</groupId>
36+
<artifactId>camel-quarkus-aws2-translate</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>io.quarkus</groupId>
40+
<artifactId>quarkus-resteasy</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>io.quarkus</groupId>
44+
<artifactId>quarkus-resteasy-jackson</artifactId>
45+
</dependency>
46+
47+
<!-- test dependencies -->
48+
<dependency>
49+
<groupId>io.quarkus</groupId>
50+
<artifactId>quarkus-junit</artifactId>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>io.rest-assured</groupId>
55+
<artifactId>rest-assured</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.apache.camel.quarkus</groupId>
60+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.apache.camel.quarkus</groupId>
64+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
65+
<type>test-jar</type>
66+
<scope>test</scope>
67+
</dependency>
68+
</dependencies>
69+
70+
<profiles>
71+
<profile>
72+
<id>native</id>
73+
<activation>
74+
<property>
75+
<name>native</name>
76+
</property>
77+
</activation>
78+
<properties>
79+
<quarkus.native.enabled>true</quarkus.native.enabled>
80+
</properties>
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-failsafe-plugin</artifactId>
86+
<executions>
87+
<execution>
88+
<goals>
89+
<goal>integration-test</goal>
90+
<goal>verify</goal>
91+
</goals>
92+
</execution>
93+
</executions>
94+
</plugin>
95+
</plugins>
96+
</build>
97+
</profile>
98+
<profile>
99+
<id>virtualDependencies</id>
100+
<activation>
101+
<property>
102+
<name>!noVirtualDependencies</name>
103+
</property>
104+
</activation>
105+
<dependencies>
106+
<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
107+
<dependency>
108+
<groupId>org.apache.camel.quarkus</groupId>
109+
<artifactId>camel-quarkus-aws2-translate-deployment</artifactId>
110+
<version>${project.version}</version>
111+
<type>pom</type>
112+
<scope>test</scope>
113+
<exclusions>
114+
<exclusion>
115+
<groupId>*</groupId>
116+
<artifactId>*</artifactId>
117+
</exclusion>
118+
</exclusions>
119+
</dependency>
120+
</dependencies>
121+
</profile>
122+
<profile>
123+
<id>skip-testcontainers-tests</id>
124+
<activation>
125+
<property>
126+
<name>skip-testcontainers-tests</name>
127+
</property>
128+
</activation>
129+
<properties>
130+
<skipTests>true</skipTests>
131+
</properties>
132+
</profile>
133+
</profiles>
134+
135+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.quarkus.component.aws2.translate.it;
18+
19+
import jakarta.enterprise.context.ApplicationScoped;
20+
import jakarta.inject.Inject;
21+
import jakarta.ws.rs.Consumes;
22+
import jakarta.ws.rs.POST;
23+
import jakarta.ws.rs.Path;
24+
import jakarta.ws.rs.Produces;
25+
import jakarta.ws.rs.QueryParam;
26+
import jakarta.ws.rs.core.MediaType;
27+
import org.apache.camel.ProducerTemplate;
28+
import org.apache.camel.component.aws2.translate.Translate2Constants;
29+
import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
30+
31+
@Path("/aws2-translate")
32+
@ApplicationScoped
33+
public class Aws2TranslateResource extends BaseAws2Resource {
34+
35+
@Inject
36+
ProducerTemplate producerTemplate;
37+
38+
public Aws2TranslateResource() {
39+
super("translate");
40+
}
41+
42+
@Path("/translate")
43+
@POST
44+
@Consumes(MediaType.TEXT_PLAIN)
45+
@Produces(MediaType.TEXT_PLAIN)
46+
public String translate(
47+
String text,
48+
@QueryParam("sourceLanguage") String sourceLanguage,
49+
@QueryParam("targetLanguage") String targetLanguage) throws Exception {
50+
return producerTemplate.requestBodyAndHeaders(
51+
"aws2-translate://test?operation=translateText",
52+
text,
53+
java.util.Map.of(
54+
Translate2Constants.SOURCE_LANGUAGE, sourceLanguage,
55+
Translate2Constants.TARGET_LANGUAGE, targetLanguage),
56+
String.class);
57+
}
58+
59+
@Path("/languages")
60+
@POST
61+
@Produces(MediaType.APPLICATION_JSON)
62+
public java.util.List<String> listLanguages() throws Exception {
63+
return producerTemplate.requestBody(
64+
"aws2-translate://test?operation=listLanguages",
65+
null,
66+
java.util.List.class);
67+
}
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.quarkus.component.aws2.translate.it;
18+
19+
import io.quarkus.test.junit.QuarkusIntegrationTest;
20+
21+
@QuarkusIntegrationTest
22+
class Aws2TranslateIT extends Aws2TranslateTest {
23+
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.quarkus.component.aws2.translate.it;
18+
19+
import io.quarkus.test.common.QuarkusTestResource;
20+
import io.quarkus.test.junit.QuarkusTest;
21+
import io.restassured.RestAssured;
22+
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
23+
import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
24+
import org.junit.jupiter.api.Test;
25+
26+
import static org.hamcrest.core.Is.is;
27+
28+
@QuarkusTest
29+
@QuarkusTestResource(Aws2TestResource.class)
30+
class Aws2TranslateTest extends BaseAWs2TestSupport {
31+
32+
public Aws2TranslateTest() {
33+
super("/aws2-translate");
34+
}
35+
36+
@Test
37+
public void translate() {
38+
RestAssured.given()
39+
.queryParam("sourceLanguage", "en")
40+
.queryParam("targetLanguage", "fr")
41+
.body("Hello")
42+
.post("/aws2-translate/translate")
43+
.then()
44+
.statusCode(200)
45+
.body(is("Bonjour"));
46+
}
47+
48+
@Override
49+
public void testMethodForDefaultCredentialsProvider() {
50+
RestAssured.given()
51+
.queryParam("sourceLanguage", "en")
52+
.queryParam("targetLanguage", "fr")
53+
.body("Hello")
54+
.post("/aws2-translate/translate")
55+
.then()
56+
.statusCode(200);
57+
}
58+
59+
@Test
60+
public void listLanguages() {
61+
RestAssured.given()
62+
.post("/aws2-translate/languages")
63+
.then()
64+
.statusCode(200)
65+
.body("size()", org.hamcrest.Matchers.greaterThan(0));
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.quarkus.component.aws2.translate.it;
18+
19+
import org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvContext;
20+
import org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer;
21+
import org.apache.camel.quarkus.test.support.aws2.Service;
22+
23+
public class Aws2TranslateTestEnvCustomizer implements Aws2TestEnvCustomizer {
24+
25+
@Override
26+
public Service[] localstackServices() {
27+
return new Service[] { Service.TRANSLATE };
28+
}
29+
30+
@Override
31+
public void customize(Aws2TestEnvContext envContext) {
32+
// No specific customization needed for Translate service beyond enabling it
33+
}
34+
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.apache.camel.quarkus.component.aws2.translate.it.Aws2TranslateTestEnvCustomizer

integration-test-groups/aws2/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<module>aws2-ses</module>
4747
<module>aws2-sqs</module>
4848
<module>aws2-sqs-sns</module>
49+
<module>aws2-translate</module>
4950
</modules>
5051

5152
</project>

integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Service.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public enum Service {
3838
CLOUDWATCHLOGS("logs"),
3939
STS("sts"),
4040
IAM("iam"),
41-
KMS("kms");
41+
KMS("kms"),
42+
TRANSLATE("translate");
4243

4344
private final String serviceName;
4445

integration-tests/aws2-grouped/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
<groupId>org.apache.camel.quarkus</groupId>
9797
<artifactId>camel-quarkus-aws2-sqs</artifactId>
9898
</dependency>
99+
<dependency>
100+
<groupId>org.apache.camel.quarkus</groupId>
101+
<artifactId>camel-quarkus-aws2-translate</artifactId>
102+
</dependency>
99103
<dependency>
100104
<groupId>org.apache.camel.quarkus</groupId>
101105
<artifactId>camel-quarkus-direct</artifactId>
@@ -339,6 +343,19 @@
339343
</exclusion>
340344
</exclusions>
341345
</dependency>
346+
<dependency>
347+
<groupId>org.apache.camel.quarkus</groupId>
348+
<artifactId>camel-quarkus-aws2-translate-deployment</artifactId>
349+
<version>${project.version}</version>
350+
<type>pom</type>
351+
<scope>test</scope>
352+
<exclusions>
353+
<exclusion>
354+
<groupId>*</groupId>
355+
<artifactId>*</artifactId>
356+
</exclusion>
357+
</exclusions>
358+
</dependency>
342359
<dependency>
343360
<groupId>org.apache.camel.quarkus</groupId>
344361
<artifactId>camel-quarkus-direct-deployment</artifactId>

0 commit comments

Comments
 (0)