├── .gitignore
├── README.md
├── bin
├── consul.sh
├── graphite.sh
├── logstash.conf
├── postgresql.sh
├── psql.sh
├── rabbitmq.sh
├── redis-cli.sh
├── redis.sh
├── zipkin.sh
└── zipkin
│ └── docker-compose.yml
├── code-java
├── auth-service
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── authservice
│ │ │ │ └── AuthServiceApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── authservice
│ │ └── AuthServiceApplicationTests.java
├── config-service
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── configservice
│ │ │ │ └── ConfigServiceApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── configservice
│ │ └── ConfigServiceApplicationTests.java
├── dataflow-service
│ └── spring-cloud-dataflow-server-local-1.2.3.RELEASE.jar
├── eureka-service
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── eurekaservice
│ │ │ │ └── EurekaServiceApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── eurekaservice
│ │ └── EurekaServiceApplicationTests.java
├── hystrix-dashboard
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── hystrixdashboard
│ │ │ │ └── HystrixDashboardApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── hystrixdashboard
│ │ └── HystrixDashboardApplicationTests.java
├── reservation-client
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── reservationclient
│ │ │ │ └── ReservationClientApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── reservationclient
│ │ │ ├── ReservationClientApplicationTests.java
│ │ │ └── ReservationReaderTest.java
│ │ └── resources
│ │ └── application.properties
├── reservation-service
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── reservationservice
│ │ │ │ └── ReservationServiceApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── reservationservice
│ │ │ ├── BaseClass.java
│ │ │ ├── ReservationRestControllerTest.java
│ │ │ ├── ReservationServiceApplicationTests.java
│ │ │ └── ReservationTest.java
│ │ └── resources
│ │ └── contracts
│ │ └── shouldReturnAllReservations.groovy
└── zipkin-service
│ ├── .gitignore
│ ├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── zipkinservice
│ │ │ └── ZipkinServiceApplication.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── example
│ └── zipkinservice
│ └── ZipkinServiceApplicationTests.java
├── code-kotlin
├── config-service
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── configservice
│ │ │ │ └── ConfigServiceApplication.kt
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── kotlin
│ │ └── com
│ │ └── example
│ │ └── configservice
│ │ └── ConfigServiceApplicationTests.kt
├── demo.zip
├── eureka-service
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── eurekaservice
│ │ │ │ └── EurekaServiceApplication.kt
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── kotlin
│ │ └── com
│ │ └── example
│ │ └── eurekaservice
│ │ └── EurekaServiceApplicationTests.kt
├── hystrix-dashboard
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── hystrixdashboard
│ │ │ │ └── HystrixDashboardApplication.kt
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── kotlin
│ │ └── com
│ │ └── example
│ │ └── hystrixdashboard
│ │ └── HystrixDashboardApplicationTests.kt
├── reservation-client
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── reservationclient
│ │ │ │ └── ReservationClientApplication.kt
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── kotlin
│ │ └── com
│ │ └── example
│ │ └── reservationclient
│ │ └── ReservationClientApplicationTests.kt
├── reservation-service
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── reservationservice
│ │ │ │ └── ReservationServiceApplication.kt
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── kotlin
│ │ └── com
│ │ └── example
│ │ └── reservationservice
│ │ └── ReservationServiceApplicationTests.kt
└── zipkin-service
│ ├── .gitignore
│ ├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── kotlin
│ │ └── com
│ │ │ └── example
│ │ │ └── zipkinservice
│ │ │ └── ZipkinServiceApplication.kt
│ └── resources
│ │ ├── application.properties
│ │ └── banner.txt
│ └── test
│ └── kotlin
│ └── com
│ └── example
│ └── zipkinservice
│ └── ZipkinServiceApplicationTests.kt
└── labs
├── 1
└── reservation-service
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ ├── DemoApplication.java
│ │ │ └── Reservation.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
├── 2
└── reservation-service
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ ├── DemoApplication.java
│ │ │ └── Reservation.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
├── 3
├── config-service
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
└── reservation-service
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ ├── DemoApplication.java
│ │ │ └── Reservation.java
│ └── resources
│ │ └── bootstrap.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
├── 4
├── config-service
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── eureka-service
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── reservation-client
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
└── reservation-service
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ ├── DemoApplication.java
│ │ │ └── Reservation.java
│ └── resources
│ │ └── bootstrap.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
├── 5
├── config-service
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── eureka-service
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── hystrix-dashboard
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── reservation-client
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
└── reservation-service
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ ├── DemoApplication.java
│ │ │ └── Reservation.java
│ └── resources
│ │ └── bootstrap.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
├── 6
├── cf-simple.sh
├── cf.sh
├── config-service
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── eureka-service
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── hystrix-dashboard
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── reservation-client
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
└── reservation-service
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ ├── DemoApplication.java
│ │ │ └── Reservation.java
│ └── resources
│ │ └── bootstrap.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
├── 7
├── cf-simple.sh
├── cf.sh
├── config-service
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── eureka-service
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── hystrix-dashboard
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── reservation-client
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── demo
│ │ └── DemoApplicationTests.java
└── reservation-service
│ ├── manifest.yml
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ ├── DemoApplication.java
│ │ │ └── Reservation.java
│ └── resources
│ │ └── bootstrap.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
└── 8
├── cf-simple.sh
├── cf.sh
├── config-service
├── manifest.yml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ └── DemoApplication.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
├── eureka-service
├── manifest.yml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ └── DemoApplication.java
│ └── resources
│ │ └── bootstrap.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
├── hystrix-dashboard
├── manifest.yml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ └── DemoApplication.java
│ └── resources
│ │ └── bootstrap.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
├── reservation-client
├── manifest.yml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── demo
│ │ │ └── DemoApplication.java
│ └── resources
│ │ └── bootstrap.properties
│ └── test
│ └── java
│ └── demo
│ └── DemoApplicationTests.java
└── reservation-service
├── manifest.yml
├── pom.xml
└── src
├── main
├── java
│ └── demo
│ │ ├── DemoApplication.java
│ │ └── Reservation.java
└── resources
│ └── bootstrap.properties
└── test
└── java
└── demo
└── DemoApplicationTests.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | target
3 | .idea
4 | *.DS_Store
5 |
--------------------------------------------------------------------------------
/bin/consul.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ### NB!! you'll need to add an entry to your local /etc/hosts (not that of the Docker container!) of the following form:
3 | ### 127.0.0.1 cna
4 | ### in order for this to work.
5 |
6 | # --add-host cna:10.0.2.2
7 | docker run -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h cna progrium/consul -server -bootstrap -ui-dir /ui
8 |
--------------------------------------------------------------------------------
/bin/graphite.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | docker run --name cna-graphite -p 80:80 -p 2003:2003 -p 8125:8125/udp hopsoft/graphite-statsd
3 |
--------------------------------------------------------------------------------
/bin/logstash.conf:
--------------------------------------------------------------------------------
1 | input {
2 | stdin {
3 | type => "stdin-type"
4 | }
5 |
6 | file {
7 | type => "syslog"
8 | path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog" ]
9 | }
10 |
11 | file {
12 | type => "logstash"
13 | path => [ "/var/log/logstash/logstash.log" ]
14 | start_position => "beginning"
15 | }
16 |
17 | tcp {
18 | port => 10042
19 | codec => json {
20 | charset => "UTF-8"
21 | }
22 | }
23 | }
24 |
25 | filter {
26 | if [type] == "docker" {
27 | json {
28 | source => "message"
29 | }
30 | mutate {
31 | rename => [ "log", "message" ]
32 | }
33 | date {
34 | match => [ "time", "ISO8601" ]
35 | }
36 | }
37 | }
38 |
39 | output {
40 | stdout {
41 | codec => rubydebug
42 | }
43 |
44 | elasticsearch {
45 | embedded => ES_EMBEDDED
46 | host => "ES_HOST"
47 | port => "ES_PORT"
48 | protocol => "http"
49 | }
50 | }
--------------------------------------------------------------------------------
/bin/postgresql.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | docker run --name cna-postgres -e POSTGRES_PASSWORD=password -p 5432:5432 postgres
3 |
--------------------------------------------------------------------------------
/bin/psql.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker run -it --link cna-postgres:postgres --rm postgres sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
4 |
--------------------------------------------------------------------------------
/bin/rabbitmq.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker run -d --hostname cna-rabbit -p 5672:5672 -d rabbitmq:3
4 |
5 | docker run -d -p 15672:15672 rabbitmq:3-management
6 |
--------------------------------------------------------------------------------
/bin/redis-cli.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | docker run -it --name redis-cli --link redis:redis --rm redis sh -c 'exec redis-cli -h "$REDIS_PORT_6379_TCP_ADDR" -p "$REDIS_PORT_6379_TCP_PORT"'
3 |
--------------------------------------------------------------------------------
/bin/redis.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | redis_container_id=$( docker ps -a | grep redis | cut -f1 -d\ )
4 |
5 |
6 | if [ "$redis_container_id" = "" ] ;
7 | then
8 | docker run --name redis -p 6379:6379 redis
9 | else
10 | echo "we found a container called 'redis' with this container ID: $redis_container_id."
11 | docker start $redis_container_id
12 | fi
13 |
--------------------------------------------------------------------------------
/bin/zipkin.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | cd zipkin;
3 | docker-compose up
4 |
--------------------------------------------------------------------------------
/bin/zipkin/docker-compose.yml:
--------------------------------------------------------------------------------
1 |
2 | mysql:
3 | image: openzipkin/zipkin-mysql:1.33.0
4 | ports:
5 | - 3306:3306
6 | query:
7 | image: openzipkin/zipkin-java:0.5.2
8 | environment:
9 | - STORAGE_TYPE=mysql
10 | ports:
11 | - 9411:9411
12 | links:
13 | - mysql:storage
14 | web:
15 | image: openzipkin/zipkin-web:1.33.0
16 | ports:
17 | - 8080:8080
18 | environment:
19 | - TRANSPORT_TYPE=http
20 | links:
21 | - query
22 |
--------------------------------------------------------------------------------
/code-java/auth-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-java/auth-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-java/auth-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-java/auth-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-java/auth-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.example
7 | auth-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | auth-service
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.5.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 | Dalston.SR4
26 |
27 |
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-oauth2
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-data-jpa
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-web
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-config
44 |
45 |
46 | org.springframework.cloud
47 | spring-cloud-starter-eureka
48 |
49 |
50 | com.h2database
51 | h2
52 | runtime
53 |
54 |
55 | org.projectlombok
56 | lombok
57 | true
58 |
59 |
60 | org.springframework.boot
61 | spring-boot-starter-test
62 | test
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.springframework.cloud
70 | spring-cloud-dependencies
71 | ${spring-cloud.version}
72 | pom
73 | import
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | org.springframework.boot
82 | spring-boot-maven-plugin
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/code-java/auth-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=auth-service
--------------------------------------------------------------------------------
/code-java/auth-service/src/test/java/com/example/authservice/AuthServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.authservice;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class AuthServiceApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-java/config-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-java/config-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-java/config-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-java/config-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-java/config-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.example
7 | config-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | config-service
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.5.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 | Dalston.SR4
26 |
27 |
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-config-server
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 |
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-dependencies
46 | ${spring-cloud.version}
47 | pom
48 | import
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | org.springframework.boot
57 | spring-boot-maven-plugin
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/code-java/config-service/src/main/java/com/example/configservice/ConfigServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.configservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @EnableConfigServer
8 | @SpringBootApplication
9 | public class ConfigServiceApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(ConfigServiceApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/code-java/config-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8888
2 | spring.cloud.config.server.git.uri=${HOME}/Desktop/config
--------------------------------------------------------------------------------
/code-java/config-service/src/test/java/com/example/configservice/ConfigServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.configservice;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ConfigServiceApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-java/dataflow-service/spring-cloud-dataflow-server-local-1.2.3.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-java/dataflow-service/spring-cloud-dataflow-server-local-1.2.3.RELEASE.jar
--------------------------------------------------------------------------------
/code-java/eureka-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-java/eureka-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-java/eureka-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-java/eureka-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-java/eureka-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.example
7 | eureka-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-service
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.5.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 | Dalston.SR4
26 |
27 |
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-config
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka-server
36 |
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-starter-test
41 | test
42 |
43 |
44 |
45 |
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-dependencies
50 | ${spring-cloud.version}
51 | pom
52 | import
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | org.springframework.boot
61 | spring-boot-maven-plugin
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/code-java/eureka-service/src/main/java/com/example/eurekaservice/EurekaServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.eurekaservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServiceApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServiceApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/code-java/eureka-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=eureka-service
--------------------------------------------------------------------------------
/code-java/eureka-service/src/test/java/com/example/eurekaservice/EurekaServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.eurekaservice;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServiceApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-java/hystrix-dashboard/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-java/hystrix-dashboard/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-java/hystrix-dashboard/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-java/hystrix-dashboard/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-java/hystrix-dashboard/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.example
7 | hystrix-dashboard
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | hystrix-dashboard
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.5.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 | Dalston.SR4
26 |
27 |
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-config
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-hystrix-dashboard
40 |
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-starter-test
45 | test
46 |
47 |
48 |
49 |
50 |
51 |
52 | org.springframework.cloud
53 | spring-cloud-dependencies
54 | ${spring-cloud.version}
55 | pom
56 | import
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.boot
65 | spring-boot-maven-plugin
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/code-java/hystrix-dashboard/src/main/java/com/example/hystrixdashboard/HystrixDashboardApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.hystrixdashboard;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
8 |
9 | @EnableHystrixDashboard
10 | @EnableDiscoveryClient
11 | @SpringBootApplication
12 | public class HystrixDashboardApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(HystrixDashboardApplication.class, args);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/code-java/hystrix-dashboard/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=hystrix-dashboard
--------------------------------------------------------------------------------
/code-java/hystrix-dashboard/src/test/java/com/example/hystrixdashboard/HystrixDashboardApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.hystrixdashboard;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class HystrixDashboardApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-java/reservation-client/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-java/reservation-client/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-java/reservation-client/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-java/reservation-client/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-java/reservation-client/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-client
--------------------------------------------------------------------------------
/code-java/reservation-client/src/test/java/com/example/reservationclient/ReservationClientApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.reservationclient;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ReservationClientApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-java/reservation-client/src/test/java/com/example/reservationclient/ReservationReaderTest.java:
--------------------------------------------------------------------------------
1 | package com.example.reservationclient;
2 |
3 | import org.assertj.core.api.Assertions;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 | import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner;
10 | import org.springframework.test.context.junit4.SpringRunner;
11 |
12 | import java.util.Collection;
13 |
14 | /**
15 | * @author Josh Long
16 | */
17 | @SpringBootTest(classes = ReservationClientApplication.class)
18 | @RunWith(SpringRunner.class)
19 | //@AutoConfigureWireMock(port = 8000)
20 | @AutoConfigureStubRunner(ids = "com.example:reservation-service:+:8000", workOffline = true)
21 | @AutoConfigureJsonTesters
22 | public class ReservationReaderTest {
23 |
24 |
25 | // @Autowired
26 | // private ObjectMapper objectMapper;
27 |
28 | @Autowired
29 | private ReservationReader reservationReader;
30 |
31 | @Test
32 | public void read() throws Exception {
33 |
34 | /* String json = this.objectMapper.writeValueAsString(Arrays.asList(new Reservation(1L, "Jane"),
35 | new Reservation(2L, "John")));
36 |
37 | WireMock.stubFor(
38 | WireMock.get(WireMock.urlMatching("/reservations"))
39 | .willReturn(WireMock.aResponse()
40 | .withBody( json )
41 | .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)
42 | .withStatus(HttpStatus.OK.value())));*/
43 |
44 | Collection reservations = this.reservationReader.read();
45 | Assertions.assertThat(reservations.size()).isEqualTo(2);
46 | Assertions.assertThat(reservations.iterator().next().getReservationName()).isEqualTo("Jane");
47 |
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/code-java/reservation-client/src/test/resources/application.properties:
--------------------------------------------------------------------------------
1 | eureka.client.enabled=false
2 | stubrunner.ids-to-service-ids.reservation-service=reservation-service
--------------------------------------------------------------------------------
/code-java/reservation-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-java/reservation-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-java/reservation-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-java/reservation-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-java/reservation-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-service
2 | #spring.cloud.config.uri=http://localhost:8888
--------------------------------------------------------------------------------
/code-java/reservation-service/src/test/java/com/example/reservationservice/BaseClass.java:
--------------------------------------------------------------------------------
1 | package com.example.reservationservice;
2 |
3 | import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
4 | import org.junit.Before;
5 | import org.junit.runner.RunWith;
6 | import org.mockito.Mockito;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 | import org.springframework.boot.test.mock.mockito.MockBean;
10 | import org.springframework.test.context.junit4.SpringRunner;
11 |
12 | import java.util.Arrays;
13 |
14 | /**
15 | * @author Josh Long
16 | */
17 |
18 | @SpringBootTest(classes = ReservationServiceApplication.class)
19 | @RunWith(SpringRunner.class)
20 | public class BaseClass {
21 |
22 | @Autowired
23 | private ReservationRestController controller;
24 |
25 | @MockBean
26 | private ReservationRepository reservationRepository;
27 |
28 | @Before
29 | public void before() throws Exception {
30 | Mockito.when(this.reservationRepository.findAll()).thenReturn(Arrays.asList(new Reservation(1L, "Jane"),
31 | new Reservation(2L, "Joe")));
32 |
33 | RestAssuredMockMvc.standaloneSetup(this.controller);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/code-java/reservation-service/src/test/java/com/example/reservationservice/ReservationRestControllerTest.java:
--------------------------------------------------------------------------------
1 | package com.example.reservationservice;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.mockito.Mockito;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 | import org.springframework.boot.test.mock.mockito.MockBean;
10 | import org.springframework.http.MediaType;
11 | import org.springframework.test.context.junit4.SpringRunner;
12 | import org.springframework.test.web.servlet.MockMvc;
13 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
14 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
15 |
16 | import java.util.Arrays;
17 |
18 | /**
19 | * @author Josh Long
20 | */
21 | @SpringBootTest(classes = ReservationServiceApplication.class, webEnvironment = SpringBootTest.WebEnvironment.MOCK)
22 | @RunWith(SpringRunner.class)
23 | @AutoConfigureMockMvc
24 | public class ReservationRestControllerTest {
25 |
26 | @MockBean
27 | private ReservationRepository reservationRepository;
28 |
29 | @Autowired
30 | private MockMvc mockMvc;
31 |
32 | @Test
33 | public void reservations() throws Exception {
34 |
35 | Mockito.when(this.reservationRepository.findAll()).thenReturn(Arrays.asList(new Reservation(1L, "Jane"),
36 | new Reservation(2L, "Joe")));
37 |
38 | this.mockMvc.perform(MockMvcRequestBuilders.get("/reservations"))
39 | .andExpect(MockMvcResultMatchers.status().isOk())
40 | .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8))
41 | .andExpect(MockMvcResultMatchers.jsonPath("@.[0].id").value(1L))
42 | .andExpect(MockMvcResultMatchers.jsonPath("@.[0].reservationName").value("Jane"));
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/code-java/reservation-service/src/test/java/com/example/reservationservice/ReservationServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.reservationservice;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ReservationServiceApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-java/reservation-service/src/test/java/com/example/reservationservice/ReservationTest.java:
--------------------------------------------------------------------------------
1 | package com.example.reservationservice;
2 |
3 | import org.assertj.core.api.Assertions;
4 | import org.assertj.core.api.BDDAssertions;
5 | import org.hamcrest.Matchers;
6 | import org.junit.Assert;
7 | import org.junit.Test;
8 |
9 | /**
10 | * @author Josh Long
11 | */
12 | public class ReservationTest {
13 |
14 | @Test
15 | public void constructor() {
16 | Reservation reservation = new Reservation(1l, "Bob");
17 | Assert.assertEquals("id == 1", (long) reservation.getId(), 1L);
18 | Assert.assertThat(reservation.getId(), Matchers.is(1L));
19 | Assertions.assertThat(reservation.getId()).isEqualTo(1L);
20 |
21 | }
22 | }
--------------------------------------------------------------------------------
/code-java/reservation-service/src/test/resources/contracts/shouldReturnAllReservations.groovy:
--------------------------------------------------------------------------------
1 | import org.springframework.cloud.contract.spec.Contract
2 | import org.springframework.http.HttpHeaders
3 | import org.springframework.http.MediaType
4 |
5 | Contract.make {
6 | description "should return all Reservations"
7 | request {
8 | method GET()
9 | url "/reservations"
10 | }
11 | response {
12 | status 200
13 | headers {
14 | header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)
15 | }
16 | body([[id: 1, reservationName: "Jane"], [id: 2, reservationName: "Joe"]])
17 | }
18 | }
--------------------------------------------------------------------------------
/code-java/zipkin-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-java/zipkin-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-java/zipkin-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-java/zipkin-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-java/zipkin-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.example
7 | zipkin-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | zipkin-service
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.5.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 | Dalston.SR4
26 |
27 |
28 |
29 |
30 | io.zipkin.java
31 | zipkin-server
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-config
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-eureka
40 |
41 |
42 |
43 | io.zipkin.java
44 | zipkin-autoconfigure-ui
45 | runtime
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-starter-test
50 | test
51 |
52 |
53 |
54 |
55 |
56 |
57 | org.springframework.cloud
58 | spring-cloud-dependencies
59 | ${spring-cloud.version}
60 | pom
61 | import
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.springframework.boot
70 | spring-boot-maven-plugin
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/code-java/zipkin-service/src/main/java/com/example/zipkinservice/ZipkinServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.zipkinservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import zipkin.server.EnableZipkinServer;
7 |
8 | @EnableDiscoveryClient
9 | @EnableZipkinServer
10 | @SpringBootApplication
11 | public class ZipkinServiceApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(ZipkinServiceApplication.class, args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/code-java/zipkin-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=zipkin-service
--------------------------------------------------------------------------------
/code-java/zipkin-service/src/test/java/com/example/zipkinservice/ZipkinServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.zipkinservice;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ZipkinServiceApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-kotlin/config-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-kotlin/config-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-kotlin/config-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-kotlin/config-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-kotlin/config-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.example
7 | config-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | config-service
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.5.6.RELEASE
18 |
19 |
20 |
21 |
22 | true
23 | UTF-8
24 | UTF-8
25 | 1.8
26 | 1.1.4
27 | Dalston.SR3
28 |
29 |
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-config-server
34 |
35 |
36 | org.jetbrains.kotlin
37 | kotlin-stdlib-jre8
38 | ${kotlin.version}
39 |
40 |
41 | org.jetbrains.kotlin
42 | kotlin-reflect
43 | ${kotlin.version}
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-starter-test
49 | test
50 |
51 |
52 |
53 |
54 |
55 |
56 | org.springframework.cloud
57 | spring-cloud-dependencies
58 | ${spring-cloud.version}
59 | pom
60 | import
61 |
62 |
63 |
64 |
65 |
66 | ${project.basedir}/src/main/kotlin
67 | ${project.basedir}/src/test/kotlin
68 |
69 |
70 | org.springframework.boot
71 | spring-boot-maven-plugin
72 |
73 |
74 | kotlin-maven-plugin
75 | org.jetbrains.kotlin
76 | ${kotlin.version}
77 |
78 |
79 | spring
80 |
81 | 1.8
82 |
83 |
84 |
85 | compile
86 | compile
87 |
88 | compile
89 |
90 |
91 |
92 | test-compile
93 | test-compile
94 |
95 | test-compile
96 |
97 |
98 |
99 |
100 |
101 | org.jetbrains.kotlin
102 | kotlin-maven-allopen
103 | ${kotlin.version}
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/code-kotlin/config-service/src/main/kotlin/com/example/configservice/ConfigServiceApplication.kt:
--------------------------------------------------------------------------------
1 | package com.example.configservice
2 |
3 | import org.springframework.boot.SpringApplication
4 | import org.springframework.boot.autoconfigure.SpringBootApplication
5 | import org.springframework.cloud.config.server.EnableConfigServer
6 |
7 | @EnableConfigServer
8 | @SpringBootApplication
9 | class ConfigServiceApplication
10 |
11 | fun main(args: Array) {
12 | SpringApplication.run(ConfigServiceApplication::class.java, *args)
13 | }
14 |
--------------------------------------------------------------------------------
/code-kotlin/config-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.server.git.uri=${HOME}/Desktop/config
2 | server.port=8888
--------------------------------------------------------------------------------
/code-kotlin/config-service/src/test/kotlin/com/example/configservice/ConfigServiceApplicationTests.kt:
--------------------------------------------------------------------------------
1 | package com.example.configservice
2 |
3 | import org.junit.Test
4 | import org.junit.runner.RunWith
5 | import org.springframework.boot.test.context.SpringBootTest
6 | import org.springframework.test.context.junit4.SpringRunner
7 |
8 | @RunWith(SpringRunner::class)
9 | @SpringBootTest
10 | class ConfigServiceApplicationTests {
11 |
12 | @Test
13 | fun contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-kotlin/demo.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-kotlin/demo.zip
--------------------------------------------------------------------------------
/code-kotlin/eureka-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-kotlin/eureka-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-kotlin/eureka-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-kotlin/eureka-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-kotlin/eureka-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.example
7 | eureka-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-service
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.5.6.RELEASE
18 |
19 |
20 |
21 |
22 | true
23 | UTF-8
24 | UTF-8
25 | 1.8
26 | 1.1.4
27 | Dalston.SR3
28 |
29 |
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-config
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-eureka-server
38 |
39 |
40 | org.jetbrains.kotlin
41 | kotlin-stdlib-jre8
42 | ${kotlin.version}
43 |
44 |
45 | org.jetbrains.kotlin
46 | kotlin-reflect
47 | ${kotlin.version}
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-starter-test
53 | test
54 |
55 |
56 |
57 |
58 |
59 |
60 | org.springframework.cloud
61 | spring-cloud-dependencies
62 | ${spring-cloud.version}
63 | pom
64 | import
65 |
66 |
67 |
68 |
69 |
70 | ${project.basedir}/src/main/kotlin
71 | ${project.basedir}/src/test/kotlin
72 |
73 |
74 | org.springframework.boot
75 | spring-boot-maven-plugin
76 |
77 |
78 | kotlin-maven-plugin
79 | org.jetbrains.kotlin
80 | ${kotlin.version}
81 |
82 |
83 | spring
84 |
85 | 1.8
86 |
87 |
88 |
89 | compile
90 | compile
91 |
92 | compile
93 |
94 |
95 |
96 | test-compile
97 | test-compile
98 |
99 | test-compile
100 |
101 |
102 |
103 |
104 |
105 | org.jetbrains.kotlin
106 | kotlin-maven-allopen
107 | ${kotlin.version}
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/code-kotlin/eureka-service/src/main/kotlin/com/example/eurekaservice/EurekaServiceApplication.kt:
--------------------------------------------------------------------------------
1 | package com.example.eurekaservice
2 |
3 | import org.springframework.boot.SpringApplication
4 | import org.springframework.boot.autoconfigure.SpringBootApplication
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | class EurekaServiceApplication
10 |
11 | fun main(args: Array) {
12 | SpringApplication.run(EurekaServiceApplication::class.java, *args)
13 | }
14 |
--------------------------------------------------------------------------------
/code-kotlin/eureka-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=eureka-service
--------------------------------------------------------------------------------
/code-kotlin/eureka-service/src/test/kotlin/com/example/eurekaservice/EurekaServiceApplicationTests.kt:
--------------------------------------------------------------------------------
1 | package com.example.eurekaservice
2 |
3 | import org.junit.Test
4 | import org.junit.runner.RunWith
5 | import org.springframework.boot.test.context.SpringBootTest
6 | import org.springframework.test.context.junit4.SpringRunner
7 |
8 | @RunWith(SpringRunner::class)
9 | @SpringBootTest
10 | class EurekaServiceApplicationTests {
11 |
12 | @Test
13 | fun contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-kotlin/hystrix-dashboard/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-kotlin/hystrix-dashboard/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-kotlin/hystrix-dashboard/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-kotlin/hystrix-dashboard/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-kotlin/hystrix-dashboard/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.example
7 | hystrix-dashboard
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | hystrix-dashboard
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.5.6.RELEASE
18 |
19 |
20 |
21 |
22 | true
23 | UTF-8
24 | UTF-8
25 | 1.8
26 | 1.1.4
27 | Dalston.SR3
28 |
29 |
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-config
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-eureka
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-hystrix-dashboard
42 |
43 |
44 | org.jetbrains.kotlin
45 | kotlin-stdlib-jre8
46 | ${kotlin.version}
47 |
48 |
49 | org.jetbrains.kotlin
50 | kotlin-reflect
51 | ${kotlin.version}
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-starter-test
57 | test
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.cloud
65 | spring-cloud-dependencies
66 | ${spring-cloud.version}
67 | pom
68 | import
69 |
70 |
71 |
72 |
73 |
74 | ${project.basedir}/src/main/kotlin
75 | ${project.basedir}/src/test/kotlin
76 |
77 |
78 | org.springframework.boot
79 | spring-boot-maven-plugin
80 |
81 |
82 | kotlin-maven-plugin
83 | org.jetbrains.kotlin
84 | ${kotlin.version}
85 |
86 |
87 | spring
88 |
89 | 1.8
90 |
91 |
92 |
93 | compile
94 | compile
95 |
96 | compile
97 |
98 |
99 |
100 | test-compile
101 | test-compile
102 |
103 | test-compile
104 |
105 |
106 |
107 |
108 |
109 | org.jetbrains.kotlin
110 | kotlin-maven-allopen
111 | ${kotlin.version}
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/code-kotlin/hystrix-dashboard/src/main/kotlin/com/example/hystrixdashboard/HystrixDashboardApplication.kt:
--------------------------------------------------------------------------------
1 | package com.example.hystrixdashboard
2 |
3 | import org.springframework.boot.SpringApplication
4 | import org.springframework.boot.autoconfigure.SpringBootApplication
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient
6 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard
7 |
8 | @EnableDiscoveryClient
9 | @EnableHystrixDashboard
10 | @SpringBootApplication
11 | class HystrixDashboardApplication
12 |
13 | fun main(args: Array) {
14 | SpringApplication.run(HystrixDashboardApplication::class.java, *args)
15 | }
16 |
--------------------------------------------------------------------------------
/code-kotlin/hystrix-dashboard/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=hystrix-dashboard
--------------------------------------------------------------------------------
/code-kotlin/hystrix-dashboard/src/test/kotlin/com/example/hystrixdashboard/HystrixDashboardApplicationTests.kt:
--------------------------------------------------------------------------------
1 | package com.example.hystrixdashboard
2 |
3 | import org.junit.Test
4 | import org.junit.runner.RunWith
5 | import org.springframework.boot.test.context.SpringBootTest
6 | import org.springframework.test.context.junit4.SpringRunner
7 |
8 | @RunWith(SpringRunner::class)
9 | @SpringBootTest
10 | class HystrixDashboardApplicationTests {
11 |
12 | @Test
13 | fun contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-kotlin/reservation-client/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-kotlin/reservation-client/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-kotlin/reservation-client/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-kotlin/reservation-client/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-kotlin/reservation-client/src/main/kotlin/com/example/reservationclient/ReservationClientApplication.kt:
--------------------------------------------------------------------------------
1 | package com.example.reservationclient
2 |
3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand
4 | import org.springframework.boot.SpringApplication
5 | import org.springframework.boot.autoconfigure.SpringBootApplication
6 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker
7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient
8 | import org.springframework.cloud.netflix.feign.EnableFeignClients
9 | import org.springframework.cloud.netflix.feign.FeignClient
10 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy
11 | import org.springframework.cloud.stream.annotation.EnableBinding
12 | import org.springframework.cloud.stream.messaging.Source
13 | import org.springframework.messaging.support.MessageBuilder
14 | import org.springframework.web.bind.annotation.*
15 |
16 |
17 | @EnableBinding(Source::class)
18 | @EnableCircuitBreaker
19 | @EnableFeignClients
20 | @EnableZuulProxy
21 | @EnableDiscoveryClient
22 | @SpringBootApplication
23 | class ReservationClientApplication
24 |
25 | fun main(args: Array) {
26 | SpringApplication.run(ReservationClientApplication::class.java, *args)
27 | }
28 |
29 | @FeignClient("reservation-service")
30 | interface ReservationReader {
31 |
32 | @GetMapping("/reservations")
33 | fun read(): Array
34 |
35 | }
36 |
37 | class Reservation(var id: Long? = null, var reservationName: String? = null) {
38 | constructor() : this(null, null)
39 | }
40 |
41 | @RestController
42 | @RequestMapping("/reservations")
43 | class ReservationApiAdapterRestController(
44 | val reader: ReservationReader,
45 | val source: Source) {
46 |
47 | @PostMapping
48 | fun write(@RequestBody reservation: Reservation) {
49 | // todo send to reservation-service
50 | val msg = MessageBuilder
51 | .withPayload(reservation.reservationName)
52 | .build()
53 | this.source.output().send(msg)
54 | }
55 |
56 | fun fallback(): List = emptyList()
57 |
58 | @HystrixCommand(fallbackMethod = "fallback")
59 | @GetMapping("/names")
60 | fun names(): List = reader.read().map { it.reservationName }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/code-kotlin/reservation-client/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-client
--------------------------------------------------------------------------------
/code-kotlin/reservation-client/src/test/kotlin/com/example/reservationclient/ReservationClientApplicationTests.kt:
--------------------------------------------------------------------------------
1 | package com.example.reservationclient
2 |
3 | import org.junit.Test
4 | import org.junit.runner.RunWith
5 | import org.springframework.boot.test.context.SpringBootTest
6 | import org.springframework.test.context.junit4.SpringRunner
7 |
8 | @RunWith(SpringRunner::class)
9 | @SpringBootTest
10 | class ReservationClientApplicationTests {
11 |
12 | @Test
13 | fun contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-kotlin/reservation-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-kotlin/reservation-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-kotlin/reservation-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-kotlin/reservation-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-kotlin/reservation-service/src/main/kotlin/com/example/reservationservice/ReservationServiceApplication.kt:
--------------------------------------------------------------------------------
1 | package com.example.reservationservice
2 |
3 | import org.springframework.beans.factory.annotation.Value
4 | import org.springframework.boot.ApplicationRunner
5 | import org.springframework.boot.SpringApplication
6 | import org.springframework.boot.actuate.health.Health
7 | import org.springframework.boot.actuate.health.HealthIndicator
8 | import org.springframework.boot.autoconfigure.SpringBootApplication
9 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient
10 | import org.springframework.cloud.context.config.annotation.RefreshScope
11 | import org.springframework.cloud.stream.annotation.EnableBinding
12 | import org.springframework.cloud.stream.annotation.StreamListener
13 | import org.springframework.cloud.stream.messaging.Sink
14 | import org.springframework.context.annotation.Bean
15 | import org.springframework.data.jpa.repository.JpaRepository
16 | import org.springframework.stereotype.Component
17 | import org.springframework.web.bind.annotation.GetMapping
18 | import org.springframework.web.bind.annotation.RestController
19 | import javax.persistence.Entity
20 | import javax.persistence.GeneratedValue
21 | import javax.persistence.Id
22 |
23 | @EnableBinding(Sink::class)
24 | @EnableDiscoveryClient
25 | @SpringBootApplication
26 | class ReservationServiceApplication {
27 |
28 | @Bean
29 | fun intializer(repository: ReservationRepository) =
30 | ApplicationRunner {
31 | arrayOf("Josh", "Sheng", "Wei", "Jialin",
32 | "Kevin", "Ning", "Liz", "Abel")
33 | .forEach { name -> repository.save(Reservation(reservationName = name)) }
34 |
35 | repository.findAll().forEach { println(it) }
36 | }
37 |
38 | @Bean
39 | fun health() = HealthIndicator {
40 | return@HealthIndicator Health.status("I <3 Microsoft!!").build()
41 | }
42 | }
43 |
44 | @RefreshScope
45 | @RestController
46 | class MessageRestController(@Value("\${message}") m: String) {
47 |
48 | var message: String? = m
49 |
50 | @GetMapping("/message")
51 | fun message() = this.message
52 |
53 | }
54 |
55 | @Component
56 | class MessageProcessor(val repository: ReservationRepository) {
57 |
58 | @StreamListener("input")
59 | fun onNewMessagePleaseWriteToDatabaseThankYou(reservationName: String) {
60 | repository.save(Reservation(reservationName = reservationName))
61 | }
62 | }
63 |
64 |
65 | @RestController
66 | class ReservationRestController(val repository: ReservationRepository) {
67 |
68 | @GetMapping("/reservations")
69 | fun reservations() =
70 | repository.findAll()
71 | }
72 |
73 | fun main(args: Array) {
74 | SpringApplication.run(ReservationServiceApplication::class.java, *args)
75 | }
76 |
77 |
78 | interface ReservationRepository : JpaRepository
79 |
80 | @Entity
81 | class Reservation(@Id @GeneratedValue var id: Long? = null, var reservationName: String? = null) {
82 | constructor() : this(null, null)
83 | }
--------------------------------------------------------------------------------
/code-kotlin/reservation-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-service
--------------------------------------------------------------------------------
/code-kotlin/reservation-service/src/test/kotlin/com/example/reservationservice/ReservationServiceApplicationTests.kt:
--------------------------------------------------------------------------------
1 | package com.example.reservationservice
2 |
3 | import org.junit.Test
4 | import org.junit.runner.RunWith
5 | import org.springframework.boot.test.context.SpringBootTest
6 | import org.springframework.test.context.junit4.SpringRunner
7 |
8 | @RunWith(SpringRunner::class)
9 | @SpringBootTest
10 | class ReservationServiceApplicationTests {
11 |
12 | @Test
13 | fun contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/code-kotlin/zipkin-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/code-kotlin/zipkin-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/code-kotlin/zipkin-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/code-kotlin/zipkin-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/code-kotlin/zipkin-service/src/main/kotlin/com/example/zipkinservice/ZipkinServiceApplication.kt:
--------------------------------------------------------------------------------
1 | package com.example.zipkinservice
2 |
3 | import org.springframework.boot.SpringApplication
4 | import org.springframework.boot.autoconfigure.SpringBootApplication
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient
6 | import zipkin.server.EnableZipkinServer
7 |
8 | @EnableDiscoveryClient
9 | @EnableZipkinServer
10 | @SpringBootApplication
11 | class ZipkinServiceApplication
12 |
13 | fun main(args: Array) {
14 | SpringApplication.run(ZipkinServiceApplication::class.java, *args)
15 | }
16 |
--------------------------------------------------------------------------------
/code-kotlin/zipkin-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=zipkin-service
--------------------------------------------------------------------------------
/code-kotlin/zipkin-service/src/test/kotlin/com/example/zipkinservice/ZipkinServiceApplicationTests.kt:
--------------------------------------------------------------------------------
1 | package com.example.zipkinservice
2 |
3 | import org.junit.Test
4 | import org.junit.runner.RunWith
5 | import org.springframework.boot.test.context.SpringBootTest
6 | import org.springframework.test.context.junit4.SpringRunner
7 |
8 | @RunWith(SpringRunner::class)
9 | @SpringBootTest
10 | class ZipkinServiceApplicationTests {
11 |
12 | @Test
13 | fun contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/1/reservation-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | reservation-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.3.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.data
29 | spring-data-rest-hal-browser
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-data-jpa
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-data-rest
38 |
39 |
40 | com.vaadin
41 | vaadin-spring-boot-starter
42 | 1.0.0
43 |
44 |
45 | org.springframework.boot
46 | spring-boot-starter-web
47 |
48 |
49 | com.h2database
50 | h2
51 |
52 |
53 | org.springframework.boot
54 | spring-boot-starter-test
55 | test
56 |
57 |
58 |
59 |
60 |
61 |
62 | com.vaadin
63 | vaadin-bom
64 | 7.5.5
65 | pom
66 | import
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | org.springframework.boot
75 | spring-boot-maven-plugin
76 |
77 |
78 |
79 |
80 |
81 |
82 | spring-snapshots
83 | Spring Snapshots
84 | https://repo.spring.io/snapshot
85 |
86 | true
87 |
88 |
89 |
90 | spring-milestones
91 | Spring Milestones
92 | https://repo.spring.io/milestone
93 |
94 | false
95 |
96 |
97 |
98 |
99 |
100 | spring-snapshots
101 | Spring Snapshots
102 | https://repo.spring.io/snapshot
103 |
104 | true
105 |
106 |
107 |
108 | spring-milestones
109 | Spring Milestones
110 | https://repo.spring.io/milestone
111 |
112 | false
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/labs/1/reservation-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import com.vaadin.annotations.Theme;
4 | import com.vaadin.data.util.BeanItemContainer;
5 | import com.vaadin.server.VaadinRequest;
6 | import com.vaadin.spring.annotation.SpringUI;
7 | import com.vaadin.ui.Table;
8 | import com.vaadin.ui.UI;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.boot.CommandLineRunner;
11 | import org.springframework.boot.SpringApplication;
12 | import org.springframework.boot.autoconfigure.SpringBootApplication;
13 | import org.springframework.context.annotation.Bean;
14 | import org.springframework.data.jpa.repository.JpaRepository;
15 | import org.springframework.data.repository.query.Param;
16 | import org.springframework.data.rest.core.annotation.RepositoryRestResource;
17 | import org.springframework.data.rest.core.annotation.RestResource;
18 | import org.springframework.hateoas.Link;
19 | import org.springframework.hateoas.Resource;
20 | import org.springframework.hateoas.ResourceProcessor;
21 | import org.springframework.stereotype.Component;
22 |
23 | import javax.persistence.Entity;
24 | import javax.persistence.GeneratedValue;
25 | import javax.persistence.Id;
26 | import java.util.Arrays;
27 | import java.util.Collection;
28 |
29 | @SpringBootApplication
30 | public class DemoApplication {
31 |
32 | @Bean
33 | CommandLineRunner runner(ReservationRepository rr) {
34 | return args ->
35 | Arrays.asList("Marten,Josh,Dave,Mark,Mark,Juergen".split(","))
36 | .forEach(x -> rr.save(new Reservation(x)));
37 |
38 | }
39 |
40 | public static void main(String[] args) {
41 | SpringApplication.run(DemoApplication.class, args);
42 | }
43 | }
44 |
45 |
46 | @SpringUI(path = "ui")
47 | @Theme("valo")
48 | class ReservationUI extends UI {
49 |
50 | @Autowired
51 | private ReservationRepository reservationRepository;
52 |
53 | @Override
54 | protected void init(VaadinRequest vaadinRequest) {
55 | Table components = new Table();
56 | components.setContainerDataSource(new BeanItemContainer<>(
57 | Reservation.class,
58 | this.reservationRepository.findAll()
59 | ));
60 | components.setSizeFull();
61 | setContent(components);
62 | }
63 |
64 | }
65 |
66 | @Component
67 | class ReservationResourceProcessor implements ResourceProcessor> {
68 |
69 | @Override
70 | public Resource process(Resource reservationResource) {
71 | Reservation reservation = reservationResource.getContent();
72 | Long id = reservation.getId();
73 | String url = "http://aws.images.com/" + id + ".jpg";
74 | reservationResource.add(new Link(url, "profile-photo"));
75 | return reservationResource;
76 | }
77 | }
78 |
79 | @RepositoryRestResource
80 | interface ReservationRepository extends JpaRepository {
81 |
82 | @RestResource(path = "by-name")
83 | Collection findByReservationName(@Param("rn") String rn);
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/labs/1/reservation-service/src/main/java/demo/Reservation.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Reservation {
9 |
10 | public Reservation() {
11 | }
12 |
13 | public Reservation(String reservationName) {
14 | this.reservationName = reservationName;
15 | }
16 |
17 | @Id
18 | @GeneratedValue
19 | private Long id;
20 | private String reservationName;
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public String getReservationName() {
27 | return reservationName;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/labs/1/reservation-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshlong/cloud-native-workshop/b6b67c1e81fed1d26b5ffc2f476624ec88ed20e8/labs/1/reservation-service/src/main/resources/application.properties
--------------------------------------------------------------------------------
/labs/1/reservation-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 | import org.springframework.test.context.web.WebAppConfiguration;
11 | import org.springframework.test.web.servlet.MockMvc;
12 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
13 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15 | import org.springframework.web.context.WebApplicationContext;
16 |
17 | @RunWith(SpringJUnit4ClassRunner.class)
18 | @SpringApplicationConfiguration(classes = DemoApplication.class)
19 | @WebAppConfiguration
20 | public class DemoApplicationTests {
21 |
22 | @Autowired
23 | private WebApplicationContext webApplicationContext;
24 |
25 | private MockMvc mockMvc;
26 |
27 | @Before
28 | public void before() throws Exception {
29 | this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
30 | }
31 |
32 | @Test
33 | public void contextLoads() throws Exception {
34 | this.mockMvc.perform(MockMvcRequestBuilders.get("/reservations"))
35 | .andExpect(MockMvcResultMatchers.content().contentType(MediaType.parseMediaType("application/hal+json")))
36 | .andExpect(MockMvcResultMatchers.status().isOk());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/labs/2/reservation-service/src/main/java/demo/Reservation.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Reservation {
9 |
10 | public Reservation() {
11 | }
12 |
13 | public Reservation(String reservationName) {
14 | this.reservationName = reservationName;
15 | }
16 |
17 | @Id
18 | @GeneratedValue
19 | private Long id;
20 | private String reservationName;
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public String getReservationName() {
27 | return reservationName;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/labs/2/reservation-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | info.build.artifact=${project.artifactId}
2 | info.build.version=${project.version}
--------------------------------------------------------------------------------
/labs/2/reservation-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 | import org.springframework.test.context.web.WebAppConfiguration;
11 | import org.springframework.test.web.servlet.MockMvc;
12 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
13 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15 | import org.springframework.web.context.WebApplicationContext;
16 |
17 | @RunWith(SpringJUnit4ClassRunner.class)
18 | @SpringApplicationConfiguration(classes = DemoApplication.class)
19 | @WebAppConfiguration
20 | public class DemoApplicationTests {
21 |
22 | @Autowired
23 | private WebApplicationContext webApplicationContext;
24 |
25 | private MockMvc mockMvc;
26 |
27 | @Before
28 | public void before() throws Exception {
29 | this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
30 | }
31 |
32 | @Test
33 | public void contextLoads() throws Exception {
34 | this.mockMvc.perform(MockMvcRequestBuilders.get("/reservations"))
35 | .andExpect(MockMvcResultMatchers.content().contentType(MediaType.parseMediaType("application/hal+json")))
36 | .andExpect(MockMvcResultMatchers.status().isOk());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/labs/3/config-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | config-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.3.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M5
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-maven-plugin
56 |
57 |
58 |
59 |
60 |
61 |
62 | spring-snapshots
63 | Spring Snapshots
64 | https://repo.spring.io/snapshot
65 |
66 | true
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 | spring-snapshots
81 | Spring Snapshots
82 | https://repo.spring.io/snapshot
83 |
84 | true
85 |
86 |
87 |
88 | spring-milestones
89 | Spring Milestones
90 | https://repo.spring.io/milestone
91 |
92 | false
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/labs/3/config-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @EnableConfigServer
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/3/config-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.server.git.uri=https://github.com/joshlong/bootiful-microservices-config.git
2 | server.port=8888
3 |
--------------------------------------------------------------------------------
/labs/3/config-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/3/reservation-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.beans.factory.annotation.Value;
7 | import org.springframework.boot.CommandLineRunner;
8 | import org.springframework.boot.SpringApplication;
9 | import org.springframework.boot.actuate.health.Health;
10 | import org.springframework.boot.actuate.health.HealthIndicator;
11 | import org.springframework.boot.actuate.metrics.CounterService;
12 | import org.springframework.boot.autoconfigure.SpringBootApplication;
13 | import org.springframework.cloud.context.config.annotation.RefreshScope;
14 | import org.springframework.context.annotation.Bean;
15 | import org.springframework.data.jpa.repository.JpaRepository;
16 | import org.springframework.data.repository.query.Param;
17 | import org.springframework.data.rest.core.annotation.*;
18 | import org.springframework.hateoas.Link;
19 | import org.springframework.hateoas.Resource;
20 | import org.springframework.hateoas.ResourceProcessor;
21 | import org.springframework.stereotype.Component;
22 | import org.springframework.web.bind.annotation.RequestMapping;
23 | import org.springframework.web.bind.annotation.RestController;
24 |
25 | import java.util.Arrays;
26 | import java.util.Collection;
27 |
28 | @SpringBootApplication
29 | public class DemoApplication {
30 |
31 | private static Logger LOGGER = LoggerFactory.getLogger(
32 | DemoApplication.class);
33 |
34 |
35 | @Bean
36 | HealthIndicator healthIndicator() {
37 | return () -> Health.status("I <3 Spring!").build();
38 | }
39 |
40 | @Bean
41 | CommandLineRunner runner(ReservationRepository rr) {
42 | return args ->
43 | Arrays.asList("Marten,Josh,Dave,Mark,Mark,Juergen".split(","))
44 | .forEach(x -> rr.save(new Reservation(x)));
45 |
46 | }
47 |
48 | public static void main(String[] args) {
49 | SpringApplication.run(DemoApplication.class, args);
50 | }
51 |
52 | @Component
53 | @RepositoryEventHandler
54 | public static class ReservationEventHandler {
55 |
56 | @Autowired
57 | private CounterService counterService;
58 |
59 | @HandleAfterCreate
60 | public void create(Reservation p) {
61 | count("reservations.create", p);
62 | }
63 |
64 | @HandleAfterSave
65 | public void save(Reservation p) {
66 | count("reservations.save", p);
67 | count("reservations." + p.getId() + ".save", p);
68 | }
69 |
70 | @HandleAfterDelete
71 | public void delete(Reservation p) {
72 | count("reservations.delete", p);
73 | }
74 |
75 | protected void count(String evt, Reservation p) {
76 | this.counterService.increment(evt);
77 | this.counterService.increment("meter." + evt);
78 | }
79 | }
80 | }
81 |
82 | @RefreshScope
83 | @RestController
84 | class MessageRestController {
85 |
86 | @Value("${message}")
87 | private String message;
88 |
89 | @RequestMapping("/message")
90 | String getMessage() {
91 | return this.message;
92 | }
93 | }
94 |
95 | @Component
96 | class ReservationResourceProcessor implements ResourceProcessor> {
97 |
98 | @Override
99 | public Resource process(Resource reservationResource) {
100 | Reservation reservation = reservationResource.getContent();
101 | Long id = reservation.getId();
102 | String url = "http://aws.images.com/" + id + ".jpg";
103 | reservationResource.add(new Link(url, "profile-photo"));
104 | return reservationResource;
105 | }
106 | }
107 |
108 | @RepositoryRestResource
109 | interface ReservationRepository extends JpaRepository {
110 |
111 | @RestResource(path = "by-name")
112 | Collection findByReservationName(@Param("rn") String rn);
113 | }
114 |
115 |
--------------------------------------------------------------------------------
/labs/3/reservation-service/src/main/java/demo/Reservation.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Reservation {
9 |
10 | public Reservation() {
11 | }
12 |
13 | public Reservation(String reservationName) {
14 | this.reservationName = reservationName;
15 | }
16 |
17 | @Id
18 | @GeneratedValue
19 | private Long id;
20 | private String reservationName;
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public String getReservationName() {
27 | return reservationName;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/labs/3/reservation-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-service
2 | spring.cloud.config.uri=http://localhost:8888
--------------------------------------------------------------------------------
/labs/3/reservation-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 | import org.springframework.test.context.web.WebAppConfiguration;
11 | import org.springframework.test.web.servlet.MockMvc;
12 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
13 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15 | import org.springframework.web.context.WebApplicationContext;
16 |
17 | @RunWith(SpringJUnit4ClassRunner.class)
18 | @SpringApplicationConfiguration(classes = DemoApplication.class)
19 | @WebAppConfiguration
20 | public class DemoApplicationTests {
21 |
22 | @Autowired
23 | private WebApplicationContext webApplicationContext;
24 |
25 | private MockMvc mockMvc;
26 |
27 | @Before
28 | public void before() throws Exception {
29 | this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
30 | }
31 |
32 | @Test
33 | public void contextLoads() throws Exception {
34 | this.mockMvc.perform(MockMvcRequestBuilders.get("/reservations"))
35 | .andExpect(MockMvcResultMatchers.content().contentType(MediaType.parseMediaType("application/hal+json")))
36 | .andExpect(MockMvcResultMatchers.status().isOk());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/labs/4/config-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | config-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.3.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M5
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-maven-plugin
56 |
57 |
58 |
59 |
60 |
61 |
62 | spring-snapshots
63 | Spring Snapshots
64 | https://repo.spring.io/snapshot
65 |
66 | true
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 | spring-snapshots
81 | Spring Snapshots
82 | https://repo.spring.io/snapshot
83 |
84 | true
85 |
86 |
87 |
88 | spring-milestones
89 | Spring Milestones
90 | https://repo.spring.io/milestone
91 |
92 | false
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/labs/4/config-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @EnableConfigServer
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/4/config-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.server.git.uri=https://github.com/joshlong/bootiful-microservices-config.git
2 | server.port=8888
--------------------------------------------------------------------------------
/labs/4/config-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/4/eureka-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | eureka-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.3.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-config
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-eureka-server
34 |
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-test
39 | test
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.springframework.cloud
47 | spring-cloud-starter-parent
48 | Brixton.M5
49 | pom
50 | import
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | org.springframework.boot
59 | spring-boot-maven-plugin
60 |
61 |
62 |
63 |
64 |
65 |
66 | spring-snapshots
67 | Spring Snapshots
68 | https://repo.spring.io/snapshot
69 |
70 | true
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 | spring-snapshots
85 | Spring Snapshots
86 | https://repo.spring.io/snapshot
87 |
88 | true
89 |
90 |
91 |
92 | spring-milestones
93 | Spring Milestones
94 | https://repo.spring.io/milestone
95 |
96 | false
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/labs/4/eureka-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
7 |
8 | @EnableEurekaServer
9 | @SpringBootApplication
10 | public class DemoApplication {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(DemoApplication.class, args);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/labs/4/eureka-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.uri=http://localhost:8888
2 | spring.application.name=eureka-service
--------------------------------------------------------------------------------
/labs/4/eureka-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/4/reservation-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | reservation-client
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.3.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-config
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-eureka
34 |
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-test
39 | test
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.springframework.cloud
47 | spring-cloud-starter-parent
48 | Brixton.M5
49 | pom
50 | import
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | org.springframework.boot
59 | spring-boot-maven-plugin
60 |
61 |
62 |
63 |
64 |
65 |
66 | spring-snapshots
67 | Spring Snapshots
68 | https://repo.spring.io/snapshot
69 |
70 | true
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 | spring-snapshots
85 | Spring Snapshots
86 | https://repo.spring.io/snapshot
87 |
88 | true
89 |
90 |
91 |
92 | spring-milestones
93 | Spring Milestones
94 | https://repo.spring.io/milestone
95 |
96 | false
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/labs/4/reservation-client/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.CommandLineRunner;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.client.discovery.DiscoveryClient;
7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
8 | import org.springframework.context.annotation.Bean;
9 |
10 | @EnableDiscoveryClient
11 | @SpringBootApplication
12 | public class DemoApplication {
13 |
14 | @Bean
15 | CommandLineRunner runner(DiscoveryClient dc) {
16 | return args ->
17 | dc.getInstances("reservation-service")
18 | .forEach(si -> System.out.println(String.format(
19 | "%s %s:%s", si.getServiceId(), si.getHost(), si.getPort())));
20 | }
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(DemoApplication.class, args);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/labs/4/reservation-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-client
2 | spring.cloud.config.uri=http://localhost:8888
--------------------------------------------------------------------------------
/labs/4/reservation-client/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/4/reservation-service/src/main/java/demo/Reservation.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Reservation {
9 |
10 | public Reservation() {
11 | }
12 |
13 | public Reservation(String reservationName) {
14 | this.reservationName = reservationName;
15 | }
16 |
17 | @Id
18 | @GeneratedValue
19 | private Long id;
20 | private String reservationName;
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public String getReservationName() {
27 | return reservationName;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/labs/4/reservation-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-service
2 | spring.cloud.config.uri=http://localhost:8888
--------------------------------------------------------------------------------
/labs/4/reservation-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 | import org.springframework.test.context.web.WebAppConfiguration;
11 | import org.springframework.test.web.servlet.MockMvc;
12 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
13 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15 | import org.springframework.web.context.WebApplicationContext;
16 |
17 | @RunWith(SpringJUnit4ClassRunner.class)
18 | @SpringApplicationConfiguration(classes = DemoApplication.class)
19 | @WebAppConfiguration
20 | public class DemoApplicationTests {
21 |
22 | @Autowired
23 | private WebApplicationContext webApplicationContext;
24 |
25 | private MockMvc mockMvc;
26 |
27 | @Before
28 | public void before() throws Exception {
29 | this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
30 | }
31 |
32 | @Test
33 | public void contextLoads() throws Exception {
34 | this.mockMvc.perform(MockMvcRequestBuilders.get("/reservations"))
35 | .andExpect(MockMvcResultMatchers.content().contentType(MediaType.parseMediaType("application/hal+json")))
36 | .andExpect(MockMvcResultMatchers.status().isOk());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/labs/5/config-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | config-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M1
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-maven-plugin
56 |
57 |
58 |
59 |
60 |
61 |
62 | spring-snapshots
63 | Spring Snapshots
64 | https://repo.spring.io/snapshot
65 |
66 | true
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 | spring-snapshots
81 | Spring Snapshots
82 | https://repo.spring.io/snapshot
83 |
84 | true
85 |
86 |
87 |
88 | spring-milestones
89 | Spring Milestones
90 | https://repo.spring.io/milestone
91 |
92 | false
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/labs/5/config-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @EnableConfigServer
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/5/config-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.server.git.uri=https://github.com/joshlong/bootiful-microservices-config.git
2 | server.port=8888
--------------------------------------------------------------------------------
/labs/5/config-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/5/eureka-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | eureka-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-config
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-eureka-server
34 |
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-test
39 | test
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.springframework.cloud
47 | spring-cloud-starter-parent
48 | Brixton.M1
49 | pom
50 | import
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | org.springframework.boot
59 | spring-boot-maven-plugin
60 |
61 |
62 |
63 |
64 |
65 |
66 | spring-snapshots
67 | Spring Snapshots
68 | https://repo.spring.io/snapshot
69 |
70 | true
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 | spring-snapshots
85 | Spring Snapshots
86 | https://repo.spring.io/snapshot
87 |
88 | true
89 |
90 |
91 |
92 | spring-milestones
93 | Spring Milestones
94 | https://repo.spring.io/milestone
95 |
96 | false
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/labs/5/eureka-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
7 |
8 | @EnableEurekaServer
9 | @SpringBootApplication
10 | public class DemoApplication {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(DemoApplication.class, args);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/labs/5/eureka-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.uri=http://localhost:8888
2 | spring.application.name=eureka-service
--------------------------------------------------------------------------------
/labs/5/eureka-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/5/hystrix-dashboard/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | hystrix-dashboard
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-hystrix-dashboard
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M1
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-maven-plugin
56 |
57 |
58 |
59 |
60 |
61 |
62 | spring-snapshots
63 | Spring Snapshots
64 | https://repo.spring.io/snapshot
65 |
66 | true
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 | spring-snapshots
81 | Spring Snapshots
82 | https://repo.spring.io/snapshot
83 |
84 | true
85 |
86 |
87 |
88 | spring-milestones
89 | Spring Milestones
90 | https://repo.spring.io/milestone
91 |
92 | false
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/labs/5/hystrix-dashboard/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
6 |
7 | @EnableHystrixDashboard
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/5/hystrix-dashboard/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=hystrix-dashboard
2 | spring.cloud.config.uri=http://localhost:8888
--------------------------------------------------------------------------------
/labs/5/hystrix-dashboard/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/5/reservation-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | reservation-client
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-hateoas
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-actuator
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-config
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-eureka
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-zuul
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-starter-hystrix
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-starter-test
54 | test
55 |
56 |
57 |
58 |
59 |
60 |
61 | org.springframework.cloud
62 | spring-cloud-starter-parent
63 | Brixton.M1
64 | pom
65 | import
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | org.springframework.boot
74 | spring-boot-maven-plugin
75 |
76 |
77 |
78 |
79 |
80 |
81 | spring-snapshots
82 | Spring Snapshots
83 | https://repo.spring.io/snapshot
84 |
85 | true
86 |
87 |
88 |
89 | spring-milestones
90 | Spring Milestones
91 | https://repo.spring.io/milestone
92 |
93 | false
94 |
95 |
96 |
97 |
98 |
99 | spring-snapshots
100 | Spring Snapshots
101 | https://repo.spring.io/snapshot
102 |
103 | true
104 |
105 |
106 |
107 | spring-milestones
108 | Spring Milestones
109 | https://repo.spring.io/milestone
110 |
111 | false
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/labs/5/reservation-client/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.boot.CommandLineRunner;
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
9 | import org.springframework.cloud.client.discovery.DiscoveryClient;
10 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
11 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
12 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
13 | import org.springframework.context.annotation.Bean;
14 | import org.springframework.core.ParameterizedTypeReference;
15 | import org.springframework.hateoas.Resources;
16 | import org.springframework.http.HttpMethod;
17 | import org.springframework.http.ResponseEntity;
18 | import org.springframework.web.bind.annotation.RequestMapping;
19 | import org.springframework.web.bind.annotation.RestController;
20 | import org.springframework.web.client.RestTemplate;
21 |
22 | import java.util.Collection;
23 | import java.util.Collections;
24 | import java.util.stream.Collectors;
25 |
26 | @EnableZuulProxy
27 | @EnableCircuitBreaker
28 | @EnableDiscoveryClient
29 | @SpringBootApplication
30 | public class DemoApplication {
31 |
32 | @Bean
33 | CommandLineRunner runner(DiscoveryClient dc) {
34 | return args ->
35 | dc.getInstances("reservation-service")
36 | .forEach(si -> System.out.println(String.format(
37 | "%s %s:%s", si.getServiceId(), si.getHost(), si.getPort())));
38 | }
39 |
40 | public static void main(String[] args) {
41 | SpringApplication.run(DemoApplication.class, args);
42 | }
43 | }
44 |
45 | @RestController
46 | @RequestMapping("/reservations")
47 | class ReservationApiGatewayRestController {
48 |
49 | @Autowired
50 | @LoadBalanced
51 | private RestTemplate rt;
52 |
53 | public Collection getReservationNamesFallback() {
54 | return Collections.emptyList();
55 | }
56 |
57 | @RequestMapping("/names")
58 | @HystrixCommand(fallbackMethod = "getReservationNamesFallback")
59 | public Collection getReservationNames() {
60 |
61 | ParameterizedTypeReference> parameterizedTypeReference =
62 | new ParameterizedTypeReference>() {
63 | };
64 |
65 | ResponseEntity> exchange = rt.exchange(
66 | "http://reservation-service/reservations", HttpMethod.GET, null, parameterizedTypeReference);
67 |
68 | return exchange
69 | .getBody()
70 | .getContent()
71 | .stream()
72 | .map(Reservation::getReservationName)
73 | .collect(Collectors.toList());
74 | }
75 |
76 | }
77 |
78 | class Reservation {
79 |
80 | private Long id;
81 | private String reservationName;
82 |
83 | public Long getId() {
84 | return id;
85 | }
86 |
87 | public String getReservationName() {
88 | return reservationName;
89 | }
90 | }
--------------------------------------------------------------------------------
/labs/5/reservation-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-client
2 | spring.cloud.config.uri=http://localhost:8888
--------------------------------------------------------------------------------
/labs/5/reservation-client/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/5/reservation-service/src/main/java/demo/Reservation.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Reservation {
9 |
10 | public Reservation() {
11 | }
12 |
13 | public Reservation(String reservationName) {
14 | this.reservationName = reservationName;
15 | }
16 |
17 | @Id
18 | @GeneratedValue
19 | private Long id;
20 | private String reservationName;
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public String getReservationName() {
27 | return reservationName;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/labs/5/reservation-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-service
2 | spring.cloud.config.uri=http://localhost:8888
--------------------------------------------------------------------------------
/labs/5/reservation-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 | import org.springframework.test.context.web.WebAppConfiguration;
11 | import org.springframework.test.web.servlet.MockMvc;
12 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
13 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15 | import org.springframework.web.context.WebApplicationContext;
16 |
17 | @RunWith(SpringJUnit4ClassRunner.class)
18 | @SpringApplicationConfiguration(classes = DemoApplication.class)
19 | @WebAppConfiguration
20 | public class DemoApplicationTests {
21 |
22 | @Autowired
23 | private WebApplicationContext webApplicationContext;
24 |
25 | private MockMvc mockMvc;
26 |
27 | @Before
28 | public void before() throws Exception {
29 | this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
30 | }
31 |
32 | @Test
33 | public void contextLoads() throws Exception {
34 | this.mockMvc.perform(MockMvcRequestBuilders.get("/reservations"))
35 | .andExpect(MockMvcResultMatchers.content().contentType(MediaType.parseMediaType("application/hal+json")))
36 | .andExpect(MockMvcResultMatchers.status().isOk());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/labs/6/cf-simple.sh:
--------------------------------------------------------------------------------
1 |
2 | cd config-service
3 | cf push
4 | # run cf apps to get the URL of config-service,
5 | # or note it from the "urls" output of the `cf push`
6 | # and place it in the next line where it says _URL_
7 | cf cups config-service -p '{"uri":"http://config-service-unfiercely-alkalimetry.cfapps.io"}'
8 | cd ..
9 |
10 | cd eureka-service
11 | cf push
12 | # run cf apps to get the URL of eureka-service,
13 | # or note it from the "urls" output of the `cf push`,
14 | # and place it in the next line where it says _URL_
15 | cf cups eureka-service -p '{"uri":"http://eureka-service-rooted-subquarter.cfapps.io"}'
16 | cd ..
17 |
18 | cd reservation-service
19 | cf push
20 | cd ..
21 |
22 | cd reservation-client
23 | cf push
24 | cd ..
25 |
--------------------------------------------------------------------------------
/labs/6/cf.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | #
5 | # the big CloudFoundry installer
6 | #
7 |
8 | CLOUD_DOMAIN=${DOMAIN:-run.pivotal.io}
9 | CLOUD_TARGET=api.${DOMAIN}
10 |
11 | function login(){
12 | cf api | grep ${CLOUD_TARGET} || cf api ${CLOUD_TARGET} --skip-ssl-validation
13 | cf a | grep OK || cf login
14 | }
15 |
16 | function app_domain(){
17 | D=`cf apps | grep $1 | tr -s ' ' | cut -d' ' -f 6 | cut -d, -f1`
18 | echo $D
19 | }
20 |
21 | ## COMMON
22 |
23 | function deploy_app(){
24 | APP_NAME=$1
25 | echo "APP_NAME=$APP_NAME"
26 | cd $APP_NAME
27 | cf push $APP_NAME
28 | cd ..
29 | }
30 |
31 | function deploy_service(){
32 | N=$1
33 | D=`app_domain $N`
34 | JSON='{"uri":"http://'$D'"}'
35 | echo cf cups $N -p $JSON
36 | cf cups $N -p $JSON
37 | }
38 |
39 | function deploy_config_service(){
40 | NAME=config-service
41 | deploy_app $NAME
42 | deploy_service $NAME
43 | }
44 |
45 | function deploy_eureka_service(){
46 | NAME=eureka-service
47 | deploy_app $NAME
48 | deploy_service $NAME
49 | }
50 |
51 | function deploy_hystrix_dashboard(){
52 | deploy_app hystrix-dashboard
53 | }
54 |
55 |
56 | function deploy_reservation_service(){
57 | cf cs elephantsql turtle reservations-postgresql
58 | deploy_app reservation-service
59 | }
60 |
61 | function deploy_reservation_client(){
62 | deploy_app reservation-client
63 | }
64 |
65 | function reset(){
66 |
67 | echo "reset.."
68 | apps="hystrix-dashboard reservation-client reservation-service eureka-service config-service"
69 | apps_arr=( $apps )
70 | for a in "${apps_arr[@]}";
71 | do
72 | echo $a
73 | cf d -f $a
74 | done
75 |
76 | services="reservations-postgresql eureka-service config-service"
77 | services_arr=( $services )
78 | for s in "${services_arr[@]}";
79 | do
80 | echo $s
81 | cf ds -f $s
82 | done
83 |
84 | cf delete-orphaned-routes -f
85 |
86 | }
87 |
88 | ###
89 | ### INSTALLATION STEPS
90 | ###
91 |
92 | #mvn -DskipTests=true clean install
93 |
94 | function install(){
95 | apps="hystrix-dashboard reservation-client reservation-service eureka-service config-service"
96 | apps_arr=( $apps )
97 | for a in "${apps_arr[@]}";
98 | do
99 | echo $a
100 | mvn -f $a/pom.xml -DskipTests=true clean install
101 | done
102 | }
103 |
104 | #login
105 | reset
106 | install
107 | deploy_config_service
108 | deploy_eureka_service
109 | #deploy_hystrix_dashboard
110 | deploy_reservation_service
111 | deploy_reservation_client
112 |
--------------------------------------------------------------------------------
/labs/6/config-service/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: config-service
4 | host: config-service-${random-word}
5 | memory: 512M
6 | path: target/config-service.jar
7 | env:
8 | SPRING_PROFILES_ACTIVE: cloud
9 | DEBUG: "true"
10 | SPRING_CLOUD_CONFIG_SERVER_GIT_URI: https://github.com/joshlong/bootiful-microservices-config
11 |
--------------------------------------------------------------------------------
/labs/6/config-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | config-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M1
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 | ${project.artifactId}
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
63 | spring-snapshots
64 | Spring Snapshots
65 | https://repo.spring.io/snapshot
66 |
67 | true
68 |
69 |
70 |
71 | spring-milestones
72 | Spring Milestones
73 | https://repo.spring.io/milestone
74 |
75 | false
76 |
77 |
78 |
79 |
80 |
81 | spring-snapshots
82 | Spring Snapshots
83 | https://repo.spring.io/snapshot
84 |
85 | true
86 |
87 |
88 |
89 | spring-milestones
90 | Spring Milestones
91 | https://repo.spring.io/milestone
92 |
93 | false
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/labs/6/config-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @EnableConfigServer
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/6/config-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.server.git.uri=https://github.com/joshlong/bootiful-microservices-config.git
2 | server.port=8888
--------------------------------------------------------------------------------
/labs/6/config-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/6/eureka-service/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: eureka-service
4 | host: eureka-service-${random-word}
5 | memory: 512M
6 | path: target/eureka-service.jar
7 | services:
8 | - config-service
9 | env:
10 | SPRING_PROFILES_ACTIVE: cloud
11 | DEBUG: "true"
12 |
--------------------------------------------------------------------------------
/labs/6/eureka-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | eureka-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 |
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-config
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-starter-eureka-server
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-starter-parent
49 | Brixton.M1
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 | ${project.artifactId}
58 |
59 |
60 |
61 | org.springframework.boot
62 | spring-boot-maven-plugin
63 |
64 |
65 |
66 |
67 |
68 |
69 | spring-snapshots
70 | Spring Snapshots
71 | https://repo.spring.io/snapshot
72 |
73 | true
74 |
75 |
76 |
77 | spring-milestones
78 | Spring Milestones
79 | https://repo.spring.io/milestone
80 |
81 | false
82 |
83 |
84 |
85 |
86 |
87 | spring-snapshots
88 | Spring Snapshots
89 | https://repo.spring.io/snapshot
90 |
91 | true
92 |
93 |
94 |
95 | spring-milestones
96 | Spring Milestones
97 | https://repo.spring.io/milestone
98 |
99 | false
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/labs/6/eureka-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
7 |
8 | @EnableEurekaServer
9 | @SpringBootApplication
10 | public class DemoApplication {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(DemoApplication.class, args);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/labs/6/eureka-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
2 | spring.application.name=eureka-service
3 |
--------------------------------------------------------------------------------
/labs/6/eureka-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/6/hystrix-dashboard/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: hystrix-dashboard
4 | host: hystrix-dashboard-${random-word}
5 | path: target/hystrix-dashboard.jar
6 | services:
7 | - config-service
8 | - eureka-service
9 | env:
10 | SPRING_PROFILES_ACTIVE: cloud
11 | DEBUG: "true"
12 |
--------------------------------------------------------------------------------
/labs/6/hystrix-dashboard/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | hystrix-dashboard
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-hystrix-dashboard
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M1
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 | ${project.artifactId}
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
63 | spring-snapshots
64 | Spring Snapshots
65 | https://repo.spring.io/snapshot
66 |
67 | true
68 |
69 |
70 |
71 | spring-milestones
72 | Spring Milestones
73 | https://repo.spring.io/milestone
74 |
75 | false
76 |
77 |
78 |
79 |
80 |
81 | spring-snapshots
82 | Spring Snapshots
83 | https://repo.spring.io/snapshot
84 |
85 | true
86 |
87 |
88 |
89 | spring-milestones
90 | Spring Milestones
91 | https://repo.spring.io/milestone
92 |
93 | false
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/labs/6/hystrix-dashboard/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
6 |
7 | @EnableHystrixDashboard
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/6/hystrix-dashboard/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=hystrix-dashboard
2 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
3 |
--------------------------------------------------------------------------------
/labs/6/hystrix-dashboard/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/6/reservation-client/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: reservation-client
4 | host: reservation-client-${random-word}
5 | path: target/reservation-client.jar
6 | memory: 512M
7 | services:
8 | - config-service
9 | - eureka-service
10 | env:
11 | SPRING_PROFILES_ACTIVE: cloud
12 | DEBUG: "true"
13 | debug: "true"
14 |
--------------------------------------------------------------------------------
/labs/6/reservation-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | reservation-client
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-cloud-connectors
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-hateoas
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-actuator
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-config
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-eureka
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-starter-zuul
50 |
51 |
52 | org.springframework.cloud
53 | spring-cloud-starter-hystrix
54 |
55 |
56 | org.springframework.boot
57 | spring-boot-starter-test
58 | test
59 |
60 |
61 |
62 |
63 |
64 |
65 | org.springframework.cloud
66 | spring-cloud-starter-parent
67 | Brixton.M1
68 | pom
69 | import
70 |
71 |
72 |
73 |
74 | ${project.artifactId}
75 |
76 |
77 |
78 | org.springframework.boot
79 | spring-boot-maven-plugin
80 |
81 |
82 |
83 |
84 |
85 |
86 | spring-snapshots
87 | Spring Snapshots
88 | https://repo.spring.io/snapshot
89 |
90 | true
91 |
92 |
93 |
94 | spring-milestones
95 | Spring Milestones
96 | https://repo.spring.io/milestone
97 |
98 | false
99 |
100 |
101 |
102 |
103 |
104 | spring-snapshots
105 | Spring Snapshots
106 | https://repo.spring.io/snapshot
107 |
108 | true
109 |
110 |
111 |
112 | spring-milestones
113 | Spring Milestones
114 | https://repo.spring.io/milestone
115 |
116 | false
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/labs/6/reservation-client/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.boot.CommandLineRunner;
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
9 | import org.springframework.cloud.client.discovery.DiscoveryClient;
10 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
11 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
12 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
13 | import org.springframework.context.annotation.Bean;
14 | import org.springframework.core.ParameterizedTypeReference;
15 | import org.springframework.hateoas.Resources;
16 | import org.springframework.http.HttpMethod;
17 | import org.springframework.http.ResponseEntity;
18 | import org.springframework.web.bind.annotation.RequestMapping;
19 | import org.springframework.web.bind.annotation.RestController;
20 | import org.springframework.web.client.RestTemplate;
21 |
22 | import java.util.Collection;
23 | import java.util.Collections;
24 | import java.util.stream.Collectors;
25 |
26 | @EnableZuulProxy
27 | @EnableCircuitBreaker
28 | @EnableDiscoveryClient
29 | @SpringBootApplication
30 | public class DemoApplication {
31 |
32 | @Bean
33 | CommandLineRunner runner(DiscoveryClient dc) {
34 | return args ->
35 | dc.getInstances("reservation-service")
36 | .forEach(si -> System.out.println(String.format(
37 | "%s %s:%s", si.getServiceId(), si.getHost(), si.getPort())));
38 | }
39 |
40 | public static void main(String[] args) {
41 | SpringApplication.run(DemoApplication.class, args);
42 | }
43 | }
44 |
45 | @RestController
46 | @RequestMapping("/reservations")
47 | class ReservationApiGatewayRestController {
48 |
49 | @Autowired
50 | @LoadBalanced
51 | private RestTemplate rt;
52 |
53 | public Collection getReservationNamesFallback() {
54 | return Collections.emptyList();
55 | }
56 |
57 | @RequestMapping("/names")
58 | @HystrixCommand(fallbackMethod = "getReservationNamesFallback")
59 | public Collection getReservationNames() {
60 |
61 | ParameterizedTypeReference> parameterizedTypeReference =
62 | new ParameterizedTypeReference>() {
63 | };
64 |
65 | ResponseEntity> exchange = rt.exchange(
66 | "http://reservation-service/reservations", HttpMethod.GET, null, parameterizedTypeReference);
67 |
68 | return exchange
69 | .getBody()
70 | .getContent()
71 | .stream()
72 | .map(Reservation::getReservationName)
73 | .collect(Collectors.toList());
74 | }
75 |
76 | }
77 |
78 | class Reservation {
79 |
80 | private Long id;
81 | private String reservationName;
82 |
83 | public Long getId() {
84 | return id;
85 | }
86 |
87 | public String getReservationName() {
88 | return reservationName;
89 | }
90 | }
--------------------------------------------------------------------------------
/labs/6/reservation-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-client
2 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
3 |
--------------------------------------------------------------------------------
/labs/6/reservation-client/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/6/reservation-service/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: reservation-service
4 | path: target/reservation-service.jar
5 | host: reservation-service-${random-word}
6 | memory: 512M
7 | services:
8 | - config-service
9 | - eureka-service
10 | env:
11 | DEBUG: "true"
12 | debug: "true"
13 |
--------------------------------------------------------------------------------
/labs/6/reservation-service/src/main/java/demo/Reservation.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Reservation {
9 |
10 | public Reservation() {
11 | }
12 |
13 | public Reservation(String reservationName) {
14 | this.reservationName = reservationName;
15 | }
16 |
17 | @Id
18 | @GeneratedValue
19 | private Long id;
20 | private String reservationName;
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public String getReservationName() {
27 | return reservationName;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/labs/6/reservation-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-service
2 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
3 |
--------------------------------------------------------------------------------
/labs/6/reservation-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 | import org.springframework.test.context.web.WebAppConfiguration;
11 | import org.springframework.test.web.servlet.MockMvc;
12 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
13 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15 | import org.springframework.web.context.WebApplicationContext;
16 |
17 | @RunWith(SpringJUnit4ClassRunner.class)
18 | @SpringApplicationConfiguration(classes = DemoApplication.class)
19 | @WebAppConfiguration
20 | public class DemoApplicationTests {
21 |
22 | @Autowired
23 | private WebApplicationContext webApplicationContext;
24 |
25 | private MockMvc mockMvc;
26 |
27 | @Before
28 | public void before() throws Exception {
29 | this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
30 | }
31 |
32 | @Test
33 | public void contextLoads() throws Exception {
34 | this.mockMvc.perform(MockMvcRequestBuilders.get("/reservations"))
35 | .andExpect(MockMvcResultMatchers.content().contentType(MediaType.parseMediaType("application/hal+json")))
36 | .andExpect(MockMvcResultMatchers.status().isOk());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/labs/7/cf-simple.sh:
--------------------------------------------------------------------------------
1 |
2 | cd config-service
3 | cf push
4 | # run cf apps to get the URL of config-service,
5 | # or note it from the "urls" output of the `cf push`
6 | # and place it in the next line where it says _URL_
7 | cf cups config-service -p '{"uri":"http://config-service-unfiercely-alkalimetry.cfapps.io"}'
8 | cd ..
9 |
10 | cd eureka-service
11 | cf push
12 | # run cf apps to get the URL of eureka-service,
13 | # or note it from the "urls" output of the `cf push`,
14 | # and place it in the next line where it says _URL_
15 | cf cups eureka-service -p '{"uri":"http://eureka-service-rooted-subquarter.cfapps.io"}'
16 | cd ..
17 |
18 | cd reservation-service
19 | cf push
20 | cd ..
21 |
22 | cd reservation-client
23 | cf push
24 | cd ..
25 |
--------------------------------------------------------------------------------
/labs/7/cf.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | #
5 | # the big CloudFoundry installer
6 | #
7 |
8 | CLOUD_DOMAIN=${DOMAIN:-run.pivotal.io}
9 | CLOUD_TARGET=api.${DOMAIN}
10 |
11 | function login(){
12 | cf api | grep ${CLOUD_TARGET} || cf api ${CLOUD_TARGET} --skip-ssl-validation
13 | cf a | grep OK || cf login
14 | }
15 |
16 | function app_domain(){
17 | D=`cf apps | grep $1 | tr -s ' ' | cut -d' ' -f 6 | cut -d, -f1`
18 | echo $D
19 | }
20 |
21 | ## COMMON
22 |
23 | function deploy_app(){
24 | APP_NAME=$1
25 | echo "APP_NAME=$APP_NAME"
26 | cd $APP_NAME
27 | cf push $APP_NAME
28 | cd ..
29 | }
30 |
31 | function deploy_service(){
32 | N=$1
33 | D=`app_domain $N`
34 | JSON='{"uri":"http://'$D'"}'
35 | echo cf cups $N -p $JSON
36 | cf cups $N -p $JSON
37 | }
38 |
39 | function deploy_config_service(){
40 | NAME=config-service
41 | deploy_app $NAME
42 | deploy_service $NAME
43 | }
44 |
45 | function deploy_eureka_service(){
46 | NAME=eureka-service
47 | deploy_app $NAME
48 | deploy_service $NAME
49 | }
50 |
51 | function deploy_hystrix_dashboard(){
52 | deploy_app hystrix-dashboard
53 | }
54 |
55 |
56 | function deploy_reservation_service(){
57 | cf cs elephantsql turtle reservations-postgresql
58 | deploy_app reservation-service
59 | }
60 |
61 | function deploy_reservation_client(){
62 | deploy_app reservation-client
63 | }
64 |
65 | function reset(){
66 |
67 | echo "reset.."
68 | apps="hystrix-dashboard reservation-client reservation-service eureka-service config-service"
69 | apps_arr=( $apps )
70 | for a in "${apps_arr[@]}";
71 | do
72 | echo $a
73 | cf d -f $a
74 | done
75 |
76 | services="reservations-postgresql eureka-service config-service"
77 | services_arr=( $services )
78 | for s in "${services_arr[@]}";
79 | do
80 | echo $s
81 | cf ds -f $s
82 | done
83 |
84 | cf delete-orphaned-routes -f
85 |
86 | }
87 |
88 | ###
89 | ### INSTALLATION STEPS
90 | ###
91 |
92 | #mvn -DskipTests=true clean install
93 |
94 | function install(){
95 | apps="hystrix-dashboard reservation-client reservation-service eureka-service config-service"
96 | apps_arr=( $apps )
97 | for a in "${apps_arr[@]}";
98 | do
99 | echo $a
100 | mvn -f $a/pom.xml -DskipTests=true clean install
101 | done
102 | }
103 |
104 | #login
105 | reset
106 | install
107 | deploy_config_service
108 | deploy_eureka_service
109 | #deploy_hystrix_dashboard
110 | deploy_reservation_service
111 | deploy_reservation_client
112 |
--------------------------------------------------------------------------------
/labs/7/config-service/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: config-service
4 | host: config-service-${random-word}
5 | memory: 512M
6 | path: target/config-service.jar
7 | env:
8 | SPRING_PROFILES_ACTIVE: cloud
9 | DEBUG: "true"
10 | SPRING_CLOUD_CONFIG_SERVER_GIT_URI: https://github.com/joshlong/bootiful-microservices-config
11 |
--------------------------------------------------------------------------------
/labs/7/config-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | config-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M1
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 | ${project.artifactId}
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
63 | spring-snapshots
64 | Spring Snapshots
65 | https://repo.spring.io/snapshot
66 |
67 | true
68 |
69 |
70 |
71 | spring-milestones
72 | Spring Milestones
73 | https://repo.spring.io/milestone
74 |
75 | false
76 |
77 |
78 |
79 |
80 |
81 | spring-snapshots
82 | Spring Snapshots
83 | https://repo.spring.io/snapshot
84 |
85 | true
86 |
87 |
88 |
89 | spring-milestones
90 | Spring Milestones
91 | https://repo.spring.io/milestone
92 |
93 | false
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/labs/7/config-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @EnableConfigServer
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/7/config-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.server.git.uri=https://github.com/joshlong/bootiful-microservices-config.git
2 | server.port=8888
--------------------------------------------------------------------------------
/labs/7/config-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/7/eureka-service/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: eureka-service
4 | host: eureka-service-${random-word}
5 | memory: 512M
6 | path: target/eureka-service.jar
7 | services:
8 | - config-service
9 | env:
10 | SPRING_PROFILES_ACTIVE: cloud
11 | DEBUG: "true"
12 |
--------------------------------------------------------------------------------
/labs/7/eureka-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | eureka-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 |
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-config
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-starter-eureka-server
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-starter-parent
49 | Brixton.M1
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 | ${project.artifactId}
58 |
59 |
60 |
61 | org.springframework.boot
62 | spring-boot-maven-plugin
63 |
64 |
65 |
66 |
67 |
68 |
69 | spring-snapshots
70 | Spring Snapshots
71 | https://repo.spring.io/snapshot
72 |
73 | true
74 |
75 |
76 |
77 | spring-milestones
78 | Spring Milestones
79 | https://repo.spring.io/milestone
80 |
81 | false
82 |
83 |
84 |
85 |
86 |
87 | spring-snapshots
88 | Spring Snapshots
89 | https://repo.spring.io/snapshot
90 |
91 | true
92 |
93 |
94 |
95 | spring-milestones
96 | Spring Milestones
97 | https://repo.spring.io/milestone
98 |
99 | false
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/labs/7/eureka-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
7 |
8 | @EnableEurekaServer
9 | @SpringBootApplication
10 | public class DemoApplication {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(DemoApplication.class, args);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/labs/7/eureka-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
2 | spring.application.name=eureka-service
3 |
--------------------------------------------------------------------------------
/labs/7/eureka-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/7/hystrix-dashboard/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: hystrix-dashboard
4 | host: hystrix-dashboard-${random-word}
5 | path: target/hystrix-dashboard.jar
6 | services:
7 | - config-service
8 | - eureka-service
9 | env:
10 | SPRING_PROFILES_ACTIVE: cloud
11 | DEBUG: "true"
12 |
--------------------------------------------------------------------------------
/labs/7/hystrix-dashboard/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | hystrix-dashboard
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-hystrix-dashboard
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M1
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 | ${project.artifactId}
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
63 | spring-snapshots
64 | Spring Snapshots
65 | https://repo.spring.io/snapshot
66 |
67 | true
68 |
69 |
70 |
71 | spring-milestones
72 | Spring Milestones
73 | https://repo.spring.io/milestone
74 |
75 | false
76 |
77 |
78 |
79 |
80 |
81 | spring-snapshots
82 | Spring Snapshots
83 | https://repo.spring.io/snapshot
84 |
85 | true
86 |
87 |
88 |
89 | spring-milestones
90 | Spring Milestones
91 | https://repo.spring.io/milestone
92 |
93 | false
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/labs/7/hystrix-dashboard/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
6 |
7 | @EnableHystrixDashboard
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/7/hystrix-dashboard/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=hystrix-dashboard
2 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
3 |
--------------------------------------------------------------------------------
/labs/7/hystrix-dashboard/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/7/reservation-client/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: reservation-client
4 | host: reservation-client-${random-word}
5 | path: target/reservation-client.jar
6 | memory: 512M
7 | services:
8 | - config-service
9 | - eureka-service
10 | env:
11 | SPRING_PROFILES_ACTIVE: cloud
12 | DEBUG: "true"
13 | debug: "true"
14 |
--------------------------------------------------------------------------------
/labs/7/reservation-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-client
2 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
3 |
--------------------------------------------------------------------------------
/labs/7/reservation-client/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/7/reservation-service/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: reservation-service
4 | path: target/reservation-service.jar
5 | host: reservation-service-${random-word}
6 | memory: 512M
7 | services:
8 | - config-service
9 | - eureka-service
10 | env:
11 | DEBUG: "true"
12 | debug: "true"
13 |
--------------------------------------------------------------------------------
/labs/7/reservation-service/src/main/java/demo/Reservation.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Reservation {
9 |
10 | public Reservation() {
11 | }
12 |
13 | public Reservation(String reservationName) {
14 | this.reservationName = reservationName;
15 | }
16 |
17 | @Id
18 | @GeneratedValue
19 | private Long id;
20 | private String reservationName;
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public String getReservationName() {
27 | return reservationName;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/labs/7/reservation-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-service
2 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
3 |
--------------------------------------------------------------------------------
/labs/7/reservation-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 | import org.springframework.test.context.web.WebAppConfiguration;
11 | import org.springframework.test.web.servlet.MockMvc;
12 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
13 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15 | import org.springframework.web.context.WebApplicationContext;
16 |
17 | @RunWith(SpringJUnit4ClassRunner.class)
18 | @SpringApplicationConfiguration(classes = DemoApplication.class)
19 | @WebAppConfiguration
20 | public class DemoApplicationTests {
21 |
22 | @Autowired
23 | private WebApplicationContext webApplicationContext;
24 |
25 | private MockMvc mockMvc;
26 |
27 | @Before
28 | public void before() throws Exception {
29 | this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
30 | }
31 |
32 | @Test
33 | public void contextLoads() throws Exception {
34 | this.mockMvc.perform(MockMvcRequestBuilders.get("/reservations"))
35 | .andExpect(MockMvcResultMatchers.content().contentType(MediaType.parseMediaType("application/hal+json")))
36 | .andExpect(MockMvcResultMatchers.status().isOk());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/labs/8/cf-simple.sh:
--------------------------------------------------------------------------------
1 |
2 | cd config-service
3 | cf push
4 | # run cf apps to get the URL of config-service,
5 | # or note it from the "urls" output of the `cf push`
6 | # and place it in the next line where it says _URL_
7 | cf cups config-service -p '{"uri":"http://config-service-unfiercely-alkalimetry.cfapps.io"}'
8 | cd ..
9 |
10 | cd eureka-service
11 | cf push
12 | # run cf apps to get the URL of eureka-service,
13 | # or note it from the "urls" output of the `cf push`,
14 | # and place it in the next line where it says _URL_
15 | cf cups eureka-service -p '{"uri":"http://eureka-service-rooted-subquarter.cfapps.io"}'
16 | cd ..
17 |
18 | cd reservation-service
19 | cf push
20 | cd ..
21 |
22 | cd reservation-client
23 | cf push
24 | cd ..
25 |
--------------------------------------------------------------------------------
/labs/8/cf.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | #
5 | # the big CloudFoundry installer
6 | #
7 |
8 | CLOUD_DOMAIN=${DOMAIN:-run.pivotal.io}
9 | CLOUD_TARGET=api.${DOMAIN}
10 |
11 | function login(){
12 | cf api | grep ${CLOUD_TARGET} || cf api ${CLOUD_TARGET} --skip-ssl-validation
13 | cf a | grep OK || cf login
14 | }
15 |
16 | function app_domain(){
17 | D=`cf apps | grep $1 | tr -s ' ' | cut -d' ' -f 6 | cut -d, -f1`
18 | echo $D
19 | }
20 |
21 | ## COMMON
22 |
23 | function deploy_app(){
24 | APP_NAME=$1
25 | echo "APP_NAME=$APP_NAME"
26 | cd $APP_NAME
27 | cf push $APP_NAME
28 | cd ..
29 | }
30 |
31 | function deploy_service(){
32 | N=$1
33 | D=`app_domain $N`
34 | JSON='{"uri":"http://'$D'"}'
35 | echo cf cups $N -p $JSON
36 | cf cups $N -p $JSON
37 | }
38 |
39 | function deploy_config_service(){
40 | NAME=config-service
41 | deploy_app $NAME
42 | deploy_service $NAME
43 | }
44 |
45 | function deploy_eureka_service(){
46 | NAME=eureka-service
47 | deploy_app $NAME
48 | deploy_service $NAME
49 | }
50 |
51 | function deploy_hystrix_dashboard(){
52 | deploy_app hystrix-dashboard
53 | }
54 |
55 |
56 | function deploy_reservation_service(){
57 | cf cs elephantsql turtle reservations-postgresql
58 | deploy_app reservation-service
59 | }
60 |
61 | function deploy_reservation_client(){
62 | deploy_app reservation-client
63 | }
64 |
65 | function reset(){
66 |
67 | echo "reset.."
68 | apps="hystrix-dashboard reservation-client reservation-service eureka-service config-service"
69 | apps_arr=( $apps )
70 | for a in "${apps_arr[@]}";
71 | do
72 | echo $a
73 | cf d -f $a
74 | done
75 |
76 | services="reservations-postgresql eureka-service config-service"
77 | services_arr=( $services )
78 | for s in "${services_arr[@]}";
79 | do
80 | echo $s
81 | cf ds -f $s
82 | done
83 |
84 | cf delete-orphaned-routes -f
85 |
86 | }
87 |
88 | ###
89 | ### INSTALLATION STEPS
90 | ###
91 |
92 | #mvn -DskipTests=true clean install
93 |
94 | function install(){
95 | apps="hystrix-dashboard reservation-client reservation-service eureka-service config-service"
96 | apps_arr=( $apps )
97 | for a in "${apps_arr[@]}";
98 | do
99 | echo $a
100 | mvn -f $a/pom.xml -DskipTests=true clean install
101 | done
102 | }
103 |
104 | #login
105 | reset
106 | install
107 | deploy_config_service
108 | deploy_eureka_service
109 | #deploy_hystrix_dashboard
110 | deploy_reservation_service
111 | deploy_reservation_client
112 |
--------------------------------------------------------------------------------
/labs/8/config-service/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: config-service
4 | host: config-service-${random-word}
5 | memory: 512M
6 | path: target/config-service.jar
7 | env:
8 | SPRING_PROFILES_ACTIVE: cloud
9 | DEBUG: "true"
10 | SPRING_CLOUD_CONFIG_SERVER_GIT_URI: https://github.com/joshlong/bootiful-microservices-config
11 |
--------------------------------------------------------------------------------
/labs/8/config-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | config-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M1
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 | ${project.artifactId}
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
63 | spring-snapshots
64 | Spring Snapshots
65 | https://repo.spring.io/snapshot
66 |
67 | true
68 |
69 |
70 |
71 | spring-milestones
72 | Spring Milestones
73 | https://repo.spring.io/milestone
74 |
75 | false
76 |
77 |
78 |
79 |
80 |
81 | spring-snapshots
82 | Spring Snapshots
83 | https://repo.spring.io/snapshot
84 |
85 | true
86 |
87 |
88 |
89 | spring-milestones
90 | Spring Milestones
91 | https://repo.spring.io/milestone
92 |
93 | false
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/labs/8/config-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @EnableConfigServer
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/8/config-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.server.git.uri=https://github.com/joshlong/bootiful-microservices-config.git
2 | server.port=8888
--------------------------------------------------------------------------------
/labs/8/config-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/8/eureka-service/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: eureka-service
4 | host: eureka-service-${random-word}
5 | memory: 512M
6 | path: target/eureka-service.jar
7 | services:
8 | - config-service
9 | env:
10 | SPRING_PROFILES_ACTIVE: cloud
11 | DEBUG: "true"
12 |
--------------------------------------------------------------------------------
/labs/8/eureka-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | eureka-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 |
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-config
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-starter-eureka-server
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-starter-parent
49 | Brixton.M1
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 | ${project.artifactId}
58 |
59 |
60 |
61 | org.springframework.boot
62 | spring-boot-maven-plugin
63 |
64 |
65 |
66 |
67 |
68 |
69 | spring-snapshots
70 | Spring Snapshots
71 | https://repo.spring.io/snapshot
72 |
73 | true
74 |
75 |
76 |
77 | spring-milestones
78 | Spring Milestones
79 | https://repo.spring.io/milestone
80 |
81 | false
82 |
83 |
84 |
85 |
86 |
87 | spring-snapshots
88 | Spring Snapshots
89 | https://repo.spring.io/snapshot
90 |
91 | true
92 |
93 |
94 |
95 | spring-milestones
96 | Spring Milestones
97 | https://repo.spring.io/milestone
98 |
99 | false
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/labs/8/eureka-service/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
7 |
8 | @EnableEurekaServer
9 | @SpringBootApplication
10 | public class DemoApplication {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(DemoApplication.class, args);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/labs/8/eureka-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
2 | spring.application.name=eureka-service
3 |
--------------------------------------------------------------------------------
/labs/8/eureka-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/8/hystrix-dashboard/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: hystrix-dashboard
4 | host: hystrix-dashboard-${random-word}
5 | path: target/hystrix-dashboard.jar
6 | services:
7 | - config-service
8 | - eureka-service
9 | env:
10 | SPRING_PROFILES_ACTIVE: cloud
11 | DEBUG: "true"
12 |
--------------------------------------------------------------------------------
/labs/8/hystrix-dashboard/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.test
7 | hystrix-dashboard
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.0.M5
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-hystrix-dashboard
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-parent
44 | Brixton.M1
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 | ${project.artifactId}
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
63 | spring-snapshots
64 | Spring Snapshots
65 | https://repo.spring.io/snapshot
66 |
67 | true
68 |
69 |
70 |
71 | spring-milestones
72 | Spring Milestones
73 | https://repo.spring.io/milestone
74 |
75 | false
76 |
77 |
78 |
79 |
80 |
81 | spring-snapshots
82 | Spring Snapshots
83 | https://repo.spring.io/snapshot
84 |
85 | true
86 |
87 |
88 |
89 | spring-milestones
90 | Spring Milestones
91 | https://repo.spring.io/milestone
92 |
93 | false
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/labs/8/hystrix-dashboard/src/main/java/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
6 |
7 | @EnableHystrixDashboard
8 | @SpringBootApplication
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/labs/8/hystrix-dashboard/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=hystrix-dashboard
2 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
3 |
--------------------------------------------------------------------------------
/labs/8/hystrix-dashboard/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/8/reservation-client/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: reservation-client
4 | host: reservation-client-${random-word}
5 | path: target/reservation-client.jar
6 | memory: 512M
7 | services:
8 | - config-service
9 | - eureka-service
10 | env:
11 | SPRING_PROFILES_ACTIVE: cloud
12 | DEBUG: "true"
13 | debug: "true"
14 |
--------------------------------------------------------------------------------
/labs/8/reservation-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-client
2 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
3 |
--------------------------------------------------------------------------------
/labs/8/reservation-client/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = DemoApplication.class)
10 | public class DemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/labs/8/reservation-service/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: reservation-service
4 | path: target/reservation-service.jar
5 | host: reservation-service-${random-word}
6 | memory: 512M
7 | services:
8 | - config-service
9 | - eureka-service
10 | env:
11 | DEBUG: "true"
12 | debug: "true"
13 |
--------------------------------------------------------------------------------
/labs/8/reservation-service/src/main/java/demo/Reservation.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Reservation {
9 |
10 | public Reservation() {
11 | }
12 |
13 | public Reservation(String reservationName) {
14 | this.reservationName = reservationName;
15 | }
16 |
17 | @Id
18 | @GeneratedValue
19 | private Long id;
20 | private String reservationName;
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public String getReservationName() {
27 | return reservationName;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/labs/8/reservation-service/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=reservation-service
2 | spring.cloud.config.uri=${vcap.services.config-service.credentials.uri:http://localhost:8888}
3 |
--------------------------------------------------------------------------------
/labs/8/reservation-service/src/test/java/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 | import org.springframework.test.context.web.WebAppConfiguration;
11 | import org.springframework.test.web.servlet.MockMvc;
12 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
13 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15 | import org.springframework.web.context.WebApplicationContext;
16 |
17 | @RunWith(SpringJUnit4ClassRunner.class)
18 | @SpringApplicationConfiguration(classes = DemoApplication.class)
19 | @WebAppConfiguration
20 | public class DemoApplicationTests {
21 |
22 | @Autowired
23 | private WebApplicationContext webApplicationContext;
24 |
25 | private MockMvc mockMvc;
26 |
27 | @Before
28 | public void before() throws Exception {
29 | this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
30 | }
31 |
32 | @Test
33 | public void contextLoads() throws Exception {
34 | this.mockMvc.perform(MockMvcRequestBuilders.get("/reservations"))
35 | .andExpect(MockMvcResultMatchers.content().contentType(MediaType.parseMediaType("application/hal+json")))
36 | .andExpect(MockMvcResultMatchers.status().isOk());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------