Relocate projects to spring-boot-project
Move projects to better reflect the way that Spring Boot is released. The following projects are under `spring-boot-project`: - `spring-boot` - `spring-boot-autoconfigure` - `spring-boot-tools` - `spring-boot-starters` - `spring-boot-actuator` - `spring-boot-actuator-autoconfigure` - `spring-boot-test` - `spring-boot-test-autoconfigure` - `spring-boot-devtools` - `spring-boot-cli` - `spring-boot-docs` See gh-9316
This commit is contained in:
17
spring-boot-project/spring-boot-cli/test-samples/app.groovy
Normal file
17
spring-boot-project/spring-boot-cli/test-samples/app.groovy
Normal file
@@ -0,0 +1,17 @@
|
||||
@Configuration
|
||||
class App {
|
||||
|
||||
@Bean
|
||||
MyService myService() {
|
||||
return new MyService()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MyService {
|
||||
|
||||
String sayWorld() {
|
||||
return "World!"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class Book {
|
||||
String author
|
||||
String title
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Book {
|
||||
String author
|
||||
String title
|
||||
}
|
||||
|
||||
class BookTests {
|
||||
@Test
|
||||
void testBooks() {
|
||||
Book book = new Book(author: "Tom Clancy", title: "Threat Vector")
|
||||
assertEquals("Tom Clancy", book.author)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
class FailingJUnitTests {
|
||||
@Test
|
||||
void passingTest() {
|
||||
assertTrue(true)
|
||||
}
|
||||
|
||||
@Test
|
||||
void failureByAssertion() {
|
||||
assertTrue(false)
|
||||
}
|
||||
|
||||
@Test
|
||||
void failureByException() {
|
||||
throw new RuntimeException("This should also be handled")
|
||||
}
|
||||
}
|
||||
|
||||
class FailingSpockTest extends Specification {
|
||||
def "this should pass"() {
|
||||
expect:
|
||||
name.size() == length
|
||||
|
||||
where:
|
||||
name | length
|
||||
"Spock" | 5
|
||||
}
|
||||
|
||||
def "this should fail on purpose as well"() {
|
||||
when:
|
||||
String text = "Greetings"
|
||||
|
||||
then:
|
||||
//throw new RuntimeException("This should fail!")
|
||||
true == false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
@SpringBootTest(classes=Application)
|
||||
class BookTests {
|
||||
@Autowired
|
||||
Book book
|
||||
@Test
|
||||
void testBooks() {
|
||||
assertEquals("Tom Clancy", book.author)
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
class Application {
|
||||
@Bean
|
||||
Book book() {
|
||||
new Book(author: "Tom Clancy", title: "Threat Vector")
|
||||
}
|
||||
}
|
||||
|
||||
class Book {
|
||||
String author
|
||||
String title
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.example
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootTest(classes=RestTests, webEnvironment=WebEnvironment.RANDOM_PORT)
|
||||
class RestTests {
|
||||
|
||||
@Autowired
|
||||
TestRestTemplate testRestTemplate;
|
||||
|
||||
@Test
|
||||
void testHome() {
|
||||
assertEquals('Hello', testRestTemplate.getForObject('/', String))
|
||||
}
|
||||
|
||||
@RestController
|
||||
static class Application {
|
||||
@RequestMapping('/')
|
||||
String hello() { 'Hello' }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
@SpringBootTest(classes=App)
|
||||
class AppTests {
|
||||
|
||||
@Autowired
|
||||
MyService myService
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
assertNotNull(myService)
|
||||
}
|
||||
|
||||
}
|
||||
31
spring-boot-project/spring-boot-cli/test-samples/jms.groovy
Normal file
31
spring-boot-project/spring-boot-cli/test-samples/jms.groovy
Normal file
@@ -0,0 +1,31 @@
|
||||
@Grab("spring-boot-starter-artemis")
|
||||
@Grab("artemis-jms-server")
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
@Log
|
||||
@Configuration
|
||||
@EnableJms
|
||||
class JmsExample implements CommandLineRunner {
|
||||
|
||||
private CountDownLatch latch = new CountDownLatch(1)
|
||||
|
||||
@Autowired
|
||||
JmsTemplate jmsTemplate
|
||||
|
||||
void run(String... args) {
|
||||
def messageCreator = { session ->
|
||||
session.createObjectMessage("Greetings from Spring Boot via Artemis")
|
||||
} as MessageCreator
|
||||
log.info "Sending JMS message..."
|
||||
jmsTemplate.send("spring-boot", messageCreator)
|
||||
log.info "Send JMS message, waiting..."
|
||||
latch.await()
|
||||
}
|
||||
|
||||
@JmsListener(destination = 'spring-boot')
|
||||
def receive(String message) {
|
||||
log.info "Received ${message}"
|
||||
latch.countDown()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class HelloSpock extends Specification {
|
||||
def "length of Spock's and his friends' names"() {
|
||||
expect:
|
||||
name.size() == length
|
||||
|
||||
where:
|
||||
name | length
|
||||
"Spock" | 5
|
||||
"Kirk" | 4
|
||||
"Scotty" | 6
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class BookTests {
|
||||
@Test
|
||||
void testBooks() {
|
||||
Book book = new Book(author: "Tom Clancy", title: "Threat Vector")
|
||||
assertEquals("Tom Clancy", book.author)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user