Skip to content

Commit 438762f

Browse files
committed
Merge branch '3.3.x' into 3.4.x
Closes gh-45619
2 parents f26b318 + 3e3aa5a commit 438762f

File tree

7 files changed

+196
-1
lines changed

7 files changed

+196
-1
lines changed

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-activemq/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
id "org.springframework.boot.docker-test"
44
}
55

6-
description = "Spring Boot Actuator ActiveMQ smoke test"
6+
description = "Spring Boot ActiveMQ smoke test"
77

88
dependencies {
99
dockerTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
id "java"
3+
id "org.springframework.boot.docker-test"
4+
}
5+
6+
description = "Spring Boot Artemis smoke test"
7+
8+
dependencies {
9+
dockerTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
10+
dockerTestImplementation(project(":spring-boot-project:spring-boot-testcontainers"))
11+
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
12+
dockerTestImplementation("org.awaitility:awaitility")
13+
dockerTestImplementation("org.testcontainers:junit-jupiter")
14+
dockerTestImplementation("org.testcontainers:activemq")
15+
16+
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-artemis"))
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2012-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.artemis;
18+
19+
import java.time.Duration;
20+
21+
import org.awaitility.Awaitility;
22+
import org.junit.jupiter.api.Test;
23+
import org.junit.jupiter.api.extension.ExtendWith;
24+
import org.testcontainers.activemq.ArtemisContainer;
25+
import org.testcontainers.junit.jupiter.Container;
26+
import org.testcontainers.junit.jupiter.Testcontainers;
27+
28+
import org.springframework.beans.factory.annotation.Autowired;
29+
import org.springframework.boot.test.context.SpringBootTest;
30+
import org.springframework.boot.test.system.CapturedOutput;
31+
import org.springframework.boot.test.system.OutputCaptureExtension;
32+
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
33+
import org.springframework.boot.testsupport.container.TestImage;
34+
35+
import static org.assertj.core.api.Assertions.assertThat;
36+
37+
/**
38+
* Integration tests for demo application.
39+
*
40+
* @author Eddú Meléndez
41+
* @author Stephane Nicoll
42+
*/
43+
@SpringBootTest
44+
@Testcontainers(disabledWithoutDocker = true)
45+
@ExtendWith(OutputCaptureExtension.class)
46+
class SampleArtemisTests {
47+
48+
@Container
49+
@ServiceConnection
50+
private static final ArtemisContainer container = TestImage.container(ArtemisContainer.class);
51+
52+
@Autowired
53+
private Producer producer;
54+
55+
@Test
56+
void sendSimpleMessage(CapturedOutput output) {
57+
this.producer.send("Test message");
58+
Awaitility.waitAtMost(Duration.ofMinutes(1)).untilAsserted(() -> assertThat(output).contains("Test message"));
59+
}
60+
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.artemis;
18+
19+
import org.springframework.jms.annotation.JmsListener;
20+
import org.springframework.stereotype.Component;
21+
22+
@Component
23+
public class Consumer {
24+
25+
@JmsListener(destination = "sample.queue")
26+
public void receiveQueue(String text) {
27+
System.out.println(text);
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.artemis;
18+
19+
import jakarta.jms.Queue;
20+
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.boot.CommandLineRunner;
23+
import org.springframework.jms.core.JmsMessagingTemplate;
24+
import org.springframework.stereotype.Component;
25+
26+
@Component
27+
public class Producer implements CommandLineRunner {
28+
29+
@Autowired
30+
private JmsMessagingTemplate jmsMessagingTemplate;
31+
32+
@Autowired
33+
private Queue queue;
34+
35+
@Override
36+
public void run(String... args) throws Exception {
37+
send("Sample message");
38+
System.out.println("Message was sent to the Queue");
39+
}
40+
41+
public void send(String msg) {
42+
this.jmsMessagingTemplate.convertAndSend(this.queue, msg);
43+
}
44+
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.artemis;
18+
19+
import jakarta.jms.Queue;
20+
import org.apache.activemq.artemis.jms.client.ActiveMQQueue;
21+
22+
import org.springframework.boot.SpringApplication;
23+
import org.springframework.boot.autoconfigure.SpringBootApplication;
24+
import org.springframework.context.annotation.Bean;
25+
import org.springframework.jms.annotation.EnableJms;
26+
27+
@SpringBootApplication
28+
@EnableJms
29+
public class SampleArtemisApplication {
30+
31+
@Bean
32+
public Queue queue() {
33+
return new ActiveMQQueue("sample.queue");
34+
}
35+
36+
public static void main(String[] args) {
37+
SpringApplication.run(SampleArtemisApplication.class, args);
38+
}
39+
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
spring.artemis.pool.enabled=false
2+
spring.jms.cache.enabled=false

0 commit comments

Comments
 (0)