Skip to content

Commit bec1c8f

Browse files
author
Phillip Webb
committed
Polish
1 parent d784cb6 commit bec1c8f

File tree

14 files changed

+104
-112
lines changed

14 files changed

+104
-112
lines changed

spring-boot-cli/samples/book.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class Book {
2-
String author
3-
String title
4-
}
2+
String author
3+
String title
4+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class Book {
2-
String author
3-
String title
2+
String author
3+
String title
44
}
55

66
class BookTests {
7-
@Test
8-
void testBooks() {
9-
Book book = new Book(author: "Tom Clancy", title: "Threat Vector")
10-
assertEquals("Tom Clancy", book.author)
11-
}
12-
}
7+
@Test
8+
void testBooks() {
9+
Book book = new Book(author: "Tom Clancy", title: "Threat Vector")
10+
assertEquals("Tom Clancy", book.author)
11+
}
12+
}

spring-boot-cli/samples/failures.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ class FailingSpockTest extends Specification {
3333
//throw new RuntimeException("This should fail!")
3434
true == false
3535
}
36-
37-
}
36+
}

spring-boot-cli/samples/jms.groovy

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ class JmsExample implements CommandLineRunner {
3434
jmsTemplate.send("spring-boot", messageCreator)
3535
latch.await()
3636
}
37-
3837
}
3938

4039
@Log
4140
class Receiver {
4241
CountDownLatch latch
43-
44-
def receive(String message) {
45-
log.info "Received ${message}"
46-
latch.countDown()
47-
}
42+
def receive(String message) {
43+
log.info "Received ${message}"
44+
latch.countDown()
45+
}
4846
}

spring-boot-cli/samples/job.groovy

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class JobConfig {
1313

1414
@Bean
1515
protected Tasklet tasklet() {
16-
return new Tasklet() {
17-
@Override
18-
RepeatStatus execute(StepContribution contribution, ChunkContext context) {
19-
return RepeatStatus.FINISHED
20-
}
21-
}
16+
return new Tasklet() {
17+
@Override
18+
RepeatStatus execute(StepContribution contribution, ChunkContext context) {
19+
return RepeatStatus.FINISHED
20+
}
21+
}
2222
}
2323

2424
@Bean
@@ -31,5 +31,3 @@ class JobConfig {
3131
return steps.get("step1").tasklet(tasklet()).build()
3232
}
3333
}
34-
35-

spring-boot-cli/samples/rabbit.groovy

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,57 @@ import java.util.concurrent.CountDownLatch
77
@EnableRabbitMessaging
88
class RabbitExample implements CommandLineRunner {
99

10-
private CountDownLatch latch = new CountDownLatch(1)
11-
12-
@Autowired
13-
RabbitTemplate rabbitTemplate
14-
15-
private String queueName = "spring-boot"
16-
17-
@Bean
18-
Queue queue() {
19-
new Queue(queueName, false)
20-
}
21-
22-
@Bean
23-
TopicExchange exchange() {
24-
new TopicExchange("spring-boot-exchange")
25-
}
26-
27-
/**
28-
* The queue and topic exchange cannot be inlined inside this method and have
29-
* dynamic creation with Spring AMQP work properly.
30-
*/
31-
@Bean
32-
Binding binding(Queue queue, TopicExchange exchange) {
33-
BindingBuilder
34-
.bind(queue)
35-
.to(exchange)
36-
.with("spring-boot")
37-
}
38-
39-
@Bean
40-
SimpleMessageListenerContainer container(CachingConnectionFactory connectionFactory) {
41-
return new SimpleMessageListenerContainer(
42-
connectionFactory: connectionFactory,
43-
queueNames: [queueName],
44-
messageListener: new MessageListenerAdapter(new Receiver(latch:latch), "receive")
45-
)
46-
}
47-
48-
void run(String... args) {
49-
log.info "Sending RabbitMQ message..."
50-
rabbitTemplate.convertAndSend(queueName, "Greetings from Spring Boot via RabbitMQ")
51-
latch.await()
52-
}
53-
10+
private CountDownLatch latch = new CountDownLatch(1)
11+
12+
@Autowired
13+
RabbitTemplate rabbitTemplate
14+
15+
private String queueName = "spring-boot"
16+
17+
@Bean
18+
Queue queue() {
19+
new Queue(queueName, false)
20+
}
21+
22+
@Bean
23+
TopicExchange exchange() {
24+
new TopicExchange("spring-boot-exchange")
25+
}
26+
27+
/**
28+
* The queue and topic exchange cannot be inlined inside this method and have
29+
* dynamic creation with Spring AMQP work properly.
30+
*/
31+
@Bean
32+
Binding binding(Queue queue, TopicExchange exchange) {
33+
BindingBuilder
34+
.bind(queue)
35+
.to(exchange)
36+
.with("spring-boot")
37+
}
38+
39+
@Bean
40+
SimpleMessageListenerContainer container(CachingConnectionFactory connectionFactory) {
41+
return new SimpleMessageListenerContainer(
42+
connectionFactory: connectionFactory,
43+
queueNames: [queueName],
44+
messageListener: new MessageListenerAdapter(new Receiver(latch:latch), "receive")
45+
)
46+
}
47+
48+
void run(String... args) {
49+
log.info "Sending RabbitMQ message..."
50+
rabbitTemplate.convertAndSend(queueName, "Greetings from Spring Boot via RabbitMQ")
51+
latch.await()
52+
}
5453
}
5554

5655
@Log
5756
class Receiver {
58-
CountDownLatch latch
57+
CountDownLatch latch
5958

60-
def receive(String message) {
61-
log.info "Received ${message}"
62-
latch.countDown()
63-
}
59+
def receive(String message) {
60+
log.info "Received ${message}"
61+
latch.countDown()
62+
}
6463
}

spring-boot-cli/samples/reactor.groovy

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import java.util.concurrent.CountDownLatch;
55
@EnableReactor
66
@Log
77
class Runner implements CommandLineRunner {
8-
8+
99
@Autowired
1010
Reactor reactor
11-
11+
1212
private CountDownLatch latch = new CountDownLatch(1)
13-
13+
1414
@PostConstruct
1515
void init() {
1616
log.info "Registering consumer"
@@ -21,12 +21,10 @@ class Runner implements CommandLineRunner {
2121
log.info "Notified Phil"
2222
latch.await()
2323
}
24-
24+
2525
@Selector(reactor="reactor", value="hello")
2626
void receive(String data) {
2727
log.info "Hello ${data}"
2828
latch.countDown()
29-
}
29+
}
3030
}
31-
32-

spring-boot-cli/samples/runner.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@ class Runner implements CommandLineRunner {
66
print "Hello World!"
77
}
88
}
9-
10-

spring-boot-cli/samples/spock.groovy

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class HelloSpock extends Specification {
2-
def "length of Spock's and his friends' names"() {
3-
expect:
4-
name.size() == length
2+
def "length of Spock's and his friends' names"() {
3+
expect:
4+
name.size() == length
55

6-
where:
7-
name | length
8-
"Spock" | 5
9-
"Kirk" | 4
10-
"Scotty" | 6
11-
}
12-
}
6+
where:
7+
name | length
8+
"Spock" | 5
9+
"Kirk" | 4
10+
"Scotty" | 6
11+
}
12+
}

spring-boot-cli/samples/template.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@ class MyService {
2121
return "World"
2222
}
2323
}
24-
25-

0 commit comments

Comments
 (0)